@acorex/components 21.0.3-next.38 → 21.0.3-next.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{conversation2 → conversation}/README.md +23 -23
- package/fesm2022/acorex-components-button.mjs +4 -4
- package/fesm2022/acorex-components-button.mjs.map +1 -1
- package/fesm2022/acorex-components-conversation-acorex-components-conversation-YhVa42TC.mjs +13711 -0
- package/fesm2022/acorex-components-conversation-acorex-components-conversation-YhVa42TC.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-audio-attachment.component-CLvS3W8F.mjs +119 -0
- package/fesm2022/acorex-components-conversation-audio-attachment.component-CLvS3W8F.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-audio-composer.payload-BHQJNyXz.mjs +59 -0
- package/fesm2022/acorex-components-conversation-audio-composer.payload-BHQJNyXz.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-audio-picker.component-BD_fN2Ip.mjs +432 -0
- package/fesm2022/acorex-components-conversation-audio-picker.component-BD_fN2Ip.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-audio-renderer.component-CcxVVprx.mjs +177 -0
- package/fesm2022/acorex-components-conversation-audio-renderer.component-CcxVVprx.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-audio.payload-Bag4aTut.mjs +54 -0
- package/fesm2022/acorex-components-conversation-audio.payload-Bag4aTut.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-composer-action-choice-dialog.component-C28hl7iD.mjs +101 -0
- package/fesm2022/acorex-components-conversation-composer-action-choice-dialog.component-C28hl7iD.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-conversation-audio.file-type-CfGSVnMA.mjs +100 -0
- package/fesm2022/acorex-components-conversation-conversation-audio.file-type-CfGSVnMA.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-conversation-file.file-type-DB-2xhaC.mjs +121 -0
- package/fesm2022/acorex-components-conversation-conversation-file.file-type-DB-2xhaC.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-conversation-image.file-type-C02OzZZB.mjs +84 -0
- package/fesm2022/acorex-components-conversation-conversation-image.file-type-C02OzZZB.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-conversation-info-media-view.component-Mhk7JE6K.mjs +238 -0
- package/fesm2022/acorex-components-conversation-conversation-info-media-view.component-Mhk7JE6K.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-conversation-info-panel.component-CNaM5ajR.mjs +1080 -0
- package/fesm2022/acorex-components-conversation-conversation-info-panel.component-CNaM5ajR.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-conversation-video.file-type-Pescv4Vu.mjs +102 -0
- package/fesm2022/acorex-components-conversation-conversation-video.file-type-Pescv4Vu.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-conversation-voice.file-type-DDd47o4r.mjs +90 -0
- package/fesm2022/acorex-components-conversation-conversation-voice.file-type-DDd47o4r.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-emoji-categories-C7Gm95V0.mjs +1840 -0
- package/fesm2022/acorex-components-conversation-emoji-categories-C7Gm95V0.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-fallback-renderer.component-CYh_6O6j.mjs +44 -0
- package/fesm2022/acorex-components-conversation-fallback-renderer.component-CYh_6O6j.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-file-composer.payload-Dy7aG-EH.mjs +64 -0
- package/fesm2022/acorex-components-conversation-file-composer.payload-Dy7aG-EH.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-file-picker.component-DCVgl33l.mjs +468 -0
- package/fesm2022/acorex-components-conversation-file-picker.component-DCVgl33l.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-file-renderer.component-DgCi06Mg.mjs +125 -0
- package/fesm2022/acorex-components-conversation-file-renderer.component-DgCi06Mg.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-file.payload-DyFxTQYn.mjs +50 -0
- package/fesm2022/acorex-components-conversation-file.payload-DyFxTQYn.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-format-media-DUD4vA6F.mjs +21 -0
- package/fesm2022/acorex-components-conversation-format-media-DUD4vA6F.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-image-attachment.component-CLMGxXPl.mjs +77 -0
- package/fesm2022/acorex-components-conversation-image-attachment.component-CLMGxXPl.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-image-picker.component-CS343UDa.mjs +407 -0
- package/fesm2022/acorex-components-conversation-image-picker.component-CS343UDa.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-image-renderer.component-Cy0TA6cL.mjs +83 -0
- package/fesm2022/acorex-components-conversation-image-renderer.component-Cy0TA6cL.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-index-3V2b14I0.mjs +184 -0
- package/fesm2022/acorex-components-conversation-index-3V2b14I0.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-index-MCvfr9Zd.mjs +266 -0
- package/fesm2022/acorex-components-conversation-index-MCvfr9Zd.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-location-picker.component-DcNQzuoU.mjs +149 -0
- package/fesm2022/acorex-components-conversation-location-picker.component-DcNQzuoU.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-location-renderer.component-Cw2PB0LM.mjs +118 -0
- package/fesm2022/acorex-components-conversation-location-renderer.component-Cw2PB0LM.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-media-formatters-DV3wEEno.mjs +17 -0
- package/fesm2022/acorex-components-conversation-media-formatters-DV3wEEno.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-media-playback-info-bar-banner.component-DbWUl6M2.mjs +140 -0
- package/fesm2022/acorex-components-conversation-media-playback-info-bar-banner.component-DbWUl6M2.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-message-renderer-copy-host.component-oXTr_Lfq.mjs +33 -0
- package/fesm2022/acorex-components-conversation-message-renderer-copy-host.component-oXTr_Lfq.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-message-renderer-state.component-Dp-JdHWr.mjs +172 -0
- package/fesm2022/acorex-components-conversation-message-renderer-state.component-Dp-JdHWr.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-open-composer-picker-for-files-Du8Lj9Sp.mjs +224 -0
- package/fesm2022/acorex-components-conversation-open-composer-picker-for-files-Du8Lj9Sp.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-pagination-demo-data-oIT_YJmN.mjs +81 -0
- package/fesm2022/acorex-components-conversation-pagination-demo-data-oIT_YJmN.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-picker-header.component-BneIFjXq.mjs +91 -0
- package/fesm2022/acorex-components-conversation-picker-header.component-BneIFjXq.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-picker-toolbar.component-BthRvEeE.mjs +537 -0
- package/fesm2022/acorex-components-conversation-picker-toolbar.component-BthRvEeE.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-picker-upload-C-PlKPaU.mjs +163 -0
- package/fesm2022/acorex-components-conversation-picker-upload-C-PlKPaU.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-playback-banner-sync-D8FFKde6.mjs +68 -0
- package/fesm2022/acorex-components-conversation-playback-banner-sync-D8FFKde6.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-renderer-shared.styles-Digah3Zn.mjs +95 -0
- package/fesm2022/acorex-components-conversation-renderer-shared.styles-Digah3Zn.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-search.component-B-nc6xiA.mjs +187 -0
- package/fesm2022/acorex-components-conversation-search.component-B-nc6xiA.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-send-message-media-BRklgfV7.mjs +170 -0
- package/fesm2022/acorex-components-conversation-send-message-media-BRklgfV7.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-shared-storage.seed-J9PA4l3c.mjs +750 -0
- package/fesm2022/acorex-components-conversation-shared-storage.seed-J9PA4l3c.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-sticker-renderer.component-BmBwy7Ig.mjs +103 -0
- package/fesm2022/acorex-components-conversation-sticker-renderer.component-BmBwy7Ig.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-system-renderer.component-uie3tm5N.mjs +55 -0
- package/fesm2022/acorex-components-conversation-system-renderer.component-uie3tm5N.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-text-renderer.component-DNAquHYK.mjs +109 -0
- package/fesm2022/acorex-components-conversation-text-renderer.component-DNAquHYK.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-video-attachment.component-CGaUhnSb.mjs +105 -0
- package/fesm2022/acorex-components-conversation-video-attachment.component-CGaUhnSb.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-video-composer.payload-DMqRkafr.mjs +62 -0
- package/fesm2022/acorex-components-conversation-video-composer.payload-DMqRkafr.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-video-picker.component-DPwSBnoH.mjs +446 -0
- package/fesm2022/acorex-components-conversation-video-picker.component-DPwSBnoH.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-video-renderer.component-DKa9mUe2.mjs +181 -0
- package/fesm2022/acorex-components-conversation-video-renderer.component-DKa9mUe2.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-video.payload-C8QaqxuX.mjs +54 -0
- package/fesm2022/acorex-components-conversation-video.payload-C8QaqxuX.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-voice-composer.payload-DLVow7ex.mjs +17 -0
- package/fesm2022/acorex-components-conversation-voice-composer.payload-DLVow7ex.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-voice-recorder.component-D_rdANZN.mjs +344 -0
- package/fesm2022/acorex-components-conversation-voice-recorder.component-D_rdANZN.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation-voice-renderer.component-BY5FJcT8.mjs +270 -0
- package/fesm2022/acorex-components-conversation-voice-renderer.component-BY5FJcT8.mjs.map +1 -0
- package/fesm2022/acorex-components-conversation.mjs +2 -0
- package/fesm2022/acorex-components-conversation.mjs.map +1 -0
- package/fesm2022/acorex-components-kbd.mjs +2 -2
- package/fesm2022/acorex-components-kbd.mjs.map +1 -1
- package/fesm2022/acorex-components-scheduler-picker.mjs +22 -14
- package/fesm2022/acorex-components-scheduler-picker.mjs.map +1 -1
- package/fesm2022/acorex-components-tree-view.mjs +2 -2
- package/fesm2022/acorex-components-tree-view.mjs.map +1 -1
- package/package.json +6 -6
- package/types/{acorex-components-conversation2.d.ts → acorex-components-conversation.d.ts} +1127 -1928
- package/types/acorex-components-scheduler-picker.d.ts +2 -0
- package/fesm2022/acorex-components-conversation2.mjs +0 -22347
- package/fesm2022/acorex-components-conversation2.mjs.map +0 -1
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { AXUploaderService } from '@acorex/cdk/uploader';
|
|
2
|
+
import * as i1 from '@acorex/components/progress-bar';
|
|
3
|
+
import { AXProgressBarModule } from '@acorex/components/progress-bar';
|
|
4
|
+
import { AXToastService } from '@acorex/components/toast';
|
|
5
|
+
import { AXFileService, AXFileTypeRegistryService, runFileTypeUtilityForFile } from '@acorex/core/file';
|
|
6
|
+
import { AXTranslationService, AXTranslationModule } from '@acorex/core/translation';
|
|
7
|
+
import { CommonModule } from '@angular/common';
|
|
8
|
+
import * as i0 from '@angular/core';
|
|
9
|
+
import { input, inject, PLATFORM_ID, signal, computed, Component } from '@angular/core';
|
|
10
|
+
import { s as resolvePersistableMediaUrl, c as resolvePersistedThumbnailUrl, o as AXConversationComposerService, t as AX_CONVERSATION_IMAGE_CATALOG } from './acorex-components-conversation-acorex-components-conversation-YhVa42TC.mjs';
|
|
11
|
+
import { A as AXConversationPickerHeaderComponent, a as AXConversationPickerFooterComponent } from './acorex-components-conversation-picker-header.component-BneIFjXq.mjs';
|
|
12
|
+
import { A as AXConversationPickerEmptyComponent, a as AXConversationPickerToolbarComponent, b as AXConversationPickerCaptionComponent, c as AXConversationPickerShellComponent } from './acorex-components-conversation-picker-toolbar.component-BthRvEeE.mjs';
|
|
13
|
+
import { s as seedPickerInitialFiles, l as limitFilesToCapacity, a as notifyMaxFilesCapacityExceeded, n as notifyPickerValidationErrors, u as uploadPickerFile, i as isUploadAborted, c as cleanupPickerUploads, p as pickerItemToUploadResult, d as dismissComposerPickerHost, g as getPickerCancelUploadLabel } from './acorex-components-conversation-picker-upload-C-PlKPaU.mjs';
|
|
14
|
+
import { AX_CONVERSATION_IMAGE_PRESENTATION, createConversationImageFileType } from './acorex-components-conversation-conversation-image.file-type-C02OzZZB.mjs';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Image Picker Component
|
|
18
|
+
* Full-width image selection and preview interface for the composer
|
|
19
|
+
*/
|
|
20
|
+
function imageItemFromUpload(file, result) {
|
|
21
|
+
const url = resolvePersistableMediaUrl(result.url);
|
|
22
|
+
const item = {
|
|
23
|
+
mediaId: result.mediaId,
|
|
24
|
+
mimeType: result.mimeType,
|
|
25
|
+
size: result.size,
|
|
26
|
+
thumbnailUrl: resolvePersistedThumbnailUrl(result.thumbnailUrl, url),
|
|
27
|
+
width: 0,
|
|
28
|
+
height: 0,
|
|
29
|
+
metadata: result.metadata,
|
|
30
|
+
};
|
|
31
|
+
if (url) {
|
|
32
|
+
item.url = url;
|
|
33
|
+
}
|
|
34
|
+
return item;
|
|
35
|
+
}
|
|
36
|
+
class AXConversationImagePickerComponent {
|
|
37
|
+
get composerService() {
|
|
38
|
+
const svc = this.service() ?? this.composerServiceFromInjector;
|
|
39
|
+
if (!svc) {
|
|
40
|
+
throw new Error('AXConversationComposerService is required for the image picker');
|
|
41
|
+
}
|
|
42
|
+
return svc;
|
|
43
|
+
}
|
|
44
|
+
constructor() {
|
|
45
|
+
this.uploadsDismissed = false;
|
|
46
|
+
/** Uploaded blobs are referenced by the sent message — do not delete on dismiss. */
|
|
47
|
+
this.retainUploadedOnDismiss = false;
|
|
48
|
+
this.service = input(...(ngDevMode ? [undefined, { debugName: "service" }] : /* istanbul ignore next */ []));
|
|
49
|
+
this.composerServiceFromInjector = inject(AXConversationComposerService, { optional: true });
|
|
50
|
+
this.uploader = inject(AXUploaderService);
|
|
51
|
+
this.fileService = inject(AXFileService);
|
|
52
|
+
this.fileTypeRegistry = inject(AXFileTypeRegistryService);
|
|
53
|
+
this.platformId = inject(PLATFORM_ID);
|
|
54
|
+
this.toast = inject(AXToastService);
|
|
55
|
+
this.translation = inject(AXTranslationService);
|
|
56
|
+
this.catalogFileType = AX_CONVERSATION_IMAGE_CATALOG;
|
|
57
|
+
this.conversation = input.required(...(ngDevMode ? [{ debugName: "conversation" }] : /* istanbul ignore next */ []));
|
|
58
|
+
this.maxFiles = input(10, ...(ngDevMode ? [{ debugName: "maxFiles" }] : /* istanbul ignore next */ []));
|
|
59
|
+
this.initialFiles = input([], ...(ngDevMode ? [{ debugName: "initialFiles" }] : /* istanbul ignore next */ []));
|
|
60
|
+
this.__popup__ = input(...(ngDevMode ? [undefined, { debugName: "__popup__" }] : /* istanbul ignore next */ []));
|
|
61
|
+
this.images = signal([], ...(ngDevMode ? [{ debugName: "images" }] : /* istanbul ignore next */ []));
|
|
62
|
+
this.isDragging = signal(false, ...(ngDevMode ? [{ debugName: "isDragging" }] : /* istanbul ignore next */ []));
|
|
63
|
+
this.emptyIconClass = computed(() => this.isDragging() ? 'fa-light fa-cloud-arrow-up' : AX_CONVERSATION_IMAGE_PRESENTATION.icon, ...(ngDevMode ? [{ debugName: "emptyIconClass" }] : /* istanbul ignore next */ []));
|
|
64
|
+
this.caption = '';
|
|
65
|
+
this.allowMultiple = computed(() => this.maxFiles() > 1, ...(ngDevMode ? [{ debugName: "allowMultiple" }] : /* istanbul ignore next */ []));
|
|
66
|
+
this.fileTypeRegistry.registerTypes([createConversationImageFileType()]);
|
|
67
|
+
seedPickerInitialFiles(this.initialFiles, (files) => this.handleFiles(files));
|
|
68
|
+
}
|
|
69
|
+
createUtilityContext() {
|
|
70
|
+
return {
|
|
71
|
+
readAsDataUrl: (file) => this.fileService.blobToBase64(file),
|
|
72
|
+
platformId: this.platformId,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async loadImageFileType() {
|
|
76
|
+
this.imageFileType ??= await this.fileService.getFileType(this.catalogFileType);
|
|
77
|
+
return this.imageFileType;
|
|
78
|
+
}
|
|
79
|
+
async handleFiles(files) {
|
|
80
|
+
const max = this.maxFiles();
|
|
81
|
+
const capacity = limitFilesToCapacity(files, this.images().length, max);
|
|
82
|
+
if (capacity.length < files.length) {
|
|
83
|
+
notifyMaxFilesCapacityExceeded(this.toast, this.translation, max);
|
|
84
|
+
}
|
|
85
|
+
if (capacity.length === 0) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const { accepted, rejected } = await this.uploader.validateFiles(capacity, this.catalogFileType);
|
|
89
|
+
notifyPickerValidationErrors(this.toast, this.translation, rejected);
|
|
90
|
+
const fileType = await this.loadImageFileType();
|
|
91
|
+
const ctx = this.createUtilityContext();
|
|
92
|
+
for (const file of accepted) {
|
|
93
|
+
try {
|
|
94
|
+
const previewValue = fileType
|
|
95
|
+
? await runFileTypeUtilityForFile(fileType, ctx, file, 'preview')
|
|
96
|
+
: undefined;
|
|
97
|
+
const preview = typeof previewValue === 'string' ? previewValue : '';
|
|
98
|
+
let index = -1;
|
|
99
|
+
this.images.update((images) => {
|
|
100
|
+
index = images.length;
|
|
101
|
+
return [...images, { file, preview, uploadProgress: 0, uploading: true }];
|
|
102
|
+
});
|
|
103
|
+
if (index >= 0) {
|
|
104
|
+
void this.uploadImageAt(index, file);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
console.error('Failed to process image:', error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async uploadImageAt(index, file) {
|
|
113
|
+
const abortController = new AbortController();
|
|
114
|
+
this.patchImage(index, { abortController });
|
|
115
|
+
try {
|
|
116
|
+
const result = await uploadPickerFile(this.uploader, this.conversation().id, file, (progress) => this.patchImage(index, { uploadProgress: progress, uploading: true }), abortController.signal);
|
|
117
|
+
this.patchImage(index, {
|
|
118
|
+
uploadProgress: 100,
|
|
119
|
+
uploading: false,
|
|
120
|
+
uploaded: true,
|
|
121
|
+
uploadedUrl: result.url,
|
|
122
|
+
mediaId: result.mediaId,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
if (this.uploadsDismissed || isUploadAborted(err, abortController.signal)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
this.patchImage(index, {
|
|
130
|
+
uploadProgress: 0,
|
|
131
|
+
uploading: false,
|
|
132
|
+
uploaded: false,
|
|
133
|
+
error: this.translation.translateSync('@acorex:chat.errors.upload-failed'),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
patchImage(index, patch) {
|
|
138
|
+
if (this.uploadsDismissed) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
this.images.update((items) => {
|
|
142
|
+
const next = [...items];
|
|
143
|
+
if (next[index]) {
|
|
144
|
+
next[index] = { ...next[index], ...patch };
|
|
145
|
+
}
|
|
146
|
+
return next;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
removeImage(index) {
|
|
150
|
+
const item = this.images()[index];
|
|
151
|
+
if (item) {
|
|
152
|
+
cleanupPickerUploads(this.uploader, [item]);
|
|
153
|
+
}
|
|
154
|
+
this.images.update((images) => images.filter((_, i) => i !== index));
|
|
155
|
+
}
|
|
156
|
+
async sendImages() {
|
|
157
|
+
const imageList = this.images();
|
|
158
|
+
if (!this.canSend())
|
|
159
|
+
return;
|
|
160
|
+
const images = imageList.flatMap((image) => {
|
|
161
|
+
const result = pickerItemToUploadResult(image);
|
|
162
|
+
return result ? [imageItemFromUpload(image.file, result)] : [];
|
|
163
|
+
});
|
|
164
|
+
if (images.length === 0) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const command = {
|
|
168
|
+
conversationId: this.conversation().id,
|
|
169
|
+
type: 'image',
|
|
170
|
+
payload: {
|
|
171
|
+
type: 'image',
|
|
172
|
+
images,
|
|
173
|
+
caption: this.caption.trim() || undefined,
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
this.retainUploadedOnDismiss = true;
|
|
177
|
+
const popup = this.__popup__();
|
|
178
|
+
this.dismissPicker();
|
|
179
|
+
dismissComposerPickerHost(this.composerService, popup);
|
|
180
|
+
void this.composerService.sendMessage(command).catch(() => {
|
|
181
|
+
this.retainUploadedOnDismiss = false;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
canSend() {
|
|
185
|
+
const list = this.images();
|
|
186
|
+
return list.length > 0 && list.every((i) => i.uploaded && !i.error && !i.uploading);
|
|
187
|
+
}
|
|
188
|
+
getUploadingLabel(progress) {
|
|
189
|
+
return this.translation.translateSync('@acorex:chat.pickers.files.uploading-progress', {
|
|
190
|
+
params: { progress },
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
getCancelUploadLabel() {
|
|
194
|
+
return getPickerCancelUploadLabel(this.translation);
|
|
195
|
+
}
|
|
196
|
+
cancel() {
|
|
197
|
+
this.dismissPicker();
|
|
198
|
+
dismissComposerPickerHost(this.composerService, this.__popup__());
|
|
199
|
+
}
|
|
200
|
+
ngOnDestroy() {
|
|
201
|
+
this.dismissPicker();
|
|
202
|
+
}
|
|
203
|
+
dismissPicker() {
|
|
204
|
+
if (this.uploadsDismissed) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
this.uploadsDismissed = true;
|
|
208
|
+
const snapshot = [...this.images()];
|
|
209
|
+
cleanupPickerUploads(this.uploader, snapshot, {
|
|
210
|
+
retainUploaded: this.retainUploadedOnDismiss,
|
|
211
|
+
});
|
|
212
|
+
this.retainUploadedOnDismiss = false;
|
|
213
|
+
this.images.set([]);
|
|
214
|
+
this.caption = '';
|
|
215
|
+
}
|
|
216
|
+
getEmptyTitle() {
|
|
217
|
+
return this.isDragging()
|
|
218
|
+
? this.translation.translateSync('@acorex:chat.pickers.images.drop-to-attach')
|
|
219
|
+
: this.translation.translateSync('@acorex:chat.pickers.images.select');
|
|
220
|
+
}
|
|
221
|
+
getEmptySubtitle() {
|
|
222
|
+
return this.isDragging()
|
|
223
|
+
? this.translation.translateSync('@acorex:chat.pickers.common.release-to-upload')
|
|
224
|
+
: this.translation.translateSync('@acorex:chat.pickers.common.click-to-browse');
|
|
225
|
+
}
|
|
226
|
+
getSelectedCountText() {
|
|
227
|
+
return this.translation.translateSync('@acorex:chat.pickers.images.selected-count', {
|
|
228
|
+
params: { count: this.images().length },
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
getSendText() {
|
|
232
|
+
return this.translation.translateSync('@acorex:chat.pickers.images.send-count', {
|
|
233
|
+
params: { count: this.images().length },
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXConversationImagePickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
237
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: AXConversationImagePickerComponent, isStandalone: true, selector: "ax-conversation-image-picker", inputs: { service: { classPropertyName: "service", publicName: "service", isSignal: true, isRequired: false, transformFunction: null }, conversation: { classPropertyName: "conversation", publicName: "conversation", isSignal: true, isRequired: true, transformFunction: null }, maxFiles: { classPropertyName: "maxFiles", publicName: "maxFiles", isSignal: true, isRequired: false, transformFunction: null }, initialFiles: { classPropertyName: "initialFiles", publicName: "initialFiles", isSignal: true, isRequired: false, transformFunction: null }, __popup__: { classPropertyName: "__popup__", publicName: "__popup__", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
238
|
+
<ax-conversation-picker-shell
|
|
239
|
+
[fileType]="catalogFileType"
|
|
240
|
+
[multiple]="allowMultiple()"
|
|
241
|
+
(filesSelected)="handleFiles($event)"
|
|
242
|
+
(dragEnter)="isDragging.set(true)"
|
|
243
|
+
(dragLeave)="isDragging.set(false)"
|
|
244
|
+
>
|
|
245
|
+
<ax-conversation-picker-header [title]="translation.translateSync('@acorex:chat.pickers.images.title')" (onClose)="cancel()" />
|
|
246
|
+
|
|
247
|
+
<div class="ax-conversation-picker__scroll">
|
|
248
|
+
@if (images().length === 0) {
|
|
249
|
+
<ax-conversation-picker-empty
|
|
250
|
+
[title]="getEmptyTitle()"
|
|
251
|
+
[hint]="getEmptySubtitle()"
|
|
252
|
+
[iconClass]="emptyIconClass()"
|
|
253
|
+
[dragOver]="isDragging()"
|
|
254
|
+
/>
|
|
255
|
+
} @else {
|
|
256
|
+
<div class="ax-conversation-picker__body">
|
|
257
|
+
<ax-conversation-picker-toolbar
|
|
258
|
+
[countLabel]="getSelectedCountText()"
|
|
259
|
+
[addMoreLabel]="translation.translateSync('@acorex:chat.pickers.common.add-more')"
|
|
260
|
+
/>
|
|
261
|
+
|
|
262
|
+
<div class="ax-conversation-picker__grid">
|
|
263
|
+
@for (image of images(); track $index) {
|
|
264
|
+
<div class="ax-conversation-picker__tile">
|
|
265
|
+
<img [src]="image.preview" [alt]="image.file.name" />
|
|
266
|
+
@if (image.uploading || image.uploaded || image.error) {
|
|
267
|
+
<div class="ax-conversation-picker__tile-overlay">
|
|
268
|
+
@if (image.uploading) {
|
|
269
|
+
<span class="ax-conversation-picker__tile-status">{{
|
|
270
|
+
getUploadingLabel(image.uploadProgress ?? 0)
|
|
271
|
+
}}</span>
|
|
272
|
+
<ax-progress-bar [progress]="image.uploadProgress || 0" [mode]="'determinate'" [height]="3" />
|
|
273
|
+
} @else if (image.uploaded) {
|
|
274
|
+
<span class="ax-conversation-picker__tile-status"
|
|
275
|
+
><i class="fa-light fa-check"></i>
|
|
276
|
+
{{ translation.translateSync('@acorex:chat.pickers.files.uploaded') }}</span
|
|
277
|
+
>
|
|
278
|
+
} @else if (image.error) {
|
|
279
|
+
<span class="ax-conversation-picker__tile-status">{{ image.error }}</span>
|
|
280
|
+
}
|
|
281
|
+
</div>
|
|
282
|
+
}
|
|
283
|
+
<button
|
|
284
|
+
type="button"
|
|
285
|
+
class="ax-conversation-picker__tile-remove"
|
|
286
|
+
(click)="removeImage($index)"
|
|
287
|
+
[attr.aria-label]="
|
|
288
|
+
image.uploading
|
|
289
|
+
? getCancelUploadLabel()
|
|
290
|
+
: translation.translateSync('@acorex:chat.pickers.common.remove')
|
|
291
|
+
"
|
|
292
|
+
>
|
|
293
|
+
<i class="fa-light fa-xmark"></i>
|
|
294
|
+
</button>
|
|
295
|
+
</div>
|
|
296
|
+
}
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
}
|
|
300
|
+
</div>
|
|
301
|
+
|
|
302
|
+
<ax-conversation-picker-caption [(caption)]="caption" />
|
|
303
|
+
|
|
304
|
+
@if (images().length > 0) {
|
|
305
|
+
<ax-conversation-picker-footer
|
|
306
|
+
[sendText]="getSendText()"
|
|
307
|
+
[sendDisabled]="!canSend()"
|
|
308
|
+
(onCancel)="cancel()"
|
|
309
|
+
(onSend)="sendImages()"
|
|
310
|
+
/>
|
|
311
|
+
}
|
|
312
|
+
</ax-conversation-picker-shell>
|
|
313
|
+
`, isInline: true, styles: [":host{display:block;width:100%;max-width:100%;min-height:0}.ax-conversation-picker__scroll{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}.ax-conversation-picker__empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.375rem;min-height:8.5rem;margin:.75rem;padding:1rem .75rem;border:1px dashed rgb(var(--ax-sys-color-border-surface));border-radius:var(--ax-sys-border-radius, .5rem);cursor:pointer;transition:border-color .15s ease,background-color .15s ease;text-align:center;touch-action:manipulation}.ax-conversation-picker__empty:hover,.ax-conversation-picker__empty--drag{border-color:rgb(var(--ax-sys-color-primary-500));background:rgba(var(--ax-sys-color-primary-500),.06)}.ax-conversation-picker__empty-icon{font-size:1.75rem;line-height:1;color:rgba(var(--ax-sys-color-on-surface),.55)}.ax-conversation-picker__empty-title{margin:0;font-size:.8125rem;font-weight:600;color:rgb(var(--ax-sys-color-on-surface))}.ax-conversation-picker__empty-hint{margin:0;font-size:.75rem;color:rgba(var(--ax-sys-color-on-surface),.6)}.ax-conversation-picker__body{padding:0 .75rem .75rem}.ax-conversation-picker__list{display:flex;flex-direction:column;gap:.5rem;padding-top:.5rem}.ax-conversation-picker__row{display:flex;align-items:center;gap:.625rem;padding:.5rem .625rem;border:1px solid rgb(var(--ax-sys-color-border-light-surface));border-radius:var(--ax-sys-border-radius, .375rem);background:rgb(var(--ax-sys-color-surface));transition:background-color .15s ease}@media(hover:hover){.ax-conversation-picker__row:hover{background:rgb(var(--ax-sys-color-light-surface))}}.ax-conversation-picker__thumb{position:relative;display:flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;flex-shrink:0;border-radius:var(--ax-sys-border-radius, .375rem);background:rgba(var(--ax-sys-color-primary-500),.08);color:rgb(var(--ax-sys-color-primary-500));font-size:1.125rem;overflow:hidden}.ax-conversation-picker__thumb img,.ax-conversation-picker__thumb video{width:100%;height:100%;object-fit:cover;display:block;pointer-events:none}.ax-conversation-picker__thumb-badge{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#00000052;color:rgb(var(--ax-sys-color-light));font-size:.625rem;pointer-events:none}.ax-conversation-picker__details{flex:1;min-width:0;display:flex;flex-direction:column;gap:.125rem}.ax-conversation-picker__name{font-size:.8125rem;font-weight:500;color:rgb(var(--ax-sys-color-on-surface));overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ax-conversation-picker__status{display:flex;flex-wrap:wrap;gap:.375rem;font-size:.6875rem;color:rgba(var(--ax-sys-color-on-surface),.65)}.ax-conversation-picker__status--ok{color:rgb(var(--ax-sys-color-success-600));font-weight:500}.ax-conversation-picker__status--err{color:rgb(var(--ax-sys-color-danger-600));font-weight:500}.ax-conversation-picker__progress{width:100%;margin-top:.125rem}.ax-conversation-picker__remove{display:flex;align-items:center;justify-content:center;width:2.75rem;height:2.75rem;flex-shrink:0;border:none;border-radius:var(--ax-sys-border-radius, .25rem);background:transparent;color:rgba(var(--ax-sys-color-on-surface),.55);font-size:1rem;cursor:pointer;touch-action:manipulation;transition:background-color .15s ease,color .15s ease}.ax-conversation-picker__remove:hover,.ax-conversation-picker__remove:focus-visible{background:rgba(var(--ax-sys-color-danger-500),.1);color:rgb(var(--ax-sys-color-danger-500));outline:none}.ax-conversation-picker__grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(5.25rem,1fr));gap:.5rem}.ax-conversation-picker__tile{position:relative;aspect-ratio:1;border-radius:var(--ax-sys-border-radius, .375rem);overflow:hidden;border:1px solid rgb(var(--ax-sys-color-border-light-surface));background:rgb(var(--ax-sys-color-light-surface))}.ax-conversation-picker__tile img{width:100%;height:100%;object-fit:cover;display:block}.ax-conversation-picker__tile-remove{position:absolute;top:.25rem;inset-inline-end:.25rem;z-index:2;display:flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;border:none;border-radius:50%;background:rgb(var(--ax-sys-color-danger-500));color:rgb(var(--ax-sys-color-light));font-size:.6875rem;cursor:pointer;touch-action:manipulation;box-shadow:0 1px 3px #0003}.ax-conversation-picker__tile-overlay{position:absolute;inset-inline:0;bottom:0;padding:.25rem;background:linear-gradient(transparent,#0000008c)}.ax-conversation-picker__tile-status{font-size:.625rem;color:rgb(var(--ax-sys-color-light));line-height:1.2}.ax-conversation-picker__caption-slot{flex-shrink:0;padding:.5rem .75rem;border-top:1px solid rgb(var(--ax-sys-color-border-light-surface));background:rgb(var(--ax-sys-color-lightest-surface))}.ax-conversation-picker__input-hidden{display:none}@container picker (max-width: 480px){.ax-conversation-picker__grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:.375rem}.ax-conversation-picker__row{padding:.4375rem .5rem;gap:.5rem}.ax-conversation-picker__thumb{width:2.25rem;height:2.25rem}.ax-conversation-picker__empty{min-height:7.5rem;margin:.5rem}.ax-conversation-picker__body{padding-inline:.5rem;padding-bottom:.5rem}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: AXProgressBarModule }, { kind: "component", type: i1.AXProgressBarComponent, selector: "ax-progress-bar", inputs: ["color", "mode", "progress", "height"], outputs: ["ValueChange", "sizeChange"] }, { kind: "ngmodule", type: AXTranslationModule }, { kind: "component", type: AXConversationPickerHeaderComponent, selector: "ax-conversation-picker-header", inputs: ["title"], outputs: ["onClose"] }, { kind: "component", type: AXConversationPickerFooterComponent, selector: "ax-conversation-picker-footer", inputs: ["sendText", "sendDisabled"], outputs: ["onCancel", "onSend"] }, { kind: "component", type: AXConversationPickerEmptyComponent, selector: "ax-conversation-picker-empty", inputs: ["title", "hint", "iconClass", "dragOver"] }, { kind: "component", type: AXConversationPickerToolbarComponent, selector: "ax-conversation-picker-toolbar", inputs: ["countLabel", "addMoreLabel"] }, { kind: "component", type: AXConversationPickerCaptionComponent, selector: "ax-conversation-picker-caption", inputs: ["caption"], outputs: ["captionChange"] }, { kind: "component", type: AXConversationPickerShellComponent, selector: "ax-conversation-picker-shell", inputs: ["fileType", "multiple"], outputs: ["filesSelected", "dragEnter", "dragLeave", "dragOver"] }] }); }
|
|
314
|
+
}
|
|
315
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXConversationImagePickerComponent, decorators: [{
|
|
316
|
+
type: Component,
|
|
317
|
+
args: [{ selector: 'ax-conversation-image-picker', imports: [
|
|
318
|
+
CommonModule,
|
|
319
|
+
AXProgressBarModule,
|
|
320
|
+
AXTranslationModule,
|
|
321
|
+
AXConversationPickerHeaderComponent,
|
|
322
|
+
AXConversationPickerFooterComponent,
|
|
323
|
+
AXConversationPickerEmptyComponent,
|
|
324
|
+
AXConversationPickerToolbarComponent,
|
|
325
|
+
AXConversationPickerCaptionComponent,
|
|
326
|
+
AXConversationPickerShellComponent,
|
|
327
|
+
], template: `
|
|
328
|
+
<ax-conversation-picker-shell
|
|
329
|
+
[fileType]="catalogFileType"
|
|
330
|
+
[multiple]="allowMultiple()"
|
|
331
|
+
(filesSelected)="handleFiles($event)"
|
|
332
|
+
(dragEnter)="isDragging.set(true)"
|
|
333
|
+
(dragLeave)="isDragging.set(false)"
|
|
334
|
+
>
|
|
335
|
+
<ax-conversation-picker-header [title]="translation.translateSync('@acorex:chat.pickers.images.title')" (onClose)="cancel()" />
|
|
336
|
+
|
|
337
|
+
<div class="ax-conversation-picker__scroll">
|
|
338
|
+
@if (images().length === 0) {
|
|
339
|
+
<ax-conversation-picker-empty
|
|
340
|
+
[title]="getEmptyTitle()"
|
|
341
|
+
[hint]="getEmptySubtitle()"
|
|
342
|
+
[iconClass]="emptyIconClass()"
|
|
343
|
+
[dragOver]="isDragging()"
|
|
344
|
+
/>
|
|
345
|
+
} @else {
|
|
346
|
+
<div class="ax-conversation-picker__body">
|
|
347
|
+
<ax-conversation-picker-toolbar
|
|
348
|
+
[countLabel]="getSelectedCountText()"
|
|
349
|
+
[addMoreLabel]="translation.translateSync('@acorex:chat.pickers.common.add-more')"
|
|
350
|
+
/>
|
|
351
|
+
|
|
352
|
+
<div class="ax-conversation-picker__grid">
|
|
353
|
+
@for (image of images(); track $index) {
|
|
354
|
+
<div class="ax-conversation-picker__tile">
|
|
355
|
+
<img [src]="image.preview" [alt]="image.file.name" />
|
|
356
|
+
@if (image.uploading || image.uploaded || image.error) {
|
|
357
|
+
<div class="ax-conversation-picker__tile-overlay">
|
|
358
|
+
@if (image.uploading) {
|
|
359
|
+
<span class="ax-conversation-picker__tile-status">{{
|
|
360
|
+
getUploadingLabel(image.uploadProgress ?? 0)
|
|
361
|
+
}}</span>
|
|
362
|
+
<ax-progress-bar [progress]="image.uploadProgress || 0" [mode]="'determinate'" [height]="3" />
|
|
363
|
+
} @else if (image.uploaded) {
|
|
364
|
+
<span class="ax-conversation-picker__tile-status"
|
|
365
|
+
><i class="fa-light fa-check"></i>
|
|
366
|
+
{{ translation.translateSync('@acorex:chat.pickers.files.uploaded') }}</span
|
|
367
|
+
>
|
|
368
|
+
} @else if (image.error) {
|
|
369
|
+
<span class="ax-conversation-picker__tile-status">{{ image.error }}</span>
|
|
370
|
+
}
|
|
371
|
+
</div>
|
|
372
|
+
}
|
|
373
|
+
<button
|
|
374
|
+
type="button"
|
|
375
|
+
class="ax-conversation-picker__tile-remove"
|
|
376
|
+
(click)="removeImage($index)"
|
|
377
|
+
[attr.aria-label]="
|
|
378
|
+
image.uploading
|
|
379
|
+
? getCancelUploadLabel()
|
|
380
|
+
: translation.translateSync('@acorex:chat.pickers.common.remove')
|
|
381
|
+
"
|
|
382
|
+
>
|
|
383
|
+
<i class="fa-light fa-xmark"></i>
|
|
384
|
+
</button>
|
|
385
|
+
</div>
|
|
386
|
+
}
|
|
387
|
+
</div>
|
|
388
|
+
</div>
|
|
389
|
+
}
|
|
390
|
+
</div>
|
|
391
|
+
|
|
392
|
+
<ax-conversation-picker-caption [(caption)]="caption" />
|
|
393
|
+
|
|
394
|
+
@if (images().length > 0) {
|
|
395
|
+
<ax-conversation-picker-footer
|
|
396
|
+
[sendText]="getSendText()"
|
|
397
|
+
[sendDisabled]="!canSend()"
|
|
398
|
+
(onCancel)="cancel()"
|
|
399
|
+
(onSend)="sendImages()"
|
|
400
|
+
/>
|
|
401
|
+
}
|
|
402
|
+
</ax-conversation-picker-shell>
|
|
403
|
+
`, styles: [":host{display:block;width:100%;max-width:100%;min-height:0}.ax-conversation-picker__scroll{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}.ax-conversation-picker__empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.375rem;min-height:8.5rem;margin:.75rem;padding:1rem .75rem;border:1px dashed rgb(var(--ax-sys-color-border-surface));border-radius:var(--ax-sys-border-radius, .5rem);cursor:pointer;transition:border-color .15s ease,background-color .15s ease;text-align:center;touch-action:manipulation}.ax-conversation-picker__empty:hover,.ax-conversation-picker__empty--drag{border-color:rgb(var(--ax-sys-color-primary-500));background:rgba(var(--ax-sys-color-primary-500),.06)}.ax-conversation-picker__empty-icon{font-size:1.75rem;line-height:1;color:rgba(var(--ax-sys-color-on-surface),.55)}.ax-conversation-picker__empty-title{margin:0;font-size:.8125rem;font-weight:600;color:rgb(var(--ax-sys-color-on-surface))}.ax-conversation-picker__empty-hint{margin:0;font-size:.75rem;color:rgba(var(--ax-sys-color-on-surface),.6)}.ax-conversation-picker__body{padding:0 .75rem .75rem}.ax-conversation-picker__list{display:flex;flex-direction:column;gap:.5rem;padding-top:.5rem}.ax-conversation-picker__row{display:flex;align-items:center;gap:.625rem;padding:.5rem .625rem;border:1px solid rgb(var(--ax-sys-color-border-light-surface));border-radius:var(--ax-sys-border-radius, .375rem);background:rgb(var(--ax-sys-color-surface));transition:background-color .15s ease}@media(hover:hover){.ax-conversation-picker__row:hover{background:rgb(var(--ax-sys-color-light-surface))}}.ax-conversation-picker__thumb{position:relative;display:flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;flex-shrink:0;border-radius:var(--ax-sys-border-radius, .375rem);background:rgba(var(--ax-sys-color-primary-500),.08);color:rgb(var(--ax-sys-color-primary-500));font-size:1.125rem;overflow:hidden}.ax-conversation-picker__thumb img,.ax-conversation-picker__thumb video{width:100%;height:100%;object-fit:cover;display:block;pointer-events:none}.ax-conversation-picker__thumb-badge{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#00000052;color:rgb(var(--ax-sys-color-light));font-size:.625rem;pointer-events:none}.ax-conversation-picker__details{flex:1;min-width:0;display:flex;flex-direction:column;gap:.125rem}.ax-conversation-picker__name{font-size:.8125rem;font-weight:500;color:rgb(var(--ax-sys-color-on-surface));overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ax-conversation-picker__status{display:flex;flex-wrap:wrap;gap:.375rem;font-size:.6875rem;color:rgba(var(--ax-sys-color-on-surface),.65)}.ax-conversation-picker__status--ok{color:rgb(var(--ax-sys-color-success-600));font-weight:500}.ax-conversation-picker__status--err{color:rgb(var(--ax-sys-color-danger-600));font-weight:500}.ax-conversation-picker__progress{width:100%;margin-top:.125rem}.ax-conversation-picker__remove{display:flex;align-items:center;justify-content:center;width:2.75rem;height:2.75rem;flex-shrink:0;border:none;border-radius:var(--ax-sys-border-radius, .25rem);background:transparent;color:rgba(var(--ax-sys-color-on-surface),.55);font-size:1rem;cursor:pointer;touch-action:manipulation;transition:background-color .15s ease,color .15s ease}.ax-conversation-picker__remove:hover,.ax-conversation-picker__remove:focus-visible{background:rgba(var(--ax-sys-color-danger-500),.1);color:rgb(var(--ax-sys-color-danger-500));outline:none}.ax-conversation-picker__grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(5.25rem,1fr));gap:.5rem}.ax-conversation-picker__tile{position:relative;aspect-ratio:1;border-radius:var(--ax-sys-border-radius, .375rem);overflow:hidden;border:1px solid rgb(var(--ax-sys-color-border-light-surface));background:rgb(var(--ax-sys-color-light-surface))}.ax-conversation-picker__tile img{width:100%;height:100%;object-fit:cover;display:block}.ax-conversation-picker__tile-remove{position:absolute;top:.25rem;inset-inline-end:.25rem;z-index:2;display:flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;border:none;border-radius:50%;background:rgb(var(--ax-sys-color-danger-500));color:rgb(var(--ax-sys-color-light));font-size:.6875rem;cursor:pointer;touch-action:manipulation;box-shadow:0 1px 3px #0003}.ax-conversation-picker__tile-overlay{position:absolute;inset-inline:0;bottom:0;padding:.25rem;background:linear-gradient(transparent,#0000008c)}.ax-conversation-picker__tile-status{font-size:.625rem;color:rgb(var(--ax-sys-color-light));line-height:1.2}.ax-conversation-picker__caption-slot{flex-shrink:0;padding:.5rem .75rem;border-top:1px solid rgb(var(--ax-sys-color-border-light-surface));background:rgb(var(--ax-sys-color-lightest-surface))}.ax-conversation-picker__input-hidden{display:none}@container picker (max-width: 480px){.ax-conversation-picker__grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:.375rem}.ax-conversation-picker__row{padding:.4375rem .5rem;gap:.5rem}.ax-conversation-picker__thumb{width:2.25rem;height:2.25rem}.ax-conversation-picker__empty{min-height:7.5rem;margin:.5rem}.ax-conversation-picker__body{padding-inline:.5rem;padding-bottom:.5rem}}\n"] }]
|
|
404
|
+
}], ctorParameters: () => [], propDecorators: { service: [{ type: i0.Input, args: [{ isSignal: true, alias: "service", required: false }] }], conversation: [{ type: i0.Input, args: [{ isSignal: true, alias: "conversation", required: true }] }], maxFiles: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxFiles", required: false }] }], initialFiles: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialFiles", required: false }] }], __popup__: [{ type: i0.Input, args: [{ isSignal: true, alias: "__popup__", required: false }] }] } });
|
|
405
|
+
|
|
406
|
+
export { AXConversationImagePickerComponent };
|
|
407
|
+
//# sourceMappingURL=acorex-components-conversation-image-picker.component-CS343UDa.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-components-conversation-image-picker.component-CS343UDa.mjs","sources":["../../../../packages/components/conversation/src/lib/plugins/composer/components/image-picker/image-picker.component.ts"],"sourcesContent":["/**\n * Image Picker Component\n * Full-width image selection and preview interface for the composer\n */\n\nimport { AXUploaderService } from '@acorex/cdk/uploader';\nimport { AXProgressBarModule } from '@acorex/components/progress-bar';\nimport type { AXPopupRef } from '@acorex/components/popup';\nimport { AXToastService } from '@acorex/components/toast';\nimport { AXFileService, AXFileTypeRegistryService, runFileTypeUtilityForFile, type AXFileType } from '@acorex/core/file';\nimport { AXTranslationModule, AXTranslationService } from '@acorex/core/translation';\nimport { CommonModule } from '@angular/common';\nimport { Component, OnDestroy, PLATFORM_ID, computed, inject, input, signal } from '@angular/core';\nimport { AXConversationComposerService } from '../../../../components/composer/composer.service';\nimport { AXConversation, AXConversationImageMediaItem, AXConversationSendMessageCommand } from '../../../../models';\nimport type { AXConversationUploaderResult } from '../../../../models/conversation-upload.types';\nimport { AXConversationPickerFooterComponent } from '../picker-footer/picker-footer.component';\nimport { AXConversationPickerHeaderComponent } from '../picker-header/picker-header.component';\nimport { AXConversationPickerCaptionComponent } from '../shared/picker-caption.component';\nimport { AXConversationPickerEmptyComponent } from '../shared/picker-empty.component';\nimport { AX_CONVERSATION_PICKER_SHARED_STYLES } from '../shared/picker-shared.styles';\nimport { AXConversationPickerShellComponent } from '../shared/picker-shell.component';\nimport { AXConversationPickerToolbarComponent } from '../shared/picker-toolbar.component';\nimport {\n type AXConversationComposerPickerUploadItem,\n cleanupPickerUploads,\n dismissComposerPickerHost,\n getPickerCancelUploadLabel,\n isUploadAborted,\n seedPickerInitialFiles,\n limitFilesToCapacity,\n notifyMaxFilesCapacityExceeded,\n notifyPickerValidationErrors,\n pickerItemToUploadResult,\n uploadPickerFile,\n} from '../shared/picker-upload';\nimport { resolvePersistableMediaUrl, resolvePersistedThumbnailUrl } from '../shared/persisted-media-url';\nimport {\n createConversationImageFileType,\n AX_CONVERSATION_IMAGE_CATALOG,\n AX_CONVERSATION_IMAGE_PRESENTATION,\n} from './conversation-image.file-type';\n\ninterface AXConversationImageFile extends AXConversationComposerPickerUploadItem {\n preview: string;\n}\n\nfunction imageItemFromUpload(file: File, result: AXConversationUploaderResult): AXConversationImageMediaItem {\n const url = resolvePersistableMediaUrl(result.url);\n const item: AXConversationImageMediaItem = {\n mediaId: result.mediaId,\n mimeType: result.mimeType,\n size: result.size,\n thumbnailUrl: resolvePersistedThumbnailUrl(result.thumbnailUrl, url),\n width: 0,\n height: 0,\n metadata: result.metadata,\n };\n if (url) {\n item.url = url;\n }\n return item;\n}\n\n@Component({\n selector: 'ax-conversation-image-picker',\n imports: [\n CommonModule,\n AXProgressBarModule,\n AXTranslationModule,\n AXConversationPickerHeaderComponent,\n AXConversationPickerFooterComponent,\n AXConversationPickerEmptyComponent,\n AXConversationPickerToolbarComponent,\n AXConversationPickerCaptionComponent,\n AXConversationPickerShellComponent,\n ],\n template: `\n <ax-conversation-picker-shell\n [fileType]=\"catalogFileType\"\n [multiple]=\"allowMultiple()\"\n (filesSelected)=\"handleFiles($event)\"\n (dragEnter)=\"isDragging.set(true)\"\n (dragLeave)=\"isDragging.set(false)\"\n >\n <ax-conversation-picker-header [title]=\"translation.translateSync('@acorex:chat.pickers.images.title')\" (onClose)=\"cancel()\" />\n\n <div class=\"ax-conversation-picker__scroll\">\n @if (images().length === 0) {\n <ax-conversation-picker-empty\n [title]=\"getEmptyTitle()\"\n [hint]=\"getEmptySubtitle()\"\n [iconClass]=\"emptyIconClass()\"\n [dragOver]=\"isDragging()\"\n />\n } @else {\n <div class=\"ax-conversation-picker__body\">\n <ax-conversation-picker-toolbar\n [countLabel]=\"getSelectedCountText()\"\n [addMoreLabel]=\"translation.translateSync('@acorex:chat.pickers.common.add-more')\"\n />\n\n <div class=\"ax-conversation-picker__grid\">\n @for (image of images(); track $index) {\n <div class=\"ax-conversation-picker__tile\">\n <img [src]=\"image.preview\" [alt]=\"image.file.name\" />\n @if (image.uploading || image.uploaded || image.error) {\n <div class=\"ax-conversation-picker__tile-overlay\">\n @if (image.uploading) {\n <span class=\"ax-conversation-picker__tile-status\">{{\n getUploadingLabel(image.uploadProgress ?? 0)\n }}</span>\n <ax-progress-bar [progress]=\"image.uploadProgress || 0\" [mode]=\"'determinate'\" [height]=\"3\" />\n } @else if (image.uploaded) {\n <span class=\"ax-conversation-picker__tile-status\"\n ><i class=\"fa-light fa-check\"></i>\n {{ translation.translateSync('@acorex:chat.pickers.files.uploaded') }}</span\n >\n } @else if (image.error) {\n <span class=\"ax-conversation-picker__tile-status\">{{ image.error }}</span>\n }\n </div>\n }\n <button\n type=\"button\"\n class=\"ax-conversation-picker__tile-remove\"\n (click)=\"removeImage($index)\"\n [attr.aria-label]=\"\n image.uploading\n ? getCancelUploadLabel()\n : translation.translateSync('@acorex:chat.pickers.common.remove')\n \"\n >\n <i class=\"fa-light fa-xmark\"></i>\n </button>\n </div>\n }\n </div>\n </div>\n }\n </div>\n\n <ax-conversation-picker-caption [(caption)]=\"caption\" />\n\n @if (images().length > 0) {\n <ax-conversation-picker-footer\n [sendText]=\"getSendText()\"\n [sendDisabled]=\"!canSend()\"\n (onCancel)=\"cancel()\"\n (onSend)=\"sendImages()\"\n />\n }\n </ax-conversation-picker-shell>\n `,\n styles: [AX_CONVERSATION_PICKER_SHARED_STYLES],\n})\nexport class AXConversationImagePickerComponent implements OnDestroy {\n private uploadsDismissed = false;\n /** Uploaded blobs are referenced by the sent message — do not delete on dismiss. */\n private retainUploadedOnDismiss = false;\n readonly service = input<AXConversationComposerService | undefined>();\n private readonly composerServiceFromInjector = inject(AXConversationComposerService, { optional: true });\n\n private get composerService(): AXConversationComposerService {\n const svc = this.service() ?? this.composerServiceFromInjector;\n if (!svc) {\n throw new Error('AXConversationComposerService is required for the image picker');\n }\n return svc;\n }\n private readonly uploader = inject(AXUploaderService);\n private readonly fileService = inject(AXFileService);\n private readonly fileTypeRegistry = inject(AXFileTypeRegistryService);\n private readonly platformId = inject(PLATFORM_ID);\n private readonly toast = inject(AXToastService);\n readonly translation = inject(AXTranslationService);\n\n readonly catalogFileType = AX_CONVERSATION_IMAGE_CATALOG;\n\n readonly conversation = input.required<AXConversation>();\n readonly maxFiles = input<number>(10);\n readonly initialFiles = input<File[]>([]);\n readonly __popup__ = input<AXPopupRef | undefined>();\n\n readonly images = signal<AXConversationImageFile[]>([]);\n readonly isDragging = signal(false);\n readonly emptyIconClass = computed(() =>\n this.isDragging() ? 'fa-light fa-cloud-arrow-up' : AX_CONVERSATION_IMAGE_PRESENTATION.icon,\n );\n caption = '';\n\n readonly allowMultiple = computed(() => this.maxFiles() > 1);\n private imageFileType?: AXFileType;\n\n constructor() {\n this.fileTypeRegistry.registerTypes([createConversationImageFileType()]);\n seedPickerInitialFiles(this.initialFiles, (files) => this.handleFiles(files));\n }\n\n private createUtilityContext() {\n return {\n readAsDataUrl: (file: File | Blob) => this.fileService.blobToBase64(file),\n platformId: this.platformId,\n };\n }\n\n private async loadImageFileType(): Promise<AXFileType | undefined> {\n this.imageFileType ??= await this.fileService.getFileType(this.catalogFileType);\n return this.imageFileType;\n }\n\n async handleFiles(files: File[]): Promise<void> {\n const max = this.maxFiles();\n const capacity = limitFilesToCapacity(files, this.images().length, max);\n if (capacity.length < files.length) {\n notifyMaxFilesCapacityExceeded(this.toast, this.translation, max);\n }\n if (capacity.length === 0) {\n return;\n }\n\n const { accepted, rejected } = await this.uploader.validateFiles(capacity, this.catalogFileType);\n notifyPickerValidationErrors(this.toast, this.translation, rejected);\n\n const fileType = await this.loadImageFileType();\n const ctx = this.createUtilityContext();\n\n for (const file of accepted) {\n try {\n const previewValue = fileType\n ? await runFileTypeUtilityForFile(fileType, ctx, file, 'preview')\n : undefined;\n const preview = typeof previewValue === 'string' ? previewValue : '';\n let index = -1;\n this.images.update((images) => {\n index = images.length;\n return [...images, { file, preview, uploadProgress: 0, uploading: true }];\n });\n if (index >= 0) {\n void this.uploadImageAt(index, file);\n }\n } catch (error) {\n console.error('Failed to process image:', error);\n }\n }\n }\n\n private async uploadImageAt(index: number, file: File): Promise<void> {\n const abortController = new AbortController();\n this.patchImage(index, { abortController });\n\n try {\n const result = await uploadPickerFile(\n this.uploader,\n this.conversation().id,\n file,\n (progress) => this.patchImage(index, { uploadProgress: progress, uploading: true }),\n abortController.signal,\n );\n this.patchImage(index, {\n uploadProgress: 100,\n uploading: false,\n uploaded: true,\n uploadedUrl: result.url,\n mediaId: result.mediaId,\n });\n } catch (err) {\n if (this.uploadsDismissed || isUploadAborted(err, abortController.signal)) {\n return;\n }\n this.patchImage(index, {\n uploadProgress: 0,\n uploading: false,\n uploaded: false,\n error: this.translation.translateSync('@acorex:chat.errors.upload-failed'),\n });\n }\n }\n\n private patchImage(index: number, patch: Partial<AXConversationImageFile>): void {\n if (this.uploadsDismissed) {\n return;\n }\n this.images.update((items) => {\n const next = [...items];\n if (next[index]) {\n next[index] = { ...next[index], ...patch };\n }\n return next;\n });\n }\n\n removeImage(index: number): void {\n const item = this.images()[index];\n if (item) {\n cleanupPickerUploads(this.uploader, [item]);\n }\n this.images.update((images) => images.filter((_, i) => i !== index));\n }\n\n async sendImages(): Promise<void> {\n const imageList = this.images();\n if (!this.canSend()) return;\n\n const images = imageList.flatMap((image) => {\n const result = pickerItemToUploadResult(image);\n return result ? [imageItemFromUpload(image.file, result)] : [];\n });\n\n if (images.length === 0) {\n return;\n }\n\n const command: AXConversationSendMessageCommand = {\n conversationId: this.conversation().id,\n type: 'image',\n payload: {\n type: 'image',\n images,\n caption: this.caption.trim() || undefined,\n },\n };\n\n this.retainUploadedOnDismiss = true;\n const popup = this.__popup__();\n this.dismissPicker();\n dismissComposerPickerHost(this.composerService, popup);\n\n void this.composerService.sendMessage(command).catch(() => {\n this.retainUploadedOnDismiss = false;\n });\n }\n\n canSend(): boolean {\n const list = this.images();\n return list.length > 0 && list.every((i) => i.uploaded && !i.error && !i.uploading);\n }\n\n getUploadingLabel(progress: number): string {\n return this.translation.translateSync('@acorex:chat.pickers.files.uploading-progress', {\n params: { progress },\n });\n }\n\n getCancelUploadLabel(): string {\n return getPickerCancelUploadLabel(this.translation);\n }\n\n cancel(): void {\n this.dismissPicker();\n dismissComposerPickerHost(this.composerService, this.__popup__());\n }\n\n ngOnDestroy(): void {\n this.dismissPicker();\n }\n\n private dismissPicker(): void {\n if (this.uploadsDismissed) {\n return;\n }\n this.uploadsDismissed = true;\n const snapshot = [...this.images()];\n cleanupPickerUploads(this.uploader, snapshot, {\n retainUploaded: this.retainUploadedOnDismiss,\n });\n this.retainUploadedOnDismiss = false;\n this.images.set([]);\n this.caption = '';\n }\n\n getEmptyTitle(): string {\n return this.isDragging()\n ? this.translation.translateSync('@acorex:chat.pickers.images.drop-to-attach')\n : this.translation.translateSync('@acorex:chat.pickers.images.select');\n }\n\n getEmptySubtitle(): string {\n return this.isDragging()\n ? this.translation.translateSync('@acorex:chat.pickers.common.release-to-upload')\n : this.translation.translateSync('@acorex:chat.pickers.common.click-to-browse');\n }\n\n getSelectedCountText(): string {\n return this.translation.translateSync('@acorex:chat.pickers.images.selected-count', {\n params: { count: this.images().length },\n });\n }\n\n getSendText(): string {\n return this.translation.translateSync('@acorex:chat.pickers.images.send-count', {\n params: { count: this.images().length },\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;AAGG;AA4CH,SAAS,mBAAmB,CAAC,IAAU,EAAE,MAAoC,EAAA;IAC3E,MAAM,GAAG,GAAG,0BAA0B,CAAC,MAAM,CAAC,GAAG,CAAC;AAClD,IAAA,MAAM,IAAI,GAAiC;QACzC,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,YAAY,EAAE,4BAA4B,CAAC,MAAM,CAAC,YAAY,EAAE,GAAG,CAAC;AACpE,QAAA,KAAK,EAAE,CAAC;AACR,QAAA,MAAM,EAAE,CAAC;QACT,QAAQ,EAAE,MAAM,CAAC,QAAQ;KAC1B;IACD,IAAI,GAAG,EAAE;AACP,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;IAChB;AACA,IAAA,OAAO,IAAI;AACb;MA8Fa,kCAAkC,CAAA;AAO7C,IAAA,IAAY,eAAe,GAAA;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,2BAA2B;QAC9D,IAAI,CAAC,GAAG,EAAE;AACR,YAAA,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC;QACnF;AACA,QAAA,OAAO,GAAG;IACZ;AAyBA,IAAA,WAAA,GAAA;QArCQ,IAAA,CAAA,gBAAgB,GAAG,KAAK;;QAExB,IAAA,CAAA,uBAAuB,GAAG,KAAK;QAC9B,IAAA,CAAA,OAAO,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,SAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAA6C;QACpD,IAAA,CAAA,2BAA2B,GAAG,MAAM,CAAC,6BAA6B,EAAE,EAAE,QAAQ,EAAE,IA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AA;;;;;"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AXFileTypeRegistryService } from '@acorex/core/file';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { inject, input, computed, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
5
|
+
import { A as AXConversationImageAttachmentComponent } from './acorex-components-conversation-image-attachment.component-CLMGxXPl.mjs';
|
|
6
|
+
import { A as AXConversationMessageRendererCopyHostComponent, m as mediaCopyText } from './acorex-components-conversation-message-renderer-copy-host.component-oXTr_Lfq.mjs';
|
|
7
|
+
import { n as normalizeImagePayload, l as copyWithFileTypeFallback } from './acorex-components-conversation-acorex-components-conversation-YhVa42TC.mjs';
|
|
8
|
+
import { A as AXConversationMessageRendererStateComponent } from './acorex-components-conversation-message-renderer-state.component-Dp-JdHWr.mjs';
|
|
9
|
+
import './acorex-components-conversation-renderer-shared.styles-Digah3Zn.mjs';
|
|
10
|
+
|
|
11
|
+
class AXConversationImageRendererComponent extends AXConversationMessageRendererCopyHostComponent {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.fileTypes = inject(AXFileTypeRegistryService);
|
|
15
|
+
this.message = input.required(...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
|
|
16
|
+
this.rendererState = computed(() => ({
|
|
17
|
+
deliveryStatus: this.message().status,
|
|
18
|
+
contentState: 'ready',
|
|
19
|
+
}), ...(ngDevMode ? [{ debugName: "rendererState" }] : /* istanbul ignore next */ []));
|
|
20
|
+
this.payload = computed(() => normalizeImagePayload(this.message().payload), ...(ngDevMode ? [{ debugName: "payload" }] : /* istanbul ignore next */ []));
|
|
21
|
+
this.images = computed(() => this.payload().images, ...(ngDevMode ? [{ debugName: "images" }] : /* istanbul ignore next */ []));
|
|
22
|
+
this.caption = computed(() => this.payload().caption?.trim() || '', ...(ngDevMode ? [{ debugName: "caption" }] : /* istanbul ignore next */ []));
|
|
23
|
+
this.gridModeClass = computed(() => {
|
|
24
|
+
const n = this.images().length;
|
|
25
|
+
if (n <= 1)
|
|
26
|
+
return 'ax-conversation-msg__grid--single';
|
|
27
|
+
if (n === 2)
|
|
28
|
+
return 'ax-conversation-msg__grid--dual';
|
|
29
|
+
return 'ax-conversation-msg__grid--multi';
|
|
30
|
+
}, ...(ngDevMode ? [{ debugName: "gridModeClass" }] : /* istanbul ignore next */ []));
|
|
31
|
+
}
|
|
32
|
+
copy() {
|
|
33
|
+
return copyWithFileTypeFallback(this.message(), this.fileTypes, () => {
|
|
34
|
+
const p = this.payload();
|
|
35
|
+
return mediaCopyText(p.caption, 'Image', 'images', p.images.length, p.images.map((item) => item.url?.trim() || item.thumbnailUrl?.trim()));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXConversationImageRendererComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
39
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: AXConversationImageRendererComponent, isStandalone: true, selector: "ax-conversation-image-renderer", inputs: { message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: true, transformFunction: null } }, usesInheritance: true, ngImport: i0, template: `
|
|
40
|
+
<div class="ax-conversation-msg ax-conversation-msg--flush">
|
|
41
|
+
<div class="ax-conversation-msg__grid" [class]="gridModeClass()">
|
|
42
|
+
@for (image of images(); track image.mediaId ?? image.url) {
|
|
43
|
+
<ax-conversation-image-attachment [item]="image" [alt]="caption() || 'Image'" />
|
|
44
|
+
}
|
|
45
|
+
</div>
|
|
46
|
+
@if (caption()) {
|
|
47
|
+
<p class="ax-conversation-msg__caption">{{ caption() }}</p>
|
|
48
|
+
}
|
|
49
|
+
<ax-conversation-message-renderer-state
|
|
50
|
+
[rendererState]="rendererState()"
|
|
51
|
+
[message]="message()"
|
|
52
|
+
contentErrorLabel="Couldn't load image"
|
|
53
|
+
contentErrorStyle="inline"
|
|
54
|
+
placement="below"
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
`, isInline: true, styles: [":host{display:block;max-width:100%}.ax-conversation-msg,.ax-conversation-msg__stack{display:flex;flex-direction:column;gap:.375rem}.ax-conversation-msg__grid{display:grid;gap:2px;width:100%;border-radius:var(--ax-sys-border-radius, .5rem);overflow:hidden;background:rgb(var(--ax-sys-color-border-light-surface))}.ax-conversation-msg__grid--single{grid-template-columns:1fr}.ax-conversation-msg__grid--single ::ng-deep .ax-conversation-image-attachment{max-height:min(50dvh,20rem)}.ax-conversation-msg__grid--dual{grid-template-columns:repeat(2,1fr)}.ax-conversation-msg__grid--multi{grid-template-columns:repeat(3,1fr);grid-auto-rows:10rem}@container (max-width: 380px){.ax-conversation-msg__grid--multi{grid-template-columns:repeat(2,1fr);grid-auto-rows:10rem}}.ax-conversation-msg__caption{margin:0;padding:0 .125rem;font-size:.8125rem;line-height:1.4;word-break:break-word;opacity:.88}.ax-conversation-msg--flush{width:100%;max-width:100%;gap:0}.ax-conversation-msg--flush .ax-conversation-msg__caption{padding:.375rem .625rem 0}.ax-conversation-msg--flush .ax-conversation-msg__grid{border-radius:0;background:transparent}.ax-conversation-msg--flush .ax-conversation-msg__stack{gap:2px}.ax-conversation-msg--flush ::ng-deep .ax-conversation-video{border-radius:0}.ax-conversation-msg__card{border-radius:var(--ax-sys-border-radius, .5rem);border:1px solid rgb(var(--ax-sys-color-border-light-surface));background:rgb(var(--ax-sys-color-surface));overflow:hidden}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: AXConversationImageAttachmentComponent, selector: "ax-conversation-image-attachment", inputs: ["item", "alt"] }, { kind: "component", type: AXConversationMessageRendererStateComponent, selector: "ax-conversation-message-renderer-state", inputs: ["rendererState", "message", "contentErrorLabel", "deliveryFailedLabel", "showContentErrorChrome", "contentErrorStyle", "contentErrorIconClass", "placement", "contentRetryEnabled"], outputs: ["contentRetry"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
58
|
+
}
|
|
59
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXConversationImageRendererComponent, decorators: [{
|
|
60
|
+
type: Component,
|
|
61
|
+
args: [{ selector: 'ax-conversation-image-renderer', imports: [CommonModule, AXConversationImageAttachmentComponent, AXConversationMessageRendererStateComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
62
|
+
<div class="ax-conversation-msg ax-conversation-msg--flush">
|
|
63
|
+
<div class="ax-conversation-msg__grid" [class]="gridModeClass()">
|
|
64
|
+
@for (image of images(); track image.mediaId ?? image.url) {
|
|
65
|
+
<ax-conversation-image-attachment [item]="image" [alt]="caption() || 'Image'" />
|
|
66
|
+
}
|
|
67
|
+
</div>
|
|
68
|
+
@if (caption()) {
|
|
69
|
+
<p class="ax-conversation-msg__caption">{{ caption() }}</p>
|
|
70
|
+
}
|
|
71
|
+
<ax-conversation-message-renderer-state
|
|
72
|
+
[rendererState]="rendererState()"
|
|
73
|
+
[message]="message()"
|
|
74
|
+
contentErrorLabel="Couldn't load image"
|
|
75
|
+
contentErrorStyle="inline"
|
|
76
|
+
placement="below"
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
`, styles: [":host{display:block;max-width:100%}.ax-conversation-msg,.ax-conversation-msg__stack{display:flex;flex-direction:column;gap:.375rem}.ax-conversation-msg__grid{display:grid;gap:2px;width:100%;border-radius:var(--ax-sys-border-radius, .5rem);overflow:hidden;background:rgb(var(--ax-sys-color-border-light-surface))}.ax-conversation-msg__grid--single{grid-template-columns:1fr}.ax-conversation-msg__grid--single ::ng-deep .ax-conversation-image-attachment{max-height:min(50dvh,20rem)}.ax-conversation-msg__grid--dual{grid-template-columns:repeat(2,1fr)}.ax-conversation-msg__grid--multi{grid-template-columns:repeat(3,1fr);grid-auto-rows:10rem}@container (max-width: 380px){.ax-conversation-msg__grid--multi{grid-template-columns:repeat(2,1fr);grid-auto-rows:10rem}}.ax-conversation-msg__caption{margin:0;padding:0 .125rem;font-size:.8125rem;line-height:1.4;word-break:break-word;opacity:.88}.ax-conversation-msg--flush{width:100%;max-width:100%;gap:0}.ax-conversation-msg--flush .ax-conversation-msg__caption{padding:.375rem .625rem 0}.ax-conversation-msg--flush .ax-conversation-msg__grid{border-radius:0;background:transparent}.ax-conversation-msg--flush .ax-conversation-msg__stack{gap:2px}.ax-conversation-msg--flush ::ng-deep .ax-conversation-video{border-radius:0}.ax-conversation-msg__card{border-radius:var(--ax-sys-border-radius, .5rem);border:1px solid rgb(var(--ax-sys-color-border-light-surface));background:rgb(var(--ax-sys-color-surface));overflow:hidden}\n"] }]
|
|
80
|
+
}], propDecorators: { message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: true }] }] } });
|
|
81
|
+
|
|
82
|
+
export { AXConversationImageRendererComponent };
|
|
83
|
+
//# sourceMappingURL=acorex-components-conversation-image-renderer.component-Cy0TA6cL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-components-conversation-image-renderer.component-Cy0TA6cL.mjs","sources":["../../../../packages/components/conversation/src/lib/plugins/message-list/components/image-renderer/image-renderer.component.ts"],"sourcesContent":["import { AXFileTypeRegistryService } from '@acorex/core/file';\nimport { CommonModule } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core';\nimport type { AXConversationImagePayload, AXConversationMessage } from '../../../../models';\nimport { AXConversationImageAttachmentComponent } from '../shared/image-attachment.component';\nimport {\n AXConversationMessageRendererCopyHostComponent,\n mediaCopyText,\n} from '../shared/message-renderer-copy-host.component';\nimport { copyWithFileTypeFallback } from '../../../../utils/file-type-message.resolve';\nimport { AXConversationMessageRendererStateComponent } from '../shared/message-renderer-state.component';\nimport { AX_CONVERSATION_RENDERER_SHARED_STYLES } from '../shared/renderer-shared.styles';\nimport { normalizeImagePayload } from './image.payload';\n\n@Component({\n selector: 'ax-conversation-image-renderer',\n imports: [CommonModule, AXConversationImageAttachmentComponent, AXConversationMessageRendererStateComponent],\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div class=\"ax-conversation-msg ax-conversation-msg--flush\">\n <div class=\"ax-conversation-msg__grid\" [class]=\"gridModeClass()\">\n @for (image of images(); track image.mediaId ?? image.url) {\n <ax-conversation-image-attachment [item]=\"image\" [alt]=\"caption() || 'Image'\" />\n }\n </div>\n @if (caption()) {\n <p class=\"ax-conversation-msg__caption\">{{ caption() }}</p>\n }\n <ax-conversation-message-renderer-state\n [rendererState]=\"rendererState()\"\n [message]=\"message()\"\n contentErrorLabel=\"Couldn't load image\"\n contentErrorStyle=\"inline\"\n placement=\"below\"\n />\n </div>\n `,\n styles: [AX_CONVERSATION_RENDERER_SHARED_STYLES],\n})\nexport class AXConversationImageRendererComponent extends AXConversationMessageRendererCopyHostComponent {\n private readonly fileTypes = inject(AXFileTypeRegistryService);\n\n readonly message = input.required<AXConversationMessage>();\n readonly rendererState = computed(() => ({\n deliveryStatus: this.message().status,\n contentState: 'ready' as const,\n }));\n\n readonly payload = computed(() => normalizeImagePayload(this.message().payload as AXConversationImagePayload));\n readonly images = computed(() => this.payload().images);\n readonly caption = computed(() => this.payload().caption?.trim() || '');\n\n copy(): Promise<string> {\n return copyWithFileTypeFallback(this.message(), this.fileTypes, () => {\n const p = this.payload();\n return mediaCopyText(\n p.caption,\n 'Image',\n 'images',\n p.images.length,\n p.images.map((item) => item.url?.trim() || item.thumbnailUrl?.trim()),\n );\n });\n }\n\n readonly gridModeClass = computed(() => {\n const n = this.images().length;\n if (n <= 1) return 'ax-conversation-msg__grid--single';\n if (n === 2) return 'ax-conversation-msg__grid--dual';\n return 'ax-conversation-msg__grid--multi';\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;AAuCM,MAAO,oCAAqC,SAAQ,8CAA8C,CAAA;AAzBxG,IAAA,WAAA,GAAA;;AA0BmB,QAA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