vue-intergrall-plugins 1.1.11 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +220 -220
  2. package/dist/vue-intergrall-plugins.esm.js +56 -48
  3. package/dist/vue-intergrall-plugins.min.js +1 -1
  4. package/dist/vue-intergrall-plugins.ssr.js +129 -121
  5. package/package.json +66 -66
  6. package/src/lib-components/Buttons/IconButton.vue +27 -27
  7. package/src/lib-components/Buttons/SimpleButton.vue +140 -140
  8. package/src/lib-components/Cards/Card.vue +490 -490
  9. package/src/lib-components/Cards/CardCheck.vue +35 -35
  10. package/src/lib-components/Cards/CardFile.vue +163 -163
  11. package/src/lib-components/Chat/BtnDownloadAllFiles.vue +36 -36
  12. package/src/lib-components/Chat/BtnEmojis.vue +118 -118
  13. package/src/lib-components/Chat/BtnExpand.vue +17 -17
  14. package/src/lib-components/Chat/BtnFiles.vue +486 -486
  15. package/src/lib-components/Chat/BtnMic.vue +60 -60
  16. package/src/lib-components/Chat/BtnScreenShare.vue +31 -31
  17. package/src/lib-components/Chat/BtnStandardMessages.vue +17 -17
  18. package/src/lib-components/Chat/ExpandTextarea.vue +427 -427
  19. package/src/lib-components/Chat/MultipleFilePreview.vue +291 -291
  20. package/src/lib-components/Chat/Picker.vue +405 -405
  21. package/src/lib-components/Chat/RemainingCharacters.vue +28 -28
  22. package/src/lib-components/Chat/SingleFilePreview.vue +94 -94
  23. package/src/lib-components/Chat/SkeletonPicker.vue +110 -110
  24. package/src/lib-components/Chat/StandardMessages.vue +252 -252
  25. package/src/lib-components/Chat/TextFooter.vue +1007 -1007
  26. package/src/lib-components/Email/EmailExpanded.vue +270 -270
  27. package/src/lib-components/Email/EmailFile.vue +192 -192
  28. package/src/lib-components/Email/EmailFrom.vue +66 -66
  29. package/src/lib-components/Email/EmailItem.vue +941 -933
  30. package/src/lib-components/Email/EmailTo.vue +57 -57
  31. package/src/lib-components/Loader/Loader.vue +78 -78
  32. package/src/lib-components/Messages/AnexoMensagem.vue +415 -415
  33. package/src/lib-components/Messages/CardAttachment.vue +61 -61
  34. package/src/lib-components/Messages/CardMessages.vue +687 -687
  35. package/src/lib-components/Messages/InteratividadeBotoes.vue +199 -199
  36. package/src/lib-components/Messages/InteratividadeContato.vue +32 -32
  37. package/src/lib-components/Messages/InteratividadeContatoItem.vue +213 -213
  38. package/src/lib-components/Messages/InteratividadeFormulario.vue +334 -334
  39. package/src/lib-components/Messages/InteratividadePopup.vue +95 -95
  40. package/src/lib-components/Messages/LinkPreview.vue +176 -176
  41. package/src/lib-components/Scroll/ScrollContent.vue +166 -166
  42. package/src/lib-components/Templates/TemplateGenerator.vue +640 -640
  43. package/src/lib-components/Templates/TemplateMessage.vue +83 -83
  44. package/src/lib-components/Templates/TemplateSingle.vue +478 -478
@@ -1,934 +1,942 @@
1
- <template>
2
- <div
3
- :class="['email-item box-shadow-active', isOpen ? isOpenClass : `${isClosedClass} cursor-pointer`, showInfos ? 'info-open' : '', origem, customClass]"
4
- @click="openByItem($event)">
5
- <div v-if="showInfos" class="email-overlay"></div>
6
- <div class="email-author" v-if="autor" :class="[origem, isMainEmail ? 'main' : '']" @click.stop="toggleIsOpen"
7
- :key="autor">
8
- <span :title="`Enviado por: ${autor}`"><fa-icon :icon="['fas', 'reply']" :class="[origem]" /></span>
9
- <p class="email-author-name" v-text="returnAuthorName" :title="returnAuthorName"></p>
10
- <span :title="`E-mail ${origem === 'outros' ? 'recebido' : 'enviado'}`">
11
- <fa-icon :icon="['fas', origem === 'outros' ? 'user' : 'headset']" class="email-to-svg" />
12
- </span>
13
- </div>
14
- <div class="email-custom-buttons" v-if="customButtons && customButtons.length" @click.stop>
15
- <span v-for="(button, index) in customButtons" :key="button.id || index" v-show="button.use"
16
- @click="button.callback(returnParams(button.params))" :class="`${button.customClass || 'menu-mensagem'}`"
17
- v-tippy :content="button.tippyContent">
18
- <fa-icon :icon="['fas', button.icon || 'question-circle']" v-if="!button.svgIcon" />
19
- <span v-else v-html="button.svgIcon" :class="button.svgClass ? button.svgClass : ''"></span>
20
- </span>
21
- </div>
22
- <div class="email-custom-action-buttons" v-if="customActionButtons && customActionButtons.length" @click.stop>
23
- <button v-for="(button, index) in customActionButtons" :key="button.id || index" v-show="button.use"
24
- @click="button.callback(returnParams(button.params))"
25
- :class="`${button.customClass || 'email-custom-action-button'}`" v-tippy :content="button.tippyContent">
26
- <fa-icon :icon="['fas', button.icon || 'question-circle']" v-if="!button.svgIcon" />
27
- <span v-else v-html="button.svgIcon" :class="button.svgClass ? button.svgClass : ''"></span>
28
- <span v-if="button.label" class="email-custom-action-label" v-text="button.label"></span>
29
- </button>
30
- </div>
31
- <div class="email-header" @click.stop="toggleIsOpen">
32
- <p class="email-subject" :title="returnMainValue()">
33
- {{ returnMainValue() }}
34
- </p>
35
- <div class="header-container">
36
- <div :class="`email-header-content${isOpen ? ' open' : ''}`">
37
- <div class="email-header-infos">
38
- <template v-if="para && para.length">
39
- <div class="email-to-from-container" ref="emailToContainer">
40
- <EmailTo v-for="(recipient, index) in paraCopia" :key="`to-${recipient.email}`"
41
- :currentName="formattedToName(recipient.name, index, paraCopia.length)" :email="recipient.email"
42
- :showMail="isOpen" />
43
- <div class="email-to-btn" v-show="isOpen" @click.stop="toggleShowInfos()">
44
- <fa-icon :icon="['fas', 'caret-down']" />
45
- </div>
46
- </div>
47
- </template>
48
- <div v-if="!isMainEmail && isOpen" class="email-subject-secondary">
49
- <span class="email-subject-span"
50
- v-text="`Assunto: ${htmlEntityToEmoji(replaceUnicodeWithEmoji(assunto)) || '(Sem assunto)'}`"></span>
51
- </div>
52
- </div>
53
- </div>
54
- <span :class="`email-date ${isOpen ? isOpenClass : isClosedClass}`" :title="formattedDate" ref="emailDate"
55
- v-show="formattedDate">
56
- <fa-icon :icon="['fas', 'calendar']" />
57
- {{ formattedDate }}
58
- </span>
59
- </div>
60
- <ul v-if="showInfos" ref="emailToInfos" class="email-to-infos box-shadow" v-clickaway="() => showInfos = false"
61
- @click.stop>
62
- <li v-for="(info, index) in mailInfos" :key="`info-${index}`" class="email-info">
63
- <span v-text="info.label"></span>
64
- {{ info.value }}
65
- </li>
66
- </ul>
67
- <span v-if="isOpen" :class="['email-actions box-shadow', { active: actionsOpen }, { main: isMainEmail }]"
68
- @click.stop="toggleActions">
69
- <span></span>
70
- <span></span>
71
- <span></span>
72
- </span>
73
- <ul class="email-actions-list box-shadow" v-if="actionsOpen && isOpen" v-clickaway="closeActions" @click.stop>
74
- <li class="email-action" @click.stop="toggleOpenMessage">
75
- {{ !openMessage ? 'Visualizar' : 'Esconder' }} texto do e-mail
76
- </li>
77
- </ul>
78
- </div>
79
- <div class="email-content" v-show="isOpen" ref="emailIframeParent">
80
- <VueLoader v-if="isIframeLoading" />
81
- <div v-if="hasError" class="email-error-content">
82
- <p>Erro ao carregar o e-mail</p>
83
- <button class="box-shadow" @click="handleTryAgain()">Tentar novamente</button>
84
- </div>
85
- <iframe v-show="!hasError" ref="emailIframe"
86
- :class="`email-html ${isIframeLoading ? 'visibility-hidden' : ''}`"></iframe>
87
- <span class="email-raw" v-if="openMessage">{{ mensagem }}</span>
88
- </div>
89
- <div v-if="filteredFiles && filteredFiles.length" class="email-files" v-show="isOpen || isMainEmail">
90
- <EmailFile v-for="(anexo, index) in filteredFiles" :key="index" :anexo="anexo" :dominio="dominio" />
91
- </div>
92
- </div>
93
- </template>
94
-
95
- <script>
96
- import EmailFile from "./EmailFile.vue";
97
- import EmailTo from "./EmailTo.vue";
98
- import { textoLongo } from "@/mixins/formatarTexto";
99
- import Clickaway from '@/directives/clickaway';
100
-
101
- export default {
102
- mixins: [textoLongo],
103
- directives: {
104
- clickaway: Clickaway
105
- },
106
- components: { EmailFile, EmailTo },
107
- props: {
108
- dominio: {
109
- type: String,
110
- required: true
111
- },
112
- dicionario: {
113
- type: Object,
114
- required: true
115
- },
116
- customClass: {
117
- type: String,
118
- default: ''
119
- },
120
- from: {
121
- type: Array,
122
- default: () => []
123
- },
124
- para: {
125
- type: Array,
126
- default: () => []
127
- },
128
- copia: {
129
- type: Array,
130
- default: () => []
131
- },
132
- html: {
133
- type: String,
134
- default: ""
135
- },
136
- assunto: {
137
- type: String,
138
- default: ""
139
- },
140
- dataHora: {
141
- type: String,
142
- default: ""
143
- },
144
- mensagem: {
145
- type: String,
146
- default: ""
147
- },
148
- anexos: {
149
- type: [Array, String],
150
- default: () => []
151
- },
152
- iniciarAberto: {
153
- type: Boolean,
154
- default: false
155
- },
156
- dataServer: {
157
- type: String,
158
- default: ""
159
- },
160
- isOpenClass: {
161
- type: String,
162
- default: 'bg-dark-white-2'
163
- },
164
- isClosedClass: {
165
- type: String,
166
- default: 'bg-white'
167
- },
168
- refKey: {
169
- type: String,
170
- },
171
- showRawMessageInsideEmail: {
172
- type: Boolean,
173
- default: false
174
- },
175
- origem: {
176
- type: String,
177
- default: 'outros'
178
- },
179
- autor: {
180
- type: String
181
- },
182
- isMainEmail: {
183
- type: Boolean,
184
- default: true
185
- },
186
- customButtons: {
187
- type: Array
188
- },
189
- customActionButtons: {
190
- type: Array
191
- }
192
- },
193
- data() {
194
- return {
195
- isOpen: this.iniciarAberto,
196
- openMessage: false,
197
- actionsOpen: false,
198
- showInfos: false,
199
- isIframeLoading: true,
200
- hasError: false,
201
- errorCount: 0
202
- };
203
- },
204
- computed: {
205
- paraCopia() {
206
- if (!this.copia || !this.copia.length) return this.para && this.para.length ? this.para : []
207
- return this.para && this.para.length ? this.para.concat(this.copia) : this.copia
208
- },
209
- formattedDate() {
210
- return this.formataDateHoraDateFns(this.dataHora, this.dataServer, this.dicionario);
211
- },
212
- mailInfos() {
213
- const formatAsString = (arr) => {
214
- let str = ''
215
- arr.forEach(({ name, email }, index) => {
216
- if (!name && !email) str += ''
217
- else str += `${name || ''} ${email ? `<${email}>` : ''}${((name || email) && index !== arr.length - 1) ? ', ' : ''}`
218
- })
219
- return str
220
- }
221
-
222
- const infos = [
223
- {
224
- label: 'De:',
225
- value: this.from && this.from.length ? formatAsString(this.from) : '--'
226
- },
227
- {
228
- label: 'Para:',
229
- value: this.para && this.para.length ? formatAsString(this.para) : '--'
230
- },
231
- {
232
- label: 'Assunto:',
233
- value: this.htmlEntityToEmoji(this.replaceUnicodeWithEmoji(this.assunto)) || '(Sem assunto)'
234
- },
235
- {
236
- label: 'Data:',
237
- value: this.formataDataHora(this.dataHora) || '--'
238
- },
239
- ]
240
-
241
- if (this.copia && this.copia.length) {
242
- infos.push({
243
- label: this.dicionario.tit_copia,
244
- value: formatAsString(this.copia)
245
- })
246
- }
247
-
248
- return infos
249
- },
250
- filteredFiles() {
251
- if (!this.anexos || !this.anexos.length) return
252
-
253
- return this.anexos.filter(anexo => {
254
- return !this.html.includes(anexo.name);
255
- })
256
- },
257
- returnAuthorName() {
258
- if (!this.from || !this.from.length) return this.autor || ''
259
- const { email, name } = this.from[0]
260
- if (!name) return email
261
- if (!email) return name
262
- if (this.isOpen) return `${name} (${email})`
263
- return name
264
- },
265
- formattedToName() {
266
- return (name, index, length) => {
267
- let addVirgulaDps = index < length - 1
268
- let addVirgulaAntes = index === 1 && length >= 2
269
- const text = index === 0 ? `Para: ${name || ''}` : name ? `${addVirgulaAntes ? ', ' : ''}${name}${addVirgulaDps ? ', ' : ''}` : '';
270
- return text
271
- }
272
- }
273
- },
274
- watch: {
275
- isOpen: 'updateIframeContent'
276
- },
277
- mounted() {
278
- this.updateIframeContent();
279
- this.adjustMaxWidth()
280
-
281
- if (this.refKey) this.$root.$refs[`${refKey}`] = this
282
-
283
- setTimeout(() => {
284
- if (this.isIframeLoading) this.adjustIframeHeight()
285
- }, 15000);
286
- },
287
- methods: {
288
- handleTryAgain() {
289
- this.isOpen = true
290
- this.isIframeLoading = true
291
- this.hasError = false
292
-
293
- this.$nextTick(this.updateIframeContent())
294
- },
295
- gerarMensagemEstilizada(msg) {
296
- try {
297
- const currentStyles = [
298
- { tagAbertura: "<i>", tagFechamento: "</i>", find: /_(.*?)_/g },
299
- { tagAbertura: "<b>", tagFechamento: "</b>", find: /\*(.*?)\*/g },
300
- { tagAbertura: "<del>", tagFechamento: "</del>", find: /~(.*?)~/g }
301
- ]
302
-
303
- const isLetterOrUnderscore = (char) => {
304
- return /[a-zA-Z_]/.test(char)
305
- }
306
-
307
- const isValidMatch = (message, fullMatch, startIndex) => {
308
- const beforeChar = message[startIndex - 1]
309
- const afterChar = message[startIndex + fullMatch.length]
310
- return (
311
- (beforeChar === undefined || !isLetterOrUnderscore(beforeChar)) &&
312
- (afterChar === undefined || !isLetterOrUnderscore(afterChar))
313
- )
314
- }
315
-
316
- let message = msg
317
-
318
- for (const { tagAbertura, tagFechamento, find } of currentStyles) {
319
- let match
320
- while ((match = find.exec(message)) !== null) {
321
- const fullMatch = match[0]
322
- const content = match[1]
323
- const startIndex = match.index
324
-
325
- if (isValidMatch(message, fullMatch, startIndex)) {
326
- const endIndex = startIndex + fullMatch.length
327
- const replacedContent = `${tagAbertura}${content}${tagFechamento}`
328
- message = message.slice(0, startIndex) + replacedContent + message.slice(endIndex)
329
- }
330
- }
331
- }
332
-
333
- return message
334
- } catch (err) {
335
- console.error('Erro ao gerar mensagem estilizada: ', err)
336
- return msg
337
- }
338
- },
339
- updateIframeContent() {
340
- this.$nextTick(() => {
341
- if (this.isOpen && this.isIframeLoading) {
342
- const iframe = this.$refs.emailIframe;
343
- if (!iframe) return
344
- const doc = iframe.contentDocument || iframe.contentWindow.document;
345
- if (!doc) return
346
- let content = this.html
347
- if (!/<[a-z][\s\S]*>/i.test(content)) {
348
- content = content.replace(/\n/g, '<br>');
349
- content = this.gerarMensagemEstilizada(content)
350
- content = `<p>${content}</p>`;
351
- }
352
-
353
- doc.open();
354
- doc.write(content);
355
- doc.close();
356
-
357
- const images = doc.getElementsByTagName('img');
358
- let imagesLoaded = 0;
359
-
360
- const imageLoadHandler = () => {
361
- imagesLoaded++;
362
- if (imagesLoaded === images.length) {
363
- this.adjustIframeHeight();
364
- }
365
- };
366
-
367
- if (images.length === 0) {
368
- this.adjustIframeHeight();
369
- } else {
370
- for (let img of images) {
371
- img.addEventListener('load', imageLoadHandler);
372
- img.addEventListener('error', imageLoadHandler);
373
- }
374
- }
375
- }
376
- });
377
- },
378
- adjustIframeHeight() {
379
- this.$nextTick(() => {
380
- const iframe = this.$refs.emailIframe;
381
- const emailParent = this.$refs.emailIframeParent
382
- if (iframe && emailParent) {
383
- setTimeout(() => {
384
- const doc = iframe.contentDocument || iframe.contentWindow.document;
385
- const margin = 20
386
- const value = doc.documentElement.offsetHeight + margin
387
- if (value === 0 || doc.documentElement.querySelector('body').innerHTML === '') {
388
- this.errorCount++
389
- if (this.errorCount > 3) {
390
- this.hasError = true
391
- if (this.isIframeLoading) this.isIframeLoading = false
392
- return
393
- }
394
- this.isIframeLoading = true
395
- this.updateIframeContent()
396
- return
397
- }
398
- if (this.hasError || this.errorCount > 0) {
399
- this.hasError = false
400
- this.errorCount = 0
401
- }
402
- iframe.style.height = `${value}px`;
403
- emailParent.style.minHeight = `${value}px`
404
- }, 100)
405
- }
406
-
407
- if (this.isIframeLoading) this.isIframeLoading = false
408
- });
409
- },
410
- toggleShowInfos() {
411
- this.showInfos = !this.showInfos;
412
- if (this.showInfos) {
413
- this.$nextTick(() => {
414
- this.adjustTopPosition();
415
- });
416
- }
417
- },
418
- adjustTopPosition() {
419
- const ulElement = this.$refs.emailToInfos;
420
- if (!ulElement) return
421
- const ulHeight = ulElement.offsetHeight;
422
- const maxHeight = 300
423
- const finalHeight = ulHeight < maxHeight ? ulHeight : maxHeight
424
- ulElement.style.bottom = `-${finalHeight}px`;
425
- },
426
- toggleIsOpen() {
427
- this.isOpen = !this.isOpen;
428
- if (!this.isOpen) {
429
- this.actionsOpen = false;
430
- this.openMessage = false;
431
- this.showInfos = false
432
- }
433
- },
434
- adjustMaxWidth() {
435
- this.$nextTick(() => {
436
- const toContainer = this.$refs.emailToContainer
437
- const dateContainer = this.$refs.emailDate
438
- if (!toContainer || !dateContainer) return
439
- toContainer.style.maxWidth = `calc(100% - ${dateContainer.offsetWidth}px)`
440
- })
441
- },
442
- toggleActions() {
443
- this.actionsOpen = !this.actionsOpen;
444
- },
445
- toggleOpenMessage() {
446
- if (this.showRawMessageInsideEmail) {
447
- this.openMessage = !this.openMessage;
448
- }
449
-
450
- this.$emit('open-message', {
451
- dicionario: this.dicionario,
452
- from: this.from,
453
- para: this.para,
454
- html: this.html,
455
- assunto: this.assunto,
456
- dataHora: this.dataHora,
457
- mensagem: this.mensagem,
458
- anexos: this.filteredFiles,
459
- dataServer: this.dataServer,
460
- dominio: this.dominio
461
- })
462
- },
463
- closeActions() {
464
- this.actionsOpen = false;
465
- },
466
- returnMainValue() {
467
- if (this.isMainEmail) return this.htmlEntityToEmoji(this.replaceUnicodeWithEmoji(this.assunto)) || '(Sem assunto)'
468
- return ''
469
- },
470
- openByItem(event) {
471
- if (this.isOpen) return;
472
-
473
- event.preventDefault();
474
- event.stopPropagation();
475
-
476
- this.toggleIsOpen();
477
- },
478
- returnParams(params) {
479
- const defaultParams = {
480
- message: this.mensagem,
481
- };
482
-
483
- if (!params) return defaultParams;
484
-
485
- const keys = params.instanceKeys.split("|");
486
- if (!keys || !keys.length)
487
- return {
488
- defaultParams,
489
- ...params.values,
490
- };
491
-
492
- const customParams = { ...params.values };
493
- keys.forEach((key) => {
494
- if (this[key]) customParams[key] = this[key];
495
- else console.warn(`Cant find ${key} on 'this' instance`);
496
- });
497
-
498
- return Object.keys(customParams).length ? customParams : defaultParams;
499
- }
500
- }
501
- };
502
- </script>
503
-
504
- <style scoped>
505
- .show-y-top-enter-active,
506
- .show-y-top-leave-enter {
507
- opacity: 1;
508
- transform: translateY(0);
509
- transition: all 200ms linear;
510
- }
511
-
512
- .show-y-top-enter,
513
- .show-y-top-leave-to {
514
- opacity: 0;
515
- transform: translateY(-2%);
516
- }
517
- </style>
518
-
519
- <style>
520
- .visibility-hidden {
521
- visibility: hidden;
522
- }
523
-
524
- .box-shadow-active {
525
- box-shadow: 0px 0px 4px 2px rgba(0, 0, 0, 0.25);
526
- }
527
-
528
- .bg-dark-white-2 {
529
- background-color: #f7f7f7;
530
- }
531
-
532
- .bg-white {
533
- background-color: #FFF;
534
- }
535
-
536
- .cursor-pointer {
537
- cursor: pointer;
538
- }
539
-
540
- .email-overlay {
541
- width: 100%;
542
- height: 100%;
543
- background-color: transparent;
544
- z-index: 1;
545
- position: absolute;
546
- top: 0;
547
- left: 0;
548
- }
549
-
550
- .email-item {
551
- --konecta-gray-3: #515050;
552
- --konecta-light: #f8f9fa;
553
- --blue-silver-4: #dae0e5;
554
- --email-principal: #faa732;
555
- --email-outros: #86b7fe;
556
- font-family: "Roboto", sans-serif;
557
- flex: 1;
558
- margin: 0 0 10px 0;
559
- color: #222;
560
- min-height: 60px;
561
- display: flex;
562
- flex-wrap: wrap;
563
- padding: 10px;
564
- border-radius: 5px;
565
- transition: all 150ms ease-in-out;
566
- max-width: 100%;
567
- width: 100%;
568
- overflow: hidden;
569
- position: relative;
570
- }
571
-
572
- .email-custom-action-buttons {
573
- display: flex;
574
- gap: 7px;
575
- align-items: center;
576
- flex-wrap: wrap;
577
- max-width: 100%;
578
- cursor: default;
579
- }
580
-
581
- .email-custom-action-button {
582
- margin-top: 10px;
583
- background-color: var(--konecta-light) !important;
584
- color: var(--konecta-dark) !important;
585
- border: 1px solid var(--blue-silver-4) !important;
586
- flex: 1;
587
- min-width: 100px;
588
- display: flex;
589
- align-items: center;
590
- justify-content: center;
591
- gap: 5px;
592
- padding: 5px;
593
- overflow: hidden;
594
- border-radius: 5px;
595
- text-overflow: ellipsis;
596
- white-space: nowrap;
597
- transition: all 100ms ease-in-out;
598
- max-width: 100%;
599
- cursor: pointer
600
- }
601
-
602
- .email-custom-action-button:hover {
603
- background-color: #e9ecef !important;
604
- }
605
-
606
- .email-custom-action-button:disabled {
607
- background-color: var(--konecta-gray-3) !important;
608
- border: 1px solid #25282b !important;
609
- cursor: not-allowed !important;
610
- }
611
-
612
- .email-item.outros {
613
- border-left: 3px solid var(--email-outros);
614
- }
615
-
616
- .email-author-name {
617
- margin: 0 5px;
618
- max-width: 100%;
619
- overflow: hidden;
620
- text-overflow: ellipsis;
621
- white-space: nowrap;
622
- }
623
-
624
- .email-author.outros {
625
- color: var(--email-outros);
626
- }
627
-
628
- .email-author.outros>svg:nth-child(1) {
629
- transform: rotate(180deg);
630
- }
631
-
632
- .email-author.principal {
633
- color: var(--email-principal);
634
- }
635
-
636
- .email-author.main {
637
- font-size: 16.4px;
638
- }
639
-
640
- .email-item.principal {
641
- border-left: 3px solid var(--email-principal);
642
- }
643
-
644
- .email-item.info-open {
645
- overflow: visible
646
- }
647
-
648
- .email-header {
649
- width: 100%;
650
- display: flex;
651
- flex-direction: column;
652
- cursor: pointer;
653
- border-top-right-radius: 5px;
654
- border-top-left-radius: 5px;
655
- position: relative;
656
- overflow: visible;
657
- }
658
-
659
- .header-container {
660
- display: flex;
661
- overflow: hidden;
662
- position: relative;
663
- }
664
-
665
- .email-header-content {
666
- display: flex;
667
- align-items: center;
668
- flex: 1;
669
- min-width: 250px;
670
- }
671
-
672
- .email-header-infos {
673
- display: flex;
674
- flex-direction: column;
675
- flex: 1;
676
- }
677
-
678
- .email-subject {
679
- margin: 5px 0 0 0;
680
- font-size: 16.4px;
681
- cursor: pointer;
682
- }
683
-
684
- .email-date {
685
- --width: 245px;
686
- font-size: 12.8px;
687
- text-overflow: ellipsis;
688
- white-space: nowrap;
689
- overflow: hidden;
690
- position: absolute;
691
- right: 0;
692
- top: 0;
693
- min-width: var(--width);
694
- width: var(--width);
695
- max-width: var(--width);
696
- display: flex;
697
- justify-content: flex-end;
698
- gap: 3px;
699
- align-items: center;
700
- }
701
-
702
- .email-content {
703
- display: flex;
704
- flex-direction: column;
705
- align-items: center;
706
- justify-content: flex-start;
707
- width: 100%;
708
- background-color: #FFF;
709
- position: relative;
710
- max-width: 100%;
711
- }
712
-
713
- .email-actions {
714
- align-self: flex-end;
715
- display: flex;
716
- border-radius: 10px;
717
- cursor: pointer;
718
- align-items: center;
719
- justify-content: center;
720
- gap: 3px;
721
- padding: 5px 7px;
722
- background-color: #dddddd;
723
- position: absolute;
724
- right: 0;
725
- top: 30px;
726
- z-index: 1;
727
- }
728
-
729
- .email-actions.main {
730
- top: 10px
731
- }
732
-
733
- .email-actions.active {
734
- background-color: #dfdfdf;
735
- }
736
-
737
- .email-actions>span {
738
- width: 4px;
739
- height: 4px;
740
- min-width: 4px;
741
- min-height: 4px;
742
- max-width: 4px;
743
- max-height: 4px;
744
- background-color: #222;
745
- border-radius: 50%;
746
- }
747
-
748
- .email-actions-list {
749
- position: absolute;
750
- right: 45px;
751
- width: 250px;
752
- top: 5px;
753
- margin: 0;
754
- list-style-type: none;
755
- padding: 0;
756
- border-radius: 5px;
757
- z-index: 1;
758
- }
759
-
760
- .email-action {
761
- background-color: #dfdfdf;
762
- padding: 5px 10px;
763
- cursor: pointer;
764
- transition: background-color 150ms ease-in-out;
765
- font-size: 14.4px;
766
- user-select: none;
767
- }
768
-
769
- .email-action:nth-child(1) {
770
- border-top-left-radius: 5px;
771
- border-top-right-radius: 5px;
772
- }
773
-
774
- .email-action:last-child {
775
- border-bottom-left-radius: 5px;
776
- border-bottom-right-radius: 5px;
777
- }
778
-
779
- .email-action:hover {
780
- background-color: #CCC;
781
- }
782
-
783
- .email-html {
784
- width: 100%;
785
- min-width: 300px;
786
- max-width: 100%;
787
- border: none;
788
- overflow: auto;
789
- }
790
-
791
- .email-raw {
792
- width: 100%;
793
- max-width: 100%;
794
- padding: 15px;
795
- font-size: 14.4px;
796
- color: #222;
797
- }
798
-
799
- .email-files {
800
- display: flex;
801
- gap: 10px;
802
- flex-wrap: wrap;
803
- width: 100%;
804
- margin-top: 5px;
805
- }
806
-
807
- .email-header-content,
808
- .email-header-infos {
809
- max-width: 100%;
810
- overflow: hidden;
811
- }
812
-
813
- .email-to-from-container {
814
- margin-bottom: 5px;
815
- max-width: 100%;
816
- min-width: 250px;
817
- overflow: hidden;
818
- display: flex;
819
- align-items: center;
820
- flex-wrap: wrap;
821
- flex: 1;
822
- gap: 5px;
823
- }
824
-
825
- .email-to-btn {
826
- padding: 0 5px;
827
- font-size: 14.4px;
828
- cursor: pointer;
829
- color: #666;
830
- }
831
-
832
- .email-to-infos {
833
- position: absolute;
834
- bottom: -325px;
835
- border: 1px solid #CCC;
836
- z-index: 2;
837
- padding: 10px;
838
- background-color: #FFF;
839
- max-height: 300px;
840
- overflow-y: auto;
841
- overflow-x: hidden;
842
- width: 300px;
843
- display: flex;
844
- flex-direction: column;
845
- gap: 5px;
846
- margin: 0;
847
- cursor: default;
848
- }
849
-
850
- .email-info {
851
- width: 100%;
852
- font-size: 12.8px;
853
- }
854
-
855
- .email-info>span {
856
- font-size: 12px;
857
- color: gray;
858
- margin-right: 3px;
859
- }
860
-
861
- .email-author {
862
- display: flex;
863
- align-items: center;
864
- height: 5px;
865
- font-size: 12px;
866
- font-weight: bold;
867
- transform: translateY(-2px);
868
- width: 100%;
869
- cursor: pointer;
870
- }
871
-
872
- .email-subject-secondary {
873
- margin-top: -5px;
874
- }
875
-
876
- .email-subject-span {
877
- font-size: 11.2px;
878
- color: gray;
879
- }
880
-
881
- .email-to-svg {
882
- font-size: 13.6px;
883
- }
884
-
885
- .email-custom-buttons {
886
- display: flex;
887
- gap: 7px;
888
- position: absolute;
889
- top: 5px;
890
- right: 5px;
891
- z-index: 1;
892
- font-size: 12.8px;
893
- }
894
-
895
- .menu-mensagem {
896
- cursor: pointer;
897
- padding: 1px;
898
- opacity: .7;
899
- transition: opacity 100ms ease-in-out;
900
- }
901
-
902
- .menu-mensagem:hover,
903
- .menu-mensagem:focus,
904
- .menu-mensagem:active {
905
- opacity: 1;
906
- }
907
-
908
- .email-error-content {
909
- display: flex;
910
- justify-content: center;
911
- align-items: center;
912
- flex-direction: column;
913
- gap: 5px;
914
- padding: 10px;
915
- }
916
-
917
- .email-error-content p {
918
- margin: 0;
919
- color: #E74C3C;
920
- }
921
-
922
- .email-error-content button {
923
- border: 1px solid #CCC;
924
- border-radius: 3px;
925
- padding: 5px 10px;
926
- background-color: #FFF;
927
- cursor: pointer;
928
- transition: background-color 150ms ease-in-out;
929
- }
930
-
931
- .email-error-content button:hover {
932
- background-color: #EEE;
933
- }
1
+ <template>
2
+ <div
3
+ :class="['email-item box-shadow-active', isOpen ? isOpenClass : `${isClosedClass} cursor-pointer`, showInfos ? 'info-open' : '', origem, customClass]"
4
+ @click="openByItem($event)">
5
+ <div v-if="showInfos" class="email-overlay"></div>
6
+ <div class="email-author" v-if="autor" :class="[origem, isMainEmail ? 'main' : '']" @click.stop="toggleIsOpen"
7
+ :key="autor">
8
+ <span :title="`Enviado ${status !== 'C' ? '' : status_msg ? status_msg : 'com erro'} por: ${autor}`"><fa-icon :icon="['fas', status !== 'C' ? 'reply' : 'times']" :class="[origem]" /></span>
9
+ <p class="email-author-name" v-text="returnAuthorName" :title="returnAuthorName"></p>
10
+ <span :title="`E-mail ${origem === 'outros' ? 'recebido' : 'enviado'}`">
11
+ <fa-icon :icon="['fas', origem === 'outros' ? 'user' : 'headset']" class="email-to-svg" />
12
+ </span>
13
+ </div>
14
+ <div class="email-custom-buttons" v-if="customButtons && customButtons.length" @click.stop>
15
+ <span v-for="(button, index) in customButtons" :key="button.id || index" v-show="button.use"
16
+ @click="button.callback ? button.callback(returnParams(button.params)) : $emit(button.emitName, returnParams(button.params))" :class="`${button.customClass || 'menu-mensagem'}`"
17
+ v-tippy :content="button.tippyContent">
18
+ <fa-icon :icon="['fas', button.icon || 'question-circle']" v-if="!button.svgIcon" />
19
+ <span v-else v-html="button.svgIcon" :class="button.svgClass ? button.svgClass : ''"></span>
20
+ </span>
21
+ </div>
22
+ <div class="email-custom-action-buttons" v-if="customActionButtons && customActionButtons.length" @click.stop>
23
+ <button v-for="(button, index) in customActionButtons" :key="button.id || index" v-show="button.use"
24
+ @click="button.callback(returnParams(button.params))"
25
+ :class="`${button.customClass || 'email-custom-action-button'}`" v-tippy :content="button.tippyContent">
26
+ <fa-icon :icon="['fas', button.icon || 'question-circle']" v-if="!button.svgIcon" />
27
+ <span v-else v-html="button.svgIcon" :class="button.svgClass ? button.svgClass : ''"></span>
28
+ <span v-if="button.label" class="email-custom-action-label" v-text="button.label"></span>
29
+ </button>
30
+ </div>
31
+ <div class="email-header" @click.stop="toggleIsOpen">
32
+ <p class="email-subject" :title="returnMainValue()">
33
+ {{ returnMainValue() }}
34
+ </p>
35
+ <div class="header-container">
36
+ <div :class="`email-header-content${isOpen ? ' open' : ''}`">
37
+ <div class="email-header-infos">
38
+ <template v-if="para && para.length">
39
+ <div class="email-to-from-container" ref="emailToContainer">
40
+ <EmailTo v-for="(recipient, index) in paraCopia" :key="`to-${recipient.email}`"
41
+ :currentName="formattedToName(recipient.name, index, paraCopia.length)" :email="recipient.email"
42
+ :showMail="isOpen" />
43
+ <div class="email-to-btn" v-show="isOpen" @click.stop="toggleShowInfos()">
44
+ <fa-icon :icon="['fas', 'caret-down']" />
45
+ </div>
46
+ </div>
47
+ </template>
48
+ <div v-if="!isMainEmail && isOpen" class="email-subject-secondary">
49
+ <span class="email-subject-span"
50
+ v-text="`Assunto: ${htmlEntityToEmoji(replaceUnicodeWithEmoji(assunto)) || '(Sem assunto)'}`"></span>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ <span :class="`email-date ${isOpen ? isOpenClass : isClosedClass}`" :title="formattedDate" ref="emailDate"
55
+ v-show="formattedDate">
56
+ <fa-icon :icon="['fas', 'calendar']" />
57
+ {{ formattedDate }}
58
+ </span>
59
+ </div>
60
+ <ul v-if="showInfos" ref="emailToInfos" class="email-to-infos box-shadow" v-clickaway="() => showInfos = false"
61
+ @click.stop>
62
+ <li v-for="(info, index) in mailInfos" :key="`info-${index}`" class="email-info">
63
+ <span v-text="info.label"></span>
64
+ {{ info.value }}
65
+ </li>
66
+ </ul>
67
+ <span v-if="isOpen" :class="['email-actions box-shadow', { active: actionsOpen }, { main: isMainEmail }]"
68
+ @click.stop="toggleActions">
69
+ <span></span>
70
+ <span></span>
71
+ <span></span>
72
+ </span>
73
+ <ul class="email-actions-list box-shadow" v-if="actionsOpen && isOpen" v-clickaway="closeActions" @click.stop>
74
+ <li class="email-action" @click.stop="toggleOpenMessage">
75
+ {{ !openMessage ? 'Visualizar' : 'Esconder' }} texto do e-mail
76
+ </li>
77
+ </ul>
78
+ </div>
79
+ <div class="email-content" v-show="isOpen" ref="emailIframeParent">
80
+ <VueLoader v-if="isIframeLoading" />
81
+ <div v-if="hasError" class="email-error-content">
82
+ <p>Erro ao carregar o e-mail</p>
83
+ <button class="box-shadow" @click="handleTryAgain()">Tentar novamente</button>
84
+ </div>
85
+ <iframe v-show="!hasError" ref="emailIframe"
86
+ :class="`email-html ${isIframeLoading ? 'visibility-hidden' : ''}`"></iframe>
87
+ <span class="email-raw" v-if="openMessage">{{ mensagem }}</span>
88
+ </div>
89
+ <div v-if="filteredFiles && filteredFiles.length" class="email-files" v-show="isOpen || isMainEmail">
90
+ <EmailFile v-for="(anexo, index) in filteredFiles" :key="index" :anexo="anexo" :dominio="dominio" />
91
+ </div>
92
+ </div>
93
+ </template>
94
+
95
+ <script>
96
+ import EmailFile from "./EmailFile.vue";
97
+ import EmailTo from "./EmailTo.vue";
98
+ import { textoLongo } from "@/mixins/formatarTexto";
99
+ import Clickaway from '@/directives/clickaway';
100
+
101
+ export default {
102
+ mixins: [textoLongo],
103
+ directives: {
104
+ clickaway: Clickaway
105
+ },
106
+ components: { EmailFile, EmailTo },
107
+ props: {
108
+ dominio: {
109
+ type: String,
110
+ required: true
111
+ },
112
+ dicionario: {
113
+ type: Object,
114
+ required: true
115
+ },
116
+ customClass: {
117
+ type: String,
118
+ default: ''
119
+ },
120
+ from: {
121
+ type: Array,
122
+ default: () => []
123
+ },
124
+ para: {
125
+ type: Array,
126
+ default: () => []
127
+ },
128
+ copia: {
129
+ type: Array,
130
+ default: () => []
131
+ },
132
+ html: {
133
+ type: String,
134
+ default: ""
135
+ },
136
+ assunto: {
137
+ type: String,
138
+ default: ""
139
+ },
140
+ dataHora: {
141
+ type: String,
142
+ default: ""
143
+ },
144
+ mensagem: {
145
+ type: String,
146
+ default: ""
147
+ },
148
+ anexos: {
149
+ type: [Array, String],
150
+ default: () => []
151
+ },
152
+ iniciarAberto: {
153
+ type: Boolean,
154
+ default: false
155
+ },
156
+ dataServer: {
157
+ type: String,
158
+ default: ""
159
+ },
160
+ isOpenClass: {
161
+ type: String,
162
+ default: 'bg-dark-white-2'
163
+ },
164
+ isClosedClass: {
165
+ type: String,
166
+ default: 'bg-white'
167
+ },
168
+ refKey: {
169
+ type: String,
170
+ },
171
+ showRawMessageInsideEmail: {
172
+ type: Boolean,
173
+ default: false
174
+ },
175
+ origem: {
176
+ type: String,
177
+ default: 'outros'
178
+ },
179
+ autor: {
180
+ type: String
181
+ },
182
+ isMainEmail: {
183
+ type: Boolean,
184
+ default: true
185
+ },
186
+ customButtons: {
187
+ type: Array
188
+ },
189
+ customActionButtons: {
190
+ type: Array
191
+ },
192
+ status: {
193
+ type: String,
194
+ default: ''
195
+ },
196
+ status_msg: {
197
+ type: String,
198
+ default: ''
199
+ }
200
+ },
201
+ data() {
202
+ return {
203
+ isOpen: this.iniciarAberto,
204
+ openMessage: false,
205
+ actionsOpen: false,
206
+ showInfos: false,
207
+ isIframeLoading: true,
208
+ hasError: false,
209
+ errorCount: 0
210
+ };
211
+ },
212
+ computed: {
213
+ paraCopia() {
214
+ if (!this.copia || !this.copia.length) return this.para && this.para.length ? this.para : []
215
+ return this.para && this.para.length ? this.para.concat(this.copia) : this.copia
216
+ },
217
+ formattedDate() {
218
+ return this.formataDateHoraDateFns(this.dataHora, this.dataServer, this.dicionario);
219
+ },
220
+ mailInfos() {
221
+ const formatAsString = (arr) => {
222
+ let str = ''
223
+ arr.forEach(({ name, email }, index) => {
224
+ if (!name && !email) str += ''
225
+ else str += `${name || ''} ${email ? `<${email}>` : ''}${((name || email) && index !== arr.length - 1) ? ', ' : ''}`
226
+ })
227
+ return str
228
+ }
229
+
230
+ const infos = [
231
+ {
232
+ label: 'De:',
233
+ value: this.from && this.from.length ? formatAsString(this.from) : '--'
234
+ },
235
+ {
236
+ label: 'Para:',
237
+ value: this.para && this.para.length ? formatAsString(this.para) : '--'
238
+ },
239
+ {
240
+ label: 'Assunto:',
241
+ value: this.htmlEntityToEmoji(this.replaceUnicodeWithEmoji(this.assunto)) || '(Sem assunto)'
242
+ },
243
+ {
244
+ label: 'Data:',
245
+ value: this.formataDataHora(this.dataHora) || '--'
246
+ },
247
+ ]
248
+
249
+ if (this.copia && this.copia.length) {
250
+ infos.push({
251
+ label: this.dicionario.tit_copia,
252
+ value: formatAsString(this.copia)
253
+ })
254
+ }
255
+
256
+ return infos
257
+ },
258
+ filteredFiles() {
259
+ if (!this.anexos || !this.anexos.length) return
260
+
261
+ return this.anexos.filter(anexo => {
262
+ return !this.html.includes(anexo.name);
263
+ })
264
+ },
265
+ returnAuthorName() {
266
+ if (!this.from || !this.from.length) return this.autor || ''
267
+ const { email, name } = this.from[0]
268
+ if (!name) return email
269
+ if (!email) return name
270
+ if (this.isOpen) return `${name} (${email})`
271
+ return name
272
+ },
273
+ formattedToName() {
274
+ return (name, index, length) => {
275
+ let addVirgulaDps = index < length - 1
276
+ let addVirgulaAntes = index === 1 && length >= 2
277
+ const text = index === 0 ? `Para: ${name || ''}` : name ? `${addVirgulaAntes ? ', ' : ''}${name}${addVirgulaDps ? ', ' : ''}` : '';
278
+ return text
279
+ }
280
+ }
281
+ },
282
+ watch: {
283
+ isOpen: 'updateIframeContent'
284
+ },
285
+ mounted() {
286
+ this.updateIframeContent();
287
+ this.adjustMaxWidth()
288
+
289
+ if (this.refKey) this.$root.$refs[`${refKey}`] = this
290
+
291
+ setTimeout(() => {
292
+ if (this.isIframeLoading) this.adjustIframeHeight()
293
+ }, 15000);
294
+ },
295
+ methods: {
296
+ handleTryAgain() {
297
+ this.isOpen = true
298
+ this.isIframeLoading = true
299
+ this.hasError = false
300
+
301
+ this.$nextTick(this.updateIframeContent())
302
+ },
303
+ gerarMensagemEstilizada(msg) {
304
+ try {
305
+ const currentStyles = [
306
+ { tagAbertura: "<i>", tagFechamento: "</i>", find: /_(.*?)_/g },
307
+ { tagAbertura: "<b>", tagFechamento: "</b>", find: /\*(.*?)\*/g },
308
+ { tagAbertura: "<del>", tagFechamento: "</del>", find: /~(.*?)~/g }
309
+ ]
310
+
311
+ const isLetterOrUnderscore = (char) => {
312
+ return /[a-zA-Z_]/.test(char)
313
+ }
314
+
315
+ const isValidMatch = (message, fullMatch, startIndex) => {
316
+ const beforeChar = message[startIndex - 1]
317
+ const afterChar = message[startIndex + fullMatch.length]
318
+ return (
319
+ (beforeChar === undefined || !isLetterOrUnderscore(beforeChar)) &&
320
+ (afterChar === undefined || !isLetterOrUnderscore(afterChar))
321
+ )
322
+ }
323
+
324
+ let message = msg
325
+
326
+ for (const { tagAbertura, tagFechamento, find } of currentStyles) {
327
+ let match
328
+ while ((match = find.exec(message)) !== null) {
329
+ const fullMatch = match[0]
330
+ const content = match[1]
331
+ const startIndex = match.index
332
+
333
+ if (isValidMatch(message, fullMatch, startIndex)) {
334
+ const endIndex = startIndex + fullMatch.length
335
+ const replacedContent = `${tagAbertura}${content}${tagFechamento}`
336
+ message = message.slice(0, startIndex) + replacedContent + message.slice(endIndex)
337
+ }
338
+ }
339
+ }
340
+
341
+ return message
342
+ } catch (err) {
343
+ console.error('Erro ao gerar mensagem estilizada: ', err)
344
+ return msg
345
+ }
346
+ },
347
+ updateIframeContent() {
348
+ this.$nextTick(() => {
349
+ if (this.isOpen && this.isIframeLoading) {
350
+ const iframe = this.$refs.emailIframe;
351
+ if (!iframe) return
352
+ const doc = iframe.contentDocument || iframe.contentWindow.document;
353
+ if (!doc) return
354
+ let content = this.html
355
+ if (!/<[a-z][\s\S]*>/i.test(content)) {
356
+ content = content.replace(/\n/g, '<br>');
357
+ content = this.gerarMensagemEstilizada(content)
358
+ content = `<p>${content}</p>`;
359
+ }
360
+
361
+ doc.open();
362
+ doc.write(content);
363
+ doc.close();
364
+
365
+ const images = doc.getElementsByTagName('img');
366
+ let imagesLoaded = 0;
367
+
368
+ const imageLoadHandler = () => {
369
+ imagesLoaded++;
370
+ if (imagesLoaded === images.length) {
371
+ this.adjustIframeHeight();
372
+ }
373
+ };
374
+
375
+ if (images.length === 0) {
376
+ this.adjustIframeHeight();
377
+ } else {
378
+ for (let img of images) {
379
+ img.addEventListener('load', imageLoadHandler);
380
+ img.addEventListener('error', imageLoadHandler);
381
+ }
382
+ }
383
+ }
384
+ });
385
+ },
386
+ adjustIframeHeight() {
387
+ this.$nextTick(() => {
388
+ const iframe = this.$refs.emailIframe;
389
+ const emailParent = this.$refs.emailIframeParent
390
+ if (iframe && emailParent) {
391
+ setTimeout(() => {
392
+ const doc = iframe.contentDocument || iframe.contentWindow.document;
393
+ const margin = 20
394
+ const value = doc.documentElement.offsetHeight + margin
395
+ if (value === 0 || doc.documentElement.querySelector('body').innerHTML === '') {
396
+ this.errorCount++
397
+ if (this.errorCount > 3) {
398
+ this.hasError = true
399
+ if (this.isIframeLoading) this.isIframeLoading = false
400
+ return
401
+ }
402
+ this.isIframeLoading = true
403
+ this.updateIframeContent()
404
+ return
405
+ }
406
+ if (this.hasError || this.errorCount > 0) {
407
+ this.hasError = false
408
+ this.errorCount = 0
409
+ }
410
+ iframe.style.height = `${value}px`;
411
+ emailParent.style.minHeight = `${value}px`
412
+ }, 100)
413
+ }
414
+
415
+ if (this.isIframeLoading) this.isIframeLoading = false
416
+ });
417
+ },
418
+ toggleShowInfos() {
419
+ this.showInfos = !this.showInfos;
420
+ if (this.showInfos) {
421
+ this.$nextTick(() => {
422
+ this.adjustTopPosition();
423
+ });
424
+ }
425
+ },
426
+ adjustTopPosition() {
427
+ const ulElement = this.$refs.emailToInfos;
428
+ if (!ulElement) return
429
+ const ulHeight = ulElement.offsetHeight;
430
+ const maxHeight = 300
431
+ const finalHeight = ulHeight < maxHeight ? ulHeight : maxHeight
432
+ ulElement.style.bottom = `-${finalHeight}px`;
433
+ },
434
+ toggleIsOpen() {
435
+ this.isOpen = !this.isOpen;
436
+ if (!this.isOpen) {
437
+ this.actionsOpen = false;
438
+ this.openMessage = false;
439
+ this.showInfos = false
440
+ }
441
+ },
442
+ adjustMaxWidth() {
443
+ this.$nextTick(() => {
444
+ const toContainer = this.$refs.emailToContainer
445
+ const dateContainer = this.$refs.emailDate
446
+ if (!toContainer || !dateContainer) return
447
+ toContainer.style.maxWidth = `calc(100% - ${dateContainer.offsetWidth}px)`
448
+ })
449
+ },
450
+ toggleActions() {
451
+ this.actionsOpen = !this.actionsOpen;
452
+ },
453
+ toggleOpenMessage() {
454
+ if (this.showRawMessageInsideEmail) {
455
+ this.openMessage = !this.openMessage;
456
+ }
457
+
458
+ this.$emit('open-message', {
459
+ dicionario: this.dicionario,
460
+ from: this.from,
461
+ para: this.para,
462
+ html: this.html,
463
+ assunto: this.assunto,
464
+ dataHora: this.dataHora,
465
+ mensagem: this.mensagem,
466
+ anexos: this.filteredFiles,
467
+ dataServer: this.dataServer,
468
+ dominio: this.dominio
469
+ })
470
+ },
471
+ closeActions() {
472
+ this.actionsOpen = false;
473
+ },
474
+ returnMainValue() {
475
+ if (this.isMainEmail) return this.htmlEntityToEmoji(this.replaceUnicodeWithEmoji(this.assunto)) || '(Sem assunto)'
476
+ return ''
477
+ },
478
+ openByItem(event) {
479
+ if (this.isOpen) return;
480
+
481
+ event.preventDefault();
482
+ event.stopPropagation();
483
+
484
+ this.toggleIsOpen();
485
+ },
486
+ returnParams(params) {
487
+ const defaultParams = {
488
+ message: this.mensagem,
489
+ };
490
+
491
+ if (!params) return defaultParams;
492
+
493
+ const keys = params.instanceKeys.split("|");
494
+ if (!keys || !keys.length)
495
+ return {
496
+ defaultParams,
497
+ ...params.values,
498
+ };
499
+
500
+ const customParams = { ...params.values };
501
+ keys.forEach((key) => {
502
+ if (this[key]) customParams[key] = this[key];
503
+ else console.warn(`Cant find ${key} on 'this' instance`);
504
+ });
505
+
506
+ return Object.keys(customParams).length ? customParams : defaultParams;
507
+ }
508
+ }
509
+ };
510
+ </script>
511
+
512
+ <style scoped>
513
+ .show-y-top-enter-active,
514
+ .show-y-top-leave-enter {
515
+ opacity: 1;
516
+ transform: translateY(0);
517
+ transition: all 200ms linear;
518
+ }
519
+
520
+ .show-y-top-enter,
521
+ .show-y-top-leave-to {
522
+ opacity: 0;
523
+ transform: translateY(-2%);
524
+ }
525
+ </style>
526
+
527
+ <style>
528
+ .visibility-hidden {
529
+ visibility: hidden;
530
+ }
531
+
532
+ .box-shadow-active {
533
+ box-shadow: 0px 0px 4px 2px rgba(0, 0, 0, 0.25);
534
+ }
535
+
536
+ .bg-dark-white-2 {
537
+ background-color: #f7f7f7;
538
+ }
539
+
540
+ .bg-white {
541
+ background-color: #FFF;
542
+ }
543
+
544
+ .cursor-pointer {
545
+ cursor: pointer;
546
+ }
547
+
548
+ .email-overlay {
549
+ width: 100%;
550
+ height: 100%;
551
+ background-color: transparent;
552
+ z-index: 1;
553
+ position: absolute;
554
+ top: 0;
555
+ left: 0;
556
+ }
557
+
558
+ .email-item {
559
+ --konecta-gray-3: #515050;
560
+ --konecta-light: #f8f9fa;
561
+ --blue-silver-4: #dae0e5;
562
+ --email-principal: #faa732;
563
+ --email-outros: #86b7fe;
564
+ font-family: "Roboto", sans-serif;
565
+ flex: 1;
566
+ margin: 0 0 10px 0;
567
+ color: #222;
568
+ min-height: 60px;
569
+ display: flex;
570
+ flex-wrap: wrap;
571
+ padding: 10px;
572
+ border-radius: 5px;
573
+ transition: all 150ms ease-in-out;
574
+ max-width: 100%;
575
+ width: 100%;
576
+ overflow: hidden;
577
+ position: relative;
578
+ }
579
+
580
+ .email-custom-action-buttons {
581
+ display: flex;
582
+ gap: 7px;
583
+ align-items: center;
584
+ flex-wrap: wrap;
585
+ max-width: 100%;
586
+ cursor: default;
587
+ }
588
+
589
+ .email-custom-action-button {
590
+ margin-top: 10px;
591
+ background-color: var(--konecta-light) !important;
592
+ color: var(--konecta-dark) !important;
593
+ border: 1px solid var(--blue-silver-4) !important;
594
+ flex: 1;
595
+ min-width: 100px;
596
+ display: flex;
597
+ align-items: center;
598
+ justify-content: center;
599
+ gap: 5px;
600
+ padding: 5px;
601
+ overflow: hidden;
602
+ border-radius: 5px;
603
+ text-overflow: ellipsis;
604
+ white-space: nowrap;
605
+ transition: all 100ms ease-in-out;
606
+ max-width: 100%;
607
+ cursor: pointer
608
+ }
609
+
610
+ .email-custom-action-button:hover {
611
+ background-color: #e9ecef !important;
612
+ }
613
+
614
+ .email-custom-action-button:disabled {
615
+ background-color: var(--konecta-gray-3) !important;
616
+ border: 1px solid #25282b !important;
617
+ cursor: not-allowed !important;
618
+ }
619
+
620
+ .email-item.outros {
621
+ border-left: 3px solid var(--email-outros);
622
+ }
623
+
624
+ .email-author-name {
625
+ margin: 0 5px;
626
+ max-width: 100%;
627
+ overflow: hidden;
628
+ text-overflow: ellipsis;
629
+ white-space: nowrap;
630
+ }
631
+
632
+ .email-author.outros {
633
+ color: var(--email-outros);
634
+ }
635
+
636
+ .email-author.outros>svg:nth-child(1) {
637
+ transform: rotate(180deg);
638
+ }
639
+
640
+ .email-author.principal {
641
+ color: var(--email-principal);
642
+ }
643
+
644
+ .email-author.main {
645
+ font-size: 16.4px;
646
+ }
647
+
648
+ .email-item.principal {
649
+ border-left: 3px solid var(--email-principal);
650
+ }
651
+
652
+ .email-item.info-open {
653
+ overflow: visible
654
+ }
655
+
656
+ .email-header {
657
+ width: 100%;
658
+ display: flex;
659
+ flex-direction: column;
660
+ cursor: pointer;
661
+ border-top-right-radius: 5px;
662
+ border-top-left-radius: 5px;
663
+ position: relative;
664
+ overflow: visible;
665
+ }
666
+
667
+ .header-container {
668
+ display: flex;
669
+ overflow: hidden;
670
+ position: relative;
671
+ }
672
+
673
+ .email-header-content {
674
+ display: flex;
675
+ align-items: center;
676
+ flex: 1;
677
+ min-width: 250px;
678
+ }
679
+
680
+ .email-header-infos {
681
+ display: flex;
682
+ flex-direction: column;
683
+ flex: 1;
684
+ }
685
+
686
+ .email-subject {
687
+ margin: 5px 0 0 0;
688
+ font-size: 16.4px;
689
+ cursor: pointer;
690
+ }
691
+
692
+ .email-date {
693
+ --width: 245px;
694
+ font-size: 12.8px;
695
+ text-overflow: ellipsis;
696
+ white-space: nowrap;
697
+ overflow: hidden;
698
+ position: absolute;
699
+ right: 0;
700
+ top: 0;
701
+ min-width: var(--width);
702
+ width: var(--width);
703
+ max-width: var(--width);
704
+ display: flex;
705
+ justify-content: flex-end;
706
+ gap: 3px;
707
+ align-items: center;
708
+ }
709
+
710
+ .email-content {
711
+ display: flex;
712
+ flex-direction: column;
713
+ align-items: center;
714
+ justify-content: flex-start;
715
+ width: 100%;
716
+ background-color: #FFF;
717
+ position: relative;
718
+ max-width: 100%;
719
+ }
720
+
721
+ .email-actions {
722
+ align-self: flex-end;
723
+ display: flex;
724
+ border-radius: 10px;
725
+ cursor: pointer;
726
+ align-items: center;
727
+ justify-content: center;
728
+ gap: 3px;
729
+ padding: 5px 7px;
730
+ background-color: #dddddd;
731
+ position: absolute;
732
+ right: 0;
733
+ top: 30px;
734
+ z-index: 1;
735
+ }
736
+
737
+ .email-actions.main {
738
+ top: 10px
739
+ }
740
+
741
+ .email-actions.active {
742
+ background-color: #dfdfdf;
743
+ }
744
+
745
+ .email-actions>span {
746
+ width: 4px;
747
+ height: 4px;
748
+ min-width: 4px;
749
+ min-height: 4px;
750
+ max-width: 4px;
751
+ max-height: 4px;
752
+ background-color: #222;
753
+ border-radius: 50%;
754
+ }
755
+
756
+ .email-actions-list {
757
+ position: absolute;
758
+ right: 45px;
759
+ width: 250px;
760
+ top: 5px;
761
+ margin: 0;
762
+ list-style-type: none;
763
+ padding: 0;
764
+ border-radius: 5px;
765
+ z-index: 1;
766
+ }
767
+
768
+ .email-action {
769
+ background-color: #dfdfdf;
770
+ padding: 5px 10px;
771
+ cursor: pointer;
772
+ transition: background-color 150ms ease-in-out;
773
+ font-size: 14.4px;
774
+ user-select: none;
775
+ }
776
+
777
+ .email-action:nth-child(1) {
778
+ border-top-left-radius: 5px;
779
+ border-top-right-radius: 5px;
780
+ }
781
+
782
+ .email-action:last-child {
783
+ border-bottom-left-radius: 5px;
784
+ border-bottom-right-radius: 5px;
785
+ }
786
+
787
+ .email-action:hover {
788
+ background-color: #CCC;
789
+ }
790
+
791
+ .email-html {
792
+ width: 100%;
793
+ min-width: 300px;
794
+ max-width: 100%;
795
+ border: none;
796
+ overflow: auto;
797
+ }
798
+
799
+ .email-raw {
800
+ width: 100%;
801
+ max-width: 100%;
802
+ padding: 15px;
803
+ font-size: 14.4px;
804
+ color: #222;
805
+ }
806
+
807
+ .email-files {
808
+ display: flex;
809
+ gap: 10px;
810
+ flex-wrap: wrap;
811
+ width: 100%;
812
+ margin-top: 5px;
813
+ }
814
+
815
+ .email-header-content,
816
+ .email-header-infos {
817
+ max-width: 100%;
818
+ overflow: hidden;
819
+ }
820
+
821
+ .email-to-from-container {
822
+ margin-bottom: 5px;
823
+ max-width: 100%;
824
+ min-width: 250px;
825
+ overflow: hidden;
826
+ display: flex;
827
+ align-items: center;
828
+ flex-wrap: wrap;
829
+ flex: 1;
830
+ gap: 5px;
831
+ }
832
+
833
+ .email-to-btn {
834
+ padding: 0 5px;
835
+ font-size: 14.4px;
836
+ cursor: pointer;
837
+ color: #666;
838
+ }
839
+
840
+ .email-to-infos {
841
+ position: absolute;
842
+ bottom: -325px;
843
+ border: 1px solid #CCC;
844
+ z-index: 2;
845
+ padding: 10px;
846
+ background-color: #FFF;
847
+ max-height: 300px;
848
+ overflow-y: auto;
849
+ overflow-x: hidden;
850
+ width: 300px;
851
+ display: flex;
852
+ flex-direction: column;
853
+ gap: 5px;
854
+ margin: 0;
855
+ cursor: default;
856
+ }
857
+
858
+ .email-info {
859
+ width: 100%;
860
+ font-size: 12.8px;
861
+ }
862
+
863
+ .email-info>span {
864
+ font-size: 12px;
865
+ color: gray;
866
+ margin-right: 3px;
867
+ }
868
+
869
+ .email-author {
870
+ display: flex;
871
+ align-items: center;
872
+ height: 5px;
873
+ font-size: 12px;
874
+ font-weight: bold;
875
+ transform: translateY(-2px);
876
+ width: 100%;
877
+ cursor: pointer;
878
+ }
879
+
880
+ .email-subject-secondary {
881
+ margin-top: -5px;
882
+ }
883
+
884
+ .email-subject-span {
885
+ font-size: 11.2px;
886
+ color: gray;
887
+ }
888
+
889
+ .email-to-svg {
890
+ font-size: 13.6px;
891
+ }
892
+
893
+ .email-custom-buttons {
894
+ display: flex;
895
+ gap: 7px;
896
+ position: absolute;
897
+ top: 5px;
898
+ right: 5px;
899
+ z-index: 1;
900
+ font-size: 12.8px;
901
+ }
902
+
903
+ .menu-mensagem {
904
+ cursor: pointer;
905
+ padding: 1px;
906
+ opacity: .7;
907
+ transition: opacity 100ms ease-in-out;
908
+ }
909
+
910
+ .menu-mensagem:hover,
911
+ .menu-mensagem:focus,
912
+ .menu-mensagem:active {
913
+ opacity: 1;
914
+ }
915
+
916
+ .email-error-content {
917
+ display: flex;
918
+ justify-content: center;
919
+ align-items: center;
920
+ flex-direction: column;
921
+ gap: 5px;
922
+ padding: 10px;
923
+ }
924
+
925
+ .email-error-content p {
926
+ margin: 0;
927
+ color: #E74C3C;
928
+ }
929
+
930
+ .email-error-content button {
931
+ border: 1px solid #CCC;
932
+ border-radius: 3px;
933
+ padding: 5px 10px;
934
+ background-color: #FFF;
935
+ cursor: pointer;
936
+ transition: background-color 150ms ease-in-out;
937
+ }
938
+
939
+ .email-error-content button:hover {
940
+ background-color: #EEE;
941
+ }
934
942
  </style>