vue-intergrall-plugins 1.1.10 → 1.1.12

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 +54 -50
  3. package/dist/vue-intergrall-plugins.min.js +1 -1
  4. package/dist/vue-intergrall-plugins.ssr.js +126 -122
  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 +937 -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 -684
  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,938 @@
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' ? '' : '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
+ },
197
+ data() {
198
+ return {
199
+ isOpen: this.iniciarAberto,
200
+ openMessage: false,
201
+ actionsOpen: false,
202
+ showInfos: false,
203
+ isIframeLoading: true,
204
+ hasError: false,
205
+ errorCount: 0
206
+ };
207
+ },
208
+ computed: {
209
+ paraCopia() {
210
+ if (!this.copia || !this.copia.length) return this.para && this.para.length ? this.para : []
211
+ return this.para && this.para.length ? this.para.concat(this.copia) : this.copia
212
+ },
213
+ formattedDate() {
214
+ return this.formataDateHoraDateFns(this.dataHora, this.dataServer, this.dicionario);
215
+ },
216
+ mailInfos() {
217
+ const formatAsString = (arr) => {
218
+ let str = ''
219
+ arr.forEach(({ name, email }, index) => {
220
+ if (!name && !email) str += ''
221
+ else str += `${name || ''} ${email ? `<${email}>` : ''}${((name || email) && index !== arr.length - 1) ? ', ' : ''}`
222
+ })
223
+ return str
224
+ }
225
+
226
+ const infos = [
227
+ {
228
+ label: 'De:',
229
+ value: this.from && this.from.length ? formatAsString(this.from) : '--'
230
+ },
231
+ {
232
+ label: 'Para:',
233
+ value: this.para && this.para.length ? formatAsString(this.para) : '--'
234
+ },
235
+ {
236
+ label: 'Assunto:',
237
+ value: this.htmlEntityToEmoji(this.replaceUnicodeWithEmoji(this.assunto)) || '(Sem assunto)'
238
+ },
239
+ {
240
+ label: 'Data:',
241
+ value: this.formataDataHora(this.dataHora) || '--'
242
+ },
243
+ ]
244
+
245
+ if (this.copia && this.copia.length) {
246
+ infos.push({
247
+ label: this.dicionario.tit_copia,
248
+ value: formatAsString(this.copia)
249
+ })
250
+ }
251
+
252
+ return infos
253
+ },
254
+ filteredFiles() {
255
+ if (!this.anexos || !this.anexos.length) return
256
+
257
+ return this.anexos.filter(anexo => {
258
+ return !this.html.includes(anexo.name);
259
+ })
260
+ },
261
+ returnAuthorName() {
262
+ if (!this.from || !this.from.length) return this.autor || ''
263
+ const { email, name } = this.from[0]
264
+ if (!name) return email
265
+ if (!email) return name
266
+ if (this.isOpen) return `${name} (${email})`
267
+ return name
268
+ },
269
+ formattedToName() {
270
+ return (name, index, length) => {
271
+ let addVirgulaDps = index < length - 1
272
+ let addVirgulaAntes = index === 1 && length >= 2
273
+ const text = index === 0 ? `Para: ${name || ''}` : name ? `${addVirgulaAntes ? ', ' : ''}${name}${addVirgulaDps ? ', ' : ''}` : '';
274
+ return text
275
+ }
276
+ }
277
+ },
278
+ watch: {
279
+ isOpen: 'updateIframeContent'
280
+ },
281
+ mounted() {
282
+ this.updateIframeContent();
283
+ this.adjustMaxWidth()
284
+
285
+ if (this.refKey) this.$root.$refs[`${refKey}`] = this
286
+
287
+ setTimeout(() => {
288
+ if (this.isIframeLoading) this.adjustIframeHeight()
289
+ }, 15000);
290
+ },
291
+ methods: {
292
+ handleTryAgain() {
293
+ this.isOpen = true
294
+ this.isIframeLoading = true
295
+ this.hasError = false
296
+
297
+ this.$nextTick(this.updateIframeContent())
298
+ },
299
+ gerarMensagemEstilizada(msg) {
300
+ try {
301
+ const currentStyles = [
302
+ { tagAbertura: "<i>", tagFechamento: "</i>", find: /_(.*?)_/g },
303
+ { tagAbertura: "<b>", tagFechamento: "</b>", find: /\*(.*?)\*/g },
304
+ { tagAbertura: "<del>", tagFechamento: "</del>", find: /~(.*?)~/g }
305
+ ]
306
+
307
+ const isLetterOrUnderscore = (char) => {
308
+ return /[a-zA-Z_]/.test(char)
309
+ }
310
+
311
+ const isValidMatch = (message, fullMatch, startIndex) => {
312
+ const beforeChar = message[startIndex - 1]
313
+ const afterChar = message[startIndex + fullMatch.length]
314
+ return (
315
+ (beforeChar === undefined || !isLetterOrUnderscore(beforeChar)) &&
316
+ (afterChar === undefined || !isLetterOrUnderscore(afterChar))
317
+ )
318
+ }
319
+
320
+ let message = msg
321
+
322
+ for (const { tagAbertura, tagFechamento, find } of currentStyles) {
323
+ let match
324
+ while ((match = find.exec(message)) !== null) {
325
+ const fullMatch = match[0]
326
+ const content = match[1]
327
+ const startIndex = match.index
328
+
329
+ if (isValidMatch(message, fullMatch, startIndex)) {
330
+ const endIndex = startIndex + fullMatch.length
331
+ const replacedContent = `${tagAbertura}${content}${tagFechamento}`
332
+ message = message.slice(0, startIndex) + replacedContent + message.slice(endIndex)
333
+ }
334
+ }
335
+ }
336
+
337
+ return message
338
+ } catch (err) {
339
+ console.error('Erro ao gerar mensagem estilizada: ', err)
340
+ return msg
341
+ }
342
+ },
343
+ updateIframeContent() {
344
+ this.$nextTick(() => {
345
+ if (this.isOpen && this.isIframeLoading) {
346
+ const iframe = this.$refs.emailIframe;
347
+ if (!iframe) return
348
+ const doc = iframe.contentDocument || iframe.contentWindow.document;
349
+ if (!doc) return
350
+ let content = this.html
351
+ if (!/<[a-z][\s\S]*>/i.test(content)) {
352
+ content = content.replace(/\n/g, '<br>');
353
+ content = this.gerarMensagemEstilizada(content)
354
+ content = `<p>${content}</p>`;
355
+ }
356
+
357
+ doc.open();
358
+ doc.write(content);
359
+ doc.close();
360
+
361
+ const images = doc.getElementsByTagName('img');
362
+ let imagesLoaded = 0;
363
+
364
+ const imageLoadHandler = () => {
365
+ imagesLoaded++;
366
+ if (imagesLoaded === images.length) {
367
+ this.adjustIframeHeight();
368
+ }
369
+ };
370
+
371
+ if (images.length === 0) {
372
+ this.adjustIframeHeight();
373
+ } else {
374
+ for (let img of images) {
375
+ img.addEventListener('load', imageLoadHandler);
376
+ img.addEventListener('error', imageLoadHandler);
377
+ }
378
+ }
379
+ }
380
+ });
381
+ },
382
+ adjustIframeHeight() {
383
+ this.$nextTick(() => {
384
+ const iframe = this.$refs.emailIframe;
385
+ const emailParent = this.$refs.emailIframeParent
386
+ if (iframe && emailParent) {
387
+ setTimeout(() => {
388
+ const doc = iframe.contentDocument || iframe.contentWindow.document;
389
+ const margin = 20
390
+ const value = doc.documentElement.offsetHeight + margin
391
+ if (value === 0 || doc.documentElement.querySelector('body').innerHTML === '') {
392
+ this.errorCount++
393
+ if (this.errorCount > 3) {
394
+ this.hasError = true
395
+ if (this.isIframeLoading) this.isIframeLoading = false
396
+ return
397
+ }
398
+ this.isIframeLoading = true
399
+ this.updateIframeContent()
400
+ return
401
+ }
402
+ if (this.hasError || this.errorCount > 0) {
403
+ this.hasError = false
404
+ this.errorCount = 0
405
+ }
406
+ iframe.style.height = `${value}px`;
407
+ emailParent.style.minHeight = `${value}px`
408
+ }, 100)
409
+ }
410
+
411
+ if (this.isIframeLoading) this.isIframeLoading = false
412
+ });
413
+ },
414
+ toggleShowInfos() {
415
+ this.showInfos = !this.showInfos;
416
+ if (this.showInfos) {
417
+ this.$nextTick(() => {
418
+ this.adjustTopPosition();
419
+ });
420
+ }
421
+ },
422
+ adjustTopPosition() {
423
+ const ulElement = this.$refs.emailToInfos;
424
+ if (!ulElement) return
425
+ const ulHeight = ulElement.offsetHeight;
426
+ const maxHeight = 300
427
+ const finalHeight = ulHeight < maxHeight ? ulHeight : maxHeight
428
+ ulElement.style.bottom = `-${finalHeight}px`;
429
+ },
430
+ toggleIsOpen() {
431
+ this.isOpen = !this.isOpen;
432
+ if (!this.isOpen) {
433
+ this.actionsOpen = false;
434
+ this.openMessage = false;
435
+ this.showInfos = false
436
+ }
437
+ },
438
+ adjustMaxWidth() {
439
+ this.$nextTick(() => {
440
+ const toContainer = this.$refs.emailToContainer
441
+ const dateContainer = this.$refs.emailDate
442
+ if (!toContainer || !dateContainer) return
443
+ toContainer.style.maxWidth = `calc(100% - ${dateContainer.offsetWidth}px)`
444
+ })
445
+ },
446
+ toggleActions() {
447
+ this.actionsOpen = !this.actionsOpen;
448
+ },
449
+ toggleOpenMessage() {
450
+ if (this.showRawMessageInsideEmail) {
451
+ this.openMessage = !this.openMessage;
452
+ }
453
+
454
+ this.$emit('open-message', {
455
+ dicionario: this.dicionario,
456
+ from: this.from,
457
+ para: this.para,
458
+ html: this.html,
459
+ assunto: this.assunto,
460
+ dataHora: this.dataHora,
461
+ mensagem: this.mensagem,
462
+ anexos: this.filteredFiles,
463
+ dataServer: this.dataServer,
464
+ dominio: this.dominio
465
+ })
466
+ },
467
+ closeActions() {
468
+ this.actionsOpen = false;
469
+ },
470
+ returnMainValue() {
471
+ if (this.isMainEmail) return this.htmlEntityToEmoji(this.replaceUnicodeWithEmoji(this.assunto)) || '(Sem assunto)'
472
+ return ''
473
+ },
474
+ openByItem(event) {
475
+ if (this.isOpen) return;
476
+
477
+ event.preventDefault();
478
+ event.stopPropagation();
479
+
480
+ this.toggleIsOpen();
481
+ },
482
+ returnParams(params) {
483
+ const defaultParams = {
484
+ message: this.mensagem,
485
+ };
486
+
487
+ if (!params) return defaultParams;
488
+
489
+ const keys = params.instanceKeys.split("|");
490
+ if (!keys || !keys.length)
491
+ return {
492
+ defaultParams,
493
+ ...params.values,
494
+ };
495
+
496
+ const customParams = { ...params.values };
497
+ keys.forEach((key) => {
498
+ if (this[key]) customParams[key] = this[key];
499
+ else console.warn(`Cant find ${key} on 'this' instance`);
500
+ });
501
+
502
+ return Object.keys(customParams).length ? customParams : defaultParams;
503
+ }
504
+ }
505
+ };
506
+ </script>
507
+
508
+ <style scoped>
509
+ .show-y-top-enter-active,
510
+ .show-y-top-leave-enter {
511
+ opacity: 1;
512
+ transform: translateY(0);
513
+ transition: all 200ms linear;
514
+ }
515
+
516
+ .show-y-top-enter,
517
+ .show-y-top-leave-to {
518
+ opacity: 0;
519
+ transform: translateY(-2%);
520
+ }
521
+ </style>
522
+
523
+ <style>
524
+ .visibility-hidden {
525
+ visibility: hidden;
526
+ }
527
+
528
+ .box-shadow-active {
529
+ box-shadow: 0px 0px 4px 2px rgba(0, 0, 0, 0.25);
530
+ }
531
+
532
+ .bg-dark-white-2 {
533
+ background-color: #f7f7f7;
534
+ }
535
+
536
+ .bg-white {
537
+ background-color: #FFF;
538
+ }
539
+
540
+ .cursor-pointer {
541
+ cursor: pointer;
542
+ }
543
+
544
+ .email-overlay {
545
+ width: 100%;
546
+ height: 100%;
547
+ background-color: transparent;
548
+ z-index: 1;
549
+ position: absolute;
550
+ top: 0;
551
+ left: 0;
552
+ }
553
+
554
+ .email-item {
555
+ --konecta-gray-3: #515050;
556
+ --konecta-light: #f8f9fa;
557
+ --blue-silver-4: #dae0e5;
558
+ --email-principal: #faa732;
559
+ --email-outros: #86b7fe;
560
+ font-family: "Roboto", sans-serif;
561
+ flex: 1;
562
+ margin: 0 0 10px 0;
563
+ color: #222;
564
+ min-height: 60px;
565
+ display: flex;
566
+ flex-wrap: wrap;
567
+ padding: 10px;
568
+ border-radius: 5px;
569
+ transition: all 150ms ease-in-out;
570
+ max-width: 100%;
571
+ width: 100%;
572
+ overflow: hidden;
573
+ position: relative;
574
+ }
575
+
576
+ .email-custom-action-buttons {
577
+ display: flex;
578
+ gap: 7px;
579
+ align-items: center;
580
+ flex-wrap: wrap;
581
+ max-width: 100%;
582
+ cursor: default;
583
+ }
584
+
585
+ .email-custom-action-button {
586
+ margin-top: 10px;
587
+ background-color: var(--konecta-light) !important;
588
+ color: var(--konecta-dark) !important;
589
+ border: 1px solid var(--blue-silver-4) !important;
590
+ flex: 1;
591
+ min-width: 100px;
592
+ display: flex;
593
+ align-items: center;
594
+ justify-content: center;
595
+ gap: 5px;
596
+ padding: 5px;
597
+ overflow: hidden;
598
+ border-radius: 5px;
599
+ text-overflow: ellipsis;
600
+ white-space: nowrap;
601
+ transition: all 100ms ease-in-out;
602
+ max-width: 100%;
603
+ cursor: pointer
604
+ }
605
+
606
+ .email-custom-action-button:hover {
607
+ background-color: #e9ecef !important;
608
+ }
609
+
610
+ .email-custom-action-button:disabled {
611
+ background-color: var(--konecta-gray-3) !important;
612
+ border: 1px solid #25282b !important;
613
+ cursor: not-allowed !important;
614
+ }
615
+
616
+ .email-item.outros {
617
+ border-left: 3px solid var(--email-outros);
618
+ }
619
+
620
+ .email-author-name {
621
+ margin: 0 5px;
622
+ max-width: 100%;
623
+ overflow: hidden;
624
+ text-overflow: ellipsis;
625
+ white-space: nowrap;
626
+ }
627
+
628
+ .email-author.outros {
629
+ color: var(--email-outros);
630
+ }
631
+
632
+ .email-author.outros>svg:nth-child(1) {
633
+ transform: rotate(180deg);
634
+ }
635
+
636
+ .email-author.principal {
637
+ color: var(--email-principal);
638
+ }
639
+
640
+ .email-author.main {
641
+ font-size: 16.4px;
642
+ }
643
+
644
+ .email-item.principal {
645
+ border-left: 3px solid var(--email-principal);
646
+ }
647
+
648
+ .email-item.info-open {
649
+ overflow: visible
650
+ }
651
+
652
+ .email-header {
653
+ width: 100%;
654
+ display: flex;
655
+ flex-direction: column;
656
+ cursor: pointer;
657
+ border-top-right-radius: 5px;
658
+ border-top-left-radius: 5px;
659
+ position: relative;
660
+ overflow: visible;
661
+ }
662
+
663
+ .header-container {
664
+ display: flex;
665
+ overflow: hidden;
666
+ position: relative;
667
+ }
668
+
669
+ .email-header-content {
670
+ display: flex;
671
+ align-items: center;
672
+ flex: 1;
673
+ min-width: 250px;
674
+ }
675
+
676
+ .email-header-infos {
677
+ display: flex;
678
+ flex-direction: column;
679
+ flex: 1;
680
+ }
681
+
682
+ .email-subject {
683
+ margin: 5px 0 0 0;
684
+ font-size: 16.4px;
685
+ cursor: pointer;
686
+ }
687
+
688
+ .email-date {
689
+ --width: 245px;
690
+ font-size: 12.8px;
691
+ text-overflow: ellipsis;
692
+ white-space: nowrap;
693
+ overflow: hidden;
694
+ position: absolute;
695
+ right: 0;
696
+ top: 0;
697
+ min-width: var(--width);
698
+ width: var(--width);
699
+ max-width: var(--width);
700
+ display: flex;
701
+ justify-content: flex-end;
702
+ gap: 3px;
703
+ align-items: center;
704
+ }
705
+
706
+ .email-content {
707
+ display: flex;
708
+ flex-direction: column;
709
+ align-items: center;
710
+ justify-content: flex-start;
711
+ width: 100%;
712
+ background-color: #FFF;
713
+ position: relative;
714
+ max-width: 100%;
715
+ }
716
+
717
+ .email-actions {
718
+ align-self: flex-end;
719
+ display: flex;
720
+ border-radius: 10px;
721
+ cursor: pointer;
722
+ align-items: center;
723
+ justify-content: center;
724
+ gap: 3px;
725
+ padding: 5px 7px;
726
+ background-color: #dddddd;
727
+ position: absolute;
728
+ right: 0;
729
+ top: 30px;
730
+ z-index: 1;
731
+ }
732
+
733
+ .email-actions.main {
734
+ top: 10px
735
+ }
736
+
737
+ .email-actions.active {
738
+ background-color: #dfdfdf;
739
+ }
740
+
741
+ .email-actions>span {
742
+ width: 4px;
743
+ height: 4px;
744
+ min-width: 4px;
745
+ min-height: 4px;
746
+ max-width: 4px;
747
+ max-height: 4px;
748
+ background-color: #222;
749
+ border-radius: 50%;
750
+ }
751
+
752
+ .email-actions-list {
753
+ position: absolute;
754
+ right: 45px;
755
+ width: 250px;
756
+ top: 5px;
757
+ margin: 0;
758
+ list-style-type: none;
759
+ padding: 0;
760
+ border-radius: 5px;
761
+ z-index: 1;
762
+ }
763
+
764
+ .email-action {
765
+ background-color: #dfdfdf;
766
+ padding: 5px 10px;
767
+ cursor: pointer;
768
+ transition: background-color 150ms ease-in-out;
769
+ font-size: 14.4px;
770
+ user-select: none;
771
+ }
772
+
773
+ .email-action:nth-child(1) {
774
+ border-top-left-radius: 5px;
775
+ border-top-right-radius: 5px;
776
+ }
777
+
778
+ .email-action:last-child {
779
+ border-bottom-left-radius: 5px;
780
+ border-bottom-right-radius: 5px;
781
+ }
782
+
783
+ .email-action:hover {
784
+ background-color: #CCC;
785
+ }
786
+
787
+ .email-html {
788
+ width: 100%;
789
+ min-width: 300px;
790
+ max-width: 100%;
791
+ border: none;
792
+ overflow: auto;
793
+ }
794
+
795
+ .email-raw {
796
+ width: 100%;
797
+ max-width: 100%;
798
+ padding: 15px;
799
+ font-size: 14.4px;
800
+ color: #222;
801
+ }
802
+
803
+ .email-files {
804
+ display: flex;
805
+ gap: 10px;
806
+ flex-wrap: wrap;
807
+ width: 100%;
808
+ margin-top: 5px;
809
+ }
810
+
811
+ .email-header-content,
812
+ .email-header-infos {
813
+ max-width: 100%;
814
+ overflow: hidden;
815
+ }
816
+
817
+ .email-to-from-container {
818
+ margin-bottom: 5px;
819
+ max-width: 100%;
820
+ min-width: 250px;
821
+ overflow: hidden;
822
+ display: flex;
823
+ align-items: center;
824
+ flex-wrap: wrap;
825
+ flex: 1;
826
+ gap: 5px;
827
+ }
828
+
829
+ .email-to-btn {
830
+ padding: 0 5px;
831
+ font-size: 14.4px;
832
+ cursor: pointer;
833
+ color: #666;
834
+ }
835
+
836
+ .email-to-infos {
837
+ position: absolute;
838
+ bottom: -325px;
839
+ border: 1px solid #CCC;
840
+ z-index: 2;
841
+ padding: 10px;
842
+ background-color: #FFF;
843
+ max-height: 300px;
844
+ overflow-y: auto;
845
+ overflow-x: hidden;
846
+ width: 300px;
847
+ display: flex;
848
+ flex-direction: column;
849
+ gap: 5px;
850
+ margin: 0;
851
+ cursor: default;
852
+ }
853
+
854
+ .email-info {
855
+ width: 100%;
856
+ font-size: 12.8px;
857
+ }
858
+
859
+ .email-info>span {
860
+ font-size: 12px;
861
+ color: gray;
862
+ margin-right: 3px;
863
+ }
864
+
865
+ .email-author {
866
+ display: flex;
867
+ align-items: center;
868
+ height: 5px;
869
+ font-size: 12px;
870
+ font-weight: bold;
871
+ transform: translateY(-2px);
872
+ width: 100%;
873
+ cursor: pointer;
874
+ }
875
+
876
+ .email-subject-secondary {
877
+ margin-top: -5px;
878
+ }
879
+
880
+ .email-subject-span {
881
+ font-size: 11.2px;
882
+ color: gray;
883
+ }
884
+
885
+ .email-to-svg {
886
+ font-size: 13.6px;
887
+ }
888
+
889
+ .email-custom-buttons {
890
+ display: flex;
891
+ gap: 7px;
892
+ position: absolute;
893
+ top: 5px;
894
+ right: 5px;
895
+ z-index: 1;
896
+ font-size: 12.8px;
897
+ }
898
+
899
+ .menu-mensagem {
900
+ cursor: pointer;
901
+ padding: 1px;
902
+ opacity: .7;
903
+ transition: opacity 100ms ease-in-out;
904
+ }
905
+
906
+ .menu-mensagem:hover,
907
+ .menu-mensagem:focus,
908
+ .menu-mensagem:active {
909
+ opacity: 1;
910
+ }
911
+
912
+ .email-error-content {
913
+ display: flex;
914
+ justify-content: center;
915
+ align-items: center;
916
+ flex-direction: column;
917
+ gap: 5px;
918
+ padding: 10px;
919
+ }
920
+
921
+ .email-error-content p {
922
+ margin: 0;
923
+ color: #E74C3C;
924
+ }
925
+
926
+ .email-error-content button {
927
+ border: 1px solid #CCC;
928
+ border-radius: 3px;
929
+ padding: 5px 10px;
930
+ background-color: #FFF;
931
+ cursor: pointer;
932
+ transition: background-color 150ms ease-in-out;
933
+ }
934
+
935
+ .email-error-content button:hover {
936
+ background-color: #EEE;
937
+ }
934
938
  </style>