valtech-components 2.0.908 → 2.0.911
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.
- package/esm2022/lib/components/organisms/attachment-uploader/attachment-uploader.component.mjs +19 -2
- package/esm2022/lib/components/organisms/attachment-uploader/types.mjs +1 -1
- package/esm2022/lib/components/organisms/avatar-upload/avatar-upload.component.mjs +96 -5
- package/esm2022/lib/components/organisms/avatar-upload/types.mjs +2 -1
- package/esm2022/lib/version.mjs +2 -2
- package/fesm2022/valtech-components.mjs +114 -5
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/organisms/attachment-uploader/attachment-uploader.component.d.ts +1 -0
- package/lib/components/organisms/attachment-uploader/types.d.ts +2 -0
- package/lib/components/organisms/avatar-upload/avatar-upload.component.d.ts +6 -0
- package/lib/components/organisms/avatar-upload/types.d.ts +3 -0
- package/lib/version.d.ts +1 -1
- package/package.json +4 -3
|
@@ -45,6 +45,7 @@ import { provideHttpClient, withInterceptors, HttpClient, HttpErrorResponse } fr
|
|
|
45
45
|
import { isSupported, getMessaging as getMessaging$1 } from 'firebase/messaging';
|
|
46
46
|
import { getApps, getApp, initializeApp as initializeApp$1 } from 'firebase/app';
|
|
47
47
|
import { ImageCropperComponent } from 'ngx-image-cropper';
|
|
48
|
+
import Compressor from 'compressorjs';
|
|
48
49
|
import { Capacitor } from '@capacitor/core';
|
|
49
50
|
import 'prismjs/components/prism-scss';
|
|
50
51
|
import 'prismjs/components/prism-json';
|
|
@@ -53,7 +54,7 @@ import 'prismjs/components/prism-json';
|
|
|
53
54
|
* Current version of valtech-components.
|
|
54
55
|
* This is automatically updated during the publish process.
|
|
55
56
|
*/
|
|
56
|
-
const VERSION = '2.0.
|
|
57
|
+
const VERSION = '2.0.911';
|
|
57
58
|
|
|
58
59
|
/**
|
|
59
60
|
* Servicio para gestionar presets de componentes.
|
|
@@ -28593,9 +28594,25 @@ class AttachmentUploaderComponent {
|
|
|
28593
28594
|
this.uploadFile(id, file);
|
|
28594
28595
|
}
|
|
28595
28596
|
}
|
|
28597
|
+
compressImage(file) {
|
|
28598
|
+
return new Promise((resolve, reject) => {
|
|
28599
|
+
new Compressor(file, {
|
|
28600
|
+
quality: 0.8,
|
|
28601
|
+
maxWidth: 1920,
|
|
28602
|
+
maxHeight: 1920,
|
|
28603
|
+
convertSize: 2 * 1024 * 1024, // PNG > 2 MB → JPEG
|
|
28604
|
+
success(result) {
|
|
28605
|
+
resolve(new File([result], file.name, { type: result.type }));
|
|
28606
|
+
},
|
|
28607
|
+
error: reject,
|
|
28608
|
+
});
|
|
28609
|
+
});
|
|
28610
|
+
}
|
|
28596
28611
|
async uploadFile(id, file) {
|
|
28597
28612
|
try {
|
|
28598
|
-
const
|
|
28613
|
+
const shouldCompress = this.props().compressImages !== false && file.type.startsWith('image/');
|
|
28614
|
+
const fileToUpload = shouldCompress ? await this.compressImage(file) : file;
|
|
28615
|
+
const url = await this.feedbackService.uploadAttachment(fileToUpload);
|
|
28599
28616
|
this.attachments.update(list => list.map(a => (a.id === id ? { ...a, status: 'ready', url } : a)));
|
|
28600
28617
|
}
|
|
28601
28618
|
catch {
|
|
@@ -38695,6 +38712,7 @@ const AVATAR_UPLOAD_DEFAULTS = {
|
|
|
38695
38712
|
maxWidth: 800,
|
|
38696
38713
|
thumbnailSize: 150,
|
|
38697
38714
|
backgroundColor: '#6366f1', // Indigo
|
|
38715
|
+
showViewButton: false,
|
|
38698
38716
|
};
|
|
38699
38717
|
|
|
38700
38718
|
addIcons({ cameraOutline });
|
|
@@ -38738,6 +38756,7 @@ class AvatarUploadComponent {
|
|
|
38738
38756
|
// Internal state
|
|
38739
38757
|
this.loading = signal(false);
|
|
38740
38758
|
this.showCropModal = signal(false);
|
|
38759
|
+
this.showViewModal = signal(false);
|
|
38741
38760
|
this.selectedFile = signal(null);
|
|
38742
38761
|
this.previewUrl = signal(null);
|
|
38743
38762
|
this.imageLoadError = signal(false);
|
|
@@ -38757,6 +38776,16 @@ class AvatarUploadComponent {
|
|
|
38757
38776
|
this.i18n.lang();
|
|
38758
38777
|
return this.i18n.t('changePhoto', this.config().i18nNamespace) || 'Cambiar foto';
|
|
38759
38778
|
});
|
|
38779
|
+
/** Label for view photo button */
|
|
38780
|
+
this.viewPhotoLabel = computed(() => {
|
|
38781
|
+
this.i18n.lang();
|
|
38782
|
+
return this.i18n.t('viewPhoto', this.config().i18nNamespace) || 'Ver foto';
|
|
38783
|
+
});
|
|
38784
|
+
/** Label for close button inside photo viewer */
|
|
38785
|
+
this.closePhotoLabel = computed(() => {
|
|
38786
|
+
this.i18n.lang();
|
|
38787
|
+
return this.i18n.t('closePhoto', this.config().i18nNamespace) || 'Cerrar';
|
|
38788
|
+
});
|
|
38760
38789
|
}
|
|
38761
38790
|
/** Open file picker dialog */
|
|
38762
38791
|
openFilePicker() {
|
|
@@ -38926,6 +38955,13 @@ class AvatarUploadComponent {
|
|
|
38926
38955
|
hidden
|
|
38927
38956
|
/>
|
|
38928
38957
|
|
|
38958
|
+
<!-- View Photo Button -->
|
|
38959
|
+
@if (config().showViewButton && displayUrl()) {
|
|
38960
|
+
<button class="view-photo-btn" type="button" (click)="showViewModal.set(true)">
|
|
38961
|
+
{{ viewPhotoLabel() }}
|
|
38962
|
+
</button>
|
|
38963
|
+
}
|
|
38964
|
+
|
|
38929
38965
|
<!-- Crop Modal -->
|
|
38930
38966
|
<ion-modal
|
|
38931
38967
|
[isOpen]="showCropModal()"
|
|
@@ -38947,12 +38983,51 @@ class AvatarUploadComponent {
|
|
|
38947
38983
|
}
|
|
38948
38984
|
</ng-template>
|
|
38949
38985
|
</ion-modal>
|
|
38986
|
+
|
|
38987
|
+
<!-- Photo Viewer Modal -->
|
|
38988
|
+
<ion-modal
|
|
38989
|
+
[isOpen]="showViewModal()"
|
|
38990
|
+
(didDismiss)="showViewModal.set(false)"
|
|
38991
|
+
[breakpoints]="[0, 0.55]"
|
|
38992
|
+
[initialBreakpoint]="0.55"
|
|
38993
|
+
[handle]="true"
|
|
38994
|
+
>
|
|
38995
|
+
<ng-template>
|
|
38996
|
+
<ion-header [translucent]="true">
|
|
38997
|
+
<ion-toolbar>
|
|
38998
|
+
<ion-title>{{ viewPhotoLabel() }}</ion-title>
|
|
38999
|
+
<ion-buttons slot="end">
|
|
39000
|
+
<ion-button fill="clear" color="dark" (click)="showViewModal.set(false)">
|
|
39001
|
+
{{ closePhotoLabel() }}
|
|
39002
|
+
</ion-button>
|
|
39003
|
+
</ion-buttons>
|
|
39004
|
+
</ion-toolbar>
|
|
39005
|
+
</ion-header>
|
|
39006
|
+
<ion-content>
|
|
39007
|
+
<div class="photo-viewer">
|
|
39008
|
+
<img class="photo-viewer__img" [src]="displayUrl()" alt="Photo" />
|
|
39009
|
+
</div>
|
|
39010
|
+
</ion-content>
|
|
39011
|
+
</ng-template>
|
|
39012
|
+
</ion-modal>
|
|
38950
39013
|
</div>
|
|
38951
|
-
`, isInline: true, styles: [".avatar-upload{--avatar-size: 100px;--edit-button-size: 32px;--edit-button-offset: 4px;display:inline-block}.avatar-container{position:relative;width:var(--avatar-size);height:var(--avatar-size);border-radius:50%;overflow:visible}.avatar-image{width:100%;height:100%;border-radius:50%;object-fit:cover;background-color:var(--ion-color-light)}.avatar-initials{width:100%;height:100%;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:calc(var(--avatar-size) * .4);font-weight:600;color:#fff;text-transform:uppercase;-webkit-user-select:none;user-select:none}.edit-button{position:absolute;bottom:var(--edit-button-offset);right:var(--edit-button-offset);width:var(--edit-button-size);height:var(--edit-button-size);border-radius:50%;border:2px solid white;background:var(--ion-color-primary);color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:transform .2s ease,background-color .2s ease;box-shadow:0 2px 8px #00000026}.edit-button ion-icon{font-size:calc(var(--edit-button-size) * .5)}.edit-button:hover{transform:scale(1.1);background:var(--ion-color-primary-shade)}.edit-button:active{transform:scale(.95)}.edit-button:focus-visible{outline:2px solid var(--ion-color-primary);outline-offset:2px}.loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;border-radius:50%;background:#00000080;display:flex;align-items:center;justify-content:center}.loading-overlay ion-spinner{--color: white;width:calc(var(--avatar-size) * .4);height:calc(var(--avatar-size) * .4)}.avatar-upload--loading .edit-button{display:none}.avatar-upload--loading .avatar-image,.avatar-upload--loading .avatar-initials{filter:brightness(.7)}@container (max-width: 60px){.edit-button{--edit-button-size: 24px;--edit-button-offset: 0}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { kind: "component", type: IonSpinner, selector: "ion-spinner", inputs: ["color", "duration", "name", "paused"] }, { kind: "component", type: IonModal, selector: "ion-modal" }, { kind: "component", type: ImageCropComponent, selector: "val-image-crop", inputs: ["image", "aspectRatio", "roundCropper", "resizeToWidth", "i18nNamespace"], outputs: ["cropComplete", "cancel", "loadFailed"] }] }); }
|
|
39014
|
+
`, isInline: true, styles: [".avatar-upload{--avatar-size: 100px;--edit-button-size: 32px;--edit-button-offset: 4px;display:inline-block}.avatar-container{position:relative;width:var(--avatar-size);height:var(--avatar-size);border-radius:50%;overflow:visible}.avatar-image{width:100%;height:100%;border-radius:50%;object-fit:cover;background-color:var(--ion-color-light)}.avatar-initials{width:100%;height:100%;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:calc(var(--avatar-size) * .4);font-weight:600;color:#fff;text-transform:uppercase;-webkit-user-select:none;user-select:none}.edit-button{position:absolute;bottom:var(--edit-button-offset);right:var(--edit-button-offset);width:var(--edit-button-size);height:var(--edit-button-size);border-radius:50%;border:2px solid white;background:var(--ion-color-primary);color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:transform .2s ease,background-color .2s ease;box-shadow:0 2px 8px #00000026}.edit-button ion-icon{font-size:calc(var(--edit-button-size) * .5)}.edit-button:hover{transform:scale(1.1);background:var(--ion-color-primary-shade)}.edit-button:active{transform:scale(.95)}.edit-button:focus-visible{outline:2px solid var(--ion-color-primary);outline-offset:2px}.loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;border-radius:50%;background:#00000080;display:flex;align-items:center;justify-content:center}.loading-overlay ion-spinner{--color: white;width:calc(var(--avatar-size) * .4);height:calc(var(--avatar-size) * .4)}.avatar-upload--loading .edit-button{display:none}.avatar-upload--loading .avatar-image,.avatar-upload--loading .avatar-initials{filter:brightness(.7)}.view-photo-btn{display:block;background:none;border:none;padding:0;margin-top:6px;font-size:.8rem;color:var(--ion-color-primary);cursor:pointer;font-family:inherit;text-decoration:underline;text-underline-offset:2px;text-align:center;width:var(--avatar-size)}.view-photo-btn:active{opacity:.7}.photo-viewer{display:flex;align-items:center;justify-content:center;padding:20px 24px 28px}.photo-viewer__img{width:min(72vw,280px);height:min(72vw,280px);border-radius:20px;object-fit:cover;box-shadow:0 8px 32px #0000002e}@container (max-width: 60px){.edit-button{--edit-button-size: 24px;--edit-button-offset: 0}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { kind: "component", type: IonSpinner, selector: "ion-spinner", inputs: ["color", "duration", "name", "paused"] }, { kind: "component", type: IonModal, selector: "ion-modal" }, { kind: "component", type: IonContent, selector: "ion-content", inputs: ["color", "fixedSlotPlacement", "forceOverscroll", "fullscreen", "scrollEvents", "scrollX", "scrollY"] }, { kind: "component", type: IonHeader, selector: "ion-header", inputs: ["collapse", "mode", "translucent"] }, { kind: "component", type: IonToolbar, selector: "ion-toolbar", inputs: ["color", "mode"] }, { kind: "component", type: IonTitle, selector: "ion-title", inputs: ["color", "size"] }, { kind: "component", type: IonButtons, selector: "ion-buttons", inputs: ["collapse"] }, { kind: "component", type: IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"] }, { kind: "component", type: ImageCropComponent, selector: "val-image-crop", inputs: ["image", "aspectRatio", "roundCropper", "resizeToWidth", "i18nNamespace"], outputs: ["cropComplete", "cancel", "loadFailed"] }] }); }
|
|
38952
39015
|
}
|
|
38953
39016
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AvatarUploadComponent, decorators: [{
|
|
38954
39017
|
type: Component,
|
|
38955
|
-
args: [{ selector: 'val-avatar-upload', standalone: true, imports: [
|
|
39018
|
+
args: [{ selector: 'val-avatar-upload', standalone: true, imports: [
|
|
39019
|
+
CommonModule,
|
|
39020
|
+
IonIcon,
|
|
39021
|
+
IonSpinner,
|
|
39022
|
+
IonModal,
|
|
39023
|
+
IonContent,
|
|
39024
|
+
IonHeader,
|
|
39025
|
+
IonToolbar,
|
|
39026
|
+
IonTitle,
|
|
39027
|
+
IonButtons,
|
|
39028
|
+
IonButton,
|
|
39029
|
+
ImageCropComponent,
|
|
39030
|
+
], template: `
|
|
38956
39031
|
<div class="avatar-upload" [style.--avatar-size.px]="config().size" [class.avatar-upload--loading]="loading()">
|
|
38957
39032
|
<div class="avatar-container">
|
|
38958
39033
|
<!-- Avatar Image or Initials -->
|
|
@@ -38989,6 +39064,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
38989
39064
|
hidden
|
|
38990
39065
|
/>
|
|
38991
39066
|
|
|
39067
|
+
<!-- View Photo Button -->
|
|
39068
|
+
@if (config().showViewButton && displayUrl()) {
|
|
39069
|
+
<button class="view-photo-btn" type="button" (click)="showViewModal.set(true)">
|
|
39070
|
+
{{ viewPhotoLabel() }}
|
|
39071
|
+
</button>
|
|
39072
|
+
}
|
|
39073
|
+
|
|
38992
39074
|
<!-- Crop Modal -->
|
|
38993
39075
|
<ion-modal
|
|
38994
39076
|
[isOpen]="showCropModal()"
|
|
@@ -39010,8 +39092,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
39010
39092
|
}
|
|
39011
39093
|
</ng-template>
|
|
39012
39094
|
</ion-modal>
|
|
39095
|
+
|
|
39096
|
+
<!-- Photo Viewer Modal -->
|
|
39097
|
+
<ion-modal
|
|
39098
|
+
[isOpen]="showViewModal()"
|
|
39099
|
+
(didDismiss)="showViewModal.set(false)"
|
|
39100
|
+
[breakpoints]="[0, 0.55]"
|
|
39101
|
+
[initialBreakpoint]="0.55"
|
|
39102
|
+
[handle]="true"
|
|
39103
|
+
>
|
|
39104
|
+
<ng-template>
|
|
39105
|
+
<ion-header [translucent]="true">
|
|
39106
|
+
<ion-toolbar>
|
|
39107
|
+
<ion-title>{{ viewPhotoLabel() }}</ion-title>
|
|
39108
|
+
<ion-buttons slot="end">
|
|
39109
|
+
<ion-button fill="clear" color="dark" (click)="showViewModal.set(false)">
|
|
39110
|
+
{{ closePhotoLabel() }}
|
|
39111
|
+
</ion-button>
|
|
39112
|
+
</ion-buttons>
|
|
39113
|
+
</ion-toolbar>
|
|
39114
|
+
</ion-header>
|
|
39115
|
+
<ion-content>
|
|
39116
|
+
<div class="photo-viewer">
|
|
39117
|
+
<img class="photo-viewer__img" [src]="displayUrl()" alt="Photo" />
|
|
39118
|
+
</div>
|
|
39119
|
+
</ion-content>
|
|
39120
|
+
</ng-template>
|
|
39121
|
+
</ion-modal>
|
|
39013
39122
|
</div>
|
|
39014
|
-
`, styles: [".avatar-upload{--avatar-size: 100px;--edit-button-size: 32px;--edit-button-offset: 4px;display:inline-block}.avatar-container{position:relative;width:var(--avatar-size);height:var(--avatar-size);border-radius:50%;overflow:visible}.avatar-image{width:100%;height:100%;border-radius:50%;object-fit:cover;background-color:var(--ion-color-light)}.avatar-initials{width:100%;height:100%;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:calc(var(--avatar-size) * .4);font-weight:600;color:#fff;text-transform:uppercase;-webkit-user-select:none;user-select:none}.edit-button{position:absolute;bottom:var(--edit-button-offset);right:var(--edit-button-offset);width:var(--edit-button-size);height:var(--edit-button-size);border-radius:50%;border:2px solid white;background:var(--ion-color-primary);color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:transform .2s ease,background-color .2s ease;box-shadow:0 2px 8px #00000026}.edit-button ion-icon{font-size:calc(var(--edit-button-size) * .5)}.edit-button:hover{transform:scale(1.1);background:var(--ion-color-primary-shade)}.edit-button:active{transform:scale(.95)}.edit-button:focus-visible{outline:2px solid var(--ion-color-primary);outline-offset:2px}.loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;border-radius:50%;background:#00000080;display:flex;align-items:center;justify-content:center}.loading-overlay ion-spinner{--color: white;width:calc(var(--avatar-size) * .4);height:calc(var(--avatar-size) * .4)}.avatar-upload--loading .edit-button{display:none}.avatar-upload--loading .avatar-image,.avatar-upload--loading .avatar-initials{filter:brightness(.7)}@container (max-width: 60px){.edit-button{--edit-button-size: 24px;--edit-button-offset: 0}}\n"] }]
|
|
39123
|
+
`, styles: [".avatar-upload{--avatar-size: 100px;--edit-button-size: 32px;--edit-button-offset: 4px;display:inline-block}.avatar-container{position:relative;width:var(--avatar-size);height:var(--avatar-size);border-radius:50%;overflow:visible}.avatar-image{width:100%;height:100%;border-radius:50%;object-fit:cover;background-color:var(--ion-color-light)}.avatar-initials{width:100%;height:100%;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:calc(var(--avatar-size) * .4);font-weight:600;color:#fff;text-transform:uppercase;-webkit-user-select:none;user-select:none}.edit-button{position:absolute;bottom:var(--edit-button-offset);right:var(--edit-button-offset);width:var(--edit-button-size);height:var(--edit-button-size);border-radius:50%;border:2px solid white;background:var(--ion-color-primary);color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:transform .2s ease,background-color .2s ease;box-shadow:0 2px 8px #00000026}.edit-button ion-icon{font-size:calc(var(--edit-button-size) * .5)}.edit-button:hover{transform:scale(1.1);background:var(--ion-color-primary-shade)}.edit-button:active{transform:scale(.95)}.edit-button:focus-visible{outline:2px solid var(--ion-color-primary);outline-offset:2px}.loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;border-radius:50%;background:#00000080;display:flex;align-items:center;justify-content:center}.loading-overlay ion-spinner{--color: white;width:calc(var(--avatar-size) * .4);height:calc(var(--avatar-size) * .4)}.avatar-upload--loading .edit-button{display:none}.avatar-upload--loading .avatar-image,.avatar-upload--loading .avatar-initials{filter:brightness(.7)}.view-photo-btn{display:block;background:none;border:none;padding:0;margin-top:6px;font-size:.8rem;color:var(--ion-color-primary);cursor:pointer;font-family:inherit;text-decoration:underline;text-underline-offset:2px;text-align:center;width:var(--avatar-size)}.view-photo-btn:active{opacity:.7}.photo-viewer{display:flex;align-items:center;justify-content:center;padding:20px 24px 28px}.photo-viewer__img{width:min(72vw,280px);height:min(72vw,280px);border-radius:20px;object-fit:cover;box-shadow:0 8px 32px #0000002e}@container (max-width: 60px){.edit-button{--edit-button-size: 24px;--edit-button-offset: 0}}\n"] }]
|
|
39015
39124
|
}], propDecorators: { fileInput: [{
|
|
39016
39125
|
type: ViewChild,
|
|
39017
39126
|
args: ['fileInput']
|