@smartsoft001/angular 2.88.0 → 2.90.0

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, Injectable, ComponentFactoryResolver, InjectionToken, ApplicationRef, NgModuleRef, PLATFORM_ID, Inject, signal, NgModule, model, Component, ChangeDetectorRef, ElementRef, Injector, input, viewChild, effect, computed, Directive, ViewContainerRef, output, HostListener, ChangeDetectionStrategy, ViewEncapsulation, viewChildren, Pipe, Type, forwardRef, Renderer2, NgZone, untracked } from '@angular/core';
2
+ import { inject, Injectable, ComponentFactoryResolver, InjectionToken, ApplicationRef, NgModuleRef, PLATFORM_ID, Inject, signal, NgModule, ViewContainerRef, Directive, input, output, HostListener, Pipe, Type, model, Component, ChangeDetectorRef, ElementRef, Injector, viewChild, effect, computed, ChangeDetectionStrategy, ViewEncapsulation, viewChildren, forwardRef, Renderer2, NgZone, untracked } from '@angular/core';
3
3
  import { Title, DomSanitizer } from '@angular/platform-browser';
4
4
  import { Router, NavigationEnd, NavigationStart, NavigationCancel, NavigationError, RouterModule } from '@angular/router';
5
5
  import * as i1 from '@ngx-translate/core';
@@ -15,17 +15,17 @@ import * as i1$1 from '@angular/forms';
15
15
  import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule, FormsModule, NG_VALUE_ACCESSOR, UntypedFormControl } from '@angular/forms';
16
16
  import * as i2 from 'ngx-cookie';
17
17
  import { CookieModule } from 'ngx-cookie';
18
- import { DOCUMENT, isPlatformBrowser, NgTemplateOutlet, AsyncPipe, NgComponentOutlet, NgClass, Location, CommonModule, NgOptimizedImage } from '@angular/common';
19
18
  import { toSignal, toObservable } from '@angular/core/rxjs-interop';
20
- import { SYMBOL_MODEL, SYMBOL_FIELD, getModelFieldsWithOptions, FieldType, getModelFieldOptions, getModelOptions } from '@smartsoft001/models';
21
- import 'reflect-metadata';
22
- import * as _ from 'lodash';
23
19
  import { __decorate, __metadata } from 'tslib';
24
20
  import { Memoize } from 'lodash-decorators';
21
+ import { getModelFieldOptions, SYMBOL_MODEL, SYMBOL_FIELD, getModelFieldsWithOptions, FieldType, getModelOptions } from '@smartsoft001/models';
22
+ import { DOCUMENT, isPlatformBrowser, NgTemplateOutlet, AsyncPipe, NgComponentOutlet, NgClass, Location, NgOptimizedImage, CommonModule } from '@angular/common';
23
+ import 'reflect-metadata';
24
+ import * as _ from 'lodash';
25
25
  import { ColorPickerDirective } from 'ngx-color-picker';
26
26
  import { DynamicIoDirective, DynamicComponent, DynamicModule } from 'ng-dynamic-component';
27
27
  import { Editor, NgxEditorMenuComponent, NgxEditorComponent } from 'ngx-editor';
28
- import { CdkTableModule, CdkTable, CdkHeaderCell, CdkCell, CdkHeaderRow, CdkRow } from '@angular/cdk/table';
28
+ import { CdkTable, CdkHeaderCell, CdkCell, CdkHeaderRow, CdkRow, CdkTableModule } from '@angular/cdk/table';
29
29
  import * as i1$2 from 'ng-lazyload-image';
30
30
  import { LazyLoadImageModule } from 'ng-lazyload-image';
31
31
  import { DragDropModule } from '@angular/cdk/drag-drop';
@@ -34,6 +34,18 @@ import { createEffect, EffectsModule } from '@ngrx/effects';
34
34
  import * as i1$4 from '@ngrx/store';
35
35
  import { Guid } from 'guid-typescript';
36
36
 
37
+ var PaginationMode;
38
+ (function (PaginationMode) {
39
+ PaginationMode["infiniteScroll"] = "infiniteScroll";
40
+ PaginationMode["singlePage"] = "singlePage";
41
+ })(PaginationMode || (PaginationMode = {}));
42
+ var ListMode;
43
+ (function (ListMode) {
44
+ ListMode["mobile"] = "mobile";
45
+ ListMode["desktop"] = "desktop";
46
+ ListMode["masonryGrid"] = "masonryGrid";
47
+ })(ListMode || (ListMode = {}));
48
+
37
49
  class AppService {
38
50
  titleService = inject(Title);
39
51
  translate = inject(TranslateService);
@@ -1011,1038 +1023,1038 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImpor
1011
1023
  type: Injectable
1012
1024
  }], ctorParameters: () => [{ type: ToastService }, { type: i1.TranslateService }] });
1013
1025
 
1014
- class AccordionComponent {
1015
- show = model(false, ...(ngDevMode ? [{ debugName: "show" }] : []));
1016
- update() {
1017
- this.show.update((val) => !val);
1018
- }
1019
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AccordionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1020
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: AccordionComponent, isStandalone: true, selector: "smart-accordion", inputs: { show: { classPropertyName: "show", publicName: "show", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { show: "showChange" }, ngImport: i0, template: `
1021
- <!-- <ion-item (click)="update()">-->
1022
- <ng-content select="smart-accordion-header"></ng-content>
1023
- @if (show()) {
1024
- <!-- TODO: extend tailwind classes to have mr-6.5 = margin-right: 1.6rem-1.625rem-->
1025
- <!-- <ion-icon class="mr-6.5" name="caret-up-outline" slot="end"></ion-icon>-->
1026
- } @else {
1027
- <!-- <ion-icon class="mr-6.5" name="caret-down-outline" slot="end"></ion-icon>-->
1028
- }
1029
- <!-- </ion-item>-->
1026
+ class DynamicContentDirective {
1027
+ container = inject(ViewContainerRef);
1028
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: DynamicContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1029
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: DynamicContentDirective, isStandalone: true, selector: ".dynamic-content", ngImport: i0 });
1030
+ }
1031
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: DynamicContentDirective, decorators: [{
1032
+ type: Directive,
1033
+ args: [{
1034
+ // tslint:disable-next-line:directive-selector
1035
+ selector: '.dynamic-content',
1036
+ }]
1037
+ }] });
1030
1038
 
1031
- @if (show()) {
1032
- <ng-content select="smart-accordion-body"></ng-content>
1039
+ class DetailsDirective {
1040
+ modalService = inject(ModalService);
1041
+ hardwareService = inject(HardwareService);
1042
+ options = input.required(...(ngDevMode ? [{ debugName: "options", alias: 'smartDetails' }] : [{ alias: 'smartDetails' }]));
1043
+ smartDetailsShowed = output();
1044
+ smartDetailsDismissed = output();
1045
+ async click() {
1046
+ if (!this.options() || !this.options().component)
1047
+ return;
1048
+ let modal = await this.modalService.show({
1049
+ component: this.options().component,
1050
+ props: {
1051
+ value: this.options().params,
1052
+ },
1053
+ mode: this.options().mode ? this.options().mode : 'bottom',
1054
+ });
1055
+ this.smartDetailsShowed.emit();
1056
+ const handler = await this.hardwareService.onBackButtonClick(async () => {
1057
+ if (modal) {
1058
+ await modal.dismiss();
1059
+ }
1060
+ });
1061
+ await modal.onDidDismiss();
1062
+ handler.remove();
1063
+ modal = null;
1064
+ this.smartDetailsDismissed.emit();
1033
1065
  }
1034
- `, isInline: true });
1066
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: DetailsDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1067
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.1.0", type: DetailsDirective, isStandalone: true, selector: "[smartDetails]", inputs: { options: { classPropertyName: "options", publicName: "smartDetails", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { smartDetailsShowed: "smartDetailsShowed", smartDetailsDismissed: "smartDetailsDismissed" }, host: { listeners: { "click": "click()" } }, ngImport: i0 });
1035
1068
  }
1036
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AccordionComponent, decorators: [{
1037
- type: Component,
1069
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: DetailsDirective, decorators: [{
1070
+ type: Directive,
1038
1071
  args: [{
1039
- selector: 'smart-accordion',
1040
- template: `
1041
- <!-- <ion-item (click)="update()">-->
1042
- <ng-content select="smart-accordion-header"></ng-content>
1043
- @if (show()) {
1044
- <!-- TODO: extend tailwind classes to have mr-6.5 = margin-right: 1.6rem-1.625rem-->
1045
- <!-- <ion-icon class="mr-6.5" name="caret-up-outline" slot="end"></ion-icon>-->
1046
- } @else {
1047
- <!-- <ion-icon class="mr-6.5" name="caret-down-outline" slot="end"></ion-icon>-->
1048
- }
1049
- <!-- </ion-item>-->
1072
+ selector: '[smartDetails]',
1073
+ }]
1074
+ }], propDecorators: { click: [{
1075
+ type: HostListener,
1076
+ args: ['click']
1077
+ }] } });
1050
1078
 
1051
- @if (show()) {
1052
- <ng-content select="smart-accordion-body"></ng-content>
1053
- }
1054
- `,
1079
+ const DIRECTIVES = [DynamicContentDirective];
1080
+ class SharedDirectivesModule {
1081
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1082
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: SharedDirectivesModule, imports: [SharedServicesModule, DynamicContentDirective], exports: [DynamicContentDirective] });
1083
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedDirectivesModule, imports: [SharedServicesModule] });
1084
+ }
1085
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedDirectivesModule, decorators: [{
1086
+ type: NgModule,
1087
+ args: [{
1088
+ imports: [SharedServicesModule, ...DIRECTIVES],
1089
+ exports: [...DIRECTIVES],
1055
1090
  }]
1056
1091
  }] });
1057
1092
 
1058
- class AccordionBodyComponent {
1059
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AccordionBodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1060
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.0", type: AccordionBodyComponent, isStandalone: true, selector: "smart-accordion-body", ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, styles: [":host{width:100%;padding:0 1.2rem;display:block}\n"] });
1093
+ class IModelExportProvider {
1061
1094
  }
1062
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AccordionBodyComponent, decorators: [{
1063
- type: Component,
1064
- args: [{ selector: 'smart-accordion-body', template: `<ng-content></ng-content>`, styles: [":host{width:100%;padding:0 1.2rem;display:block}\n"] }]
1065
- }] });
1095
+ const MODEL_EXPORT_PROVIDER = new InjectionToken('MODEL_EXPORT_PROVIDER');
1066
1096
 
1067
- class AccordionHeaderComponent {
1068
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AccordionHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1069
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.0", type: AccordionHeaderComponent, isStandalone: true, selector: "smart-accordion-header", ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, styles: [":host{width:100%;padding-left:1.6rem}\n"] });
1097
+ class IModelImportProvider {
1070
1098
  }
1071
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AccordionHeaderComponent, decorators: [{
1072
- type: Component,
1073
- args: [{ selector: 'smart-accordion-header', template: `<ng-content></ng-content>`, styles: [":host{width:100%;padding-left:1.6rem}\n"] }]
1074
- }] });
1099
+ const MODEL_IMPORT_PROVIDER = new InjectionToken('MODEL_IMPORT_PROVIDER');
1075
1100
 
1076
- class AppBaseComponent {
1077
- router = inject(Router);
1078
- cd = inject(ChangeDetectorRef);
1079
- elementRef = inject(ElementRef);
1080
- styleService = inject(StyleService);
1081
- menuService = inject(MenuService);
1082
- authService = inject(AuthService);
1083
- appService = inject(AppService);
1084
- platformId = inject(PLATFORM_ID);
1085
- document = inject(DOCUMENT);
1086
- injector = inject(Injector);
1087
- _subscriptions = new Subscription();
1088
- selectedPath = '';
1089
- showMenu = signal(false).asReadonly();
1090
- menuItems = signal([]).asReadonly();
1091
- logged = signal(false).asReadonly();
1092
- username = signal('').asReadonly();
1093
- loadingPage = signal(false).asReadonly();
1094
- logo;
1095
- routerEvents = toSignal(this.router.events);
1096
- options = input.required(...(ngDevMode ? [{ debugName: "options" }] : []));
1097
- endMenuContainer = viewChild('endMenuContainer', ...(ngDevMode ? [{ debugName: "endMenuContainer" }] : []));
1098
- constructor() {
1099
- effect(() => {
1100
- const options = this.options();
1101
- this.initMenu();
1102
- if (options) {
1103
- this.logged = options.provider.logged;
1104
- this.username = options.provider.username;
1105
- this.logo = options.logo;
1106
- }
1107
- this.initLoader();
1108
- this.refreshStyles();
1109
- });
1110
- this.initPermissionClasses();
1111
- this.initSelectedPath();
1112
- if (isPlatformBrowser(this.platformId)) {
1113
- this.styleService.init(this.elementRef);
1114
- this.appService.initTitle();
1115
- }
1116
- effect(async () => {
1117
- const endContainer = this.endMenuContainer();
1118
- if (endContainer) {
1119
- await this.menuService.init(endContainer);
1120
- }
1121
- });
1122
- }
1123
- logout() {
1124
- this.options()?.provider.logout();
1101
+ class IModelLabelProvider {
1102
+ }
1103
+ const MODEL_LABEL_PROVIDER = new InjectionToken('MODEL_LABEL_PROVIDER');
1104
+
1105
+ class IModelPossibilitiesProvider {
1106
+ }
1107
+ const MODEL_POSSIBILITIES_PROVIDER = new InjectionToken('MODEL_POSSIBILITIES_PROVIDER');
1108
+
1109
+ /**
1110
+ * @example
1111
+ *
1112
+ * in module:
1113
+ @NgModule({
1114
+ providers: [
1115
+ ...
1116
+ {
1117
+ provide: MODEL_VALIDATORS_PROVIDER,
1118
+ useClass: ModelValidatorsProvider
1125
1119
  }
1126
- async ngAfterContentInit() {
1127
- this.refreshStyles();
1120
+ ],
1121
+ *
1122
+ * provider:
1123
+ * @Injectable()
1124
+ export class ModelValidatorsProvider extends IModelValidatorsProvider {
1125
+ async get(options: IModelValidatorsOptions): Promise<IModelValidators> {
1126
+ if (options.type === Todo && options.key === 'test') {
1127
+ return {
1128
+ validators: null,
1129
+ asyncValidators: null
1130
+ }
1128
1131
  }
1129
- ngOnDestroy() {
1130
- if (this._subscriptions)
1131
- this._subscriptions.unsubscribe();
1132
+
1133
+ if (options.type === Todo && options.key === 'number') {
1134
+ return {
1135
+ validators: [ Validators.required ],
1136
+ asyncValidators: null
1137
+ }
1132
1138
  }
1133
- initMenu() {
1134
- this.showMenu = computed(() => {
1135
- const options = this.options();
1136
- const logged = options.provider.logged();
1137
- const disable = this.menuService.disabled();
1138
- if (disable)
1139
- return false;
1140
- return logged || !!options?.menu?.showForAnonymous;
1141
- }, ...(ngDevMode ? [{ debugName: "showMenu" }] : []));
1142
- const options = this.options();
1143
- if (options?.menu) {
1144
- if (options.menu?.items) {
1145
- this.menuService.setMenuItems(options.menu.items);
1146
- }
1147
- this.menuItems = this.menuService.menuItems;
1139
+
1140
+ return Promise.resolve(options.base);
1141
+ }
1142
+ }
1143
+ */
1144
+ class IModelValidatorsProvider {
1145
+ }
1146
+ const MODEL_VALIDATORS_PROVIDER = new InjectionToken('MODEL_VALIDATORS_PROVIDER');
1147
+
1148
+ class ModelLabelPipe {
1149
+ translateService = inject(TranslateService);
1150
+ modelLabelProvider = inject(IModelLabelProvider);
1151
+ transform(instance, key, type) {
1152
+ if (this.modelLabelProvider) {
1153
+ const result = this.modelLabelProvider.get({
1154
+ instance: instance,
1155
+ key: key,
1156
+ type: type,
1157
+ });
1158
+ if (result())
1159
+ return result();
1148
1160
  }
1161
+ return toSignal(this.translateService.instant('MODEL.' + key))();
1149
1162
  }
1150
- initSelectedPath() {
1151
- this._subscriptions.add(this.router.events
1152
- .pipe(filter((event) => event && event instanceof NavigationEnd))
1153
- .subscribe((event) => {
1154
- if (event.urlAfterRedirects)
1155
- this.selectedPath = event.urlAfterRedirects;
1156
- else
1157
- this.selectedPath = event.url;
1158
- this.styleService.init(this.elementRef);
1159
- this.cd.detectChanges();
1160
- }));
1161
- }
1162
- initLoader() {
1163
- this.loadingPage = computed(() => {
1164
- const routerEvent = this.routerEvents();
1165
- if (routerEvent instanceof NavigationStart) {
1166
- return true;
1167
- }
1168
- else if (routerEvent instanceof NavigationEnd ||
1169
- routerEvent instanceof NavigationCancel ||
1170
- routerEvent instanceof NavigationError) {
1171
- return false;
1172
- }
1173
- return false;
1174
- }, ...(ngDevMode ? [{ debugName: "loadingPage" }] : []));
1175
- }
1176
- refreshStyles() {
1177
- if (isPlatformBrowser(this.platformId)) {
1178
- setTimeout(() => {
1179
- this.styleService.set(this.options()?.style);
1180
- const elementById = this.document.getElementById('app-favicon');
1181
- if (this.logo && elementById) {
1182
- elementById.setAttribute('href', this.logo);
1183
- }
1163
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ModelLabelPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1164
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: ModelLabelPipe, isStandalone: true, name: "smartModelLabel" });
1165
+ }
1166
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ModelLabelPipe, decorators: [{
1167
+ type: Pipe,
1168
+ args: [{
1169
+ name: 'smartModelLabel',
1170
+ }]
1171
+ }] });
1172
+
1173
+ class ListCellPipe {
1174
+ translateService = inject(TranslateService);
1175
+ transform(obj, key, pipe, type) {
1176
+ if (!obj)
1177
+ return {};
1178
+ let result;
1179
+ const fieldType = this.getFieldType(type, key);
1180
+ if (!pipe)
1181
+ result = this.getValue(obj, key);
1182
+ else {
1183
+ result = pipe.transform(obj, key, (val) => {
1184
+ return this.translateService.instant(val);
1185
+ });
1186
+ }
1187
+ if (!result)
1188
+ return result;
1189
+ if (typeof result === 'string') {
1190
+ result = this.translateService.instant(result);
1191
+ }
1192
+ if (fieldType === 'enum') {
1193
+ result = result.map((item) => {
1194
+ return this.translateService.instant(item);
1184
1195
  });
1185
1196
  }
1197
+ return {
1198
+ value: result,
1199
+ type: fieldType,
1200
+ };
1186
1201
  }
1187
- initPermissionClasses() {
1188
- if (isPlatformBrowser(this.platformId)) {
1189
- effect(() => {
1190
- const logged = this.options().provider.logged();
1191
- if (logged) {
1192
- this.authService.getPermissions().forEach((permission) => {
1193
- this.elementRef.nativeElement.classList.add('auth-permissions-' + permission);
1194
- });
1195
- }
1196
- }, { injector: this.injector }); // Auto cleanup with component
1202
+ getFieldType(type, key) {
1203
+ if (!type)
1204
+ return null;
1205
+ const options = getModelFieldOptions(new type(), key);
1206
+ return options?.type ?? null;
1207
+ }
1208
+ getValue(value, key) {
1209
+ if (key.indexOf('__array') === 0) {
1210
+ const info = key.split('.');
1211
+ const arrayKey = info[1];
1212
+ const index = Number(info[2]);
1213
+ const rowKey = info[4];
1214
+ return value[arrayKey][index][rowKey];
1197
1215
  }
1216
+ return value[key];
1198
1217
  }
1199
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AppBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1200
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.1.0", type: AppBaseComponent, isStandalone: true, inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "endMenuContainer", first: true, predicate: ["endMenuContainer"], descendants: true, isSignal: true }], ngImport: i0 });
1218
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListCellPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1219
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: ListCellPipe, isStandalone: true, name: "smartListCell" });
1201
1220
  }
1202
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AppBaseComponent, decorators: [{
1203
- type: Directive
1204
- }], ctorParameters: () => [] });
1221
+ __decorate([
1222
+ Memoize(),
1223
+ __metadata("design:type", Function),
1224
+ __metadata("design:paramtypes", [Type, String]),
1225
+ __metadata("design:returntype", Object)
1226
+ ], ListCellPipe.prototype, "getFieldType", null);
1227
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListCellPipe, decorators: [{
1228
+ type: Pipe,
1229
+ args: [{
1230
+ name: 'smartListCell',
1231
+ }]
1232
+ }], propDecorators: { getFieldType: [] } });
1205
1233
 
1206
- class BaseComponent {
1207
- get takeUntilDestroy() {
1208
- return takeUntil(this.destroy$);
1209
- }
1210
- destroy$ = new Subject();
1211
- ngOnDestroy() {
1212
- this.destroy$.next(true);
1213
- this.destroy$.unsubscribe();
1234
+ class TrustHtmlPipe {
1235
+ sanitizer = inject(DomSanitizer);
1236
+ transform(val) {
1237
+ if (!val)
1238
+ return val;
1239
+ return this.sanitizer.bypassSecurityTrustHtml(val);
1214
1240
  }
1215
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1216
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: BaseComponent, isStandalone: true, ngImport: i0 });
1241
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: TrustHtmlPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1242
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: TrustHtmlPipe, isStandalone: true, name: "smartTrustHtml" });
1217
1243
  }
1218
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BaseComponent, decorators: [{
1219
- type: Directive
1244
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: TrustHtmlPipe, decorators: [{
1245
+ type: Pipe,
1246
+ args: [{
1247
+ name: 'smartTrustHtml',
1248
+ }]
1220
1249
  }] });
1221
- function CreateDynamicComponent(type) {
1222
- class Component extends BaseComponent {
1223
- cd = inject(ChangeDetectorRef);
1224
- moduleRef = inject((NgModuleRef));
1225
- componentFactoryResolver = inject(ComponentFactoryResolver);
1226
- _renderCustom = false;
1227
- _findDynamicContent = false;
1228
- baseInstance = null;
1229
- baseComponentRef = null;
1230
- dynamicType = type;
1231
- template = signal('default', ...(ngDevMode ? [{ debugName: "template" }] : []));
1232
- refreshDynamicInstance() {
1233
- this.init();
1234
- if (!this.baseInstance)
1235
- return;
1236
- this.refreshProperties();
1237
- }
1238
- ngDoCheck() {
1239
- if (this._findDynamicContent || !this.dynamicContents())
1240
- return;
1241
- this._findDynamicContent = true;
1242
- toObservable(this.dynamicContents)
1243
- .pipe(this.takeUntilDestroy)
1244
- .subscribe(() => {
1245
- this.init();
1246
- });
1247
- this.init();
1250
+
1251
+ class ListHeaderPipe {
1252
+ translateService = inject(TranslateService);
1253
+ modelLabelProvider = inject(IModelLabelProvider);
1254
+ transform(data, key, type) {
1255
+ if (key.indexOf('__array') === 0) {
1256
+ const info = key.split('.');
1257
+ const arrayKey = info[1];
1258
+ const index = Number(info[2]);
1259
+ const headerKey = info[3];
1260
+ return signal(data[0][arrayKey][index][headerKey]);
1248
1261
  }
1249
- init() {
1250
- const component = DynamicComponentStorageService.get(this.dynamicType, this.moduleRef)[0];
1251
- this.template.set(component ? 'custom' : 'default');
1252
- if (component && !this._renderCustom) {
1253
- const factory = this.componentFactoryResolver.resolveComponentFactory(component);
1254
- const first = this.dynamicContents()[0];
1255
- if (first) {
1256
- this._renderCustom = true;
1257
- this.baseComponentRef = first.container.createComponent(factory);
1258
- this.baseInstance = this.baseComponentRef.instance;
1259
- this.refreshDynamicInstance();
1260
- this.baseInstance
1261
- ?.contentTpl()
1262
- ?.createEmbeddedView(this.contentTpl());
1263
- }
1264
- }
1265
- if (this.cd)
1266
- this.cd.detectChanges();
1262
+ if (this.modelLabelProvider) {
1263
+ const result = this.modelLabelProvider.get({ type, key });
1264
+ if (result)
1265
+ return result;
1267
1266
  }
1268
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: Component, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1269
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: Component, isStandalone: true, usesInheritance: true, ngImport: i0 });
1267
+ return signal(this.translateService.instant('MODEL.' + key));
1270
1268
  }
1271
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: Component, decorators: [{
1272
- type: Directive
1273
- }] });
1274
- return Component;
1275
- }
1276
-
1277
- class DynamicContentDirective {
1278
- container = inject(ViewContainerRef);
1279
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: DynamicContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1280
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: DynamicContentDirective, isStandalone: true, selector: ".dynamic-content", ngImport: i0 });
1269
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListHeaderPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1270
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: ListHeaderPipe, isStandalone: true, name: "smartListHeader" });
1281
1271
  }
1282
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: DynamicContentDirective, decorators: [{
1283
- type: Directive,
1272
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListHeaderPipe, decorators: [{
1273
+ type: Pipe,
1284
1274
  args: [{
1285
- // tslint:disable-next-line:directive-selector
1286
- selector: '.dynamic-content',
1275
+ name: 'smartListHeader',
1287
1276
  }]
1288
1277
  }] });
1289
1278
 
1290
- class DetailsDirective {
1291
- modalService = inject(ModalService);
1292
- hardwareService = inject(HardwareService);
1293
- options = input.required(...(ngDevMode ? [{ debugName: "options", alias: 'smartDetails' }] : [{ alias: 'smartDetails' }]));
1294
- smartDetailsShowed = output();
1295
- smartDetailsDismissed = output();
1296
- async click() {
1297
- if (!this.options() || !this.options().component)
1298
- return;
1299
- let modal = await this.modalService.show({
1300
- component: this.options().component,
1301
- props: {
1302
- value: this.options().params,
1303
- },
1304
- mode: this.options().mode ? this.options().mode : 'bottom',
1305
- });
1306
- this.smartDetailsShowed.emit();
1307
- const handler = await this.hardwareService.onBackButtonClick(async () => {
1308
- if (modal) {
1309
- await modal.dismiss();
1310
- }
1311
- });
1312
- await modal.onDidDismiss();
1313
- handler.remove();
1314
- modal = null;
1315
- this.smartDetailsDismissed.emit();
1279
+ class FileUrlPipe {
1280
+ service = inject(FileService);
1281
+ transform(file) {
1282
+ return this.service.getUrl(file.id);
1316
1283
  }
1317
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: DetailsDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1318
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.1.0", type: DetailsDirective, isStandalone: true, selector: "[smartDetails]", inputs: { options: { classPropertyName: "options", publicName: "smartDetails", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { smartDetailsShowed: "smartDetailsShowed", smartDetailsDismissed: "smartDetailsDismissed" }, host: { listeners: { "click": "click()" } }, ngImport: i0 });
1284
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FileUrlPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1285
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: FileUrlPipe, isStandalone: true, name: "smartFileUrl" });
1319
1286
  }
1320
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: DetailsDirective, decorators: [{
1321
- type: Directive,
1322
- args: [{
1323
- selector: '[smartDetails]',
1324
- }]
1325
- }], propDecorators: { click: [{
1326
- type: HostListener,
1327
- args: ['click']
1328
- }] } });
1329
-
1330
- const DIRECTIVES = [DynamicContentDirective];
1331
- class SharedDirectivesModule {
1332
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1333
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: SharedDirectivesModule, imports: [SharedServicesModule, DynamicContentDirective], exports: [DynamicContentDirective] });
1334
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedDirectivesModule, imports: [SharedServicesModule] });
1335
- }
1336
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedDirectivesModule, decorators: [{
1337
- type: NgModule,
1287
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FileUrlPipe, decorators: [{
1288
+ type: Pipe,
1338
1289
  args: [{
1339
- imports: [SharedServicesModule, ...DIRECTIVES],
1340
- exports: [...DIRECTIVES],
1290
+ name: 'smartFileUrl',
1341
1291
  }]
1342
1292
  }] });
1343
1293
 
1344
- class ButtonBaseComponent {
1345
- static smartType = 'button';
1346
- mode = signal('default', ...(ngDevMode ? [{ debugName: "mode" }] : []));
1347
- options = input.required(...(ngDevMode ? [{ debugName: "options" }] : []));
1348
- disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
1349
- contentTpl = viewChild('contentTpl', ...(ngDevMode ? [{ debugName: "contentTpl" }] : []));
1350
- invoke() {
1351
- if (!this.options())
1352
- return;
1353
- if (this.options().confirm) {
1354
- this.mode.set('confirm');
1355
- }
1356
- else {
1357
- this.options().click();
1358
- }
1359
- }
1360
- confirmInvoke() {
1361
- if (!this.options())
1362
- return;
1363
- this.options().click();
1364
- this.mode.set('default');
1365
- }
1366
- confirmCancel() {
1367
- if (!this.options())
1368
- return;
1369
- this.mode.set('default');
1294
+ class EnumToListPipe {
1295
+ transform(value) {
1296
+ if (!value)
1297
+ return value;
1298
+ return Object.keys(value);
1370
1299
  }
1371
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ButtonBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1372
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.1.0", type: ButtonBaseComponent, isStandalone: true, inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "contentTpl", first: true, predicate: ["contentTpl"], descendants: true, isSignal: true }], ngImport: i0 });
1300
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: EnumToListPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1301
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: EnumToListPipe, isStandalone: true, name: "smartEnumToList" });
1373
1302
  }
1374
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ButtonBaseComponent, decorators: [{
1375
- type: Directive
1303
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: EnumToListPipe, decorators: [{
1304
+ type: Pipe,
1305
+ args: [{
1306
+ name: 'smartEnumToList',
1307
+ }]
1376
1308
  }] });
1377
1309
 
1378
- class ButtonStandardComponent extends ButtonBaseComponent {
1379
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ButtonStandardComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1380
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: ButtonStandardComponent, isStandalone: true, selector: "smart-button-standard", usesInheritance: true, ngImport: i0, template: "@if (mode() != 'confirm') {\n @let loading = options()?.loading();\n <div class=\"text-2xl italic container\"></div>\n <!-- <ion-button-->\n <!-- class=\"h-14 min-w-14 align-middle rounded-none\" -->\n <!-- [color]=\"options?.color\"-->\n <!-- [expand]=\"options?.expand\"-->\n <!-- [type]=\"options?.type\"-->\n <!-- (click)=\"invoke()\"-->\n <!-- [disabled]=\"disabled || loading\"-->\n <!-- >-->\n @if (loading) {\n <!-- <ion-spinner></ion-spinner>-->\n } @else {\n <ng-content></ng-content>\n }\n <!-- </ion-button>-->\n} @else {\n <!-- <ion-button-->\n <!-- class=\"h-14 min-w-14 align-middle rounded-none\" -->\n <!-- [expand]=\"options?.expand\"-->\n <!-- color=\"light\"-->\n <!-- (click)=\"confirmCancel()\"-->\n <!-- >-->\n {{ 'cancel' | translate }}\n <!-- </ion-button>-->\n <!-- <ion-button-->\n <!-- class=\"h-14 min-w-14 align-middle rounded-none\" -->\n <!-- [expand]=\"options?.expand\"-->\n <!-- color=\"primary\"-->\n <!-- (click)=\"confirmInvoke()\"-->\n <!-- >-->\n {{ 'confirm' | translate }}\n <!-- </ion-button>-->\n}\n", dependencies: [{ kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1310
+ const PIPES = [
1311
+ ModelLabelPipe,
1312
+ ListCellPipe,
1313
+ TrustHtmlPipe,
1314
+ ListHeaderPipe,
1315
+ EnumToListPipe,
1316
+ ];
1317
+ class SharedPipesModule {
1318
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1319
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: SharedPipesModule, imports: [ModelLabelPipe,
1320
+ ListCellPipe,
1321
+ TrustHtmlPipe,
1322
+ ListHeaderPipe,
1323
+ EnumToListPipe], exports: [ModelLabelPipe,
1324
+ ListCellPipe,
1325
+ TrustHtmlPipe,
1326
+ ListHeaderPipe,
1327
+ EnumToListPipe] });
1328
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedPipesModule });
1381
1329
  }
1382
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ButtonStandardComponent, decorators: [{
1383
- type: Component,
1384
- args: [{ selector: 'smart-button-standard', encapsulation: ViewEncapsulation.None, imports: [TranslatePipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (mode() != 'confirm') {\n @let loading = options()?.loading();\n <div class=\"text-2xl italic container\"></div>\n <!-- <ion-button-->\n <!-- class=\"h-14 min-w-14 align-middle rounded-none\" -->\n <!-- [color]=\"options?.color\"-->\n <!-- [expand]=\"options?.expand\"-->\n <!-- [type]=\"options?.type\"-->\n <!-- (click)=\"invoke()\"-->\n <!-- [disabled]=\"disabled || loading\"-->\n <!-- >-->\n @if (loading) {\n <!-- <ion-spinner></ion-spinner>-->\n } @else {\n <ng-content></ng-content>\n }\n <!-- </ion-button>-->\n} @else {\n <!-- <ion-button-->\n <!-- class=\"h-14 min-w-14 align-middle rounded-none\" -->\n <!-- [expand]=\"options?.expand\"-->\n <!-- color=\"light\"-->\n <!-- (click)=\"confirmCancel()\"-->\n <!-- >-->\n {{ 'cancel' | translate }}\n <!-- </ion-button>-->\n <!-- <ion-button-->\n <!-- class=\"h-14 min-w-14 align-middle rounded-none\" -->\n <!-- [expand]=\"options?.expand\"-->\n <!-- color=\"primary\"-->\n <!-- (click)=\"confirmInvoke()\"-->\n <!-- >-->\n {{ 'confirm' | translate }}\n <!-- </ion-button>-->\n}\n" }]
1330
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedPipesModule, decorators: [{
1331
+ type: NgModule,
1332
+ args: [{
1333
+ declarations: [],
1334
+ imports: [PIPES],
1335
+ exports: [...PIPES],
1336
+ }]
1385
1337
  }] });
1386
1338
 
1387
- class ButtonComponent extends CreateDynamicComponent('button') {
1388
- options = input.required(...(ngDevMode ? [{ debugName: "options" }] : []));
1389
- disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
1390
- contentTpl = viewChild('contentTpl', ...(ngDevMode ? [{ debugName: "contentTpl" }] : []));
1391
- dynamicContents = viewChildren(DynamicContentDirective, ...(ngDevMode ? [{ debugName: "dynamicContents" }] : []));
1392
- constructor() {
1393
- super();
1394
- effect(() => {
1395
- this.options(); //Track changes only
1396
- this.disabled(); //Track changes only
1397
- this.refreshDynamicInstance();
1398
- });
1339
+ class AccordionComponent {
1340
+ show = model(false, ...(ngDevMode ? [{ debugName: "show" }] : []));
1341
+ update() {
1342
+ this.show.update((val) => !val);
1399
1343
  }
1400
- refreshProperties() {
1401
- this.baseInstance.options = this.options;
1402
- this.baseInstance.disabled = this.disabled;
1344
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AccordionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1345
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: AccordionComponent, isStandalone: true, selector: "smart-accordion", inputs: { show: { classPropertyName: "show", publicName: "show", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { show: "showChange" }, ngImport: i0, template: `
1346
+ <!-- <ion-item (click)="update()">-->
1347
+ <ng-content select="smart-accordion-header"></ng-content>
1348
+ @if (show()) {
1349
+ <!-- TODO: extend tailwind classes to have mr-6.5 = margin-right: 1.6rem-1.625rem-->
1350
+ <!-- <ion-icon class="mr-6.5" name="caret-up-outline" slot="end"></ion-icon>-->
1351
+ } @else {
1352
+ <!-- <ion-icon class="mr-6.5" name="caret-down-outline" slot="end"></ion-icon>-->
1403
1353
  }
1404
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1405
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: ButtonComponent, isStandalone: true, selector: "smart-button", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "contentTpl", first: true, predicate: ["contentTpl"], descendants: true, isSignal: true }, { propertyName: "dynamicContents", predicate: DynamicContentDirective, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: `
1406
- @if (template() === 'default') {
1407
- <smart-button-standard [options]="options()" [disabled]="disabled()">
1408
- <ng-container [ngTemplateOutlet]="contentTpl"></ng-container>
1409
- </smart-button-standard>
1354
+ <!-- </ion-item>-->
1355
+
1356
+ @if (show()) {
1357
+ <ng-content select="smart-accordion-body"></ng-content>
1410
1358
  }
1411
- <ng-template #contentTpl>
1412
- <ng-content></ng-content>
1413
- </ng-template>
1414
- <div class="dynamic-content"></div>
1415
- `, isInline: true, dependencies: [{ kind: "component", type: ButtonStandardComponent, selector: "smart-button-standard" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1359
+ `, isInline: true });
1416
1360
  }
1417
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ButtonComponent, decorators: [{
1361
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AccordionComponent, decorators: [{
1418
1362
  type: Component,
1419
1363
  args: [{
1420
- selector: 'smart-button',
1364
+ selector: 'smart-accordion',
1421
1365
  template: `
1422
- @if (template() === 'default') {
1423
- <smart-button-standard [options]="options()" [disabled]="disabled()">
1424
- <ng-container [ngTemplateOutlet]="contentTpl"></ng-container>
1425
- </smart-button-standard>
1366
+ <!-- <ion-item (click)="update()">-->
1367
+ <ng-content select="smart-accordion-header"></ng-content>
1368
+ @if (show()) {
1369
+ <!-- TODO: extend tailwind classes to have mr-6.5 = margin-right: 1.6rem-1.625rem-->
1370
+ <!-- <ion-icon class="mr-6.5" name="caret-up-outline" slot="end"></ion-icon>-->
1371
+ } @else {
1372
+ <!-- <ion-icon class="mr-6.5" name="caret-down-outline" slot="end"></ion-icon>-->
1373
+ }
1374
+ <!-- </ion-item>-->
1375
+
1376
+ @if (show()) {
1377
+ <ng-content select="smart-accordion-body"></ng-content>
1426
1378
  }
1427
- <ng-template #contentTpl>
1428
- <ng-content></ng-content>
1429
- </ng-template>
1430
- <div class="dynamic-content"></div>
1431
1379
  `,
1432
- encapsulation: ViewEncapsulation.None,
1433
- imports: [ButtonStandardComponent, NgTemplateOutlet],
1434
- changeDetection: ChangeDetectionStrategy.OnPush,
1435
1380
  }]
1436
- }], ctorParameters: () => [] });
1437
-
1438
- class IModelExportProvider {
1439
- }
1440
- const MODEL_EXPORT_PROVIDER = new InjectionToken('MODEL_EXPORT_PROVIDER');
1441
-
1442
- class IModelImportProvider {
1443
- }
1444
- const MODEL_IMPORT_PROVIDER = new InjectionToken('MODEL_IMPORT_PROVIDER');
1445
-
1446
- class IModelLabelProvider {
1447
- }
1448
- const MODEL_LABEL_PROVIDER = new InjectionToken('MODEL_LABEL_PROVIDER');
1381
+ }] });
1449
1382
 
1450
- class IModelPossibilitiesProvider {
1383
+ class AccordionBodyComponent {
1384
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AccordionBodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1385
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.0", type: AccordionBodyComponent, isStandalone: true, selector: "smart-accordion-body", ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, styles: [":host{width:100%;padding:0 1.2rem;display:block}\n"] });
1451
1386
  }
1452
- const MODEL_POSSIBILITIES_PROVIDER = new InjectionToken('MODEL_POSSIBILITIES_PROVIDER');
1453
-
1454
- /**
1455
- * @example
1456
- *
1457
- * in module:
1458
- @NgModule({
1459
- providers: [
1460
- ...
1461
- {
1462
- provide: MODEL_VALIDATORS_PROVIDER,
1463
- useClass: ModelValidatorsProvider
1464
- }
1465
- ],
1466
- *
1467
- * provider:
1468
- * @Injectable()
1469
- export class ModelValidatorsProvider extends IModelValidatorsProvider {
1470
- async get(options: IModelValidatorsOptions): Promise<IModelValidators> {
1471
- if (options.type === Todo && options.key === 'test') {
1472
- return {
1473
- validators: null,
1474
- asyncValidators: null
1475
- }
1476
- }
1477
-
1478
- if (options.type === Todo && options.key === 'number') {
1479
- return {
1480
- validators: [ Validators.required ],
1481
- asyncValidators: null
1482
- }
1483
- }
1387
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AccordionBodyComponent, decorators: [{
1388
+ type: Component,
1389
+ args: [{ selector: 'smart-accordion-body', template: `<ng-content></ng-content>`, styles: [":host{width:100%;padding:0 1.2rem;display:block}\n"] }]
1390
+ }] });
1484
1391
 
1485
- return Promise.resolve(options.base);
1486
- }
1487
- }
1488
- */
1489
- class IModelValidatorsProvider {
1392
+ class AccordionHeaderComponent {
1393
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AccordionHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1394
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.0", type: AccordionHeaderComponent, isStandalone: true, selector: "smart-accordion-header", ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, styles: [":host{width:100%;padding-left:1.6rem}\n"] });
1490
1395
  }
1491
- const MODEL_VALIDATORS_PROVIDER = new InjectionToken('MODEL_VALIDATORS_PROVIDER');
1396
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AccordionHeaderComponent, decorators: [{
1397
+ type: Component,
1398
+ args: [{ selector: 'smart-accordion-header', template: `<ng-content></ng-content>`, styles: [":host{width:100%;padding-left:1.6rem}\n"] }]
1399
+ }] });
1492
1400
 
1493
- class FormFactory {
1494
- fb = inject(UntypedFormBuilder);
1401
+ class AppBaseComponent {
1402
+ router = inject(Router);
1403
+ cd = inject(ChangeDetectorRef);
1404
+ elementRef = inject(ElementRef);
1405
+ styleService = inject(StyleService);
1406
+ menuService = inject(MenuService);
1495
1407
  authService = inject(AuthService);
1496
- detailsService = inject(DetailsService);
1497
- validatorsProvider = inject(MODEL_VALIDATORS_PROVIDER);
1498
- static checkModelMeta(obj) {
1499
- if (!obj)
1500
- throw new Error('You should set object as param');
1501
- if (!Reflect.hasMetadata(SYMBOL_MODEL, obj.constructor))
1502
- throw new Error('You should mark class with @Model decorator');
1503
- }
1504
- static getOptions(obj, key) {
1505
- return Reflect.getMetadata(SYMBOL_FIELD, obj, key);
1506
- }
1507
- static getOptionsFromMode(options, mode) {
1508
- let result = options;
1509
- if (!mode)
1510
- return result;
1511
- if (mode === 'create' && _.isObject(options.create)) {
1512
- result = {
1513
- ...options,
1514
- ...options.create,
1515
- };
1516
- }
1517
- else if (mode === 'update' && _.isObject(options.update)) {
1518
- result = {
1519
- ...options,
1520
- ...options.update,
1521
- };
1522
- }
1523
- return result;
1524
- }
1525
- async create(obj, ops = {}) {
1526
- FormFactory.checkModelMeta(obj);
1527
- const result = SmartFormGroup.create();
1528
- const fields = getModelFieldsWithOptions(obj).filter((field) => {
1529
- return (!ops.mode ||
1530
- (ops.mode === 'create' && field.options.create) ||
1531
- (ops.mode === 'update' && field.options.update) ||
1532
- (ops.mode === 'multiUpdate' &&
1533
- field.options?.update?.multi) ||
1534
- (ops.mode !== 'create' &&
1535
- ops.mode !== 'update' &&
1536
- field.options.customs &&
1537
- field.options.customs.some((custom) => custom.mode === ops.mode)));
1538
- });
1539
- const enabledDefinitions = [];
1540
- for (let index = 0; index < fields.length; index++) {
1541
- const field = fields[index];
1542
- let control = null;
1543
- const options = FormFactory.getOptionsFromMode(field.options, ops.mode);
1544
- if (options.permissions &&
1545
- !this.authService.expectPermissions(options.permissions)) {
1546
- continue;
1547
- }
1548
- if (field.options.type === FieldType.object) {
1549
- control = await this.create(obj[field.key], {
1550
- ...ops,
1551
- root: ops.root ? ops.root : result,
1552
- });
1553
- }
1554
- else if (field.options.type === FieldType.array) {
1555
- control = this.fb.array([]);
1556
- if (obj[field.key]) {
1557
- for (let indexField = 0; indexField < obj[field.key].length; indexField++) {
1558
- control.push(await this.create(obj[field.key][indexField], {
1559
- ...ops,
1560
- root: ops.root ? ops.root : result,
1561
- }));
1562
- }
1563
- }
1564
- }
1565
- else {
1566
- control = this.createControl(obj, field, options?.required ?? false);
1408
+ appService = inject(AppService);
1409
+ platformId = inject(PLATFORM_ID);
1410
+ document = inject(DOCUMENT);
1411
+ injector = inject(Injector);
1412
+ _subscriptions = new Subscription();
1413
+ selectedPath = '';
1414
+ showMenu = signal(false).asReadonly();
1415
+ menuItems = signal([]).asReadonly();
1416
+ logged = signal(false).asReadonly();
1417
+ username = signal('').asReadonly();
1418
+ loadingPage = signal(false).asReadonly();
1419
+ logo;
1420
+ routerEvents = toSignal(this.router.events);
1421
+ options = input.required(...(ngDevMode ? [{ debugName: "options" }] : []));
1422
+ endMenuContainer = viewChild('endMenuContainer', ...(ngDevMode ? [{ debugName: "endMenuContainer" }] : []));
1423
+ constructor() {
1424
+ effect(() => {
1425
+ const options = this.options();
1426
+ this.initMenu();
1427
+ if (options) {
1428
+ this.logged = options.provider.logged;
1429
+ this.username = options.provider.username;
1430
+ this.logo = options.logo;
1567
1431
  }
1568
- this.setValidators(field.key, control, options, result, ops.uniqueProvider);
1569
- if (this.validatorsProvider) {
1570
- const providerResult = await this.validatorsProvider.get({
1571
- key: field.key,
1572
- instance: obj,
1573
- type: obj.constructor,
1574
- base: {
1575
- validators: control?.validator ?? undefined,
1576
- asyncValidators: control?.asyncValidator ?? undefined,
1577
- },
1578
- });
1579
- control.setValidators(providerResult?.validators ?? null);
1580
- control.setAsyncValidators(providerResult?.asyncValidators ?? null);
1432
+ this.initLoader();
1433
+ this.refreshStyles();
1434
+ });
1435
+ this.initPermissionClasses();
1436
+ this.initSelectedPath();
1437
+ if (isPlatformBrowser(this.platformId)) {
1438
+ this.styleService.init(this.elementRef);
1439
+ this.appService.initTitle();
1440
+ }
1441
+ effect(async () => {
1442
+ const endContainer = this.endMenuContainer();
1443
+ if (endContainer) {
1444
+ await this.menuService.init(endContainer);
1581
1445
  }
1582
- result.addControl(field.key, control);
1583
- if (options.confirm && options.type === FieldType.object) {
1584
- throw Error('Object not supported confirms');
1446
+ });
1447
+ }
1448
+ logout() {
1449
+ this.options()?.provider.logout();
1450
+ }
1451
+ async ngAfterContentInit() {
1452
+ this.refreshStyles();
1453
+ }
1454
+ ngOnDestroy() {
1455
+ if (this._subscriptions)
1456
+ this._subscriptions.unsubscribe();
1457
+ }
1458
+ initMenu() {
1459
+ this.showMenu = computed(() => {
1460
+ const options = this.options();
1461
+ const logged = options.provider.logged();
1462
+ const disable = this.menuService.disabled();
1463
+ if (disable)
1464
+ return false;
1465
+ return logged || !!options?.menu?.showForAnonymous;
1466
+ }, ...(ngDevMode ? [{ debugName: "showMenu" }] : []));
1467
+ const options = this.options();
1468
+ if (options?.menu) {
1469
+ if (options.menu?.items) {
1470
+ this.menuService.setMenuItems(options.menu.items);
1585
1471
  }
1586
- if (options.confirm) {
1587
- const confirmControl = this.fb.control(null, [
1588
- Validators.required,
1589
- (a) => {
1590
- if (a.value !== result.controls[field.key].value) {
1591
- return {
1592
- confirm: true,
1593
- };
1594
- }
1595
- return null;
1596
- },
1597
- ]);
1598
- result.addControl(field.key + 'Confirm', confirmControl);
1472
+ this.menuItems = this.menuService.menuItems;
1473
+ }
1474
+ }
1475
+ initSelectedPath() {
1476
+ this._subscriptions.add(this.router.events
1477
+ .pipe(filter((event) => event && event instanceof NavigationEnd))
1478
+ .subscribe((event) => {
1479
+ if (event.urlAfterRedirects)
1480
+ this.selectedPath = event.urlAfterRedirects;
1481
+ else
1482
+ this.selectedPath = event.url;
1483
+ this.styleService.init(this.elementRef);
1484
+ this.cd.detectChanges();
1485
+ }));
1486
+ }
1487
+ initLoader() {
1488
+ this.loadingPage = computed(() => {
1489
+ const routerEvent = this.routerEvents();
1490
+ if (routerEvent instanceof NavigationStart) {
1491
+ return true;
1599
1492
  }
1600
- if (options.enabled) {
1601
- enabledDefinitions.push({
1602
- key: field.key,
1603
- control,
1604
- enabled: options.enabled,
1605
- });
1493
+ else if (routerEvent instanceof NavigationEnd ||
1494
+ routerEvent instanceof NavigationCancel ||
1495
+ routerEvent instanceof NavigationError) {
1496
+ return false;
1606
1497
  }
1607
- }
1608
- let rootCheck = null;
1609
- if (enabledDefinitions.some((d) => d?.enabled?.criteria &&
1610
- Object.keys(d.enabled.criteria).some((k) => k.indexOf(SPECIFICATION_ROOT_KEY) === 0)) &&
1611
- ops.root) {
1612
- rootCheck = ops.root;
1613
- }
1614
- (rootCheck ? rootCheck : result).valueChanges
1615
- .pipe(tap(() => {
1616
- enabledDefinitions.forEach((def) => {
1617
- const enabled = SpecificationService.valid({
1618
- ...(obj ? obj : {}),
1619
- ...result.value,
1620
- }, def.enabled, {
1621
- $root: rootCheck?.value,
1622
- });
1623
- def.control['__smartDisabled'] = !enabled;
1624
- });
1625
- }), delay(0))
1626
- .subscribe(() => {
1627
- if (rootCheck)
1628
- this.detailsService.setRoot(rootCheck.value, true);
1629
- enabledDefinitions.forEach((def) => {
1630
- if (!def.control['__smartDisabled'] &&
1631
- !result.controls[def.key]) {
1632
- result.addControl(def.key, def.control);
1633
- result.updateValueAndValidity();
1634
- }
1635
- else if (def.control['__smartDisabled'] &&
1636
- result.controls[def.key]) {
1637
- result.removeControl(def.key);
1638
- result.updateValueAndValidity();
1639
- }
1640
- });
1641
- });
1642
- return result;
1498
+ return false;
1499
+ }, ...(ngDevMode ? [{ debugName: "loadingPage" }] : []));
1643
1500
  }
1644
- setValidators(key, control, options, form, uniqueProvider) {
1645
- const result = [];
1646
- const asyncResult = [];
1647
- if (options.required) {
1648
- result.push(Validators.required);
1649
- }
1650
- if (options.type === FieldType.email) {
1651
- result.push((c) => {
1652
- if (!c.value)
1653
- return;
1654
- const reg = new RegExp('^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$');
1655
- if (reg.test(c.value))
1656
- return null;
1657
- return { email: true };
1501
+ refreshStyles() {
1502
+ if (isPlatformBrowser(this.platformId)) {
1503
+ setTimeout(() => {
1504
+ this.styleService.set(this.options()?.style);
1505
+ const elementById = this.document.getElementById('app-favicon');
1506
+ if (this.logo && elementById) {
1507
+ elementById.setAttribute('href', this.logo);
1508
+ }
1658
1509
  });
1659
1510
  }
1660
- if (options.type === FieldType.phoneNumber) {
1661
- result.push((c) => {
1662
- if (!c.value)
1663
- return;
1664
- const reg = new RegExp('^((\\+91-?)|0)?[0-9]{9}$');
1665
- if (reg.test(c.value))
1666
- return null;
1667
- return { phoneNumber: true };
1668
- });
1511
+ }
1512
+ initPermissionClasses() {
1513
+ if (isPlatformBrowser(this.platformId)) {
1514
+ effect(() => {
1515
+ const logged = this.options().provider.logged();
1516
+ if (logged) {
1517
+ this.authService.getPermissions().forEach((permission) => {
1518
+ this.elementRef.nativeElement.classList.add('auth-permissions-' + permission);
1519
+ });
1520
+ }
1521
+ }, { injector: this.injector }); // Auto cleanup with component
1669
1522
  }
1670
- if (options.type === FieldType.pesel) {
1671
- result.push((c) => {
1672
- if (!c.value)
1673
- return;
1674
- if (PeselService.isValid(c.value))
1675
- return null;
1676
- return { pesel: true };
1677
- });
1678
- }
1679
- if (options.possibilities?.minLength) {
1680
- result.push(Validators.minLength(options.possibilities?.minLength));
1681
- }
1682
- if (options.possibilities?.maxLength) {
1683
- result.push(Validators.maxLength(options.possibilities?.maxLength));
1684
- }
1685
- if (options.possibilities?.min || options.possibilities?.min === 0) {
1686
- result.push(Validators.min(options.possibilities?.min));
1523
+ }
1524
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AppBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1525
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.1.0", type: AppBaseComponent, isStandalone: true, inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "endMenuContainer", first: true, predicate: ["endMenuContainer"], descendants: true, isSignal: true }], ngImport: i0 });
1526
+ }
1527
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: AppBaseComponent, decorators: [{
1528
+ type: Directive
1529
+ }], ctorParameters: () => [] });
1530
+
1531
+ class BaseComponent {
1532
+ get takeUntilDestroy() {
1533
+ return takeUntil(this.destroy$);
1534
+ }
1535
+ destroy$ = new Subject();
1536
+ ngOnDestroy() {
1537
+ this.destroy$.next(true);
1538
+ this.destroy$.unsubscribe();
1539
+ }
1540
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1541
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: BaseComponent, isStandalone: true, ngImport: i0 });
1542
+ }
1543
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BaseComponent, decorators: [{
1544
+ type: Directive
1545
+ }] });
1546
+ function CreateDynamicComponent(type) {
1547
+ class Component extends BaseComponent {
1548
+ cd = inject(ChangeDetectorRef);
1549
+ moduleRef = inject((NgModuleRef));
1550
+ componentFactoryResolver = inject(ComponentFactoryResolver);
1551
+ _renderCustom = false;
1552
+ _findDynamicContent = false;
1553
+ baseInstance = null;
1554
+ baseComponentRef = null;
1555
+ dynamicType = type;
1556
+ template = signal('default', ...(ngDevMode ? [{ debugName: "template" }] : []));
1557
+ refreshDynamicInstance() {
1558
+ this.init();
1559
+ if (!this.baseInstance)
1560
+ return;
1561
+ this.refreshProperties();
1687
1562
  }
1688
- if (options.possibilities?.max || options.possibilities?.max === 0) {
1689
- result.push(Validators.max(options.possibilities?.max));
1563
+ ngDoCheck() {
1564
+ if (this._findDynamicContent || !this.dynamicContents())
1565
+ return;
1566
+ this._findDynamicContent = true;
1567
+ toObservable(this.dynamicContents)
1568
+ .pipe(this.takeUntilDestroy)
1569
+ .subscribe(() => {
1570
+ this.init();
1571
+ });
1572
+ this.init();
1690
1573
  }
1691
- if (options.unique && uniqueProvider) {
1692
- asyncResult.push(async (c) => {
1693
- const record = {
1694
- [key]: options.type === FieldType.int ? c.value : `'${c.value}'`,
1695
- };
1696
- const withFields = options.unique?.withFields;
1697
- if (form.value && withFields) {
1698
- withFields.forEach((fieldKey) => {
1699
- record[fieldKey] = form.value[fieldKey];
1700
- });
1574
+ init() {
1575
+ const component = DynamicComponentStorageService.get(this.dynamicType, this.moduleRef)[0];
1576
+ this.template.set(component ? 'custom' : 'default');
1577
+ if (component && !this._renderCustom) {
1578
+ const factory = this.componentFactoryResolver.resolveComponentFactory(component);
1579
+ const first = this.dynamicContents()[0];
1580
+ if (first) {
1581
+ this._renderCustom = true;
1582
+ this.baseComponentRef = first.container.createComponent(factory);
1583
+ this.baseInstance = this.baseComponentRef.instance;
1584
+ this.refreshDynamicInstance();
1585
+ this.baseInstance
1586
+ ?.contentTpl()
1587
+ ?.createEmbeddedView(this.contentTpl());
1701
1588
  }
1702
- if (await uniqueProvider(record))
1703
- return null;
1704
- return {
1705
- invalidUnique: true,
1706
- };
1707
- });
1589
+ }
1590
+ if (this.cd)
1591
+ this.cd.detectChanges();
1708
1592
  }
1709
- control.setValidators(result);
1710
- control.setAsyncValidators(asyncResult);
1593
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: Component, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1594
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: Component, isStandalone: true, usesInheritance: true, ngImport: i0 });
1711
1595
  }
1712
- createControl(obj, field, required) {
1713
- let result;
1714
- const zipCodeValidator = (c) => {
1715
- if (c.value && ZipCodeService.isInvalid(c.value)) {
1716
- return {
1717
- invalidZipCode: true,
1718
- };
1719
- }
1720
- return null;
1721
- };
1722
- switch (field.options.type) {
1723
- case FieldType.address:
1724
- result = this.fb.group({
1725
- city: ['', required ? [Validators.required] : null],
1726
- street: ['', required ? [Validators.required] : null],
1727
- buildingNumber: ['', required ? [Validators.required] : null],
1728
- flatNumber: [''],
1729
- zipCode: [
1730
- '',
1731
- required
1732
- ? [Validators.required, zipCodeValidator]
1733
- : [zipCodeValidator],
1734
- ],
1735
- });
1736
- break;
1737
- default:
1738
- result = this.fb.control(null);
1739
- break;
1596
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: Component, decorators: [{
1597
+ type: Directive
1598
+ }] });
1599
+ return Component;
1600
+ }
1601
+
1602
+ class ButtonBaseComponent {
1603
+ static smartType = 'button';
1604
+ mode = signal('default', ...(ngDevMode ? [{ debugName: "mode" }] : []));
1605
+ options = input.required(...(ngDevMode ? [{ debugName: "options" }] : []));
1606
+ disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
1607
+ contentTpl = viewChild('contentTpl', ...(ngDevMode ? [{ debugName: "contentTpl" }] : []));
1608
+ invoke() {
1609
+ if (!this.options())
1610
+ return;
1611
+ if (this.options().confirm) {
1612
+ this.mode.set('confirm');
1613
+ }
1614
+ else {
1615
+ this.options().click();
1740
1616
  }
1741
- const value = obj[field.key]
1742
- ? obj[field.key]
1743
- : field.options.defaltValue
1744
- ? field.options.defaltValue()
1745
- : null;
1746
- if (value)
1747
- result.setValue(value);
1748
- result.updateValueAndValidity();
1749
- return result;
1750
1617
  }
1751
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FormFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1752
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FormFactory });
1618
+ confirmInvoke() {
1619
+ if (!this.options())
1620
+ return;
1621
+ this.options().click();
1622
+ this.mode.set('default');
1623
+ }
1624
+ confirmCancel() {
1625
+ if (!this.options())
1626
+ return;
1627
+ this.mode.set('default');
1628
+ }
1629
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ButtonBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1630
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "20.1.0", type: ButtonBaseComponent, isStandalone: true, inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "contentTpl", first: true, predicate: ["contentTpl"], descendants: true, isSignal: true }], ngImport: i0 });
1753
1631
  }
1754
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FormFactory, decorators: [{
1755
- type: Injectable
1632
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ButtonBaseComponent, decorators: [{
1633
+ type: Directive
1756
1634
  }] });
1757
1635
 
1758
- class SharedFactoriesModule {
1759
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedFactoriesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1760
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: SharedFactoriesModule, imports: [ReactiveFormsModule] });
1761
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedFactoriesModule, providers: [FormFactory], imports: [ReactiveFormsModule] });
1636
+ class ButtonStandardComponent extends ButtonBaseComponent {
1637
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ButtonStandardComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1638
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: ButtonStandardComponent, isStandalone: true, selector: "smart-button-standard", usesInheritance: true, ngImport: i0, template: "@if (mode() != 'confirm') {\n @let loading = options()?.loading();\n <div class=\"text-2xl italic container\"></div>\n <!-- <ion-button-->\n <!-- class=\"h-14 min-w-14 align-middle rounded-none\" -->\n <!-- [color]=\"options?.color\"-->\n <!-- [expand]=\"options?.expand\"-->\n <!-- [type]=\"options?.type\"-->\n <!-- (click)=\"invoke()\"-->\n <!-- [disabled]=\"disabled || loading\"-->\n <!-- >-->\n @if (loading) {\n <!-- <ion-spinner></ion-spinner>-->\n } @else {\n <ng-content></ng-content>\n }\n <!-- </ion-button>-->\n} @else {\n <!-- <ion-button-->\n <!-- class=\"h-14 min-w-14 align-middle rounded-none\" -->\n <!-- [expand]=\"options?.expand\"-->\n <!-- color=\"light\"-->\n <!-- (click)=\"confirmCancel()\"-->\n <!-- >-->\n {{ 'cancel' | translate }}\n <!-- </ion-button>-->\n <!-- <ion-button-->\n <!-- class=\"h-14 min-w-14 align-middle rounded-none\" -->\n <!-- [expand]=\"options?.expand\"-->\n <!-- color=\"primary\"-->\n <!-- (click)=\"confirmInvoke()\"-->\n <!-- >-->\n {{ 'confirm' | translate }}\n <!-- </ion-button>-->\n}\n", dependencies: [{ kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1762
1639
  }
1763
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedFactoriesModule, decorators: [{
1764
- type: NgModule,
1765
- args: [{
1766
- imports: [ReactiveFormsModule],
1767
- providers: [FormFactory],
1768
- }]
1640
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ButtonStandardComponent, decorators: [{
1641
+ type: Component,
1642
+ args: [{ selector: 'smart-button-standard', encapsulation: ViewEncapsulation.None, imports: [TranslatePipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (mode() != 'confirm') {\n @let loading = options()?.loading();\n <div class=\"text-2xl italic container\"></div>\n <!-- <ion-button-->\n <!-- class=\"h-14 min-w-14 align-middle rounded-none\" -->\n <!-- [color]=\"options?.color\"-->\n <!-- [expand]=\"options?.expand\"-->\n <!-- [type]=\"options?.type\"-->\n <!-- (click)=\"invoke()\"-->\n <!-- [disabled]=\"disabled || loading\"-->\n <!-- >-->\n @if (loading) {\n <!-- <ion-spinner></ion-spinner>-->\n } @else {\n <ng-content></ng-content>\n }\n <!-- </ion-button>-->\n} @else {\n <!-- <ion-button-->\n <!-- class=\"h-14 min-w-14 align-middle rounded-none\" -->\n <!-- [expand]=\"options?.expand\"-->\n <!-- color=\"light\"-->\n <!-- (click)=\"confirmCancel()\"-->\n <!-- >-->\n {{ 'cancel' | translate }}\n <!-- </ion-button>-->\n <!-- <ion-button-->\n <!-- class=\"h-14 min-w-14 align-middle rounded-none\" -->\n <!-- [expand]=\"options?.expand\"-->\n <!-- color=\"primary\"-->\n <!-- (click)=\"confirmInvoke()\"-->\n <!-- >-->\n {{ 'confirm' | translate }}\n <!-- </ion-button>-->\n}\n" }]
1769
1643
  }] });
1770
1644
 
1771
- class ExportComponent {
1772
- value = input(undefined, ...(ngDevMode ? [{ debugName: "value" }] : []));
1773
- fileName = input(...(ngDevMode ? [undefined, { debugName: "fileName" }] : []));
1774
- handler = input.required(...(ngDevMode ? [{ debugName: "handler" }] : []));
1775
- async onClick() {
1776
- const value = this.value();
1777
- if (value) {
1778
- this.handler()(value);
1779
- return;
1780
- }
1645
+ class ButtonComponent extends CreateDynamicComponent('button') {
1646
+ options = input.required(...(ngDevMode ? [{ debugName: "options" }] : []));
1647
+ disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
1648
+ contentTpl = viewChild('contentTpl', ...(ngDevMode ? [{ debugName: "contentTpl" }] : []));
1649
+ dynamicContents = viewChildren(DynamicContentDirective, ...(ngDevMode ? [{ debugName: "dynamicContents" }] : []));
1650
+ constructor() {
1651
+ super();
1652
+ effect(() => {
1653
+ this.options(); //Track changes only
1654
+ this.disabled(); //Track changes only
1655
+ this.refreshDynamicInstance();
1656
+ });
1781
1657
  }
1782
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ExportComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1783
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.1.0", type: ExportComponent, isStandalone: true, selector: "smart-export", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, fileName: { classPropertyName: "fileName", publicName: "fileName", isSignal: true, isRequired: false, transformFunction: null }, handler: { classPropertyName: "handler", publicName: "handler", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
1784
- <!--<ion-button title="export" (click)="onClick()" slot="icon-only">-->
1785
- <!-- <ion-icon name="download"></ion-icon>-->
1786
- <!--</ion-button>-->
1787
- `, isInline: true });
1658
+ refreshProperties() {
1659
+ this.baseInstance.options = this.options;
1660
+ this.baseInstance.disabled = this.disabled;
1661
+ }
1662
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1663
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: ButtonComponent, isStandalone: true, selector: "smart-button", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "contentTpl", first: true, predicate: ["contentTpl"], descendants: true, isSignal: true }, { propertyName: "dynamicContents", predicate: DynamicContentDirective, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: `
1664
+ @if (template() === 'default') {
1665
+ <smart-button-standard [options]="options()" [disabled]="disabled()">
1666
+ <ng-container [ngTemplateOutlet]="contentTpl"></ng-container>
1667
+ </smart-button-standard>
1668
+ }
1669
+ <ng-template #contentTpl>
1670
+ <ng-content></ng-content>
1671
+ </ng-template>
1672
+ <div class="dynamic-content"></div>
1673
+ `, isInline: true, dependencies: [{ kind: "component", type: ButtonStandardComponent, selector: "smart-button-standard" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1788
1674
  }
1789
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ExportComponent, decorators: [{
1675
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ButtonComponent, decorators: [{
1790
1676
  type: Component,
1791
1677
  args: [{
1792
- selector: 'smart-export',
1678
+ selector: 'smart-button',
1793
1679
  template: `
1794
- <!--<ion-button title="export" (click)="onClick()" slot="icon-only">-->
1795
- <!-- <ion-icon name="download"></ion-icon>-->
1796
- <!--</ion-button>-->
1680
+ @if (template() === 'default') {
1681
+ <smart-button-standard [options]="options()" [disabled]="disabled()">
1682
+ <ng-container [ngTemplateOutlet]="contentTpl"></ng-container>
1683
+ </smart-button-standard>
1684
+ }
1685
+ <ng-template #contentTpl>
1686
+ <ng-content></ng-content>
1687
+ </ng-template>
1688
+ <div class="dynamic-content"></div>
1797
1689
  `,
1690
+ encapsulation: ViewEncapsulation.None,
1691
+ imports: [ButtonStandardComponent, NgTemplateOutlet],
1692
+ changeDetection: ChangeDetectionStrategy.OnPush,
1798
1693
  }]
1799
- }] });
1694
+ }], ctorParameters: () => [] });
1800
1695
 
1801
- class ImportComponent {
1802
- renderer;
1803
- accept = input('application/json', ...(ngDevMode ? [{ debugName: "accept" }] : []));
1804
- set = output();
1805
- inputElementRef = viewChild('inputObj', ...(ngDevMode ? [{ debugName: "inputElementRef" }] : []));
1806
- constructor(renderer) {
1807
- this.renderer = renderer;
1696
+ class FormFactory {
1697
+ fb = inject(UntypedFormBuilder);
1698
+ authService = inject(AuthService);
1699
+ detailsService = inject(DetailsService);
1700
+ validatorsProvider = inject(MODEL_VALIDATORS_PROVIDER);
1701
+ static checkModelMeta(obj) {
1702
+ if (!obj)
1703
+ throw new Error('You should set object as param');
1704
+ if (!Reflect.hasMetadata(SYMBOL_MODEL, obj.constructor))
1705
+ throw new Error('You should mark class with @Model decorator');
1808
1706
  }
1809
- async onClick() {
1810
- this.inputElementRef()?.nativeElement?.click();
1707
+ static getOptions(obj, key) {
1708
+ return Reflect.getMetadata(SYMBOL_FIELD, obj, key);
1811
1709
  }
1812
- ngAfterViewInit() {
1813
- const elementRef = this.inputElementRef();
1814
- if (elementRef) {
1815
- this.renderer.listen(elementRef?.nativeElement, 'change', () => {
1816
- const file = (elementRef?.nativeElement).files?.[0] ?? null;
1817
- (elementRef?.nativeElement).type = 'text';
1818
- (elementRef?.nativeElement).type = 'file';
1819
- if (file) {
1820
- this.set.emit(file);
1710
+ static getOptionsFromMode(options, mode) {
1711
+ let result = options;
1712
+ if (!mode)
1713
+ return result;
1714
+ if (mode === 'create' && _.isObject(options.create)) {
1715
+ result = {
1716
+ ...options,
1717
+ ...options.create,
1718
+ };
1719
+ }
1720
+ else if (mode === 'update' && _.isObject(options.update)) {
1721
+ result = {
1722
+ ...options,
1723
+ ...options.update,
1724
+ };
1725
+ }
1726
+ return result;
1727
+ }
1728
+ async create(obj, ops = {}) {
1729
+ FormFactory.checkModelMeta(obj);
1730
+ const result = SmartFormGroup.create();
1731
+ const fields = getModelFieldsWithOptions(obj).filter((field) => {
1732
+ return (!ops.mode ||
1733
+ (ops.mode === 'create' && field.options.create) ||
1734
+ (ops.mode === 'update' && field.options.update) ||
1735
+ (ops.mode === 'multiUpdate' &&
1736
+ field.options?.update?.multi) ||
1737
+ (ops.mode !== 'create' &&
1738
+ ops.mode !== 'update' &&
1739
+ field.options.customs &&
1740
+ field.options.customs.some((custom) => custom.mode === ops.mode)));
1741
+ });
1742
+ const enabledDefinitions = [];
1743
+ for (let index = 0; index < fields.length; index++) {
1744
+ const field = fields[index];
1745
+ let control = null;
1746
+ const options = FormFactory.getOptionsFromMode(field.options, ops.mode);
1747
+ if (options.permissions &&
1748
+ !this.authService.expectPermissions(options.permissions)) {
1749
+ continue;
1750
+ }
1751
+ if (field.options.type === FieldType.object) {
1752
+ control = await this.create(obj[field.key], {
1753
+ ...ops,
1754
+ root: ops.root ? ops.root : result,
1755
+ });
1756
+ }
1757
+ else if (field.options.type === FieldType.array) {
1758
+ control = this.fb.array([]);
1759
+ if (obj[field.key]) {
1760
+ for (let indexField = 0; indexField < obj[field.key].length; indexField++) {
1761
+ control.push(await this.create(obj[field.key][indexField], {
1762
+ ...ops,
1763
+ root: ops.root ? ops.root : result,
1764
+ }));
1765
+ }
1821
1766
  }
1822
- else {
1823
- throw Error('ImportComponent: File not found');
1767
+ }
1768
+ else {
1769
+ control = this.createControl(obj, field, options?.required ?? false);
1770
+ }
1771
+ this.setValidators(field.key, control, options, result, ops.uniqueProvider);
1772
+ if (this.validatorsProvider) {
1773
+ const providerResult = await this.validatorsProvider.get({
1774
+ key: field.key,
1775
+ instance: obj,
1776
+ type: obj.constructor,
1777
+ base: {
1778
+ validators: control?.validator ?? undefined,
1779
+ asyncValidators: control?.asyncValidator ?? undefined,
1780
+ },
1781
+ });
1782
+ control.setValidators(providerResult?.validators ?? null);
1783
+ control.setAsyncValidators(providerResult?.asyncValidators ?? null);
1784
+ }
1785
+ result.addControl(field.key, control);
1786
+ if (options.confirm && options.type === FieldType.object) {
1787
+ throw Error('Object not supported confirms');
1788
+ }
1789
+ if (options.confirm) {
1790
+ const confirmControl = this.fb.control(null, [
1791
+ Validators.required,
1792
+ (a) => {
1793
+ if (a.value !== result.controls[field.key].value) {
1794
+ return {
1795
+ confirm: true,
1796
+ };
1797
+ }
1798
+ return null;
1799
+ },
1800
+ ]);
1801
+ result.addControl(field.key + 'Confirm', confirmControl);
1802
+ }
1803
+ if (options.enabled) {
1804
+ enabledDefinitions.push({
1805
+ key: field.key,
1806
+ control,
1807
+ enabled: options.enabled,
1808
+ });
1809
+ }
1810
+ }
1811
+ let rootCheck = null;
1812
+ if (enabledDefinitions.some((d) => d?.enabled?.criteria &&
1813
+ Object.keys(d.enabled.criteria).some((k) => k.indexOf(SPECIFICATION_ROOT_KEY) === 0)) &&
1814
+ ops.root) {
1815
+ rootCheck = ops.root;
1816
+ }
1817
+ (rootCheck ? rootCheck : result).valueChanges
1818
+ .pipe(tap(() => {
1819
+ enabledDefinitions.forEach((def) => {
1820
+ const enabled = SpecificationService.valid({
1821
+ ...(obj ? obj : {}),
1822
+ ...result.value,
1823
+ }, def.enabled, {
1824
+ $root: rootCheck?.value,
1825
+ });
1826
+ def.control['__smartDisabled'] = !enabled;
1827
+ });
1828
+ }), delay(0))
1829
+ .subscribe(() => {
1830
+ if (rootCheck)
1831
+ this.detailsService.setRoot(rootCheck.value, true);
1832
+ enabledDefinitions.forEach((def) => {
1833
+ if (!def.control['__smartDisabled'] &&
1834
+ !result.controls[def.key]) {
1835
+ result.addControl(def.key, def.control);
1836
+ result.updateValueAndValidity();
1837
+ }
1838
+ else if (def.control['__smartDisabled'] &&
1839
+ result.controls[def.key]) {
1840
+ result.removeControl(def.key);
1841
+ result.updateValueAndValidity();
1824
1842
  }
1825
1843
  });
1826
- }
1844
+ });
1845
+ return result;
1827
1846
  }
1828
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ImportComponent, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
1829
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.1.0", type: ImportComponent, isStandalone: true, selector: "smart-import", inputs: { accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { set: "set" }, viewQueries: [{ propertyName: "inputElementRef", first: true, predicate: ["inputObj"], descendants: true, isSignal: true }], ngImport: i0, template: `
1830
- <!--<ion-button title="import" (click)="onClick()" slot="icon-only">-->
1831
- <!-- <ion-icon name="cloud-upload"></ion-icon>-->
1832
- <!--</ion-button>-->
1833
- <input
1834
- type="file"
1835
- [accept]="accept() ? accept() : 'application/json'"
1836
- [hidden]="true"
1837
- #inputObj
1838
- />
1839
- `, isInline: true, styles: [":host{cursor:pointer;font-size:3rem;height:3rem;margin:10px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1840
- }
1841
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ImportComponent, decorators: [{
1842
- type: Component,
1843
- args: [{ selector: 'smart-import', template: `
1844
- <!--<ion-button title="import" (click)="onClick()" slot="icon-only">-->
1845
- <!-- <ion-icon name="cloud-upload"></ion-icon>-->
1846
- <!--</ion-button>-->
1847
- <input
1848
- type="file"
1849
- [accept]="accept() ? accept() : 'application/json'"
1850
- [hidden]="true"
1851
- #inputObj
1852
- />
1853
- `, changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{cursor:pointer;font-size:3rem;height:3rem;margin:10px}\n"] }]
1854
- }], ctorParameters: () => [{ type: i0.Renderer2 }] });
1855
-
1856
- class ModelLabelPipe {
1857
- translateService = inject(TranslateService);
1858
- modelLabelProvider = inject(IModelLabelProvider);
1859
- transform(instance, key, type) {
1860
- if (this.modelLabelProvider) {
1861
- const result = this.modelLabelProvider.get({
1862
- instance: instance,
1863
- key: key,
1864
- type: type,
1847
+ setValidators(key, control, options, form, uniqueProvider) {
1848
+ const result = [];
1849
+ const asyncResult = [];
1850
+ if (options.required) {
1851
+ result.push(Validators.required);
1852
+ }
1853
+ if (options.type === FieldType.email) {
1854
+ result.push((c) => {
1855
+ if (!c.value)
1856
+ return;
1857
+ const reg = new RegExp('^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$');
1858
+ if (reg.test(c.value))
1859
+ return null;
1860
+ return { email: true };
1865
1861
  });
1866
- if (result())
1867
- return result();
1868
1862
  }
1869
- return toSignal(this.translateService.instant('MODEL.' + key))();
1870
- }
1871
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ModelLabelPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1872
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: ModelLabelPipe, isStandalone: true, name: "smartModelLabel" });
1873
- }
1874
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ModelLabelPipe, decorators: [{
1875
- type: Pipe,
1876
- args: [{
1877
- name: 'smartModelLabel',
1878
- }]
1879
- }] });
1880
-
1881
- class ListCellPipe {
1882
- translateService = inject(TranslateService);
1883
- transform(obj, key, pipe, type) {
1884
- if (!obj)
1885
- return {};
1886
- let result;
1887
- const fieldType = this.getFieldType(type, key);
1888
- if (!pipe)
1889
- result = this.getValue(obj, key);
1890
- else {
1891
- result = pipe.transform(obj, key, (val) => {
1892
- return this.translateService.instant(val);
1863
+ if (options.type === FieldType.phoneNumber) {
1864
+ result.push((c) => {
1865
+ if (!c.value)
1866
+ return;
1867
+ const reg = new RegExp('^((\\+91-?)|0)?[0-9]{9}$');
1868
+ if (reg.test(c.value))
1869
+ return null;
1870
+ return { phoneNumber: true };
1893
1871
  });
1894
1872
  }
1895
- if (!result)
1896
- return result;
1897
- if (typeof result === 'string') {
1898
- result = this.translateService.instant(result);
1873
+ if (options.type === FieldType.pesel) {
1874
+ result.push((c) => {
1875
+ if (!c.value)
1876
+ return;
1877
+ if (PeselService.isValid(c.value))
1878
+ return null;
1879
+ return { pesel: true };
1880
+ });
1899
1881
  }
1900
- if (fieldType === 'enum') {
1901
- result = result.map((item) => {
1902
- return this.translateService.instant(item);
1882
+ if (options.possibilities?.minLength) {
1883
+ result.push(Validators.minLength(options.possibilities?.minLength));
1884
+ }
1885
+ if (options.possibilities?.maxLength) {
1886
+ result.push(Validators.maxLength(options.possibilities?.maxLength));
1887
+ }
1888
+ if (options.possibilities?.min || options.possibilities?.min === 0) {
1889
+ result.push(Validators.min(options.possibilities?.min));
1890
+ }
1891
+ if (options.possibilities?.max || options.possibilities?.max === 0) {
1892
+ result.push(Validators.max(options.possibilities?.max));
1893
+ }
1894
+ if (options.unique && uniqueProvider) {
1895
+ asyncResult.push(async (c) => {
1896
+ const record = {
1897
+ [key]: options.type === FieldType.int ? c.value : `'${c.value}'`,
1898
+ };
1899
+ const withFields = options.unique?.withFields;
1900
+ if (form.value && withFields) {
1901
+ withFields.forEach((fieldKey) => {
1902
+ record[fieldKey] = form.value[fieldKey];
1903
+ });
1904
+ }
1905
+ if (await uniqueProvider(record))
1906
+ return null;
1907
+ return {
1908
+ invalidUnique: true,
1909
+ };
1903
1910
  });
1904
1911
  }
1905
- return {
1906
- value: result,
1907
- type: fieldType,
1908
- };
1912
+ control.setValidators(result);
1913
+ control.setAsyncValidators(asyncResult);
1909
1914
  }
1910
- getFieldType(type, key) {
1911
- if (!type)
1915
+ createControl(obj, field, required) {
1916
+ let result;
1917
+ const zipCodeValidator = (c) => {
1918
+ if (c.value && ZipCodeService.isInvalid(c.value)) {
1919
+ return {
1920
+ invalidZipCode: true,
1921
+ };
1922
+ }
1912
1923
  return null;
1913
- const options = getModelFieldOptions(new type(), key);
1914
- return options?.type ?? null;
1915
- }
1916
- getValue(value, key) {
1917
- if (key.indexOf('__array') === 0) {
1918
- const info = key.split('.');
1919
- const arrayKey = info[1];
1920
- const index = Number(info[2]);
1921
- const rowKey = info[4];
1922
- return value[arrayKey][index][rowKey];
1924
+ };
1925
+ switch (field.options.type) {
1926
+ case FieldType.address:
1927
+ result = this.fb.group({
1928
+ city: ['', required ? [Validators.required] : null],
1929
+ street: ['', required ? [Validators.required] : null],
1930
+ buildingNumber: ['', required ? [Validators.required] : null],
1931
+ flatNumber: [''],
1932
+ zipCode: [
1933
+ '',
1934
+ required
1935
+ ? [Validators.required, zipCodeValidator]
1936
+ : [zipCodeValidator],
1937
+ ],
1938
+ });
1939
+ break;
1940
+ default:
1941
+ result = this.fb.control(null);
1942
+ break;
1923
1943
  }
1924
- return value[key];
1944
+ const value = obj[field.key]
1945
+ ? obj[field.key]
1946
+ : field.options.defaltValue
1947
+ ? field.options.defaltValue()
1948
+ : null;
1949
+ if (value)
1950
+ result.setValue(value);
1951
+ result.updateValueAndValidity();
1952
+ return result;
1925
1953
  }
1926
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListCellPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1927
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: ListCellPipe, isStandalone: true, name: "smartListCell" });
1954
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FormFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1955
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FormFactory });
1928
1956
  }
1929
- __decorate([
1930
- Memoize(),
1931
- __metadata("design:type", Function),
1932
- __metadata("design:paramtypes", [Type, String]),
1933
- __metadata("design:returntype", Object)
1934
- ], ListCellPipe.prototype, "getFieldType", null);
1935
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListCellPipe, decorators: [{
1936
- type: Pipe,
1937
- args: [{
1938
- name: 'smartListCell',
1939
- }]
1940
- }], propDecorators: { getFieldType: [] } });
1957
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FormFactory, decorators: [{
1958
+ type: Injectable
1959
+ }] });
1941
1960
 
1942
- class TrustHtmlPipe {
1943
- sanitizer = inject(DomSanitizer);
1944
- transform(val) {
1945
- if (!val)
1946
- return val;
1947
- return this.sanitizer.bypassSecurityTrustHtml(val);
1948
- }
1949
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: TrustHtmlPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1950
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: TrustHtmlPipe, isStandalone: true, name: "smartTrustHtml" });
1961
+ class SharedFactoriesModule {
1962
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedFactoriesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1963
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: SharedFactoriesModule, imports: [ReactiveFormsModule] });
1964
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedFactoriesModule, providers: [FormFactory], imports: [ReactiveFormsModule] });
1951
1965
  }
1952
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: TrustHtmlPipe, decorators: [{
1953
- type: Pipe,
1966
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedFactoriesModule, decorators: [{
1967
+ type: NgModule,
1954
1968
  args: [{
1955
- name: 'smartTrustHtml',
1969
+ imports: [ReactiveFormsModule],
1970
+ providers: [FormFactory],
1956
1971
  }]
1957
1972
  }] });
1958
1973
 
1959
- class ListHeaderPipe {
1960
- translateService = inject(TranslateService);
1961
- modelLabelProvider = inject(IModelLabelProvider);
1962
- transform(data, key, type) {
1963
- if (key.indexOf('__array') === 0) {
1964
- const info = key.split('.');
1965
- const arrayKey = info[1];
1966
- const index = Number(info[2]);
1967
- const headerKey = info[3];
1968
- return signal(data[0][arrayKey][index][headerKey]);
1969
- }
1970
- if (this.modelLabelProvider) {
1971
- const result = this.modelLabelProvider.get({ type, key });
1972
- if (result)
1973
- return result;
1974
+ class ExportComponent {
1975
+ value = input(undefined, ...(ngDevMode ? [{ debugName: "value" }] : []));
1976
+ fileName = input(...(ngDevMode ? [undefined, { debugName: "fileName" }] : []));
1977
+ handler = input.required(...(ngDevMode ? [{ debugName: "handler" }] : []));
1978
+ async onClick() {
1979
+ const value = this.value();
1980
+ if (value) {
1981
+ this.handler()(value);
1982
+ return;
1974
1983
  }
1975
- return signal(this.translateService.instant('MODEL.' + key));
1976
1984
  }
1977
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListHeaderPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1978
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: ListHeaderPipe, isStandalone: true, name: "smartListHeader" });
1985
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ExportComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1986
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.1.0", type: ExportComponent, isStandalone: true, selector: "smart-export", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, fileName: { classPropertyName: "fileName", publicName: "fileName", isSignal: true, isRequired: false, transformFunction: null }, handler: { classPropertyName: "handler", publicName: "handler", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
1987
+ <!--<ion-button title="export" (click)="onClick()" slot="icon-only">-->
1988
+ <!-- <ion-icon name="download"></ion-icon>-->
1989
+ <!--</ion-button>-->
1990
+ `, isInline: true });
1979
1991
  }
1980
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListHeaderPipe, decorators: [{
1981
- type: Pipe,
1992
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ExportComponent, decorators: [{
1993
+ type: Component,
1982
1994
  args: [{
1983
- name: 'smartListHeader',
1995
+ selector: 'smart-export',
1996
+ template: `
1997
+ <!--<ion-button title="export" (click)="onClick()" slot="icon-only">-->
1998
+ <!-- <ion-icon name="download"></ion-icon>-->
1999
+ <!--</ion-button>-->
2000
+ `,
1984
2001
  }]
1985
2002
  }] });
1986
2003
 
1987
- class FileUrlPipe {
1988
- service = inject(FileService);
1989
- transform(file) {
1990
- return this.service.getUrl(file.id);
2004
+ class ImportComponent {
2005
+ renderer;
2006
+ accept = input('application/json', ...(ngDevMode ? [{ debugName: "accept" }] : []));
2007
+ set = output();
2008
+ inputElementRef = viewChild('inputObj', ...(ngDevMode ? [{ debugName: "inputElementRef" }] : []));
2009
+ constructor(renderer) {
2010
+ this.renderer = renderer;
1991
2011
  }
1992
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FileUrlPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1993
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: FileUrlPipe, isStandalone: true, name: "smartFileUrl" });
1994
- }
1995
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: FileUrlPipe, decorators: [{
1996
- type: Pipe,
1997
- args: [{
1998
- name: 'smartFileUrl',
1999
- }]
2000
- }] });
2001
-
2002
- class EnumToListPipe {
2003
- transform(value) {
2004
- if (!value)
2005
- return value;
2006
- return Object.keys(value);
2012
+ async onClick() {
2013
+ this.inputElementRef()?.nativeElement?.click();
2007
2014
  }
2008
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: EnumToListPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2009
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: EnumToListPipe, isStandalone: true, name: "smartEnumToList" });
2015
+ ngAfterViewInit() {
2016
+ const elementRef = this.inputElementRef();
2017
+ if (elementRef) {
2018
+ this.renderer.listen(elementRef?.nativeElement, 'change', () => {
2019
+ const file = (elementRef?.nativeElement).files?.[0] ?? null;
2020
+ (elementRef?.nativeElement).type = 'text';
2021
+ (elementRef?.nativeElement).type = 'file';
2022
+ if (file) {
2023
+ this.set.emit(file);
2024
+ }
2025
+ else {
2026
+ throw Error('ImportComponent: File not found');
2027
+ }
2028
+ });
2029
+ }
2030
+ }
2031
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ImportComponent, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
2032
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.1.0", type: ImportComponent, isStandalone: true, selector: "smart-import", inputs: { accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { set: "set" }, viewQueries: [{ propertyName: "inputElementRef", first: true, predicate: ["inputObj"], descendants: true, isSignal: true }], ngImport: i0, template: `
2033
+ <!--<ion-button title="import" (click)="onClick()" slot="icon-only">-->
2034
+ <!-- <ion-icon name="cloud-upload"></ion-icon>-->
2035
+ <!--</ion-button>-->
2036
+ <input
2037
+ type="file"
2038
+ [accept]="accept() ? accept() : 'application/json'"
2039
+ [hidden]="true"
2040
+ #inputObj
2041
+ />
2042
+ `, isInline: true, styles: [":host{cursor:pointer;font-size:3rem;height:3rem;margin:10px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2010
2043
  }
2011
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: EnumToListPipe, decorators: [{
2012
- type: Pipe,
2013
- args: [{
2014
- name: 'smartEnumToList',
2015
- }]
2016
- }] });
2017
-
2018
- const PIPES = [
2019
- ModelLabelPipe,
2020
- ListCellPipe,
2021
- TrustHtmlPipe,
2022
- ListHeaderPipe,
2023
- EnumToListPipe,
2024
- ];
2025
- class SharedPipesModule {
2026
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2027
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: SharedPipesModule, imports: [ModelLabelPipe,
2028
- ListCellPipe,
2029
- TrustHtmlPipe,
2030
- ListHeaderPipe,
2031
- EnumToListPipe], exports: [ModelLabelPipe,
2032
- ListCellPipe,
2033
- TrustHtmlPipe,
2034
- ListHeaderPipe,
2035
- EnumToListPipe] });
2036
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedPipesModule });
2037
- }
2038
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedPipesModule, decorators: [{
2039
- type: NgModule,
2040
- args: [{
2041
- declarations: [],
2042
- imports: [PIPES],
2043
- exports: [...PIPES],
2044
- }]
2045
- }] });
2044
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ImportComponent, decorators: [{
2045
+ type: Component,
2046
+ args: [{ selector: 'smart-import', template: `
2047
+ <!--<ion-button title="import" (click)="onClick()" slot="icon-only">-->
2048
+ <!-- <ion-icon name="cloud-upload"></ion-icon>-->
2049
+ <!--</ion-button>-->
2050
+ <input
2051
+ type="file"
2052
+ [accept]="accept() ? accept() : 'application/json'"
2053
+ [hidden]="true"
2054
+ #inputObj
2055
+ />
2056
+ `, changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{cursor:pointer;font-size:3rem;height:3rem;margin:10px}\n"] }]
2057
+ }], ctorParameters: () => [{ type: i0.Renderer2 }] });
2046
2058
 
2047
2059
  class InputBaseComponent extends BaseComponent {
2048
2060
  cd = inject(ChangeDetectorRef);
@@ -6042,18 +6054,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImpor
6042
6054
  }]
6043
6055
  }], ctorParameters: () => [{ type: DetailsService }] });
6044
6056
 
6045
- var PaginationMode;
6046
- (function (PaginationMode) {
6047
- PaginationMode["infiniteScroll"] = "infiniteScroll";
6048
- PaginationMode["singlePage"] = "singlePage";
6049
- })(PaginationMode || (PaginationMode = {}));
6050
- var ListMode;
6051
- (function (ListMode) {
6052
- ListMode["mobile"] = "mobile";
6053
- ListMode["desktop"] = "desktop";
6054
- ListMode["masonryGrid"] = "masonryGrid";
6055
- })(ListMode || (ListMode = {}));
6056
-
6057
6057
  class PagingComponent {
6058
6058
  page = input(null, ...(ngDevMode ? [{ debugName: "page" }] : []));
6059
6059
  totalPages = input(null, ...(ngDevMode ? [{ debugName: "totalPages" }] : []));
@@ -6123,515 +6123,139 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImpor
6123
6123
  `, changeDetection: ChangeDetectionStrategy.OnPush, imports: [TranslatePipe], styles: [":host{width:100%}\n"] }]
6124
6124
  }] });
6125
6125
 
6126
- class DetailsPage {
6127
- modalService = inject(ModalService);
6128
- styleService = inject(StyleService);
6129
- elementRef = inject(ElementRef);
6130
- // navParams: NavParams, //TODO: to be injected
6131
- pageOptions = signal({
6132
- title: 'details',
6133
- hideMenuButton: true,
6134
- }, ...(ngDevMode ? [{ debugName: "pageOptions" }] : []));
6135
- detailsOptions;
6126
+ class ListBaseComponent {
6127
+ static smartType = 'list';
6128
+ _fields;
6129
+ provider;
6130
+ authService = inject(AuthService);
6131
+ router = inject(Router);
6132
+ alertService = inject(AlertService);
6133
+ cd = inject(ChangeDetectorRef);
6134
+ translateService = inject(TranslateService);
6135
+ detailsComponent;
6136
+ selectMode;
6137
+ detailsComponentProps;
6138
+ select;
6139
+ unselect;
6140
+ itemHandler = null;
6141
+ removeHandler = null;
6142
+ checkRemoveHandler;
6143
+ detailsButtonOptions;
6144
+ removed = new Set();
6145
+ keys;
6146
+ cellPipe = null;
6147
+ loadPrevPage = null;
6148
+ loadNextPage = null;
6149
+ list;
6150
+ loading;
6151
+ page;
6152
+ totalPages;
6153
+ FieldType = FieldType;
6154
+ PaginationMode = PaginationMode;
6155
+ type;
6156
+ sort;
6157
+ options = input.required(...(ngDevMode ? [{ debugName: "options" }] : []));
6158
+ contentTpl = viewChild('contentTpl', ...(ngDevMode ? [{ debugName: "contentTpl" }] : []));
6136
6159
  constructor() {
6137
- this.detailsOptions = /*navParams.get('value')*/ {};
6138
- this.initTitle();
6139
- this.initButtons();
6140
- }
6141
- ngOnInit() {
6142
- this.styleService.init(this.elementRef);
6143
- }
6144
- initTitle() {
6145
- this.pageOptions.update((options) => {
6146
- if (this.detailsOptions.title) {
6147
- return {
6148
- ...options,
6149
- title: this.detailsOptions.title,
6160
+ effect(() => {
6161
+ const options = this.options();
6162
+ this._fields = options.fields ?? [];
6163
+ this.provider = options.provider;
6164
+ this.sort = options.sort ?? {};
6165
+ this.cellPipe = options.cellPipe ?? null;
6166
+ this.selectMode = options.select;
6167
+ this.type = options.type;
6168
+ this.initKeys();
6169
+ this.initList(options);
6170
+ this.initLoading();
6171
+ const removeHandler = options.remove;
6172
+ if (options.remove) {
6173
+ if (removeHandler?.provider?.check) {
6174
+ this.checkRemoveHandler = removeHandler.provider.check;
6175
+ }
6176
+ this.removeHandler = async (obj) => {
6177
+ await this.alertService.show({
6178
+ header: this.translateService.instant('OBJECT.confirmDelete'),
6179
+ buttons: [
6180
+ {
6181
+ text: this.translateService.instant('cancel'),
6182
+ role: 'cancel',
6183
+ },
6184
+ {
6185
+ text: this.translateService.instant('confirm'),
6186
+ handler: () => {
6187
+ removeHandler?.provider?.invoke?.(obj.id);
6188
+ },
6189
+ },
6190
+ ],
6191
+ backdropDismiss: false,
6192
+ });
6150
6193
  };
6151
6194
  }
6152
- return options;
6153
- });
6154
- }
6155
- initButtons() {
6156
- const buttons = [];
6157
- if (this.detailsOptions.removeHandler) {
6158
- buttons.push({
6159
- handler: () => {
6160
- computed(() => {
6161
- const item = this.detailsOptions.item();
6162
- this.detailsOptions?.removeHandler?.(item);
6163
- this.modalService.dismiss();
6195
+ if (options.item) {
6196
+ const itemOptions = options.item.options;
6197
+ if (!itemOptions)
6198
+ throw Error('Must set edit options');
6199
+ this.itemHandler = (id) => {
6200
+ if (itemOptions?.routingPrefix) {
6201
+ setTimeout(async () => {
6202
+ await this.router.navigate([
6203
+ itemOptions.routingPrefix.replace('//', '/'),
6204
+ id,
6205
+ ]);
6206
+ this.cd.detectChanges();
6207
+ });
6208
+ }
6209
+ else if (itemOptions?.select)
6210
+ itemOptions.select(id);
6211
+ };
6212
+ }
6213
+ const details = options.details;
6214
+ if (options.details) {
6215
+ if (!details?.provider)
6216
+ throw Error('Must set details provider');
6217
+ if (!details?.component)
6218
+ throw Error('Must set details component');
6219
+ this.detailsComponent = details.component;
6220
+ this.detailsComponentProps = {
6221
+ item: details?.provider.item,
6222
+ type: options.type,
6223
+ loading: details?.provider.loading,
6224
+ itemHandler: this.itemHandler ?? null,
6225
+ removeHandler: this.removeHandler,
6226
+ componentFactories: details?.componentFactories,
6227
+ };
6228
+ this.select = details?.provider.getData;
6229
+ this.unselect = details?.provider.clearData;
6230
+ }
6231
+ if (options.pagination) {
6232
+ this.loadNextPage = async (event = null) => {
6233
+ await options?.pagination?.loadNextPage?.();
6234
+ if (event)
6235
+ event.target.complete();
6236
+ setTimeout(() => {
6237
+ window.scrollTo(0, 0);
6164
6238
  });
6165
- },
6166
- icon: 'trash',
6167
- });
6168
- }
6169
- if (this.detailsOptions.itemHandler) {
6170
- buttons.push({
6171
- handler: () => {
6172
- computed(() => {
6173
- const item = this.detailsOptions.item();
6174
- this.detailsOptions?.removeHandler?.(item);
6175
- this.modalService.dismiss();
6239
+ };
6240
+ this.loadPrevPage = async (event = null) => {
6241
+ await options?.pagination?.loadPrevPage?.();
6242
+ if (event)
6243
+ event.target.complete();
6244
+ setTimeout(() => {
6245
+ window.scrollTo(0, 10000);
6176
6246
  });
6177
- },
6178
- icon: 'arrow-forward-outline',
6179
- });
6180
- }
6181
- this.pageOptions.update((options) => ({ ...options, endButtons: buttons }));
6182
- }
6183
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: DetailsPage, deps: [], target: i0.ɵɵFactoryTarget.Component });
6184
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.0", type: DetailsPage, isStandalone: true, selector: "ng-component", ngImport: i0, template: "<smart-page [options]=\"pageOptions()\">\n <smart-details #smartDetails [options]=\"detailsOptions\"></smart-details>\n</smart-page>\n", styles: [":host{width:100%}\n"], dependencies: [{ kind: "component", type: PageComponent, selector: "smart-page", inputs: ["options"] }, { kind: "component", type: DetailsComponent, selector: "smart-details", inputs: ["options"] }] });
6185
- }
6186
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: DetailsPage, decorators: [{
6187
- type: Component,
6188
- args: [{ imports: [PageComponent, DetailsComponent], template: "<smart-page [options]=\"pageOptions()\">\n <smart-details #smartDetails [options]=\"detailsOptions\"></smart-details>\n</smart-page>\n", styles: [":host{width:100%}\n"] }]
6189
- }], ctorParameters: () => [] });
6190
-
6191
- const ACCORDION_COMPONENTS = [
6192
- AccordionComponent,
6193
- AccordionHeaderComponent,
6194
- AccordionBodyComponent,
6195
- ];
6196
- const BUTTON_COMPONENTS = [ButtonComponent, ButtonStandardComponent];
6197
- const CARD_COMPONENTS = [CardComponent];
6198
- const DETAILS_COMPONENTS = [DetailsComponent, DetailsStandardComponent];
6199
- const DETAIL_COMPONENTS = [
6200
- DetailComponent,
6201
- DetailTextComponent,
6202
- DetailFlagComponent,
6203
- DetailEnumComponent,
6204
- DetailEmailComponent,
6205
- DetailAddressComponent,
6206
- DetailObjectComponent,
6207
- DetailColorComponent,
6208
- DetailLogoComponent,
6209
- DetailArrayComponent,
6210
- DetailPdfComponent,
6211
- DetailVideoComponent,
6212
- DetailAttachmentComponent,
6213
- DetailDateRangeComponent,
6214
- DetailImageComponent,
6215
- DetailPhoneNumberPlComponent,
6216
- ];
6217
- const FORM_COMPONENTS = [
6218
- FormStandardComponent,
6219
- FormComponent,
6220
- ];
6221
- const INPUT_COMPONENTS = [
6222
- InputComponent,
6223
- InputIntComponent,
6224
- InputErrorComponent,
6225
- InputTextComponent,
6226
- InputPasswordComponent,
6227
- InputFlagComponent,
6228
- InputEnumComponent,
6229
- InputEmailComponent,
6230
- InputCurrencyComponent,
6231
- InputDateComponent,
6232
- InputDateWithEditComponent,
6233
- InputFileComponent,
6234
- InputRadioComponent,
6235
- InputNipComponent,
6236
- InputStringsComponent,
6237
- InputLongTextComponent,
6238
- InputAddressComponent,
6239
- InputObjectComponent,
6240
- InputColorComponent,
6241
- InputLogoComponent,
6242
- InputCheckComponent,
6243
- InputIntsComponent,
6244
- InputPhoneNumberComponent,
6245
- InputPhoneNumberPlComponent,
6246
- InputPeselComponent,
6247
- InputArrayComponent,
6248
- InputPdfComponent,
6249
- InputVideoComponent,
6250
- InputAttachmentComponent,
6251
- InputDateRangeComponent,
6252
- InputImageComponent,
6253
- InputFloatComponent,
6254
- ];
6255
- const LIST_COMPONENTS = [
6256
- ListComponent,
6257
- ListMobileComponent,
6258
- ListDesktopComponent,
6259
- ListMasonryGridComponent,
6260
- ];
6261
- const LOADER_COMPONENTS = [LoaderComponent];
6262
- const PAGE_COMPONENTS = [PageStandardComponent, PageComponent];
6263
- const INFO_COMPONENTS = [InfoComponent, InfoModalComponent];
6264
- const DATE_RANGE_COMPONENTS = [
6265
- DateRangeComponent,
6266
- DateRangeModalComponent,
6267
- ];
6268
- const DATE_EDIT_COMPONENTS = [DateEditComponent];
6269
- const DYNAMIC_COMPONENTS = [DynamicComponent];
6270
- const COMPONENTS$1 = [
6271
- ...FORM_COMPONENTS,
6272
- ...INPUT_COMPONENTS,
6273
- ...PAGE_COMPONENTS,
6274
- ...ACCORDION_COMPONENTS,
6275
- ...DATE_RANGE_COMPONENTS,
6276
- ...DATE_EDIT_COMPONENTS,
6277
- ...BUTTON_COMPONENTS,
6278
- ...CARD_COMPONENTS,
6279
- ...LIST_COMPONENTS,
6280
- ...LOADER_COMPONENTS,
6281
- ...DETAIL_COMPONENTS,
6282
- ...DETAILS_COMPONENTS,
6283
- ...DYNAMIC_COMPONENTS,
6284
- ...INFO_COMPONENTS,
6285
- ExportComponent,
6286
- ImportComponent,
6287
- PasswordStrengthComponent,
6288
- ];
6289
- const IMPORTS = [
6290
- CommonModule,
6291
- ReactiveFormsModule,
6292
- FormsModule,
6293
- TranslateModule,
6294
- RouterModule,
6295
- SharedPipesModule,
6296
- SharedDirectivesModule,
6297
- HttpClientModule,
6298
- LazyLoadImageModule,
6299
- DragDropModule,
6300
- CdkTableModule,
6301
- DynamicModule,
6302
- ];
6303
- class SharedComponentsModule {
6304
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedComponentsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
6305
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: SharedComponentsModule, imports: [CommonModule,
6306
- ReactiveFormsModule,
6307
- FormsModule,
6308
- TranslateModule,
6309
- RouterModule,
6310
- SharedPipesModule,
6311
- SharedDirectivesModule,
6312
- HttpClientModule,
6313
- LazyLoadImageModule,
6314
- DragDropModule,
6315
- CdkTableModule,
6316
- DynamicModule, FormStandardComponent,
6317
- FormComponent, InputComponent,
6318
- InputIntComponent,
6319
- InputErrorComponent,
6320
- InputTextComponent,
6321
- InputPasswordComponent,
6322
- InputFlagComponent,
6323
- InputEnumComponent,
6324
- InputEmailComponent,
6325
- InputCurrencyComponent,
6326
- InputDateComponent,
6327
- InputDateWithEditComponent,
6328
- InputFileComponent,
6329
- InputRadioComponent,
6330
- InputNipComponent,
6331
- InputStringsComponent,
6332
- InputLongTextComponent,
6333
- InputAddressComponent,
6334
- InputObjectComponent,
6335
- InputColorComponent,
6336
- InputLogoComponent,
6337
- InputCheckComponent,
6338
- InputIntsComponent,
6339
- InputPhoneNumberComponent,
6340
- InputPhoneNumberPlComponent,
6341
- InputPeselComponent,
6342
- InputArrayComponent,
6343
- InputPdfComponent,
6344
- InputVideoComponent,
6345
- InputAttachmentComponent,
6346
- InputDateRangeComponent,
6347
- InputImageComponent,
6348
- InputFloatComponent, PageStandardComponent, PageComponent, AccordionComponent,
6349
- AccordionHeaderComponent,
6350
- AccordionBodyComponent, DateRangeComponent,
6351
- DateRangeModalComponent, DateEditComponent, ButtonComponent, ButtonStandardComponent, CardComponent, ListComponent,
6352
- ListMobileComponent,
6353
- ListDesktopComponent,
6354
- ListMasonryGridComponent, LoaderComponent, DetailComponent,
6355
- DetailTextComponent,
6356
- DetailFlagComponent,
6357
- DetailEnumComponent,
6358
- DetailEmailComponent,
6359
- DetailAddressComponent,
6360
- DetailObjectComponent,
6361
- DetailColorComponent,
6362
- DetailLogoComponent,
6363
- DetailArrayComponent,
6364
- DetailPdfComponent,
6365
- DetailVideoComponent,
6366
- DetailAttachmentComponent,
6367
- DetailDateRangeComponent,
6368
- DetailImageComponent,
6369
- DetailPhoneNumberPlComponent, DetailsComponent, DetailsStandardComponent, DynamicComponent, InfoComponent, InfoModalComponent, ExportComponent,
6370
- ImportComponent,
6371
- PasswordStrengthComponent], exports: [FormStandardComponent,
6372
- FormComponent, InputComponent,
6373
- InputIntComponent,
6374
- InputErrorComponent,
6375
- InputTextComponent,
6376
- InputPasswordComponent,
6377
- InputFlagComponent,
6378
- InputEnumComponent,
6379
- InputEmailComponent,
6380
- InputCurrencyComponent,
6381
- InputDateComponent,
6382
- InputDateWithEditComponent,
6383
- InputFileComponent,
6384
- InputRadioComponent,
6385
- InputNipComponent,
6386
- InputStringsComponent,
6387
- InputLongTextComponent,
6388
- InputAddressComponent,
6389
- InputObjectComponent,
6390
- InputColorComponent,
6391
- InputLogoComponent,
6392
- InputCheckComponent,
6393
- InputIntsComponent,
6394
- InputPhoneNumberComponent,
6395
- InputPhoneNumberPlComponent,
6396
- InputPeselComponent,
6397
- InputArrayComponent,
6398
- InputPdfComponent,
6399
- InputVideoComponent,
6400
- InputAttachmentComponent,
6401
- InputDateRangeComponent,
6402
- InputImageComponent,
6403
- InputFloatComponent, PageStandardComponent, PageComponent, AccordionComponent,
6404
- AccordionHeaderComponent,
6405
- AccordionBodyComponent, DateRangeComponent,
6406
- DateRangeModalComponent, DateEditComponent, ButtonComponent, ButtonStandardComponent, CardComponent, ListComponent,
6407
- ListMobileComponent,
6408
- ListDesktopComponent,
6409
- ListMasonryGridComponent, LoaderComponent, DetailComponent,
6410
- DetailTextComponent,
6411
- DetailFlagComponent,
6412
- DetailEnumComponent,
6413
- DetailEmailComponent,
6414
- DetailAddressComponent,
6415
- DetailObjectComponent,
6416
- DetailColorComponent,
6417
- DetailLogoComponent,
6418
- DetailArrayComponent,
6419
- DetailPdfComponent,
6420
- DetailVideoComponent,
6421
- DetailAttachmentComponent,
6422
- DetailDateRangeComponent,
6423
- DetailImageComponent,
6424
- DetailPhoneNumberPlComponent, DetailsComponent, DetailsStandardComponent, DynamicComponent, InfoComponent, InfoModalComponent, ExportComponent,
6425
- ImportComponent,
6426
- PasswordStrengthComponent] });
6427
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedComponentsModule, providers: [
6428
- {
6429
- provide: FORM_COMPONENT_TOKEN,
6430
- useValue: FormComponent,
6431
- },
6432
- {
6433
- provide: DETAILS_COMPONENT_TOKEN,
6434
- useValue: DetailsComponent,
6435
- },
6436
- ], imports: [IMPORTS, FormStandardComponent,
6437
- FormComponent, InputComponent,
6438
- InputIntComponent,
6439
- InputTextComponent,
6440
- InputPasswordComponent,
6441
- InputFlagComponent,
6442
- InputEmailComponent,
6443
- InputCurrencyComponent,
6444
- InputDateComponent,
6445
- InputDateWithEditComponent,
6446
- InputRadioComponent,
6447
- InputNipComponent,
6448
- InputStringsComponent,
6449
- InputLongTextComponent,
6450
- InputAddressComponent,
6451
- InputCheckComponent,
6452
- InputIntsComponent,
6453
- InputPhoneNumberComponent,
6454
- InputPhoneNumberPlComponent,
6455
- InputPeselComponent,
6456
- InputFloatComponent, PageStandardComponent, PageComponent, DateEditComponent, ListComponent,
6457
- ListMobileComponent,
6458
- ListDesktopComponent, DynamicComponent] });
6459
- }
6460
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedComponentsModule, decorators: [{
6461
- type: NgModule,
6462
- args: [{
6463
- declarations: [],
6464
- exports: [...COMPONENTS$1],
6465
- providers: [
6466
- {
6467
- provide: FORM_COMPONENT_TOKEN,
6468
- useValue: FormComponent,
6469
- },
6470
- {
6471
- provide: DETAILS_COMPONENT_TOKEN,
6472
- useValue: DetailsComponent,
6473
- },
6474
- ],
6475
- imports: [...IMPORTS, ...COMPONENTS$1],
6476
- }]
6477
- }] });
6478
-
6479
- const COMPONENTS = [DetailsPage];
6480
- class SharedPagesModule {
6481
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedPagesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
6482
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: SharedPagesModule, imports: [SharedServicesModule,
6483
- SharedComponentsModule,
6484
- SharedDirectivesModule, DetailsPage], exports: [DetailsPage] });
6485
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedPagesModule, imports: [SharedServicesModule,
6486
- SharedComponentsModule,
6487
- SharedDirectivesModule,
6488
- COMPONENTS] });
6489
- }
6490
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedPagesModule, decorators: [{
6491
- type: NgModule,
6492
- args: [{
6493
- imports: [
6494
- SharedServicesModule,
6495
- SharedComponentsModule,
6496
- SharedDirectivesModule,
6497
- COMPONENTS,
6498
- ],
6499
- declarations: [],
6500
- exports: [...COMPONENTS],
6501
- }]
6502
- }] });
6503
-
6504
- class ListBaseComponent {
6505
- static smartType = 'list';
6506
- _fields;
6507
- provider;
6508
- authService = inject(AuthService);
6509
- router = inject(Router);
6510
- alertService = inject(AlertService);
6511
- cd = inject(ChangeDetectorRef);
6512
- translateService = inject(TranslateService);
6513
- detailsComponent;
6514
- selectMode;
6515
- detailsComponentProps;
6516
- select;
6517
- unselect;
6518
- itemHandler = null;
6519
- removeHandler = null;
6520
- checkRemoveHandler;
6521
- detailsButtonOptions;
6522
- removed = new Set();
6523
- keys;
6524
- cellPipe = null;
6525
- loadPrevPage = null;
6526
- loadNextPage = null;
6527
- list;
6528
- loading;
6529
- page;
6530
- totalPages;
6531
- FieldType = FieldType;
6532
- PaginationMode = PaginationMode;
6533
- type;
6534
- sort;
6535
- options = input.required(...(ngDevMode ? [{ debugName: "options" }] : []));
6536
- contentTpl = viewChild('contentTpl', ...(ngDevMode ? [{ debugName: "contentTpl" }] : []));
6537
- constructor() {
6538
- effect(() => {
6539
- const options = this.options();
6540
- this._fields = options.fields ?? [];
6541
- this.provider = options.provider;
6542
- this.sort = options.sort ?? {};
6543
- this.cellPipe = options.cellPipe ?? null;
6544
- this.selectMode = options.select;
6545
- this.type = options.type;
6546
- this.initKeys();
6547
- this.initList(options);
6548
- this.initLoading();
6549
- const removeHandler = options.remove;
6550
- if (options.remove) {
6551
- if (removeHandler?.provider?.check) {
6552
- this.checkRemoveHandler = removeHandler.provider.check;
6553
- }
6554
- this.removeHandler = async (obj) => {
6555
- await this.alertService.show({
6556
- header: this.translateService.instant('OBJECT.confirmDelete'),
6557
- buttons: [
6558
- {
6559
- text: this.translateService.instant('cancel'),
6560
- role: 'cancel',
6561
- },
6562
- {
6563
- text: this.translateService.instant('confirm'),
6564
- handler: () => {
6565
- removeHandler?.provider?.invoke?.(obj.id);
6566
- },
6567
- },
6568
- ],
6569
- backdropDismiss: false,
6570
- });
6571
- };
6572
- }
6573
- if (options.item) {
6574
- const itemOptions = options.item.options;
6575
- if (!itemOptions)
6576
- throw Error('Must set edit options');
6577
- this.itemHandler = (id) => {
6578
- if (itemOptions?.routingPrefix) {
6579
- setTimeout(async () => {
6580
- await this.router.navigate([
6581
- itemOptions.routingPrefix.replace('//', '/'),
6582
- id,
6583
- ]);
6584
- this.cd.detectChanges();
6585
- });
6586
- }
6587
- else if (itemOptions?.select)
6588
- itemOptions.select(id);
6589
- };
6590
- }
6591
- const details = options.details;
6592
- if (options.details) {
6593
- if (!details?.provider)
6594
- throw Error('Must set details provider');
6595
- this.detailsComponent = DetailsPage;
6596
- this.detailsComponentProps = {
6597
- item: details?.provider.item,
6598
- type: options.type,
6599
- loading: details?.provider.loading,
6600
- itemHandler: this.itemHandler ?? null,
6601
- removeHandler: this.removeHandler,
6602
- componentFactories: details?.componentFactories,
6603
- };
6604
- this.select = details?.provider.getData;
6605
- this.unselect = details?.provider.clearData;
6606
- }
6607
- if (options.pagination) {
6608
- this.loadNextPage = async (event = null) => {
6609
- await options?.pagination?.loadNextPage?.();
6610
- if (event)
6611
- event.target.complete();
6612
- setTimeout(() => {
6613
- window.scrollTo(0, 0);
6614
- });
6615
- };
6616
- this.loadPrevPage = async (event = null) => {
6617
- await options?.pagination?.loadPrevPage?.();
6618
- if (event)
6619
- event.target.complete();
6620
- setTimeout(() => {
6621
- window.scrollTo(0, 10000);
6622
- });
6623
- };
6624
- this.page = options.pagination.page;
6625
- this.totalPages = options.pagination.totalPages;
6626
- }
6627
- this.afterInitOptions();
6628
- });
6629
- this.detailsButtonOptions = {
6630
- loading: this.loading,
6631
- click: () => {
6632
- this.unselect();
6633
- },
6634
- };
6247
+ };
6248
+ this.page = options.pagination.page;
6249
+ this.totalPages = options.pagination.totalPages;
6250
+ }
6251
+ this.afterInitOptions();
6252
+ });
6253
+ this.detailsButtonOptions = {
6254
+ loading: this.loading,
6255
+ click: () => {
6256
+ this.unselect();
6257
+ },
6258
+ };
6635
6259
  }
6636
6260
  initKeys(data = null) {
6637
6261
  const result = [];
@@ -6748,159 +6372,536 @@ class ListDesktopComponent extends ListBaseComponent {
6748
6372
  }
6749
6373
  }
6750
6374
  }
6751
- Object = Object;
6752
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListDesktopComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
6753
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: ListDesktopComponent, isStandalone: true, selector: "smart-list-desktop", viewQueries: [{ propertyName: "topTpl", first: true, predicate: ["topTpl"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div #topTpl></div>\n\n<!--<ion-content>-->\n<div class=\"w-full overflow-y-auto\">\n <table\n cdk-table\n [dataSource]=\"list() ?? []\"\n [trackBy]=\"myTrackById\"\n class=\"w-full overflow-y-auto\"\n >\n @for (key of desktopKeys; track key) {\n @let last = $last;\n <ng-container class=\"col-sm text-left\">\n <div>\n @switch (key) {\n @case ('selectMulti') {\n <th cdk-header-cell class=\"w-5\" *matHeaderCellDef></th>\n <td cdk-cell>\n @let list = desktopList();\n @if (list) {\n <!-- <ion-checkbox-->\n <!-- style=\"margin-right: 15px\"-->\n <!-- (ionChange)=\"-->\n <!-- onChangeMultiselect(-->\n <!-- $event.detail.checked,-->\n <!-- element,-->\n <!-- list-->\n <!-- )-->\n <!-- \"-->\n <!-- ></ion-checkbox>-->\n }\n </td>\n }\n @case ('removeAction') {\n <th cdk-header-cell class=\"w-5\" *matHeaderCellDef>\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <td cdk-cell *matCellDef=\"let element\">\n @if (!checkRemoveHandler || checkRemoveHandler(element)) {\n <!-- <ion-button (click)=\"removeHandler?.(element)\">-->\n <!-- <ion-icon slot=\"icon-only\" name=\"trash\"></ion-icon>-->\n <!-- </ion-button>-->\n }\n </td>\n }\n @case ('detailsAction') {\n <th cdk-header-cell class=\"w-5\" *matHeaderCellDef>\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <td cdk-cell *matCellDef=\"let element\">\n <!-- <ion-button-->\n <!-- (click)=\"detailsButtonOptions.click()\"-->\n <!-- [smartDetails]=\"{-->\n <!-- component: detailsComponent,-->\n <!-- params: detailsComponentProps,-->\n <!-- mode: 'bottom',-->\n <!-- }\"-->\n <!-- (smartDetailsShowed)=\"select(element.id)\"-->\n <!-- >-->\n <!-- <ion-icon-->\n <!-- slot=\"icon-only\"-->\n <!-- name=\"ellipsis-vertical-outline\"-->\n <!-- ></ion-icon>-->\n <!-- </ion-button>-->\n </td>\n }\n @case ('itemAction') {\n <th cdk-header-cell class=\"w-5\">\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <td cdk-cell *matCellDef=\"let element\">\n <!-- <ion-button (click)=\"itemHandler?.(element.id)\">-->\n <!-- <ion-icon-->\n <!-- slot=\"icon-only\"-->\n <!-- name=\"arrow-forward-outline\"-->\n <!-- ></ion-icon>-->\n <!-- </ion-button>-->\n </td>\n }\n @default {\n <th cdk-header-cell>\n {{ (list() | smartListHeader: key : type)() }}\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <ng-container *matCellDef=\"let element\">\n @let cell = element | smartListCell: key : cellPipe : type;\n @if (cell) {\n <td\n cdk-cell\n [attr.smart-item-key]=\"key\"\n [style.width.px]=\"cell.type === FieldType.image ? 60 : null\"\n [style.textAlign]=\"\n cell.type === FieldType.image ? 'center' : null\n \"\n >\n @if (cell.type === FieldType.image) {\n <img\n height=\"50\"\n [lazyLoad]=\"cell.value | smartFileUrl\"\n alt=\"\"\n src=\"\"\n />\n } @else {\n <div\n class=\"min-h-8 pt-1.5\"\n [innerHTML]=\"cell.value\"\n ></div>\n }\n </td>\n } @else {\n <td cdk-cell></td>\n }\n </ng-container>\n }\n }\n </div>\n\n <ng-template #pagination>\n @if (last && loadNextPage && totalPages()) {\n <div style=\"float: right\">\n <!-- <ion-chip>-->\n {{ 'page' | translate }}:\n <b>{{ page() }}/{{ totalPages() }}</b>\n <!-- </ion-chip>-->\n </div>\n }\n </ng-template>\n </ng-container>\n }\n\n <tr cdk-header-row *matHeaderRowDef=\"desktopKeys ?? []; sticky: true\"></tr>\n <tr cdk-row *matRowDef=\"let row; columns: desktopKeys ?? []\"></tr>\n </table>\n</div>\n\n@if (\n loadNextPage &&\n Object.keys(list() ?? [])?.length &&\n options().pagination?.mode !== PaginationMode.singlePage\n) {\n <!-- <ion-infinite-scroll threshold=\"100px\" (ionInfinite)=\"loadNextPage($event)\">-->\n <!-- <ion-infinite-scroll-content-->\n <!-- loadingSpinner=\"circles\"-->\n <!-- ></ion-infinite-scroll-content>-->\n <!-- </ion-infinite-scroll>-->\n}\n<!--</ion-content>-->\n\n@if (options()?.pagination?.mode === PaginationMode.singlePage) {\n <smart-paging\n [page]=\"page()\"\n [totalPages]=\"totalPages()\"\n (prevPage)=\"loadPrevPage?.()\"\n (nextPage)=\"loadNextPage?.()\"\n ></smart-paging>\n}\n", styles: ["table .mat-row,table .mat-header-row{background:#fff;min-width:1200px}.wrapper{height:100%}.mat-row,.mat-header-row{min-width:1200px}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: LazyLoadImageModule }, { kind: "directive", type: i1$2.LazyLoadImageDirective, selector: "[lazyLoad]", inputs: ["lazyLoad", "defaultImage", "errorImage", "scrollTarget", "customObservable", "offset", "useSrcset", "decode", "debug"], outputs: ["onStateChange"] }, { kind: "component", type: PagingComponent, selector: "smart-paging", inputs: ["page", "totalPages"], outputs: ["nextPage", "prevPage"] }, { kind: "component", type: CdkTable, selector: "cdk-table, table[cdk-table]", inputs: ["trackBy", "dataSource", "multiTemplateDataRows", "fixedLayout"], outputs: ["contentChanged"], exportAs: ["cdkTable"] }, { kind: "directive", type: CdkHeaderCell, selector: "cdk-header-cell, th[cdk-header-cell]" }, { kind: "directive", type: CdkCell, selector: "cdk-cell, td[cdk-cell]" }, { kind: "component", type: CdkHeaderRow, selector: "cdk-header-row, tr[cdk-header-row]" }, { kind: "component", type: CdkRow, selector: "cdk-row, tr[cdk-row]" }, { kind: "pipe", type: ListHeaderPipe, name: "smartListHeader" }, { kind: "pipe", type: ListCellPipe, name: "smartListCell" }, { kind: "pipe", type: FileUrlPipe, name: "smartFileUrl" }, { kind: "pipe", type: TranslatePipe, name: "translate" }] });
6375
+ Object = Object;
6376
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListDesktopComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
6377
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: ListDesktopComponent, isStandalone: true, selector: "smart-list-desktop", viewQueries: [{ propertyName: "topTpl", first: true, predicate: ["topTpl"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div #topTpl></div>\n\n<!--<ion-content>-->\n<div class=\"w-full overflow-y-auto\">\n <table\n cdk-table\n [dataSource]=\"list() ?? []\"\n [trackBy]=\"myTrackById\"\n class=\"w-full overflow-y-auto\"\n >\n @for (key of desktopKeys; track key) {\n @let last = $last;\n <ng-container class=\"col-sm text-left\">\n <div>\n @switch (key) {\n @case ('selectMulti') {\n <th cdk-header-cell class=\"w-5\" *matHeaderCellDef></th>\n <td cdk-cell>\n @let list = desktopList();\n @if (list) {\n <!-- <ion-checkbox-->\n <!-- style=\"margin-right: 15px\"-->\n <!-- (ionChange)=\"-->\n <!-- onChangeMultiselect(-->\n <!-- $event.detail.checked,-->\n <!-- element,-->\n <!-- list-->\n <!-- )-->\n <!-- \"-->\n <!-- ></ion-checkbox>-->\n }\n </td>\n }\n @case ('removeAction') {\n <th cdk-header-cell class=\"w-5\" *matHeaderCellDef>\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <td cdk-cell *matCellDef=\"let element\">\n @if (!checkRemoveHandler || checkRemoveHandler(element)) {\n <!-- <ion-button (click)=\"removeHandler?.(element)\">-->\n <!-- <ion-icon slot=\"icon-only\" name=\"trash\"></ion-icon>-->\n <!-- </ion-button>-->\n }\n </td>\n }\n @case ('detailsAction') {\n <th cdk-header-cell class=\"w-5\" *matHeaderCellDef>\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <td cdk-cell *matCellDef=\"let element\">\n <!-- <ion-button-->\n <!-- (click)=\"detailsButtonOptions.click()\"-->\n <!-- [smartDetails]=\"{-->\n <!-- component: detailsComponent,-->\n <!-- params: detailsComponentProps,-->\n <!-- mode: 'bottom',-->\n <!-- }\"-->\n <!-- (smartDetailsShowed)=\"select(element.id)\"-->\n <!-- >-->\n <!-- <ion-icon-->\n <!-- slot=\"icon-only\"-->\n <!-- name=\"ellipsis-vertical-outline\"-->\n <!-- ></ion-icon>-->\n <!-- </ion-button>-->\n </td>\n }\n @case ('itemAction') {\n <th cdk-header-cell class=\"w-5\">\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <td cdk-cell *matCellDef=\"let element\">\n <!-- <ion-button (click)=\"itemHandler?.(element.id)\">-->\n <!-- <ion-icon-->\n <!-- slot=\"icon-only\"-->\n <!-- name=\"arrow-forward-outline\"-->\n <!-- ></ion-icon>-->\n <!-- </ion-button>-->\n </td>\n }\n @default {\n <th cdk-header-cell>\n {{ (list() | smartListHeader: key : type)() }}\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <ng-container *matCellDef=\"let element\">\n @let cell = element | smartListCell: key : cellPipe : type;\n @if (cell) {\n <td\n cdk-cell\n [attr.smart-item-key]=\"key\"\n [style.width.px]=\"cell.type === FieldType.image ? 60 : null\"\n [style.textAlign]=\"\n cell.type === FieldType.image ? 'center' : null\n \"\n >\n @if (cell.type === FieldType.image) {\n <img\n height=\"50\"\n [lazyLoad]=\"cell.value | smartFileUrl\"\n alt=\"\"\n src=\"\"\n />\n } @else {\n <div\n class=\"min-h-8 pt-1.5\"\n [innerHTML]=\"cell.value\"\n ></div>\n }\n </td>\n } @else {\n <td cdk-cell></td>\n }\n </ng-container>\n }\n }\n </div>\n\n <ng-template #pagination>\n @if (last && loadNextPage && totalPages()) {\n <div style=\"float: right\">\n <!-- <ion-chip>-->\n {{ 'page' | translate }}:\n <b>{{ page() }}/{{ totalPages() }}</b>\n <!-- </ion-chip>-->\n </div>\n }\n </ng-template>\n </ng-container>\n }\n\n <tr cdk-header-row *matHeaderRowDef=\"desktopKeys ?? []; sticky: true\"></tr>\n <tr cdk-row *matRowDef=\"let row; columns: desktopKeys ?? []\"></tr>\n </table>\n</div>\n\n@if (\n loadNextPage &&\n Object.keys(list() ?? [])?.length &&\n options().pagination?.mode !== PaginationMode.singlePage\n) {\n <!-- <ion-infinite-scroll threshold=\"100px\" (ionInfinite)=\"loadNextPage($event)\">-->\n <!-- <ion-infinite-scroll-content-->\n <!-- loadingSpinner=\"circles\"-->\n <!-- ></ion-infinite-scroll-content>-->\n <!-- </ion-infinite-scroll>-->\n}\n<!--</ion-content>-->\n\n@if (options()?.pagination?.mode === PaginationMode.singlePage) {\n <smart-paging\n [page]=\"page()\"\n [totalPages]=\"totalPages()\"\n (prevPage)=\"loadPrevPage?.()\"\n (nextPage)=\"loadNextPage?.()\"\n ></smart-paging>\n}\n", styles: ["table .mat-row,table .mat-header-row{background:#fff;min-width:1200px}.wrapper{height:100%}.mat-row,.mat-header-row{min-width:1200px}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: LazyLoadImageModule }, { kind: "directive", type: i1$2.LazyLoadImageDirective, selector: "[lazyLoad]", inputs: ["lazyLoad", "defaultImage", "errorImage", "scrollTarget", "customObservable", "offset", "useSrcset", "decode", "debug"], outputs: ["onStateChange"] }, { kind: "component", type: PagingComponent, selector: "smart-paging", inputs: ["page", "totalPages"], outputs: ["nextPage", "prevPage"] }, { kind: "component", type: CdkTable, selector: "cdk-table, table[cdk-table]", inputs: ["trackBy", "dataSource", "multiTemplateDataRows", "fixedLayout"], outputs: ["contentChanged"], exportAs: ["cdkTable"] }, { kind: "directive", type: CdkHeaderCell, selector: "cdk-header-cell, th[cdk-header-cell]" }, { kind: "directive", type: CdkCell, selector: "cdk-cell, td[cdk-cell]" }, { kind: "component", type: CdkHeaderRow, selector: "cdk-header-row, tr[cdk-header-row]" }, { kind: "component", type: CdkRow, selector: "cdk-row, tr[cdk-row]" }, { kind: "pipe", type: ListHeaderPipe, name: "smartListHeader" }, { kind: "pipe", type: ListCellPipe, name: "smartListCell" }, { kind: "pipe", type: FileUrlPipe, name: "smartFileUrl" }, { kind: "pipe", type: TranslatePipe, name: "translate" }] });
6378
+ }
6379
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListDesktopComponent, decorators: [{
6380
+ type: Component,
6381
+ args: [{ selector: 'smart-list-desktop', imports: [
6382
+ NgTemplateOutlet,
6383
+ ListHeaderPipe,
6384
+ ListCellPipe,
6385
+ LazyLoadImageModule,
6386
+ FileUrlPipe,
6387
+ TranslatePipe,
6388
+ PagingComponent,
6389
+ CdkTable,
6390
+ CdkHeaderCell,
6391
+ CdkCell,
6392
+ CdkHeaderRow,
6393
+ CdkRow,
6394
+ ], template: "<div #topTpl></div>\n\n<!--<ion-content>-->\n<div class=\"w-full overflow-y-auto\">\n <table\n cdk-table\n [dataSource]=\"list() ?? []\"\n [trackBy]=\"myTrackById\"\n class=\"w-full overflow-y-auto\"\n >\n @for (key of desktopKeys; track key) {\n @let last = $last;\n <ng-container class=\"col-sm text-left\">\n <div>\n @switch (key) {\n @case ('selectMulti') {\n <th cdk-header-cell class=\"w-5\" *matHeaderCellDef></th>\n <td cdk-cell>\n @let list = desktopList();\n @if (list) {\n <!-- <ion-checkbox-->\n <!-- style=\"margin-right: 15px\"-->\n <!-- (ionChange)=\"-->\n <!-- onChangeMultiselect(-->\n <!-- $event.detail.checked,-->\n <!-- element,-->\n <!-- list-->\n <!-- )-->\n <!-- \"-->\n <!-- ></ion-checkbox>-->\n }\n </td>\n }\n @case ('removeAction') {\n <th cdk-header-cell class=\"w-5\" *matHeaderCellDef>\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <td cdk-cell *matCellDef=\"let element\">\n @if (!checkRemoveHandler || checkRemoveHandler(element)) {\n <!-- <ion-button (click)=\"removeHandler?.(element)\">-->\n <!-- <ion-icon slot=\"icon-only\" name=\"trash\"></ion-icon>-->\n <!-- </ion-button>-->\n }\n </td>\n }\n @case ('detailsAction') {\n <th cdk-header-cell class=\"w-5\" *matHeaderCellDef>\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <td cdk-cell *matCellDef=\"let element\">\n <!-- <ion-button-->\n <!-- (click)=\"detailsButtonOptions.click()\"-->\n <!-- [smartDetails]=\"{-->\n <!-- component: detailsComponent,-->\n <!-- params: detailsComponentProps,-->\n <!-- mode: 'bottom',-->\n <!-- }\"-->\n <!-- (smartDetailsShowed)=\"select(element.id)\"-->\n <!-- >-->\n <!-- <ion-icon-->\n <!-- slot=\"icon-only\"-->\n <!-- name=\"ellipsis-vertical-outline\"-->\n <!-- ></ion-icon>-->\n <!-- </ion-button>-->\n </td>\n }\n @case ('itemAction') {\n <th cdk-header-cell class=\"w-5\">\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <td cdk-cell *matCellDef=\"let element\">\n <!-- <ion-button (click)=\"itemHandler?.(element.id)\">-->\n <!-- <ion-icon-->\n <!-- slot=\"icon-only\"-->\n <!-- name=\"arrow-forward-outline\"-->\n <!-- ></ion-icon>-->\n <!-- </ion-button>-->\n </td>\n }\n @default {\n <th cdk-header-cell>\n {{ (list() | smartListHeader: key : type)() }}\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <ng-container *matCellDef=\"let element\">\n @let cell = element | smartListCell: key : cellPipe : type;\n @if (cell) {\n <td\n cdk-cell\n [attr.smart-item-key]=\"key\"\n [style.width.px]=\"cell.type === FieldType.image ? 60 : null\"\n [style.textAlign]=\"\n cell.type === FieldType.image ? 'center' : null\n \"\n >\n @if (cell.type === FieldType.image) {\n <img\n height=\"50\"\n [lazyLoad]=\"cell.value | smartFileUrl\"\n alt=\"\"\n src=\"\"\n />\n } @else {\n <div\n class=\"min-h-8 pt-1.5\"\n [innerHTML]=\"cell.value\"\n ></div>\n }\n </td>\n } @else {\n <td cdk-cell></td>\n }\n </ng-container>\n }\n }\n </div>\n\n <ng-template #pagination>\n @if (last && loadNextPage && totalPages()) {\n <div style=\"float: right\">\n <!-- <ion-chip>-->\n {{ 'page' | translate }}:\n <b>{{ page() }}/{{ totalPages() }}</b>\n <!-- </ion-chip>-->\n </div>\n }\n </ng-template>\n </ng-container>\n }\n\n <tr cdk-header-row *matHeaderRowDef=\"desktopKeys ?? []; sticky: true\"></tr>\n <tr cdk-row *matRowDef=\"let row; columns: desktopKeys ?? []\"></tr>\n </table>\n</div>\n\n@if (\n loadNextPage &&\n Object.keys(list() ?? [])?.length &&\n options().pagination?.mode !== PaginationMode.singlePage\n) {\n <!-- <ion-infinite-scroll threshold=\"100px\" (ionInfinite)=\"loadNextPage($event)\">-->\n <!-- <ion-infinite-scroll-content-->\n <!-- loadingSpinner=\"circles\"-->\n <!-- ></ion-infinite-scroll-content>-->\n <!-- </ion-infinite-scroll>-->\n}\n<!--</ion-content>-->\n\n@if (options()?.pagination?.mode === PaginationMode.singlePage) {\n <smart-paging\n [page]=\"page()\"\n [totalPages]=\"totalPages()\"\n (prevPage)=\"loadPrevPage?.()\"\n (nextPage)=\"loadNextPage?.()\"\n ></smart-paging>\n}\n", styles: ["table .mat-row,table .mat-header-row{background:#fff;min-width:1200px}.wrapper{height:100%}.mat-row,.mat-header-row{min-width:1200px}\n"] }]
6395
+ }] });
6396
+
6397
+ class ListMasonryGridComponent extends ListBaseComponent {
6398
+ componentFactories = null;
6399
+ listWithImages;
6400
+ topTpl = viewChild('topTpl', ...(ngDevMode ? [{ debugName: "topTpl" }] : []));
6401
+ ngAfterViewInit() {
6402
+ this.generateDynamicComponents();
6403
+ }
6404
+ afterInitOptions() {
6405
+ const fieldOptions = getModelFieldsWithOptions(new this.type());
6406
+ const imageFieldOptions = fieldOptions.find((item) => item.options.type === FieldType.image);
6407
+ this.listWithImages = computed(() => {
6408
+ const list = this.list();
6409
+ if (!list)
6410
+ return null;
6411
+ return list.map((item) => {
6412
+ return {
6413
+ data: item,
6414
+ image: item[imageFieldOptions?.key ?? ''],
6415
+ };
6416
+ });
6417
+ }, ...(ngDevMode ? [{ debugName: "listWithImages" }] : []));
6418
+ }
6419
+ initList(val) {
6420
+ super.initList(val);
6421
+ this.componentFactories = val?.componentFactories ?? null;
6422
+ this.generateDynamicComponents();
6423
+ }
6424
+ generateDynamicComponents() {
6425
+ if (!this.componentFactories)
6426
+ return;
6427
+ if (this.componentFactories.top && this.topTpl()) {
6428
+ if (!this.topTpl()?.get(0)) {
6429
+ this.topTpl()?.createComponent(this.componentFactories.top);
6430
+ }
6431
+ }
6432
+ }
6433
+ Object = Object;
6434
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListMasonryGridComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
6435
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: ListMasonryGridComponent, isStandalone: true, selector: "smart-list-masonry-grid", viewQueries: [{ propertyName: "topTpl", first: true, predicate: ["topTpl"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div #topTpl></div>\n\n<div class=\"ion-padding\">\n <div class=\"gap-3\">\n @for (item of listWithImages(); track item) {\n <!-- <ion-card class=\"w-full my-2.5 break-inside-avoid border border-gray-100\" (click)=\"unselect?.()\">-->\n @if (item.image) {\n <img [ngSrc]=\"item.image | smartFileUrl\" alt=\"\" fill />\n }\n\n <!-- <ion-card-content class=\"overflow-hidden after:block after:w-full after:bg-gradient-to-r after:from-transparent after:to-white after:absolute after:bottom-0\">-->\n @for (key of keys; track key) {\n @let cell = item.data | smartListCell: key : cellPipe : type;\n @if (cell && cell.value != item.image) {\n @if ($index < 2) {\n <h3\n [attr.smart-item-key]=\"key\"\n class=\"text-gray-800\"\n [innerHTML]=\"cell.value\"\n ></h3>\n } @else {\n <p\n [attr.smart-item-key]=\"key\"\n class=\"text-gray-500\"\n [innerHTML]=\"cell.value\"\n ></p>\n }\n }\n }\n <!-- </ion-card-content>-->\n\n <!-- <ion-row>-->\n @if (removeHandler) {\n <!-- <ion-col size=\"auto\">-->\n @if (!checkRemoveHandler || checkRemoveHandler(item.data)) {\n <!-- <ion-button (click)=\"removeHandler?.(item.data)\">-->\n <!-- <ion-icon slot=\"icon-only\" name=\"trash\"></ion-icon>-->\n <!-- </ion-button>-->\n }\n <!-- </ion-col>-->\n }\n <!-- <ion-col></ion-col>-->\n @if (itemHandler) {\n <!-- <ion-col size=\"auto\">-->\n <!-- <ion-button (click)=\"itemHandler?.(item.data.id)\">-->\n <!-- <ion-icon-->\n <!-- slot=\"icon-only\"-->\n <!-- name=\"arrow-forward-outline\"-->\n <!-- ></ion-icon>-->\n <!-- </ion-button>-->\n <!-- </ion-col>-->\n }\n <!-- </ion-row>-->\n <!-- </ion-card>-->\n }\n </div>\n</div>\n\n@if (\n loadNextPage &&\n Object.keys(list() ?? [])?.length &&\n options().pagination?.mode !== PaginationMode.singlePage\n) {\n <!-- <ion-infinite-scroll threshold=\"100px\" (ionInfinite)=\"loadNextPage?.($event)\">-->\n <!-- <ion-infinite-scroll-content loadingSpinner=\"circles\">-->\n <!-- </ion-infinite-scroll-content>-->\n <!-- </ion-infinite-scroll>-->\n}\n\n@if (options()?.pagination?.mode === PaginationMode.singlePage) {\n <smart-paging\n [page]=\"page()\"\n [totalPages]=\"totalPages()\"\n (prevPage)=\"loadPrevPage?.()\"\n (nextPage)=\"loadNextPage?.()\"\n ></smart-paging>\n}\n", dependencies: [{ kind: "component", type: PagingComponent, selector: "smart-paging", inputs: ["page", "totalPages"], outputs: ["nextPage", "prevPage"] }, { kind: "directive", type: NgOptimizedImage, selector: "img[ngSrc]", inputs: ["ngSrc", "ngSrcset", "sizes", "width", "height", "decoding", "loading", "priority", "loaderParams", "disableOptimizedSrcset", "fill", "placeholder", "placeholderConfig", "src", "srcset"] }, { kind: "pipe", type: FileUrlPipe, name: "smartFileUrl" }, { kind: "pipe", type: ListCellPipe, name: "smartListCell" }] });
6436
+ }
6437
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListMasonryGridComponent, decorators: [{
6438
+ type: Component,
6439
+ args: [{ selector: 'smart-list-masonry-grid', imports: [PagingComponent, FileUrlPipe, NgOptimizedImage, ListCellPipe], template: "<div #topTpl></div>\n\n<div class=\"ion-padding\">\n <div class=\"gap-3\">\n @for (item of listWithImages(); track item) {\n <!-- <ion-card class=\"w-full my-2.5 break-inside-avoid border border-gray-100\" (click)=\"unselect?.()\">-->\n @if (item.image) {\n <img [ngSrc]=\"item.image | smartFileUrl\" alt=\"\" fill />\n }\n\n <!-- <ion-card-content class=\"overflow-hidden after:block after:w-full after:bg-gradient-to-r after:from-transparent after:to-white after:absolute after:bottom-0\">-->\n @for (key of keys; track key) {\n @let cell = item.data | smartListCell: key : cellPipe : type;\n @if (cell && cell.value != item.image) {\n @if ($index < 2) {\n <h3\n [attr.smart-item-key]=\"key\"\n class=\"text-gray-800\"\n [innerHTML]=\"cell.value\"\n ></h3>\n } @else {\n <p\n [attr.smart-item-key]=\"key\"\n class=\"text-gray-500\"\n [innerHTML]=\"cell.value\"\n ></p>\n }\n }\n }\n <!-- </ion-card-content>-->\n\n <!-- <ion-row>-->\n @if (removeHandler) {\n <!-- <ion-col size=\"auto\">-->\n @if (!checkRemoveHandler || checkRemoveHandler(item.data)) {\n <!-- <ion-button (click)=\"removeHandler?.(item.data)\">-->\n <!-- <ion-icon slot=\"icon-only\" name=\"trash\"></ion-icon>-->\n <!-- </ion-button>-->\n }\n <!-- </ion-col>-->\n }\n <!-- <ion-col></ion-col>-->\n @if (itemHandler) {\n <!-- <ion-col size=\"auto\">-->\n <!-- <ion-button (click)=\"itemHandler?.(item.data.id)\">-->\n <!-- <ion-icon-->\n <!-- slot=\"icon-only\"-->\n <!-- name=\"arrow-forward-outline\"-->\n <!-- ></ion-icon>-->\n <!-- </ion-button>-->\n <!-- </ion-col>-->\n }\n <!-- </ion-row>-->\n <!-- </ion-card>-->\n }\n </div>\n</div>\n\n@if (\n loadNextPage &&\n Object.keys(list() ?? [])?.length &&\n options().pagination?.mode !== PaginationMode.singlePage\n) {\n <!-- <ion-infinite-scroll threshold=\"100px\" (ionInfinite)=\"loadNextPage?.($event)\">-->\n <!-- <ion-infinite-scroll-content loadingSpinner=\"circles\">-->\n <!-- </ion-infinite-scroll-content>-->\n <!-- </ion-infinite-scroll>-->\n}\n\n@if (options()?.pagination?.mode === PaginationMode.singlePage) {\n <smart-paging\n [page]=\"page()\"\n [totalPages]=\"totalPages()\"\n (prevPage)=\"loadPrevPage?.()\"\n (nextPage)=\"loadNextPage?.()\"\n ></smart-paging>\n}\n" }]
6440
+ }] });
6441
+
6442
+ class ListMobileComponent extends ListBaseComponent {
6443
+ listMobile = this.list;
6444
+ componentFactories = null;
6445
+ topTpl = viewChild('topTpl', ...(ngDevMode ? [{ debugName: "topTpl" }] : []));
6446
+ initList(val) {
6447
+ super.initList(val);
6448
+ this.componentFactories = val.componentFactories ?? null;
6449
+ this.generateDynamicComponents();
6450
+ }
6451
+ ngAfterViewInit() {
6452
+ this.generateDynamicComponents();
6453
+ }
6454
+ generateDynamicComponents() {
6455
+ if (!this.componentFactories)
6456
+ return;
6457
+ if (this.componentFactories.top && this.topTpl()) {
6458
+ if (!this.topTpl()?.get(0)) {
6459
+ this.topTpl()?.createComponent(this.componentFactories.top);
6460
+ }
6461
+ }
6462
+ }
6463
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListMobileComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
6464
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: ListMobileComponent, isStandalone: true, selector: "smart-list-mobile", viewQueries: [{ propertyName: "topTpl", first: true, predicate: ["topTpl"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div #topTpl></div>\n\n@let list = listMobile();\n@if (list) {\n <!-- <ion-list>-->\n @for (item of list; track item.id) {\n <!-- <ion-item-sliding>-->\n @if (removeHandler && (!checkRemoveHandler || checkRemoveHandler(item))) {\n <!-- <ion-item-options side=\"start\" (ionSwipe)=\"removeHandler?.(item)\">-->\n <!-- <ion-item-option-->\n <!-- color=\"danger\"-->\n <!-- expandable-->\n <!-- (click)=\"removeHandler?.(item)\"-->\n <!-- >-->\n {{ 'delete' | translate }}\n <!-- </ion-item-option>-->\n <!-- </ion-item-options>-->\n }\n\n <!-- <ion-item class=\"pl-5\" (click)=\"itemHandler ? itemHandler(item.id) : unselect()\">-->\n <!-- <ion-label>-->\n @for (key of keys; track key) {\n @let cell = item | smartListCell: key : cellPipe : type;\n @if (cell) {\n @if (cell.type === FieldType.image) {\n <img\n [attr.smart-item-key]=\"key\"\n height=\"100\"\n [lazyLoad]=\"cell.value | smartFileUrl\"\n alt=\"\"\n src=\"\"\n />\n } @else if ($first) {\n <h2 [attr.smart-item-key]=\"key\" [innerHTML]=\"cell.value\"></h2>\n } @else {\n <p [attr.smart-item-key]=\"key\" [innerHTML]=\"cell.value\"></p>\n }\n }\n }\n <!-- </ion-label>-->\n <!-- </ion-item>-->\n <!-- </ion-item-sliding>-->\n }\n <!-- </ion-list>-->\n}\n\n@if (\n loadNextPage &&\n list?.length &&\n options().pagination?.mode !== PaginationMode.singlePage\n) {\n <!-- <ion-infinite-scroll threshold=\"100px\" (ionInfinite)=\"loadNextPage?.($event)\">-->\n <!-- <ion-infinite-scroll-content-->\n <!-- loadingSpinner=\"circles\"-->\n <!-- ></ion-infinite-scroll-content>-->\n <!-- </ion-infinite-scroll>-->\n}\n\n@if (options()?.pagination?.mode === PaginationMode.singlePage) {\n <smart-paging\n [page]=\"page()\"\n [totalPages]=\"totalPages()\"\n (prevPage)=\"loadPrevPage?.()\"\n (nextPage)=\"loadNextPage?.()\"\n ></smart-paging>\n}\n", dependencies: [{ kind: "ngmodule", type: LazyLoadImageModule }, { kind: "directive", type: i1$2.LazyLoadImageDirective, selector: "[lazyLoad]", inputs: ["lazyLoad", "defaultImage", "errorImage", "scrollTarget", "customObservable", "offset", "useSrcset", "decode", "debug"], outputs: ["onStateChange"] }, { kind: "component", type: PagingComponent, selector: "smart-paging", inputs: ["page", "totalPages"], outputs: ["nextPage", "prevPage"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }, { kind: "pipe", type: FileUrlPipe, name: "smartFileUrl" }, { kind: "pipe", type: ListCellPipe, name: "smartListCell" }] });
6465
+ }
6466
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListMobileComponent, decorators: [{
6467
+ type: Component,
6468
+ args: [{ selector: 'smart-list-mobile', imports: [
6469
+ TranslatePipe,
6470
+ FileUrlPipe,
6471
+ LazyLoadImageModule,
6472
+ PagingComponent,
6473
+ ListCellPipe,
6474
+ ], template: "<div #topTpl></div>\n\n@let list = listMobile();\n@if (list) {\n <!-- <ion-list>-->\n @for (item of list; track item.id) {\n <!-- <ion-item-sliding>-->\n @if (removeHandler && (!checkRemoveHandler || checkRemoveHandler(item))) {\n <!-- <ion-item-options side=\"start\" (ionSwipe)=\"removeHandler?.(item)\">-->\n <!-- <ion-item-option-->\n <!-- color=\"danger\"-->\n <!-- expandable-->\n <!-- (click)=\"removeHandler?.(item)\"-->\n <!-- >-->\n {{ 'delete' | translate }}\n <!-- </ion-item-option>-->\n <!-- </ion-item-options>-->\n }\n\n <!-- <ion-item class=\"pl-5\" (click)=\"itemHandler ? itemHandler(item.id) : unselect()\">-->\n <!-- <ion-label>-->\n @for (key of keys; track key) {\n @let cell = item | smartListCell: key : cellPipe : type;\n @if (cell) {\n @if (cell.type === FieldType.image) {\n <img\n [attr.smart-item-key]=\"key\"\n height=\"100\"\n [lazyLoad]=\"cell.value | smartFileUrl\"\n alt=\"\"\n src=\"\"\n />\n } @else if ($first) {\n <h2 [attr.smart-item-key]=\"key\" [innerHTML]=\"cell.value\"></h2>\n } @else {\n <p [attr.smart-item-key]=\"key\" [innerHTML]=\"cell.value\"></p>\n }\n }\n }\n <!-- </ion-label>-->\n <!-- </ion-item>-->\n <!-- </ion-item-sliding>-->\n }\n <!-- </ion-list>-->\n}\n\n@if (\n loadNextPage &&\n list?.length &&\n options().pagination?.mode !== PaginationMode.singlePage\n) {\n <!-- <ion-infinite-scroll threshold=\"100px\" (ionInfinite)=\"loadNextPage?.($event)\">-->\n <!-- <ion-infinite-scroll-content-->\n <!-- loadingSpinner=\"circles\"-->\n <!-- ></ion-infinite-scroll-content>-->\n <!-- </ion-infinite-scroll>-->\n}\n\n@if (options()?.pagination?.mode === PaginationMode.singlePage) {\n <smart-paging\n [page]=\"page()\"\n [totalPages]=\"totalPages()\"\n (prevPage)=\"loadPrevPage?.()\"\n (nextPage)=\"loadNextPage?.()\"\n ></smart-paging>\n}\n" }]
6475
+ }] });
6476
+
6477
+ class ListComponent extends CreateDynamicComponent('list') {
6478
+ _options;
6479
+ hardwareService = inject(HardwareService);
6480
+ mode = signal(ListMode.desktop, ...(ngDevMode ? [{ debugName: "mode" }] : []));
6481
+ ListMode = ListMode;
6482
+ options = input.required(...(ngDevMode ? [{ debugName: "options" }] : []));
6483
+ get internalOptions() {
6484
+ return this._options();
6485
+ }
6486
+ contentTpl = viewChild('contentTpl', ...(ngDevMode ? [{ debugName: "contentTpl" }] : []));
6487
+ dynamicContents = viewChildren(DynamicContentDirective, ...(ngDevMode ? [{ debugName: "dynamicContents" }] : []));
6488
+ constructor() {
6489
+ super();
6490
+ effect(() => {
6491
+ this._options.set(this.options());
6492
+ this.initFields();
6493
+ this.initModel();
6494
+ this.refreshDynamicInstance();
6495
+ });
6496
+ }
6497
+ refreshProperties() {
6498
+ this.baseComponentRef.setInput('options', this._options());
6499
+ }
6500
+ initFields() {
6501
+ this._options.update((options) => {
6502
+ return {
6503
+ ...options,
6504
+ fields: _.sortBy(getModelFieldsWithOptions(new (this._options().type)()).filter((item) => item?.options?.list), (item) => (item?.options?.list).order),
6505
+ };
6506
+ });
6507
+ }
6508
+ initModel() {
6509
+ this.mode = computed(() => this._options()?.mode ??
6510
+ (this.hardwareService.isMobile ? ListMode.mobile : ListMode.desktop), ...(ngDevMode ? [{ debugName: "mode" }] : []));
6511
+ }
6512
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
6513
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: ListComponent, isStandalone: true, selector: "smart-list", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "contentTpl", first: true, predicate: ["contentTpl"], descendants: true, isSignal: true }, { propertyName: "dynamicContents", predicate: DynamicContentDirective, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "@if (template() === 'default') {\n @switch (mode()) {\n @case (ListMode.desktop) {\n <smart-list-desktop [options]=\"internalOptions\"></smart-list-desktop>\n }\n @case (ListMode.mobile) {\n <smart-list-mobile [options]=\"internalOptions\"></smart-list-mobile>\n }\n @case (ListMode.masonryGrid) {\n <smart-list-masonry-grid\n [options]=\"internalOptions\"\n ></smart-list-masonry-grid>\n }\n }\n\n <!-- <ion-row>-->\n <!-- <ion-col></ion-col>-->\n <!-- <ion-col size=\"auto\">-->\n @let loading = internalOptions?.provider?.loading();\n <smart-loader [show]=\"loading ?? false\"></smart-loader>\n @if (!loading && !internalOptions.provider.list()?.length) {\n <h2>\n <br />\n {{ 'noResults' | translate }}\n </h2>\n }\n <!-- </ion-col>-->\n <!-- <ion-col></ion-col>-->\n <!-- </ion-row>-->\n\n <ng-container [ngTemplateOutlet]=\"contentTpl\"></ng-container>\n}\n\n<ng-template #contentTpl>\n <ng-content></ng-content>\n</ng-template>\n<div class=\"dynamic-content\"></div>\n", dependencies: [{ kind: "component", type: ListDesktopComponent, selector: "smart-list-desktop" }, { kind: "component", type: ListMobileComponent, selector: "smart-list-mobile" }, { kind: "component", type: ListMasonryGridComponent, selector: "smart-list-masonry-grid" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: LoaderComponent, selector: "smart-loader", inputs: ["show", "height"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
6754
6514
  }
6755
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListDesktopComponent, decorators: [{
6515
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListComponent, decorators: [{
6756
6516
  type: Component,
6757
- args: [{ selector: 'smart-list-desktop', imports: [
6758
- NgTemplateOutlet,
6759
- ListHeaderPipe,
6760
- ListCellPipe,
6761
- LazyLoadImageModule,
6762
- FileUrlPipe,
6517
+ args: [{ selector: 'smart-list', encapsulation: ViewEncapsulation.None, imports: [
6518
+ ListDesktopComponent,
6519
+ ListMobileComponent,
6520
+ ListMasonryGridComponent,
6763
6521
  TranslatePipe,
6764
- PagingComponent,
6765
- CdkTable,
6766
- CdkHeaderCell,
6767
- CdkCell,
6768
- CdkHeaderRow,
6769
- CdkRow,
6770
- ], template: "<div #topTpl></div>\n\n<!--<ion-content>-->\n<div class=\"w-full overflow-y-auto\">\n <table\n cdk-table\n [dataSource]=\"list() ?? []\"\n [trackBy]=\"myTrackById\"\n class=\"w-full overflow-y-auto\"\n >\n @for (key of desktopKeys; track key) {\n @let last = $last;\n <ng-container class=\"col-sm text-left\">\n <div>\n @switch (key) {\n @case ('selectMulti') {\n <th cdk-header-cell class=\"w-5\" *matHeaderCellDef></th>\n <td cdk-cell>\n @let list = desktopList();\n @if (list) {\n <!-- <ion-checkbox-->\n <!-- style=\"margin-right: 15px\"-->\n <!-- (ionChange)=\"-->\n <!-- onChangeMultiselect(-->\n <!-- $event.detail.checked,-->\n <!-- element,-->\n <!-- list-->\n <!-- )-->\n <!-- \"-->\n <!-- ></ion-checkbox>-->\n }\n </td>\n }\n @case ('removeAction') {\n <th cdk-header-cell class=\"w-5\" *matHeaderCellDef>\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <td cdk-cell *matCellDef=\"let element\">\n @if (!checkRemoveHandler || checkRemoveHandler(element)) {\n <!-- <ion-button (click)=\"removeHandler?.(element)\">-->\n <!-- <ion-icon slot=\"icon-only\" name=\"trash\"></ion-icon>-->\n <!-- </ion-button>-->\n }\n </td>\n }\n @case ('detailsAction') {\n <th cdk-header-cell class=\"w-5\" *matHeaderCellDef>\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <td cdk-cell *matCellDef=\"let element\">\n <!-- <ion-button-->\n <!-- (click)=\"detailsButtonOptions.click()\"-->\n <!-- [smartDetails]=\"{-->\n <!-- component: detailsComponent,-->\n <!-- params: detailsComponentProps,-->\n <!-- mode: 'bottom',-->\n <!-- }\"-->\n <!-- (smartDetailsShowed)=\"select(element.id)\"-->\n <!-- >-->\n <!-- <ion-icon-->\n <!-- slot=\"icon-only\"-->\n <!-- name=\"ellipsis-vertical-outline\"-->\n <!-- ></ion-icon>-->\n <!-- </ion-button>-->\n </td>\n }\n @case ('itemAction') {\n <th cdk-header-cell class=\"w-5\">\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <td cdk-cell *matCellDef=\"let element\">\n <!-- <ion-button (click)=\"itemHandler?.(element.id)\">-->\n <!-- <ion-icon-->\n <!-- slot=\"icon-only\"-->\n <!-- name=\"arrow-forward-outline\"-->\n <!-- ></ion-icon>-->\n <!-- </ion-button>-->\n </td>\n }\n @default {\n <th cdk-header-cell>\n {{ (list() | smartListHeader: key : type)() }}\n <ng-container *ngTemplateOutlet=\"pagination\"></ng-container>\n </th>\n <ng-container *matCellDef=\"let element\">\n @let cell = element | smartListCell: key : cellPipe : type;\n @if (cell) {\n <td\n cdk-cell\n [attr.smart-item-key]=\"key\"\n [style.width.px]=\"cell.type === FieldType.image ? 60 : null\"\n [style.textAlign]=\"\n cell.type === FieldType.image ? 'center' : null\n \"\n >\n @if (cell.type === FieldType.image) {\n <img\n height=\"50\"\n [lazyLoad]=\"cell.value | smartFileUrl\"\n alt=\"\"\n src=\"\"\n />\n } @else {\n <div\n class=\"min-h-8 pt-1.5\"\n [innerHTML]=\"cell.value\"\n ></div>\n }\n </td>\n } @else {\n <td cdk-cell></td>\n }\n </ng-container>\n }\n }\n </div>\n\n <ng-template #pagination>\n @if (last && loadNextPage && totalPages()) {\n <div style=\"float: right\">\n <!-- <ion-chip>-->\n {{ 'page' | translate }}:\n <b>{{ page() }}/{{ totalPages() }}</b>\n <!-- </ion-chip>-->\n </div>\n }\n </ng-template>\n </ng-container>\n }\n\n <tr cdk-header-row *matHeaderRowDef=\"desktopKeys ?? []; sticky: true\"></tr>\n <tr cdk-row *matRowDef=\"let row; columns: desktopKeys ?? []\"></tr>\n </table>\n</div>\n\n@if (\n loadNextPage &&\n Object.keys(list() ?? [])?.length &&\n options().pagination?.mode !== PaginationMode.singlePage\n) {\n <!-- <ion-infinite-scroll threshold=\"100px\" (ionInfinite)=\"loadNextPage($event)\">-->\n <!-- <ion-infinite-scroll-content-->\n <!-- loadingSpinner=\"circles\"-->\n <!-- ></ion-infinite-scroll-content>-->\n <!-- </ion-infinite-scroll>-->\n}\n<!--</ion-content>-->\n\n@if (options()?.pagination?.mode === PaginationMode.singlePage) {\n <smart-paging\n [page]=\"page()\"\n [totalPages]=\"totalPages()\"\n (prevPage)=\"loadPrevPage?.()\"\n (nextPage)=\"loadNextPage?.()\"\n ></smart-paging>\n}\n", styles: ["table .mat-row,table .mat-header-row{background:#fff;min-width:1200px}.wrapper{height:100%}.mat-row,.mat-header-row{min-width:1200px}\n"] }]
6771
- }] });
6522
+ NgTemplateOutlet,
6523
+ LoaderComponent,
6524
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (template() === 'default') {\n @switch (mode()) {\n @case (ListMode.desktop) {\n <smart-list-desktop [options]=\"internalOptions\"></smart-list-desktop>\n }\n @case (ListMode.mobile) {\n <smart-list-mobile [options]=\"internalOptions\"></smart-list-mobile>\n }\n @case (ListMode.masonryGrid) {\n <smart-list-masonry-grid\n [options]=\"internalOptions\"\n ></smart-list-masonry-grid>\n }\n }\n\n <!-- <ion-row>-->\n <!-- <ion-col></ion-col>-->\n <!-- <ion-col size=\"auto\">-->\n @let loading = internalOptions?.provider?.loading();\n <smart-loader [show]=\"loading ?? false\"></smart-loader>\n @if (!loading && !internalOptions.provider.list()?.length) {\n <h2>\n <br />\n {{ 'noResults' | translate }}\n </h2>\n }\n <!-- </ion-col>-->\n <!-- <ion-col></ion-col>-->\n <!-- </ion-row>-->\n\n <ng-container [ngTemplateOutlet]=\"contentTpl\"></ng-container>\n}\n\n<ng-template #contentTpl>\n <ng-content></ng-content>\n</ng-template>\n<div class=\"dynamic-content\"></div>\n" }]
6525
+ }], ctorParameters: () => [] });
6772
6526
 
6773
- class ListMasonryGridComponent extends ListBaseComponent {
6774
- componentFactories = null;
6775
- listWithImages;
6776
- topTpl = viewChild('topTpl', ...(ngDevMode ? [{ debugName: "topTpl" }] : []));
6777
- ngAfterViewInit() {
6778
- this.generateDynamicComponents();
6527
+ class DetailsPage {
6528
+ modalService = inject(ModalService);
6529
+ styleService = inject(StyleService);
6530
+ elementRef = inject(ElementRef);
6531
+ // navParams: NavParams, //TODO: to be injected
6532
+ pageOptions = signal({
6533
+ title: 'details',
6534
+ hideMenuButton: true,
6535
+ }, ...(ngDevMode ? [{ debugName: "pageOptions" }] : []));
6536
+ detailsOptions;
6537
+ constructor() {
6538
+ this.detailsOptions = /*navParams.get('value')*/ {};
6539
+ this.initTitle();
6540
+ this.initButtons();
6779
6541
  }
6780
- afterInitOptions() {
6781
- const fieldOptions = getModelFieldsWithOptions(new this.type());
6782
- const imageFieldOptions = fieldOptions.find((item) => item.options.type === FieldType.image);
6783
- this.listWithImages = computed(() => {
6784
- const list = this.list();
6785
- if (!list)
6786
- return null;
6787
- return list.map((item) => {
6542
+ ngOnInit() {
6543
+ this.styleService.init(this.elementRef);
6544
+ }
6545
+ initTitle() {
6546
+ this.pageOptions.update((options) => {
6547
+ if (this.detailsOptions.title) {
6788
6548
  return {
6789
- data: item,
6790
- image: item[imageFieldOptions?.key ?? ''],
6549
+ ...options,
6550
+ title: this.detailsOptions.title,
6791
6551
  };
6792
- });
6793
- }, ...(ngDevMode ? [{ debugName: "listWithImages" }] : []));
6794
- }
6795
- initList(val) {
6796
- super.initList(val);
6797
- this.componentFactories = val?.componentFactories ?? null;
6798
- this.generateDynamicComponents();
6799
- }
6800
- generateDynamicComponents() {
6801
- if (!this.componentFactories)
6802
- return;
6803
- if (this.componentFactories.top && this.topTpl()) {
6804
- if (!this.topTpl()?.get(0)) {
6805
- this.topTpl()?.createComponent(this.componentFactories.top);
6806
6552
  }
6553
+ return options;
6554
+ });
6555
+ }
6556
+ initButtons() {
6557
+ const buttons = [];
6558
+ if (this.detailsOptions.removeHandler) {
6559
+ buttons.push({
6560
+ handler: () => {
6561
+ computed(() => {
6562
+ const item = this.detailsOptions.item();
6563
+ this.detailsOptions?.removeHandler?.(item);
6564
+ this.modalService.dismiss();
6565
+ });
6566
+ },
6567
+ icon: 'trash',
6568
+ });
6569
+ }
6570
+ if (this.detailsOptions.itemHandler) {
6571
+ buttons.push({
6572
+ handler: () => {
6573
+ computed(() => {
6574
+ const item = this.detailsOptions.item();
6575
+ this.detailsOptions?.removeHandler?.(item);
6576
+ this.modalService.dismiss();
6577
+ });
6578
+ },
6579
+ icon: 'arrow-forward-outline',
6580
+ });
6807
6581
  }
6582
+ this.pageOptions.update((options) => ({ ...options, endButtons: buttons }));
6808
6583
  }
6809
- Object = Object;
6810
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListMasonryGridComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
6811
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: ListMasonryGridComponent, isStandalone: true, selector: "smart-list-masonry-grid", viewQueries: [{ propertyName: "topTpl", first: true, predicate: ["topTpl"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div #topTpl></div>\n\n<div class=\"ion-padding\">\n <div class=\"gap-3\">\n @for (item of listWithImages(); track item) {\n <!-- <ion-card class=\"w-full my-2.5 break-inside-avoid border border-gray-100\" (click)=\"unselect?.()\">-->\n @if (item.image) {\n <img [ngSrc]=\"item.image | smartFileUrl\" alt=\"\" fill />\n }\n\n <!-- <ion-card-content class=\"overflow-hidden after:block after:w-full after:bg-gradient-to-r after:from-transparent after:to-white after:absolute after:bottom-0\">-->\n @for (key of keys; track key) {\n @let cell = item.data | smartListCell: key : cellPipe : type;\n @if (cell && cell.value != item.image) {\n @if ($index < 2) {\n <h3\n [attr.smart-item-key]=\"key\"\n class=\"text-gray-800\"\n [innerHTML]=\"cell.value\"\n ></h3>\n } @else {\n <p\n [attr.smart-item-key]=\"key\"\n class=\"text-gray-500\"\n [innerHTML]=\"cell.value\"\n ></p>\n }\n }\n }\n <!-- </ion-card-content>-->\n\n <!-- <ion-row>-->\n @if (removeHandler) {\n <!-- <ion-col size=\"auto\">-->\n @if (!checkRemoveHandler || checkRemoveHandler(item.data)) {\n <!-- <ion-button (click)=\"removeHandler?.(item.data)\">-->\n <!-- <ion-icon slot=\"icon-only\" name=\"trash\"></ion-icon>-->\n <!-- </ion-button>-->\n }\n <!-- </ion-col>-->\n }\n <!-- <ion-col></ion-col>-->\n @if (itemHandler) {\n <!-- <ion-col size=\"auto\">-->\n <!-- <ion-button (click)=\"itemHandler?.(item.data.id)\">-->\n <!-- <ion-icon-->\n <!-- slot=\"icon-only\"-->\n <!-- name=\"arrow-forward-outline\"-->\n <!-- ></ion-icon>-->\n <!-- </ion-button>-->\n <!-- </ion-col>-->\n }\n <!-- </ion-row>-->\n <!-- </ion-card>-->\n }\n </div>\n</div>\n\n@if (\n loadNextPage &&\n Object.keys(list() ?? [])?.length &&\n options().pagination?.mode !== PaginationMode.singlePage\n) {\n <!-- <ion-infinite-scroll threshold=\"100px\" (ionInfinite)=\"loadNextPage?.($event)\">-->\n <!-- <ion-infinite-scroll-content loadingSpinner=\"circles\">-->\n <!-- </ion-infinite-scroll-content>-->\n <!-- </ion-infinite-scroll>-->\n}\n\n@if (options()?.pagination?.mode === PaginationMode.singlePage) {\n <smart-paging\n [page]=\"page()\"\n [totalPages]=\"totalPages()\"\n (prevPage)=\"loadPrevPage?.()\"\n (nextPage)=\"loadNextPage?.()\"\n ></smart-paging>\n}\n", dependencies: [{ kind: "component", type: PagingComponent, selector: "smart-paging", inputs: ["page", "totalPages"], outputs: ["nextPage", "prevPage"] }, { kind: "directive", type: NgOptimizedImage, selector: "img[ngSrc]", inputs: ["ngSrc", "ngSrcset", "sizes", "width", "height", "decoding", "loading", "priority", "loaderParams", "disableOptimizedSrcset", "fill", "placeholder", "placeholderConfig", "src", "srcset"] }, { kind: "pipe", type: FileUrlPipe, name: "smartFileUrl" }, { kind: "pipe", type: ListCellPipe, name: "smartListCell" }] });
6584
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: DetailsPage, deps: [], target: i0.ɵɵFactoryTarget.Component });
6585
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.0", type: DetailsPage, isStandalone: true, selector: "ng-component", ngImport: i0, template: "<smart-page [options]=\"pageOptions()\">\n <smart-details #smartDetails [options]=\"detailsOptions\"></smart-details>\n</smart-page>\n", styles: [":host{width:100%}\n"], dependencies: [{ kind: "component", type: PageComponent, selector: "smart-page", inputs: ["options"] }, { kind: "component", type: DetailsComponent, selector: "smart-details", inputs: ["options"] }] });
6586
+ }
6587
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: DetailsPage, decorators: [{
6588
+ type: Component,
6589
+ args: [{ imports: [PageComponent, DetailsComponent], template: "<smart-page [options]=\"pageOptions()\">\n <smart-details #smartDetails [options]=\"detailsOptions\"></smart-details>\n</smart-page>\n", styles: [":host{width:100%}\n"] }]
6590
+ }], ctorParameters: () => [] });
6591
+
6592
+ const ACCORDION_COMPONENTS = [
6593
+ AccordionComponent,
6594
+ AccordionHeaderComponent,
6595
+ AccordionBodyComponent,
6596
+ ];
6597
+ const BUTTON_COMPONENTS = [ButtonComponent, ButtonStandardComponent];
6598
+ const CARD_COMPONENTS = [CardComponent];
6599
+ const DETAILS_COMPONENTS = [DetailsComponent, DetailsStandardComponent];
6600
+ const DETAIL_COMPONENTS = [
6601
+ DetailComponent,
6602
+ DetailTextComponent,
6603
+ DetailFlagComponent,
6604
+ DetailEnumComponent,
6605
+ DetailEmailComponent,
6606
+ DetailAddressComponent,
6607
+ DetailObjectComponent,
6608
+ DetailColorComponent,
6609
+ DetailLogoComponent,
6610
+ DetailArrayComponent,
6611
+ DetailPdfComponent,
6612
+ DetailVideoComponent,
6613
+ DetailAttachmentComponent,
6614
+ DetailDateRangeComponent,
6615
+ DetailImageComponent,
6616
+ DetailPhoneNumberPlComponent,
6617
+ ];
6618
+ const FORM_COMPONENTS = [
6619
+ FormStandardComponent,
6620
+ FormComponent,
6621
+ ];
6622
+ const INPUT_COMPONENTS = [
6623
+ InputComponent,
6624
+ InputIntComponent,
6625
+ InputErrorComponent,
6626
+ InputTextComponent,
6627
+ InputPasswordComponent,
6628
+ InputFlagComponent,
6629
+ InputEnumComponent,
6630
+ InputEmailComponent,
6631
+ InputCurrencyComponent,
6632
+ InputDateComponent,
6633
+ InputDateWithEditComponent,
6634
+ InputFileComponent,
6635
+ InputRadioComponent,
6636
+ InputNipComponent,
6637
+ InputStringsComponent,
6638
+ InputLongTextComponent,
6639
+ InputAddressComponent,
6640
+ InputObjectComponent,
6641
+ InputColorComponent,
6642
+ InputLogoComponent,
6643
+ InputCheckComponent,
6644
+ InputIntsComponent,
6645
+ InputPhoneNumberComponent,
6646
+ InputPhoneNumberPlComponent,
6647
+ InputPeselComponent,
6648
+ InputArrayComponent,
6649
+ InputPdfComponent,
6650
+ InputVideoComponent,
6651
+ InputAttachmentComponent,
6652
+ InputDateRangeComponent,
6653
+ InputImageComponent,
6654
+ InputFloatComponent,
6655
+ ];
6656
+ const LIST_COMPONENTS = [
6657
+ ListComponent,
6658
+ ListMobileComponent,
6659
+ ListDesktopComponent,
6660
+ ListMasonryGridComponent,
6661
+ ];
6662
+ const LOADER_COMPONENTS = [LoaderComponent];
6663
+ const PAGE_COMPONENTS = [PageStandardComponent, PageComponent];
6664
+ const INFO_COMPONENTS = [InfoComponent, InfoModalComponent];
6665
+ const DATE_RANGE_COMPONENTS = [
6666
+ DateRangeComponent,
6667
+ DateRangeModalComponent,
6668
+ ];
6669
+ const DATE_EDIT_COMPONENTS = [DateEditComponent];
6670
+ const DYNAMIC_COMPONENTS = [DynamicComponent];
6671
+ const COMPONENTS$1 = [
6672
+ ...FORM_COMPONENTS,
6673
+ ...INPUT_COMPONENTS,
6674
+ ...PAGE_COMPONENTS,
6675
+ ...ACCORDION_COMPONENTS,
6676
+ ...DATE_RANGE_COMPONENTS,
6677
+ ...DATE_EDIT_COMPONENTS,
6678
+ ...BUTTON_COMPONENTS,
6679
+ ...CARD_COMPONENTS,
6680
+ ...LIST_COMPONENTS,
6681
+ ...LOADER_COMPONENTS,
6682
+ ...DETAIL_COMPONENTS,
6683
+ ...DETAILS_COMPONENTS,
6684
+ ...DYNAMIC_COMPONENTS,
6685
+ ...INFO_COMPONENTS,
6686
+ ExportComponent,
6687
+ ImportComponent,
6688
+ PasswordStrengthComponent,
6689
+ ];
6690
+ const IMPORTS = [
6691
+ CommonModule,
6692
+ ReactiveFormsModule,
6693
+ FormsModule,
6694
+ TranslateModule,
6695
+ RouterModule,
6696
+ SharedPipesModule,
6697
+ SharedDirectivesModule,
6698
+ HttpClientModule,
6699
+ LazyLoadImageModule,
6700
+ DragDropModule,
6701
+ CdkTableModule,
6702
+ DynamicModule,
6703
+ ];
6704
+ class SharedComponentsModule {
6705
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedComponentsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
6706
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: SharedComponentsModule, imports: [CommonModule,
6707
+ ReactiveFormsModule,
6708
+ FormsModule,
6709
+ TranslateModule,
6710
+ RouterModule,
6711
+ SharedPipesModule,
6712
+ SharedDirectivesModule,
6713
+ HttpClientModule,
6714
+ LazyLoadImageModule,
6715
+ DragDropModule,
6716
+ CdkTableModule,
6717
+ DynamicModule, FormStandardComponent,
6718
+ FormComponent, InputComponent,
6719
+ InputIntComponent,
6720
+ InputErrorComponent,
6721
+ InputTextComponent,
6722
+ InputPasswordComponent,
6723
+ InputFlagComponent,
6724
+ InputEnumComponent,
6725
+ InputEmailComponent,
6726
+ InputCurrencyComponent,
6727
+ InputDateComponent,
6728
+ InputDateWithEditComponent,
6729
+ InputFileComponent,
6730
+ InputRadioComponent,
6731
+ InputNipComponent,
6732
+ InputStringsComponent,
6733
+ InputLongTextComponent,
6734
+ InputAddressComponent,
6735
+ InputObjectComponent,
6736
+ InputColorComponent,
6737
+ InputLogoComponent,
6738
+ InputCheckComponent,
6739
+ InputIntsComponent,
6740
+ InputPhoneNumberComponent,
6741
+ InputPhoneNumberPlComponent,
6742
+ InputPeselComponent,
6743
+ InputArrayComponent,
6744
+ InputPdfComponent,
6745
+ InputVideoComponent,
6746
+ InputAttachmentComponent,
6747
+ InputDateRangeComponent,
6748
+ InputImageComponent,
6749
+ InputFloatComponent, PageStandardComponent, PageComponent, AccordionComponent,
6750
+ AccordionHeaderComponent,
6751
+ AccordionBodyComponent, DateRangeComponent,
6752
+ DateRangeModalComponent, DateEditComponent, ButtonComponent, ButtonStandardComponent, CardComponent, ListComponent,
6753
+ ListMobileComponent,
6754
+ ListDesktopComponent,
6755
+ ListMasonryGridComponent, LoaderComponent, DetailComponent,
6756
+ DetailTextComponent,
6757
+ DetailFlagComponent,
6758
+ DetailEnumComponent,
6759
+ DetailEmailComponent,
6760
+ DetailAddressComponent,
6761
+ DetailObjectComponent,
6762
+ DetailColorComponent,
6763
+ DetailLogoComponent,
6764
+ DetailArrayComponent,
6765
+ DetailPdfComponent,
6766
+ DetailVideoComponent,
6767
+ DetailAttachmentComponent,
6768
+ DetailDateRangeComponent,
6769
+ DetailImageComponent,
6770
+ DetailPhoneNumberPlComponent, DetailsComponent, DetailsStandardComponent, DynamicComponent, InfoComponent, InfoModalComponent, ExportComponent,
6771
+ ImportComponent,
6772
+ PasswordStrengthComponent], exports: [FormStandardComponent,
6773
+ FormComponent, InputComponent,
6774
+ InputIntComponent,
6775
+ InputErrorComponent,
6776
+ InputTextComponent,
6777
+ InputPasswordComponent,
6778
+ InputFlagComponent,
6779
+ InputEnumComponent,
6780
+ InputEmailComponent,
6781
+ InputCurrencyComponent,
6782
+ InputDateComponent,
6783
+ InputDateWithEditComponent,
6784
+ InputFileComponent,
6785
+ InputRadioComponent,
6786
+ InputNipComponent,
6787
+ InputStringsComponent,
6788
+ InputLongTextComponent,
6789
+ InputAddressComponent,
6790
+ InputObjectComponent,
6791
+ InputColorComponent,
6792
+ InputLogoComponent,
6793
+ InputCheckComponent,
6794
+ InputIntsComponent,
6795
+ InputPhoneNumberComponent,
6796
+ InputPhoneNumberPlComponent,
6797
+ InputPeselComponent,
6798
+ InputArrayComponent,
6799
+ InputPdfComponent,
6800
+ InputVideoComponent,
6801
+ InputAttachmentComponent,
6802
+ InputDateRangeComponent,
6803
+ InputImageComponent,
6804
+ InputFloatComponent, PageStandardComponent, PageComponent, AccordionComponent,
6805
+ AccordionHeaderComponent,
6806
+ AccordionBodyComponent, DateRangeComponent,
6807
+ DateRangeModalComponent, DateEditComponent, ButtonComponent, ButtonStandardComponent, CardComponent, ListComponent,
6808
+ ListMobileComponent,
6809
+ ListDesktopComponent,
6810
+ ListMasonryGridComponent, LoaderComponent, DetailComponent,
6811
+ DetailTextComponent,
6812
+ DetailFlagComponent,
6813
+ DetailEnumComponent,
6814
+ DetailEmailComponent,
6815
+ DetailAddressComponent,
6816
+ DetailObjectComponent,
6817
+ DetailColorComponent,
6818
+ DetailLogoComponent,
6819
+ DetailArrayComponent,
6820
+ DetailPdfComponent,
6821
+ DetailVideoComponent,
6822
+ DetailAttachmentComponent,
6823
+ DetailDateRangeComponent,
6824
+ DetailImageComponent,
6825
+ DetailPhoneNumberPlComponent, DetailsComponent, DetailsStandardComponent, DynamicComponent, InfoComponent, InfoModalComponent, ExportComponent,
6826
+ ImportComponent,
6827
+ PasswordStrengthComponent] });
6828
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedComponentsModule, providers: [
6829
+ {
6830
+ provide: FORM_COMPONENT_TOKEN,
6831
+ useValue: FormComponent,
6832
+ },
6833
+ {
6834
+ provide: DETAILS_COMPONENT_TOKEN,
6835
+ useValue: DetailsComponent,
6836
+ },
6837
+ ], imports: [IMPORTS, FormStandardComponent,
6838
+ FormComponent, InputComponent,
6839
+ InputIntComponent,
6840
+ InputTextComponent,
6841
+ InputPasswordComponent,
6842
+ InputFlagComponent,
6843
+ InputEmailComponent,
6844
+ InputCurrencyComponent,
6845
+ InputDateComponent,
6846
+ InputDateWithEditComponent,
6847
+ InputRadioComponent,
6848
+ InputNipComponent,
6849
+ InputStringsComponent,
6850
+ InputLongTextComponent,
6851
+ InputAddressComponent,
6852
+ InputCheckComponent,
6853
+ InputIntsComponent,
6854
+ InputPhoneNumberComponent,
6855
+ InputPhoneNumberPlComponent,
6856
+ InputPeselComponent,
6857
+ InputFloatComponent, PageStandardComponent, PageComponent, DateEditComponent, ListComponent,
6858
+ ListMobileComponent,
6859
+ ListDesktopComponent, DynamicComponent] });
6812
6860
  }
6813
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListMasonryGridComponent, decorators: [{
6814
- type: Component,
6815
- args: [{ selector: 'smart-list-masonry-grid', imports: [PagingComponent, FileUrlPipe, NgOptimizedImage, ListCellPipe], template: "<div #topTpl></div>\n\n<div class=\"ion-padding\">\n <div class=\"gap-3\">\n @for (item of listWithImages(); track item) {\n <!-- <ion-card class=\"w-full my-2.5 break-inside-avoid border border-gray-100\" (click)=\"unselect?.()\">-->\n @if (item.image) {\n <img [ngSrc]=\"item.image | smartFileUrl\" alt=\"\" fill />\n }\n\n <!-- <ion-card-content class=\"overflow-hidden after:block after:w-full after:bg-gradient-to-r after:from-transparent after:to-white after:absolute after:bottom-0\">-->\n @for (key of keys; track key) {\n @let cell = item.data | smartListCell: key : cellPipe : type;\n @if (cell && cell.value != item.image) {\n @if ($index < 2) {\n <h3\n [attr.smart-item-key]=\"key\"\n class=\"text-gray-800\"\n [innerHTML]=\"cell.value\"\n ></h3>\n } @else {\n <p\n [attr.smart-item-key]=\"key\"\n class=\"text-gray-500\"\n [innerHTML]=\"cell.value\"\n ></p>\n }\n }\n }\n <!-- </ion-card-content>-->\n\n <!-- <ion-row>-->\n @if (removeHandler) {\n <!-- <ion-col size=\"auto\">-->\n @if (!checkRemoveHandler || checkRemoveHandler(item.data)) {\n <!-- <ion-button (click)=\"removeHandler?.(item.data)\">-->\n <!-- <ion-icon slot=\"icon-only\" name=\"trash\"></ion-icon>-->\n <!-- </ion-button>-->\n }\n <!-- </ion-col>-->\n }\n <!-- <ion-col></ion-col>-->\n @if (itemHandler) {\n <!-- <ion-col size=\"auto\">-->\n <!-- <ion-button (click)=\"itemHandler?.(item.data.id)\">-->\n <!-- <ion-icon-->\n <!-- slot=\"icon-only\"-->\n <!-- name=\"arrow-forward-outline\"-->\n <!-- ></ion-icon>-->\n <!-- </ion-button>-->\n <!-- </ion-col>-->\n }\n <!-- </ion-row>-->\n <!-- </ion-card>-->\n }\n </div>\n</div>\n\n@if (\n loadNextPage &&\n Object.keys(list() ?? [])?.length &&\n options().pagination?.mode !== PaginationMode.singlePage\n) {\n <!-- <ion-infinite-scroll threshold=\"100px\" (ionInfinite)=\"loadNextPage?.($event)\">-->\n <!-- <ion-infinite-scroll-content loadingSpinner=\"circles\">-->\n <!-- </ion-infinite-scroll-content>-->\n <!-- </ion-infinite-scroll>-->\n}\n\n@if (options()?.pagination?.mode === PaginationMode.singlePage) {\n <smart-paging\n [page]=\"page()\"\n [totalPages]=\"totalPages()\"\n (prevPage)=\"loadPrevPage?.()\"\n (nextPage)=\"loadNextPage?.()\"\n ></smart-paging>\n}\n" }]
6861
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedComponentsModule, decorators: [{
6862
+ type: NgModule,
6863
+ args: [{
6864
+ declarations: [],
6865
+ exports: [...COMPONENTS$1],
6866
+ providers: [
6867
+ {
6868
+ provide: FORM_COMPONENT_TOKEN,
6869
+ useValue: FormComponent,
6870
+ },
6871
+ {
6872
+ provide: DETAILS_COMPONENT_TOKEN,
6873
+ useValue: DetailsComponent,
6874
+ },
6875
+ ],
6876
+ imports: [...IMPORTS, ...COMPONENTS$1],
6877
+ }]
6816
6878
  }] });
6817
6879
 
6818
- class ListMobileComponent extends ListBaseComponent {
6819
- listMobile = this.list;
6820
- componentFactories = null;
6821
- topTpl = viewChild('topTpl', ...(ngDevMode ? [{ debugName: "topTpl" }] : []));
6822
- initList(val) {
6823
- super.initList(val);
6824
- this.componentFactories = val.componentFactories ?? null;
6825
- this.generateDynamicComponents();
6826
- }
6827
- ngAfterViewInit() {
6828
- this.generateDynamicComponents();
6829
- }
6830
- generateDynamicComponents() {
6831
- if (!this.componentFactories)
6832
- return;
6833
- if (this.componentFactories.top && this.topTpl()) {
6834
- if (!this.topTpl()?.get(0)) {
6835
- this.topTpl()?.createComponent(this.componentFactories.top);
6836
- }
6837
- }
6838
- }
6839
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListMobileComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
6840
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: ListMobileComponent, isStandalone: true, selector: "smart-list-mobile", viewQueries: [{ propertyName: "topTpl", first: true, predicate: ["topTpl"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div #topTpl></div>\n\n@let list = listMobile();\n@if (list) {\n <!-- <ion-list>-->\n @for (item of list; track item.id) {\n <!-- <ion-item-sliding>-->\n @if (removeHandler && (!checkRemoveHandler || checkRemoveHandler(item))) {\n <!-- <ion-item-options side=\"start\" (ionSwipe)=\"removeHandler?.(item)\">-->\n <!-- <ion-item-option-->\n <!-- color=\"danger\"-->\n <!-- expandable-->\n <!-- (click)=\"removeHandler?.(item)\"-->\n <!-- >-->\n {{ 'delete' | translate }}\n <!-- </ion-item-option>-->\n <!-- </ion-item-options>-->\n }\n\n <!-- <ion-item class=\"pl-5\" (click)=\"itemHandler ? itemHandler(item.id) : unselect()\">-->\n <!-- <ion-label>-->\n @for (key of keys; track key) {\n @let cell = item | smartListCell: key : cellPipe : type;\n @if (cell) {\n @if (cell.type === FieldType.image) {\n <img\n [attr.smart-item-key]=\"key\"\n height=\"100\"\n [lazyLoad]=\"cell.value | smartFileUrl\"\n alt=\"\"\n src=\"\"\n />\n } @else if ($first) {\n <h2 [attr.smart-item-key]=\"key\" [innerHTML]=\"cell.value\"></h2>\n } @else {\n <p [attr.smart-item-key]=\"key\" [innerHTML]=\"cell.value\"></p>\n }\n }\n }\n <!-- </ion-label>-->\n <!-- </ion-item>-->\n <!-- </ion-item-sliding>-->\n }\n <!-- </ion-list>-->\n}\n\n@if (\n loadNextPage &&\n list?.length &&\n options().pagination?.mode !== PaginationMode.singlePage\n) {\n <!-- <ion-infinite-scroll threshold=\"100px\" (ionInfinite)=\"loadNextPage?.($event)\">-->\n <!-- <ion-infinite-scroll-content-->\n <!-- loadingSpinner=\"circles\"-->\n <!-- ></ion-infinite-scroll-content>-->\n <!-- </ion-infinite-scroll>-->\n}\n\n@if (options()?.pagination?.mode === PaginationMode.singlePage) {\n <smart-paging\n [page]=\"page()\"\n [totalPages]=\"totalPages()\"\n (prevPage)=\"loadPrevPage?.()\"\n (nextPage)=\"loadNextPage?.()\"\n ></smart-paging>\n}\n", dependencies: [{ kind: "ngmodule", type: LazyLoadImageModule }, { kind: "directive", type: i1$2.LazyLoadImageDirective, selector: "[lazyLoad]", inputs: ["lazyLoad", "defaultImage", "errorImage", "scrollTarget", "customObservable", "offset", "useSrcset", "decode", "debug"], outputs: ["onStateChange"] }, { kind: "component", type: PagingComponent, selector: "smart-paging", inputs: ["page", "totalPages"], outputs: ["nextPage", "prevPage"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }, { kind: "pipe", type: FileUrlPipe, name: "smartFileUrl" }, { kind: "pipe", type: ListCellPipe, name: "smartListCell" }] });
6880
+ const COMPONENTS = [DetailsPage];
6881
+ class SharedPagesModule {
6882
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedPagesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
6883
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: SharedPagesModule, imports: [SharedServicesModule,
6884
+ SharedComponentsModule,
6885
+ SharedDirectivesModule, DetailsPage], exports: [DetailsPage] });
6886
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedPagesModule, imports: [SharedServicesModule,
6887
+ SharedComponentsModule,
6888
+ SharedDirectivesModule,
6889
+ COMPONENTS] });
6841
6890
  }
6842
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListMobileComponent, decorators: [{
6843
- type: Component,
6844
- args: [{ selector: 'smart-list-mobile', imports: [
6845
- TranslatePipe,
6846
- FileUrlPipe,
6847
- LazyLoadImageModule,
6848
- PagingComponent,
6849
- ListCellPipe,
6850
- ], template: "<div #topTpl></div>\n\n@let list = listMobile();\n@if (list) {\n <!-- <ion-list>-->\n @for (item of list; track item.id) {\n <!-- <ion-item-sliding>-->\n @if (removeHandler && (!checkRemoveHandler || checkRemoveHandler(item))) {\n <!-- <ion-item-options side=\"start\" (ionSwipe)=\"removeHandler?.(item)\">-->\n <!-- <ion-item-option-->\n <!-- color=\"danger\"-->\n <!-- expandable-->\n <!-- (click)=\"removeHandler?.(item)\"-->\n <!-- >-->\n {{ 'delete' | translate }}\n <!-- </ion-item-option>-->\n <!-- </ion-item-options>-->\n }\n\n <!-- <ion-item class=\"pl-5\" (click)=\"itemHandler ? itemHandler(item.id) : unselect()\">-->\n <!-- <ion-label>-->\n @for (key of keys; track key) {\n @let cell = item | smartListCell: key : cellPipe : type;\n @if (cell) {\n @if (cell.type === FieldType.image) {\n <img\n [attr.smart-item-key]=\"key\"\n height=\"100\"\n [lazyLoad]=\"cell.value | smartFileUrl\"\n alt=\"\"\n src=\"\"\n />\n } @else if ($first) {\n <h2 [attr.smart-item-key]=\"key\" [innerHTML]=\"cell.value\"></h2>\n } @else {\n <p [attr.smart-item-key]=\"key\" [innerHTML]=\"cell.value\"></p>\n }\n }\n }\n <!-- </ion-label>-->\n <!-- </ion-item>-->\n <!-- </ion-item-sliding>-->\n }\n <!-- </ion-list>-->\n}\n\n@if (\n loadNextPage &&\n list?.length &&\n options().pagination?.mode !== PaginationMode.singlePage\n) {\n <!-- <ion-infinite-scroll threshold=\"100px\" (ionInfinite)=\"loadNextPage?.($event)\">-->\n <!-- <ion-infinite-scroll-content-->\n <!-- loadingSpinner=\"circles\"-->\n <!-- ></ion-infinite-scroll-content>-->\n <!-- </ion-infinite-scroll>-->\n}\n\n@if (options()?.pagination?.mode === PaginationMode.singlePage) {\n <smart-paging\n [page]=\"page()\"\n [totalPages]=\"totalPages()\"\n (prevPage)=\"loadPrevPage?.()\"\n (nextPage)=\"loadNextPage?.()\"\n ></smart-paging>\n}\n" }]
6891
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: SharedPagesModule, decorators: [{
6892
+ type: NgModule,
6893
+ args: [{
6894
+ imports: [
6895
+ SharedServicesModule,
6896
+ SharedComponentsModule,
6897
+ SharedDirectivesModule,
6898
+ COMPONENTS,
6899
+ ],
6900
+ declarations: [],
6901
+ exports: [...COMPONENTS],
6902
+ }]
6851
6903
  }] });
6852
6904
 
6853
- class ListComponent extends CreateDynamicComponent('list') {
6854
- hardwareService;
6855
- _options;
6856
- mode = signal(ListMode.desktop, ...(ngDevMode ? [{ debugName: "mode" }] : []));
6857
- ListMode = ListMode;
6858
- options = input.required(...(ngDevMode ? [{ debugName: "options" }] : []));
6859
- get internalOptions() {
6860
- return this._options();
6861
- }
6862
- contentTpl = viewChild('contentTpl', ...(ngDevMode ? [{ debugName: "contentTpl" }] : []));
6863
- dynamicContents = viewChildren(DynamicContentDirective, ...(ngDevMode ? [{ debugName: "dynamicContents" }] : []));
6864
- constructor(hardwareService) {
6865
- super();
6866
- this.hardwareService = hardwareService;
6867
- effect(() => {
6868
- this._options.set(this.options());
6869
- this.initFields();
6870
- this.initModel();
6871
- this.refreshDynamicInstance();
6872
- });
6873
- }
6874
- refreshProperties() {
6875
- this.baseComponentRef.setInput('options', this._options());
6876
- }
6877
- initFields() {
6878
- this._options.update((options) => {
6879
- return {
6880
- ...options,
6881
- fields: _.sortBy(getModelFieldsWithOptions(new (this._options().type)()).filter((item) => item?.options?.list), (item) => (item?.options?.list).order),
6882
- };
6883
- });
6884
- }
6885
- initModel() {
6886
- this.mode = computed(() => this._options()?.mode ??
6887
- (this.hardwareService.isMobile ? ListMode.mobile : ListMode.desktop), ...(ngDevMode ? [{ debugName: "mode" }] : []));
6888
- }
6889
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListComponent, deps: [{ token: HardwareService }], target: i0.ɵɵFactoryTarget.Component });
6890
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: ListComponent, isStandalone: true, selector: "smart-list", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "contentTpl", first: true, predicate: ["contentTpl"], descendants: true, isSignal: true }, { propertyName: "dynamicContents", predicate: DynamicContentDirective, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "@if (template() === 'default') {\n @switch (mode()) {\n @case (ListMode.desktop) {\n <smart-list-desktop [options]=\"internalOptions\"></smart-list-desktop>\n }\n @case (ListMode.mobile) {\n <smart-list-mobile [options]=\"internalOptions\"></smart-list-mobile>\n }\n @case (ListMode.masonryGrid) {\n <smart-list-masonry-grid\n [options]=\"internalOptions\"\n ></smart-list-masonry-grid>\n }\n }\n\n <!-- <ion-row>-->\n <!-- <ion-col></ion-col>-->\n <!-- <ion-col size=\"auto\">-->\n @let loading = internalOptions?.provider?.loading();\n <smart-loader [show]=\"loading ?? false\"></smart-loader>\n @if (!loading && !internalOptions.provider.list()?.length) {\n <h2>\n <br />\n {{ 'noResults' | translate }}\n </h2>\n }\n <!-- </ion-col>-->\n <!-- <ion-col></ion-col>-->\n <!-- </ion-row>-->\n\n <ng-container [ngTemplateOutlet]=\"contentTpl\"></ng-container>\n}\n\n<ng-template #contentTpl>\n <ng-content></ng-content>\n</ng-template>\n<div class=\"dynamic-content\"></div>\n", dependencies: [{ kind: "component", type: ListDesktopComponent, selector: "smart-list-desktop" }, { kind: "component", type: ListMobileComponent, selector: "smart-list-mobile" }, { kind: "component", type: ListMasonryGridComponent, selector: "smart-list-masonry-grid" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: LoaderComponent, selector: "smart-loader", inputs: ["show", "height"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
6891
- }
6892
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: ListComponent, decorators: [{
6893
- type: Component,
6894
- args: [{ selector: 'smart-list', encapsulation: ViewEncapsulation.None, imports: [
6895
- ListDesktopComponent,
6896
- ListMobileComponent,
6897
- ListMasonryGridComponent,
6898
- TranslatePipe,
6899
- NgTemplateOutlet,
6900
- LoaderComponent,
6901
- ], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (template() === 'default') {\n @switch (mode()) {\n @case (ListMode.desktop) {\n <smart-list-desktop [options]=\"internalOptions\"></smart-list-desktop>\n }\n @case (ListMode.mobile) {\n <smart-list-mobile [options]=\"internalOptions\"></smart-list-mobile>\n }\n @case (ListMode.masonryGrid) {\n <smart-list-masonry-grid\n [options]=\"internalOptions\"\n ></smart-list-masonry-grid>\n }\n }\n\n <!-- <ion-row>-->\n <!-- <ion-col></ion-col>-->\n <!-- <ion-col size=\"auto\">-->\n @let loading = internalOptions?.provider?.loading();\n <smart-loader [show]=\"loading ?? false\"></smart-loader>\n @if (!loading && !internalOptions.provider.list()?.length) {\n <h2>\n <br />\n {{ 'noResults' | translate }}\n </h2>\n }\n <!-- </ion-col>-->\n <!-- <ion-col></ion-col>-->\n <!-- </ion-row>-->\n\n <ng-container [ngTemplateOutlet]=\"contentTpl\"></ng-container>\n}\n\n<ng-template #contentTpl>\n <ng-content></ng-content>\n</ng-template>\n<div class=\"dynamic-content\"></div>\n" }]
6902
- }], ctorParameters: () => [{ type: HardwareService }] });
6903
-
6904
6905
  function setDefaultTranslationsAndLang(service) {
6905
6906
  const map = {
6906
6907
  pl: TRANSLATE_DATA_PL,