@dataclouder/ngx-core 0.1.40 → 0.1.42

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.
@@ -34,7 +34,7 @@ import { SpeedDialModule } from 'primeng/speeddial';
34
34
  import { PaginatorModule } from 'primeng/paginator';
35
35
  import * as i4$2 from 'primeng/table';
36
36
  import { TableModule } from 'primeng/table';
37
- import { get } from 'lodash';
37
+ import { get } from 'es-toolkit/compat';
38
38
  import * as i6 from 'primeng/tag';
39
39
  import { TagModule } from 'primeng/tag';
40
40
  import * as i1$2 from 'primeng/fieldset';
@@ -50,10 +50,11 @@ import * as i2$5 from 'primeng/inputnumber';
50
50
  import { InputNumberModule } from 'primeng/inputnumber';
51
51
  import { toSignal } from '@angular/core/rxjs-interop';
52
52
  import { map } from 'rxjs/operators';
53
- import { firstValueFrom, catchError, lastValueFrom, tap, throwError, map as map$1 } from 'rxjs';
53
+ import { firstValueFrom, catchError, lastValueFrom, tap, throwError, map as map$1, fromEvent, distinctUntilChanged } from 'rxjs';
54
54
  import * as i4$4 from 'primeng/textarea';
55
55
  import { TextareaModule } from 'primeng/textarea';
56
56
  import { HttpClient, HttpEventType } from '@angular/common/http';
57
+ import { Capacitor } from '@capacitor/core';
57
58
 
58
59
  class EmptyStateComponent {
59
60
  constructor() {
@@ -769,7 +770,7 @@ class DcAuditableViewerComponent {
769
770
  </div>
770
771
  </p-fieldset>
771
772
  }
772
- `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FieldsetModule }, { kind: "component", type: i1$2.Fieldset, selector: "p-fieldset", inputs: ["legend", "toggleable", "collapsed", "style", "styleClass", "transitionOptions"], outputs: ["collapsedChange", "onBeforeToggle", "onAfterToggle"] }, { kind: "ngmodule", type: TagModule }, { kind: "component", type: i6.Tag, selector: "p-tag", inputs: ["styleClass", "severity", "value", "icon", "rounded"] }, { kind: "ngmodule", type: ChipModule }, { kind: "component", type: i3$3.Chip, selector: "p-chip", inputs: ["label", "icon", "image", "alt", "styleClass", "removable", "removeIcon", "chipProps"], outputs: ["onRemove", "onImageError"] }, { kind: "ngmodule", type: AvatarModule }, { kind: "pipe", type: i1$1.DatePipe, name: "date" }] }); }
773
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FieldsetModule }, { kind: "component", type: i1$2.Fieldset, selector: "p-fieldset", inputs: ["legend", "toggleable", "collapsed", "style", "styleClass", "transitionOptions"], outputs: ["collapsedChange", "onBeforeToggle", "onAfterToggle"] }, { kind: "ngmodule", type: TagModule }, { kind: "component", type: i6.Tag, selector: "p-tag", inputs: ["styleClass", "severity", "value", "icon", "rounded"] }, { kind: "ngmodule", type: ChipModule }, { kind: "component", type: i3$3.Chip, selector: "p-chip", inputs: ["label", "icon", "image", "alt", "styleClass", "disabled", "removable", "removeIcon", "chipProps"], outputs: ["onRemove", "onImageError"] }, { kind: "ngmodule", type: AvatarModule }, { kind: "pipe", type: i1$1.DatePipe, name: "date" }] }); }
773
774
  }
774
775
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: DcAuditableViewerComponent, decorators: [{
775
776
  type: Component,
@@ -935,7 +936,7 @@ class DcTagsFormComponent {
935
936
  this.arrayForm.removeAt(index);
936
937
  }
937
938
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: DcTagsFormComponent, deps: [{ token: i1.ControlContainer }], target: i0.ɵɵFactoryTarget.Component }); }
938
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.6", type: DcTagsFormComponent, isStandalone: true, selector: "dc-tags-form", ngImport: i0, template: "<div [formGroup]=\"form\">\n <div formArrayName=\"tags\">\n <div class=\"flex flex-wrap gap-2\">\n @for (tagControl of arrayForm.controls; track tagControl; let i = $index) {\n <p-chip [label]=\"tagControl.value\" [removable]=\"true\" (onRemove)=\"removeTag(i)\"></p-chip>\n }\n </div>\n </div>\n</div>\n\n<div class=\"flex mt-2\">\n <input pInputText type=\"text\" [formControl]=\"newTagControl\" placeholder=\"New tag\" (keydown.enter)=\"addTag(); $event.preventDefault()\" />\n <p-button label=\"Add Tag\" icon=\"pi pi-plus\" (click)=\"addTag()\" [disabled]=\"!newTagControl.value\"></p-button>\n</div>\n", styles: [".tag-field{display:flex;align-items:center;margin-bottom:.5rem}.tag-field input{margin-right:.5rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { kind: "ngmodule", type: ButtonModule }, { kind: "component", type: i2.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "raised", "rounded", "text", "plain", "severity", "outlined", "link", "tabindex", "size", "variant", "style", "styleClass", "badgeClass", "badgeSeverity", "ariaLabel", "buttonProps", "autofocus", "fluid"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: InputTextModule }, { kind: "directive", type: i4$1.InputText, selector: "[pInputText]", inputs: ["pSize", "variant", "fluid", "invalid"] }, { kind: "ngmodule", type: ChipModule }, { kind: "component", type: i3$3.Chip, selector: "p-chip", inputs: ["label", "icon", "image", "alt", "styleClass", "removable", "removeIcon", "chipProps"], outputs: ["onRemove", "onImageError"] }], viewProviders: [
939
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.6", type: DcTagsFormComponent, isStandalone: true, selector: "dc-tags-form", ngImport: i0, template: "<div [formGroup]=\"form\">\n <div formArrayName=\"tags\">\n <div class=\"flex flex-wrap gap-2\">\n @for (tagControl of arrayForm.controls; track tagControl; let i = $index) {\n <p-chip [label]=\"tagControl.value\" [removable]=\"true\" (onRemove)=\"removeTag(i)\"></p-chip>\n }\n </div>\n </div>\n</div>\n\n<div class=\"flex mt-2\">\n <input pInputText type=\"text\" [formControl]=\"newTagControl\" placeholder=\"New tag\" (keydown.enter)=\"addTag(); $event.preventDefault()\" />\n <p-button label=\"Add Tag\" icon=\"pi pi-plus\" (click)=\"addTag()\" [disabled]=\"!newTagControl.value\"></p-button>\n</div>\n", styles: [".tag-field{display:flex;align-items:center;margin-bottom:.5rem}.tag-field input{margin-right:.5rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { kind: "ngmodule", type: ButtonModule }, { kind: "component", type: i2.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "raised", "rounded", "text", "plain", "severity", "outlined", "link", "tabindex", "size", "variant", "style", "styleClass", "badgeClass", "badgeSeverity", "ariaLabel", "buttonProps", "autofocus", "fluid"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: InputTextModule }, { kind: "directive", type: i4$1.InputText, selector: "[pInputText]", inputs: ["pSize", "variant", "fluid", "invalid"] }, { kind: "ngmodule", type: ChipModule }, { kind: "component", type: i3$3.Chip, selector: "p-chip", inputs: ["label", "icon", "image", "alt", "styleClass", "disabled", "removable", "removeIcon", "chipProps"], outputs: ["onRemove", "onImageError"] }], viewProviders: [
939
940
  {
940
941
  provide: ControlContainer,
941
942
  useFactory: () => inject(ControlContainer, { skipSelf: true }),
@@ -1193,38 +1194,23 @@ class EntityBaseFormComponent {
1193
1194
  this.router = inject(Router);
1194
1195
  this.toastService = inject(TOAST_ALERTS_TOKEN, { optional: true });
1195
1196
  this.id = input(...(ngDevMode ? [undefined, { debugName: "id" }] : []));
1197
+ this.entityInput = input(undefined, ...(ngDevMode ? [{ debugName: "entityInput", alias: 'entity' }] : [{ alias: 'entity' }]));
1196
1198
  this.entity = signal(undefined, ...(ngDevMode ? [{ debugName: "entity" }] : []));
1197
1199
  this.entityIdFromUrl = toSignal(this.route.paramMap.pipe(map((params) => params.get('id'))));
1198
1200
  this.entityId = computed(() => this.id() ?? this.entityIdFromUrl(), ...(ngDevMode ? [{ debugName: "entityId" }] : []));
1199
- this.loadEntityEffect = effect(async () => {
1201
+ this.loadEntityEffect = effect(() => {
1202
+ const entityFromInput = this.entityInput();
1203
+ if (entityFromInput) {
1204
+ this.entity.set(entityFromInput);
1205
+ this.patchForm(entityFromInput);
1206
+ return;
1207
+ }
1200
1208
  const id = this.entityId();
1201
1209
  if (id) {
1202
- try {
1203
- const entity = await this.entityCommunicationService.findOne(id);
1204
- if (entity) {
1205
- this.entity.set(entity);
1206
- this.patchForm(entity);
1207
- }
1208
- }
1209
- catch (err) {
1210
- this.toastService?.error({ title: 'Error', subtitle: 'Error loading entity' });
1211
- console.error('Error loading entity', err);
1212
- }
1210
+ this.loadEntityById(id);
1213
1211
  }
1214
1212
  else {
1215
- // if there is no id, we create a new entity
1216
- try {
1217
- const newEntity = await this.entityCommunicationService.createOrUpdate({});
1218
- const id = newEntity?._id || newEntity?.['id'];
1219
- if (id) {
1220
- // we replace the url to avoid creating a new entity when the user goes back
1221
- this.router.navigate([id], { relativeTo: this.route, replaceUrl: true });
1222
- }
1223
- }
1224
- catch (err) {
1225
- this.toastService?.error({ title: 'Error', subtitle: 'Error creating new entity' });
1226
- console.error('Error creating new entity', err);
1227
- }
1213
+ this.createNewEntity();
1228
1214
  }
1229
1215
  }, ...(ngDevMode ? [{ debugName: "loadEntityEffect", allowSignalWrites: true }] : [{ allowSignalWrites: true }]));
1230
1216
  }
@@ -1265,8 +1251,35 @@ class EntityBaseFormComponent {
1265
1251
  const dirtyValues = this.getDirtyValues(this.form);
1266
1252
  return this.entityCommunicationService.partialUpdate(this.entityId(), dirtyValues);
1267
1253
  }
1254
+ async loadEntityById(id) {
1255
+ try {
1256
+ const entity = await this.entityCommunicationService.findOne(id);
1257
+ if (entity) {
1258
+ this.entity.set(entity);
1259
+ this.patchForm(entity);
1260
+ }
1261
+ }
1262
+ catch (err) {
1263
+ this.toastService?.error({ title: 'Error', subtitle: 'Error loading entity' });
1264
+ console.error('Error loading entity', err);
1265
+ }
1266
+ }
1267
+ async createNewEntity() {
1268
+ try {
1269
+ const newEntity = await this.entityCommunicationService.createOrUpdate({});
1270
+ const id = newEntity?._id || newEntity?.['id'];
1271
+ if (id) {
1272
+ // we replace the url to avoid creating a new entity when the user goes back
1273
+ this.router.navigate([id], { relativeTo: this.route, replaceUrl: true });
1274
+ }
1275
+ }
1276
+ catch (err) {
1277
+ this.toastService?.error({ title: 'Error', subtitle: 'Error creating new entity' });
1278
+ console.error('Error creating new entity', err);
1279
+ }
1280
+ }
1268
1281
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: EntityBaseFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1269
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.1.6", type: EntityBaseFormComponent, isStandalone: true, inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
1282
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.1.6", type: EntityBaseFormComponent, isStandalone: true, inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, entityInput: { classPropertyName: "entityInput", publicName: "entity", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
1270
1283
  }
1271
1284
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: EntityBaseFormComponent, decorators: [{
1272
1285
  type: Directive
@@ -3307,6 +3320,95 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
3307
3320
  }]
3308
3321
  }] });
3309
3322
 
3323
+ class MobileService {
3324
+ constructor() {
3325
+ this.router = inject(Router);
3326
+ this.hasReponsiveView = signal(false, ...(ngDevMode ? [{ debugName: "hasReponsiveView" }] : []));
3327
+ this.mobileWidthThreshold = 768; // Adjust the threshold as needed
3328
+ this.responsibleWidthThreshold = 994;
3329
+ // Initialize signal with current window width check
3330
+ this.hasReponsiveView.set(window.innerWidth <= this.responsibleWidthThreshold);
3331
+ this.checkMobileAgent();
3332
+ this.screenWidth$ = fromEvent(window, 'resize').pipe(map$1(() => window.innerWidth), distinctUntilChanged());
3333
+ this.screenHeight$ = fromEvent(window, 'resize').pipe(map$1(() => window.innerHeight), distinctUntilChanged());
3334
+ this.isMobile$ = this.screenWidth$.pipe(map$1((width) => width <= this.responsibleWidthThreshold), // Add type assertion to 'width'
3335
+ distinctUntilChanged());
3336
+ this.isMobile$.subscribe((isResposible) => {
3337
+ console.log('isMobile', isResposible);
3338
+ // Update signal value when screen size changes
3339
+ this.hasReponsiveView.set(isResposible);
3340
+ });
3341
+ }
3342
+ isMobileRoute(currentRoute = '') {
3343
+ if (!currentRoute) {
3344
+ currentRoute = this.router.url;
3345
+ }
3346
+ const firstRouteName = currentRoute.split('/')[1];
3347
+ return firstRouteName == 'm' ? true : false;
3348
+ }
3349
+ // Add this function to the class
3350
+ getPlatform() {
3351
+ if (Capacitor.isNativePlatform()) {
3352
+ const platform = Capacitor.getPlatform();
3353
+ // Example usage in component:
3354
+ if (platform === 'ios') {
3355
+ // iOS specific code
3356
+ return 'ios';
3357
+ }
3358
+ else if (platform === 'android') {
3359
+ // Android specific code
3360
+ return 'android';
3361
+ }
3362
+ else {
3363
+ return 'web';
3364
+ }
3365
+ }
3366
+ return 'web';
3367
+ }
3368
+ isNativeMobileOrMobileRoute() {
3369
+ if (Capacitor.isNativePlatform() || this.isMobileRoute()) {
3370
+ return true;
3371
+ }
3372
+ else {
3373
+ return false;
3374
+ }
3375
+ }
3376
+ isNativeMobile() {
3377
+ return Capacitor.isNativePlatform();
3378
+ }
3379
+ getScreenWidth() {
3380
+ return this.screenWidth$;
3381
+ }
3382
+ // isMobile(): Observable<boolean> {
3383
+ // return this.isMobile$;
3384
+ // }
3385
+ installByUser() {
3386
+ console.log('Debería hacer la instalación por el usuario');
3387
+ if (this.eventInstall) {
3388
+ this.eventInstall.prompt();
3389
+ console.log('Debio mandar el promt');
3390
+ }
3391
+ }
3392
+ checkMobileAgent() {
3393
+ if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
3394
+ // true for mobile device
3395
+ this.isMobileAgent = true;
3396
+ }
3397
+ else {
3398
+ // false for not mobile device
3399
+ this.isMobileAgent = false;
3400
+ }
3401
+ }
3402
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: MobileService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3403
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: MobileService, providedIn: 'root' }); }
3404
+ }
3405
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: MobileService, decorators: [{
3406
+ type: Injectable,
3407
+ args: [{
3408
+ providedIn: 'root',
3409
+ }]
3410
+ }], ctorParameters: () => [] });
3411
+
3310
3412
  var MoodState;
3311
3413
  (function (MoodState) {
3312
3414
  MoodState["HAPPY"] = "happy";
@@ -3392,5 +3494,5 @@ const CharacterEventActions = [
3392
3494
  * Generated bundle index. Do not edit.
3393
3495
  */
3394
3496
 
3395
- export { APP_CONFIG, AppConfigService, AudioNotificationService, AudioSpeed, AudioSpeedReverse, CharacterEventActions, ChatUserSettings, ConfirmComponent, ConfirmService, DCFilterBarComponent, DCProgressToastComponent, DcAuditableViewerComponent, DcExtensionsViewerComponent, DcLearnableFormComponent, DcLearnableViewerComponent, DcManageableFormComponent, DcManageableViewerComponent, DcReactionsViewerComponent, EModelQuality, EmptyStateComponent, EntityBaseFormComponent, EntityBaseListComponent, EntityCommunicationService, FlagPipe, FormUtilsService, GetPathPipe, HTTP_CORE_CONFIG, HttpCoreService, IAIModel, LANGUAGES, LangDescTranslation, LoadingBarComponent, LoadingBarService, ModelQualityOptions, MoodState, MoodStateOptions, OptionValue, PaginationBase, PromptService, QuickTableComponent, SUPPORTED_LANGUAGES, TOAST_ALERTS_TOKEN, ToastAlertsAbstractService, UiStateService, availibleFilters, extractJsonFromString, formatCamelCaseString, getLangDesc, getSupportedLanguageOptions, provideToastAlert, sortOptions, sortTypes };
3497
+ export { APP_CONFIG, AppConfigService, AudioNotificationService, AudioSpeed, AudioSpeedReverse, CharacterEventActions, ChatUserSettings, ConfirmComponent, ConfirmService, DCFilterBarComponent, DCProgressToastComponent, DcAuditableViewerComponent, DcExtensionsViewerComponent, DcLearnableFormComponent, DcLearnableViewerComponent, DcManageableFormComponent, DcManageableViewerComponent, DcReactionsViewerComponent, EModelQuality, EmptyStateComponent, EntityBaseFormComponent, EntityBaseListComponent, EntityCommunicationService, FlagPipe, FormUtilsService, GetPathPipe, HTTP_CORE_CONFIG, HttpCoreService, IAIModel, LANGUAGES, LangDescTranslation, LoadingBarComponent, LoadingBarService, MobileService, ModelQualityOptions, MoodState, MoodStateOptions, OptionValue, PaginationBase, PromptService, QuickTableComponent, SUPPORTED_LANGUAGES, TOAST_ALERTS_TOKEN, ToastAlertsAbstractService, UiStateService, availibleFilters, extractJsonFromString, formatCamelCaseString, getLangDesc, getSupportedLanguageOptions, provideToastAlert, sortOptions, sortTypes };
3396
3498
  //# sourceMappingURL=dataclouder-ngx-core.mjs.map