vue-intergrall-plugins 1.1.89 → 1.2.0

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 (45) hide show
  1. package/README.md +220 -220
  2. package/dist/dist/vue-intergrall-plugins.css +1 -1
  3. package/dist/vue-intergrall-plugins.esm.js +193 -78
  4. package/dist/vue-intergrall-plugins.min.js +7 -7
  5. package/dist/vue-intergrall-plugins.ssr.js +245 -136
  6. package/package.json +61 -61
  7. package/src/lib-components/Buttons/IconButton.vue +27 -27
  8. package/src/lib-components/Buttons/SimpleButton.vue +140 -140
  9. package/src/lib-components/Cards/Card.vue +490 -490
  10. package/src/lib-components/Cards/CardCheck.vue +35 -35
  11. package/src/lib-components/Cards/CardFile.vue +163 -163
  12. package/src/lib-components/Chat/BtnDownloadAllFiles.vue +36 -36
  13. package/src/lib-components/Chat/BtnEmojis.vue +118 -118
  14. package/src/lib-components/Chat/BtnExpand.vue +17 -17
  15. package/src/lib-components/Chat/BtnFiles.vue +486 -486
  16. package/src/lib-components/Chat/BtnMic.vue +60 -60
  17. package/src/lib-components/Chat/BtnScreenShare.vue +31 -31
  18. package/src/lib-components/Chat/BtnStandardMessages.vue +17 -17
  19. package/src/lib-components/Chat/ExpandTextarea.vue +427 -427
  20. package/src/lib-components/Chat/MultipleFilePreview.vue +291 -291
  21. package/src/lib-components/Chat/Picker.vue +525 -525
  22. package/src/lib-components/Chat/RemainingCharacters.vue +28 -28
  23. package/src/lib-components/Chat/SingleFilePreview.vue +94 -94
  24. package/src/lib-components/Chat/SkeletonPicker.vue +110 -110
  25. package/src/lib-components/Chat/StandardMessages.vue +252 -252
  26. package/src/lib-components/Chat/TextFooter.vue +1007 -1007
  27. package/src/lib-components/Email/EmailExpanded.vue +270 -270
  28. package/src/lib-components/Email/EmailFile.vue +192 -192
  29. package/src/lib-components/Email/EmailFrom.vue +66 -66
  30. package/src/lib-components/Email/EmailItem.vue +867 -850
  31. package/src/lib-components/Email/EmailTo.vue +64 -64
  32. package/src/lib-components/Loader/Loader.vue +78 -78
  33. package/src/lib-components/Messages/AnexoMensagem.vue +534 -497
  34. package/src/lib-components/Messages/CardAttachment.vue +61 -61
  35. package/src/lib-components/Messages/CardMessages.vue +687 -687
  36. package/src/lib-components/Messages/InteratividadeBotoes.vue +197 -197
  37. package/src/lib-components/Messages/InteratividadeContato.vue +32 -32
  38. package/src/lib-components/Messages/InteratividadeContatoItem.vue +235 -235
  39. package/src/lib-components/Messages/InteratividadeFormulario.vue +334 -334
  40. package/src/lib-components/Messages/InteratividadePopup.vue +95 -95
  41. package/src/lib-components/Messages/LinkPreview.vue +176 -176
  42. package/src/lib-components/Scroll/ScrollContent.vue +166 -166
  43. package/src/lib-components/Templates/TemplateGenerator.vue +640 -640
  44. package/src/lib-components/Templates/TemplateMessage.vue +83 -83
  45. package/src/lib-components/Templates/TemplateSingle.vue +478 -478
@@ -1,640 +1,640 @@
1
- <template>
2
- <div class="tg-container" v-if="templates && identifier">
3
- <div class="tg-options" :class="{ column: columnSelect }">
4
- <h4>Template:</h4>
5
- <v-select class="tg-select" appendToBody :calculatePosition="calculateSelectPosition" :options="templateOptions"
6
- :value="codTemplate" :reduce="(template) => template.cod" :clearable="false" @input="setTemplate"
7
- :getOptionLabel="(template) => template.label" ref="template-v-select">
8
- <div slot="no-options" v-text="dictionary.msg_sem_resultados"></div>
9
- </v-select>
10
- </div>
11
- <template v-if="selectedTemplate">
12
- <div class="tg-component" v-if="selectedTemplate.components">
13
- <TemplateSingle :key="codTemplate" :template="selectedTemplate" @set-vars="setFinalMessage"
14
- @set-file-var="setFileVar" :hasButton="hasButton" :iconButton="iconButton"
15
- @click-trigger="$emit('click-trigger')" :identifier="identifier" :allVariables="allVariables"
16
- :dictionary="dictionary" :hasSecondaryButton="hasSecondaryButton"
17
- @dispatch-clients-with-bot="$emit('dispatch-clients-with-bot')" />
18
- </div>
19
- <div class="tg-component" v-else>
20
- <TemplateMessage @final-message="setMessage" :hasButton="hasButton" :iconButton="iconButton"
21
- @click-trigger="$emit('click-trigger', true)" :dictionary="dictionary" />
22
- </div>
23
- </template>
24
- </div>
25
- </template>
26
-
27
- <script>
28
- import { createPopper } from "@popperjs/core";
29
- import TemplateSingle from "./TemplateSingle";
30
- import TemplateMessage from "./TemplateMessage";
31
-
32
- export default {
33
- components: { TemplateSingle, TemplateMessage },
34
- props: {
35
- templates: {
36
- type: Object,
37
- required: true,
38
- },
39
- hasSecondaryButton: {
40
- type: Boolean,
41
- required: false,
42
- default: false,
43
- },
44
- hasButton: {
45
- type: Boolean,
46
- required: false,
47
- default: true,
48
- },
49
- columnSelect: {
50
- type: Boolean,
51
- required: false,
52
- },
53
- resizeParentOnSelect: {
54
- type: Boolean,
55
- required: false,
56
- },
57
- allVariables: {
58
- type: Boolean,
59
- required: false,
60
- default: true,
61
- },
62
- iconButton: {
63
- type: Boolean,
64
- required: false,
65
- },
66
- identifier: {
67
- type: String,
68
- required: true,
69
- },
70
- placement: {
71
- type: String,
72
- default: "bottom",
73
- },
74
- dictionary: {
75
- type: Object,
76
- required: true,
77
- },
78
- selectInitial: {
79
- type: Boolean,
80
- required: false,
81
- default: true,
82
- },
83
- },
84
- data() {
85
- return {
86
- templateOptions: [],
87
- codTemplate: {},
88
- selectedTemplate: null,
89
- hasFile: false,
90
- };
91
- },
92
- mounted() {
93
- this.setTemplateOptions();
94
- if (this.selectInitial) this.selectIfIsUnique();
95
- this.selectIfHasContact24h();
96
- },
97
- methods: {
98
- concatTemplateMessage(template) {
99
- let fullText = "";
100
- for (let key in template) {
101
- if (key === "components" && Array.isArray(template[key])) {
102
- template[key].map((component) => {
103
- if (component && component.parameters && component.parameters.length) {
104
- component.parameters.map((param) => {
105
- fullText += param.text;
106
- });
107
- }
108
- });
109
- }
110
- }
111
-
112
- fullText = fullText.replace(/{{var_\d}}/g, " ------- ");
113
- fullText = fullText.replace(`&nbsp;`, " ");
114
- fullText = fullText.replace(/<\/?[\d\w\s=\-:./'";]+>/gi, " ");
115
-
116
- return fullText;
117
- },
118
- calculateSelectPosition(dropdownList, component, sizes) {
119
- dropdownList.style.width = sizes.width;
120
- const popper = createPopper(component.$refs.toggle, dropdownList, {
121
- placement: this.placement,
122
- modifiers: [
123
- {
124
- name: "toggleClass",
125
- enabled: true,
126
- phase: "write",
127
- fn({ state }) {
128
- component.$el.classList.toggle("drop-up", state.placement === "top");
129
- },
130
- },
131
- ],
132
- });
133
- return () => popper.destroy();
134
- },
135
- setTemplateOptions() {
136
- for (let key in this.templates) {
137
- if (this.templates[key])
138
- this.templateOptions.push({
139
- cod: key,
140
- label: `${this.concatTemplateMessage(this.templates[key])} (${this.templates[key].title
141
- })`,
142
- });
143
- }
144
- },
145
- setTemplate(key) {
146
- if (key) {
147
- this.selectedTemplate = this.templates[key];
148
- this.codTemplate = key;
149
- this.$emit("selected-template", key);
150
- this.$nextTick(() => {
151
- if (this.$root.$refs[`template-single-${this.identifier}`])
152
- this.$root.$refs[`template-single-${this.identifier}`].handleInitialFocus();
153
- });
154
- } else {
155
- this.selectedTemplate = null;
156
- }
157
- // if(this.hasFile) this.setFileVar(false)
158
- this.adjustOnSelect();
159
- },
160
- focusSelect() {
161
- if (this.$refs["template-v-select"] && this.$refs["template-v-select"].$el)
162
- this.$refs["template-v-select"].$el.querySelector("input").focus();
163
- },
164
- selectIfIsUnique() {
165
- if (Object.keys(this.templates).length === 1) {
166
- for (let key in this.templates) {
167
- this.codTemplate = this.templateOptions[0];
168
- this.selectedTemplate = this.templates[key];
169
- this.$emit("selected-template", this.codTemplate);
170
- this.adjustOnSelect();
171
- }
172
- }
173
- if (!this.codTemplate) this.focusSelect();
174
- },
175
- selectIfHasContact24h() {
176
- if (this.templates["envio_msg"]) {
177
- this.codTemplate = "envio_msg";
178
- this.selectedTemplate = this.templates["envio_msg"];
179
- this.$emit("selected-template", "envio_msg");
180
- this.adjustOnSelect();
181
- }
182
- },
183
- adjustOnSelect() {
184
- if (this.resizeParentOnSelect) this.$emit("resize-parent");
185
- },
186
- setFinalMessage(vars) {
187
- const keys = Object.keys(vars),
188
- values = Object.values(vars);
189
- this.selectedTemplate["parameters"] = {};
190
- for (let index in this.selectedTemplate) {
191
- if (index === "components" && Array.isArray(this.selectedTemplate[index])) {
192
- const arrComponents = this.selectedTemplate[index];
193
- if (arrComponents && arrComponents.length) {
194
- arrComponents.map((component) => {
195
- if (component && component.parameters && component.parameters.length) {
196
- component.parameters.map((message) => {
197
- message.currentText = message.text;
198
- let keyIndex = 0;
199
- while (keyIndex < keys.length) {
200
- const varName = `{{${keys[keyIndex]}}}`;
201
- if (message.text.indexOf(varName) != -1) {
202
- /**Gerando os obejetos de parametros da notificacao para o component */
203
- if (
204
- component.type === "header" &&
205
- !this.selectedTemplate["parameters"][component.type]
206
- ) {
207
- this.selectedTemplate["parameters"][component.type] = {};
208
- //Header so pode ter uma vari?vel
209
- this.selectedTemplate["parameters"][component.type] = {
210
- tipo: "text",
211
- text: values[keyIndex],
212
- };
213
- } else if (!this.selectedTemplate["parameters"][component.type]) {
214
- this.selectedTemplate["parameters"][component.type] = new Array();
215
- }
216
- //Aplicando valores das v?riaveis dentro dos outros componentes com execess?o do header
217
- if (
218
- this.selectedTemplate["parameters"][component.type] &&
219
- component.type !== "header"
220
- ) {
221
- this.selectedTemplate["parameters"][component.type].push(
222
- values[keyIndex]
223
- );
224
- }
225
- message.currentText = message.currentText.replace(
226
- varName,
227
- values[keyIndex]
228
- );
229
- }
230
- keyIndex++;
231
- }
232
- });
233
- } else if (component.type == "header" && component.parameters.seq) {
234
- if (this.hasFile) {
235
- if (!this.selectedTemplate["parameters"][component.type])
236
- this.selectedTemplate["parameters"][component.type] = new Array();
237
-
238
- let tipo = 'image'
239
- try {
240
- this.selectedTemplate['components'].forEach((component) => {
241
- if (component.type === 'header') {
242
- tipo = component.parameters['0'].type || 'image'
243
- }
244
- })
245
- } catch (err) {
246
- console.error('Error get tipo, err: ', err)
247
- }
248
-
249
- this.selectedTemplate["parameters"][component.type].push({
250
- tipo,
251
- template: component.parameters.seq,
252
- link: "",
253
- });
254
- } else {
255
- delete this.selectedTemplate["parameters"][component.type];
256
- }
257
- }
258
- });
259
- }
260
- }
261
- }
262
- this.$emit("template-data", this.selectedTemplate);
263
- },
264
- setFileVar(file) {
265
- this.hasFile = file ? true : false;
266
- this.$emit("set-file-var", file);
267
- if (file) this.$emit("template-data", this.selectedTemplate);
268
- },
269
- setMessage(message) {
270
- this.$emit("static-message", message);
271
- },
272
- },
273
- };
274
- </script>
275
-
276
- <style>
277
- .tg-container {
278
- width: 100%;
279
- max-width: 800px;
280
- display: flex;
281
- flex-direction: column;
282
- overflow-x: hidden;
283
- overflow-y: auto;
284
- }
285
-
286
- .tg-options {
287
- width: 100%;
288
- display: flex;
289
- }
290
-
291
- .tg-options.column {
292
- flex-direction: column;
293
- }
294
-
295
- .tg-options h4 {
296
- margin-right: 5px;
297
- }
298
-
299
- .ts-image-type {
300
- display: flex;
301
- align-items: center;
302
- }
303
-
304
- .ts-image-type img {
305
- cursor: pointer;
306
- }
307
-
308
- .ts-image-type svg {
309
- font-size: 25px;
310
- cursor: pointer;
311
- }
312
-
313
- .ts-image-type .select-image {
314
- color: #838383;
315
- }
316
-
317
- .color-red {
318
- color: #e74c3c;
319
- }
320
-
321
- .color-blue {
322
- color: #007bff;
323
- }
324
-
325
- .color-black {
326
- color: #333;
327
- }
328
-
329
- .color-purple {
330
- color: #a312a3;
331
- }
332
-
333
- .custom-tooltip-image {
334
- display: flex;
335
- justify-content: center;
336
- align-items: center;
337
- overflow: visible;
338
- padding: 5px;
339
- }
340
-
341
- .custom-tooltip-image img {
342
- max-width: 75px;
343
- max-height: 75px;
344
- }
345
-
346
- .ts-button {
347
- background-color: #fff;
348
- border-radius: 10px;
349
- display: flex;
350
- justify-content: center;
351
- align-items: center;
352
- padding: 3px 15px;
353
- transition: background-color 150ms ease-in-out;
354
- }
355
-
356
- .ts-button:hover {
357
- background-color: rgb(253, 253, 253);
358
- }
359
-
360
- .tg-select {
361
- flex: 1;
362
- height: 34px;
363
- overflow: hidden;
364
- }
365
-
366
- .tg-select .vs__dropdown-toggle {
367
- background-color: #fff;
368
- height: 34px;
369
- overflow: hidden;
370
- display: flex;
371
- align-items: center;
372
- }
373
-
374
- .tg-select .vs__selected-options {
375
- height: 34px;
376
- overflow: hidden;
377
- }
378
-
379
- .tg-select .vs__selected-options>span {
380
- white-space: nowrap;
381
- text-overflow: ellipsis;
382
- flex: 1;
383
- }
384
-
385
- .vs__dropdown-option.vs__dropdown-option--selected {
386
- background-color: rgb(26, 95, 173) !important;
387
- color: white;
388
- }
389
-
390
- .vs__dropdown-menu li {
391
- padding: 10px 15px;
392
- }
393
-
394
- .vs__dropdown-option {
395
- transition: background-color 150ms;
396
- white-space: normal;
397
- }
398
-
399
- .vs__dropdown-option:nth-child(odd) {
400
- background-color: #f1f1f1;
401
- }
402
-
403
- .vs__dropdown-option:hover,
404
- .vs__dropdown-option:focus,
405
- .vs__dropdown-option:active,
406
- .vs__dropdown-option:focus,
407
- .vs__dropdown-option--selected,
408
- .vs__dropdown-option--highlight {
409
- background-color: #5897fb !important;
410
- color: #fff;
411
- }
412
-
413
- .tg-component {
414
- width: 100%;
415
- }
416
-
417
- .ts-container {
418
- width: 100%;
419
- display: flex;
420
- justify-content: space-between;
421
- gap: 10px;
422
- }
423
-
424
- .ts-content {
425
- --border-color: #ccc;
426
- --background-color: #dff0d8;
427
- --input-background-color: #fff;
428
- --input-border-default: #007bff;
429
- --input-border-error: #e74c3c;
430
- --placeholder-color: #bbb;
431
- --border-radius: 5px;
432
-
433
- flex: 2;
434
- font-size: 11.2px;
435
- padding: 10px 0;
436
- display: flex;
437
- flex-direction: column;
438
- }
439
-
440
- .order-1 {
441
- order: 1;
442
- }
443
-
444
- .custom-box-shadow-bottom {
445
- box-shadow: 0px 3px 4px -3px rgba(0, 0, 0, 0.3);
446
- }
447
-
448
- .custom-border-gray {
449
- border: 1px solid var(--border-color) !important;
450
- }
451
-
452
- .ts-content header,
453
- .ts-content section,
454
- .ts-content footer {
455
- padding: 3px 5px;
456
- background-color: var(--background-color);
457
- }
458
-
459
- .ts-content header,
460
- .ts-content section {
461
- border-right: 1px solid var(--border-color);
462
- border-left: 1px solid var(--border-color);
463
- }
464
-
465
- .ts-content header {
466
- border-top-left-radius: var(--border-radius);
467
- border-top-right-radius: var(--border-radius);
468
- border-top: 1px solid var(--border-color);
469
- }
470
-
471
- .ts-content header {
472
- font-weight: 550;
473
- }
474
-
475
- .ts-content section {
476
- line-height: 25px;
477
- }
478
-
479
- .ts-content section.margin-bottom {
480
- border-bottom-left-radius: var(--border-radius);
481
- border-bottom-right-radius: var(--border-radius);
482
- border-bottom: 1px solid var(--border-color);
483
- }
484
-
485
- .ts-content footer,
486
- .custom-footer-style {
487
- border: 1px solid var(--border-color);
488
- border-top: unset;
489
- border-bottom-left-radius: var(--border-radius);
490
- border-bottom-right-radius: var(--border-radius);
491
- }
492
-
493
- .ts-content input {
494
- border: 1px solid transparent;
495
- outline: 0;
496
- font-size: 12.8px;
497
- padding: 2.5px 5px;
498
- background-color: var(--input-background-color);
499
- }
500
-
501
- .ts-content input::placeholder {
502
- color: var(--placeholder-color);
503
- }
504
-
505
- .ts-content input.active,
506
- .ts-content input:focus {
507
- border: 1px solid var(--input-border-default);
508
- }
509
-
510
- .ts-content input.invalid {
511
- border: 1px solid var(--input-border-error) !important;
512
- }
513
-
514
- .ts-content__var {
515
- display: inline-block;
516
- position: relative;
517
- }
518
-
519
- .ts-dropdown {
520
- margin: 0;
521
- padding: 0;
522
- position: absolute;
523
- top: 19px;
524
- left: 0;
525
- background: #eee;
526
- width: 100%;
527
- z-index: 1;
528
- transition: all 150ms;
529
- visibility: hidden;
530
- opacity: 0;
531
- list-style-type: none;
532
- border: 1px solid #444;
533
- border-top: unset;
534
- }
535
-
536
- .ts-dropdown li {
537
- width: 100%;
538
- opacity: 0.9;
539
- cursor: pointer;
540
- font-weight: 550;
541
- padding: 2px 3px;
542
- font-size: 12.8px;
543
- transition: background-color 150ms;
544
- }
545
-
546
- .ts-dropdown li:hover,
547
- .ts-dropdown li:focus-within,
548
- .ts-dropdown li:focus {
549
- opacity: 1;
550
- background-color: #555;
551
- color: #fff;
552
- }
553
-
554
- .ts-dropdown.visible {
555
- visibility: visible;
556
- opacity: 1;
557
- }
558
-
559
- .tg-btn {
560
- width: auto;
561
- display: flex;
562
- justify-content: center;
563
- align-items: center;
564
- }
565
-
566
- .tg-btn button {
567
- border: unset;
568
- display: block;
569
- min-width: 180px;
570
- height: 35px;
571
- padding: 0 10px;
572
- font-weight: 500;
573
- background-color: #007bff;
574
- color: #fff;
575
- transition: transform 300ms ease-in-out;
576
- user-select: none;
577
- cursor: pointer;
578
- box-shadow: inset 0 -2px rgba(0, 0, 0, 0.2);
579
- opacity: 0.9;
580
- border-radius: 2.5px;
581
- }
582
-
583
- .tg-btn button>svg {
584
- margin-right: 5px;
585
- color: #003166;
586
- }
587
-
588
- .tg-btn button:hover {
589
- opacity: 1;
590
- }
591
-
592
- .tg-btn button:active {
593
- opacity: 1;
594
- box-shadow: inset 0 -1px rgba(0, 0, 0, 0.2);
595
- -webkit-transform: translateY(1px);
596
- -moz-transform: translateY(1px);
597
- -o-transform: translateY(1px);
598
- -ms-transform: translateY(1px);
599
- transform: translateY(1px);
600
- }
601
-
602
- .tg-btn button:active {
603
- opacity: 1;
604
- box-shadow: inset 0 -1px rgba(0, 0, 0, 0.2);
605
- -webkit-transform: translateY(1px);
606
- -moz-transform: translateY(1px);
607
- -o-transform: translateY(1px);
608
- -ms-transform: translateY(1px);
609
- transform: translateY(1px);
610
- }
611
-
612
- .tg-btn button:focus,
613
- .tg-btn button:active {
614
- outline: 2px solid black;
615
- }
616
-
617
- .tg-btn.small-btn {
618
- width: auto;
619
- margin: 0 5px;
620
- }
621
-
622
- .tg-btn.small-btn svg {
623
- margin-right: 0;
624
- }
625
-
626
- .tg-btn.small-btn button {
627
- min-width: 35px;
628
- width: 35px;
629
- padding: 0;
630
- display: flex;
631
- justify-content: center;
632
- align-items: center;
633
- }
634
-
635
- .tm-container {
636
- border: 1px solid var(--border-color);
637
- border-radius: 5px;
638
- display: flex;
639
- }
640
- </style>
1
+ <template>
2
+ <div class="tg-container" v-if="templates && identifier">
3
+ <div class="tg-options" :class="{ column: columnSelect }">
4
+ <h4>Template:</h4>
5
+ <v-select class="tg-select" appendToBody :calculatePosition="calculateSelectPosition" :options="templateOptions"
6
+ :value="codTemplate" :reduce="(template) => template.cod" :clearable="false" @input="setTemplate"
7
+ :getOptionLabel="(template) => template.label" ref="template-v-select">
8
+ <div slot="no-options" v-text="dictionary.msg_sem_resultados"></div>
9
+ </v-select>
10
+ </div>
11
+ <template v-if="selectedTemplate">
12
+ <div class="tg-component" v-if="selectedTemplate.components">
13
+ <TemplateSingle :key="codTemplate" :template="selectedTemplate" @set-vars="setFinalMessage"
14
+ @set-file-var="setFileVar" :hasButton="hasButton" :iconButton="iconButton"
15
+ @click-trigger="$emit('click-trigger')" :identifier="identifier" :allVariables="allVariables"
16
+ :dictionary="dictionary" :hasSecondaryButton="hasSecondaryButton"
17
+ @dispatch-clients-with-bot="$emit('dispatch-clients-with-bot')" />
18
+ </div>
19
+ <div class="tg-component" v-else>
20
+ <TemplateMessage @final-message="setMessage" :hasButton="hasButton" :iconButton="iconButton"
21
+ @click-trigger="$emit('click-trigger', true)" :dictionary="dictionary" />
22
+ </div>
23
+ </template>
24
+ </div>
25
+ </template>
26
+
27
+ <script>
28
+ import { createPopper } from "@popperjs/core";
29
+ import TemplateSingle from "./TemplateSingle";
30
+ import TemplateMessage from "./TemplateMessage";
31
+
32
+ export default {
33
+ components: { TemplateSingle, TemplateMessage },
34
+ props: {
35
+ templates: {
36
+ type: Object,
37
+ required: true,
38
+ },
39
+ hasSecondaryButton: {
40
+ type: Boolean,
41
+ required: false,
42
+ default: false,
43
+ },
44
+ hasButton: {
45
+ type: Boolean,
46
+ required: false,
47
+ default: true,
48
+ },
49
+ columnSelect: {
50
+ type: Boolean,
51
+ required: false,
52
+ },
53
+ resizeParentOnSelect: {
54
+ type: Boolean,
55
+ required: false,
56
+ },
57
+ allVariables: {
58
+ type: Boolean,
59
+ required: false,
60
+ default: true,
61
+ },
62
+ iconButton: {
63
+ type: Boolean,
64
+ required: false,
65
+ },
66
+ identifier: {
67
+ type: String,
68
+ required: true,
69
+ },
70
+ placement: {
71
+ type: String,
72
+ default: "bottom",
73
+ },
74
+ dictionary: {
75
+ type: Object,
76
+ required: true,
77
+ },
78
+ selectInitial: {
79
+ type: Boolean,
80
+ required: false,
81
+ default: true,
82
+ },
83
+ },
84
+ data() {
85
+ return {
86
+ templateOptions: [],
87
+ codTemplate: {},
88
+ selectedTemplate: null,
89
+ hasFile: false,
90
+ };
91
+ },
92
+ mounted() {
93
+ this.setTemplateOptions();
94
+ if (this.selectInitial) this.selectIfIsUnique();
95
+ this.selectIfHasContact24h();
96
+ },
97
+ methods: {
98
+ concatTemplateMessage(template) {
99
+ let fullText = "";
100
+ for (let key in template) {
101
+ if (key === "components" && Array.isArray(template[key])) {
102
+ template[key].map((component) => {
103
+ if (component && component.parameters && component.parameters.length) {
104
+ component.parameters.map((param) => {
105
+ fullText += param.text;
106
+ });
107
+ }
108
+ });
109
+ }
110
+ }
111
+
112
+ fullText = fullText.replace(/{{var_\d}}/g, " ------- ");
113
+ fullText = fullText.replace(`&nbsp;`, " ");
114
+ fullText = fullText.replace(/<\/?[\d\w\s=\-:./'";]+>/gi, " ");
115
+
116
+ return fullText;
117
+ },
118
+ calculateSelectPosition(dropdownList, component, sizes) {
119
+ dropdownList.style.width = sizes.width;
120
+ const popper = createPopper(component.$refs.toggle, dropdownList, {
121
+ placement: this.placement,
122
+ modifiers: [
123
+ {
124
+ name: "toggleClass",
125
+ enabled: true,
126
+ phase: "write",
127
+ fn({ state }) {
128
+ component.$el.classList.toggle("drop-up", state.placement === "top");
129
+ },
130
+ },
131
+ ],
132
+ });
133
+ return () => popper.destroy();
134
+ },
135
+ setTemplateOptions() {
136
+ for (let key in this.templates) {
137
+ if (this.templates[key])
138
+ this.templateOptions.push({
139
+ cod: key,
140
+ label: `${this.concatTemplateMessage(this.templates[key])} (${this.templates[key].title
141
+ })`,
142
+ });
143
+ }
144
+ },
145
+ setTemplate(key) {
146
+ if (key) {
147
+ this.selectedTemplate = this.templates[key];
148
+ this.codTemplate = key;
149
+ this.$emit("selected-template", key);
150
+ this.$nextTick(() => {
151
+ if (this.$root.$refs[`template-single-${this.identifier}`])
152
+ this.$root.$refs[`template-single-${this.identifier}`].handleInitialFocus();
153
+ });
154
+ } else {
155
+ this.selectedTemplate = null;
156
+ }
157
+ // if(this.hasFile) this.setFileVar(false)
158
+ this.adjustOnSelect();
159
+ },
160
+ focusSelect() {
161
+ if (this.$refs["template-v-select"] && this.$refs["template-v-select"].$el)
162
+ this.$refs["template-v-select"].$el.querySelector("input").focus();
163
+ },
164
+ selectIfIsUnique() {
165
+ if (Object.keys(this.templates).length === 1) {
166
+ for (let key in this.templates) {
167
+ this.codTemplate = this.templateOptions[0];
168
+ this.selectedTemplate = this.templates[key];
169
+ this.$emit("selected-template", this.codTemplate);
170
+ this.adjustOnSelect();
171
+ }
172
+ }
173
+ if (!this.codTemplate) this.focusSelect();
174
+ },
175
+ selectIfHasContact24h() {
176
+ if (this.templates["envio_msg"]) {
177
+ this.codTemplate = "envio_msg";
178
+ this.selectedTemplate = this.templates["envio_msg"];
179
+ this.$emit("selected-template", "envio_msg");
180
+ this.adjustOnSelect();
181
+ }
182
+ },
183
+ adjustOnSelect() {
184
+ if (this.resizeParentOnSelect) this.$emit("resize-parent");
185
+ },
186
+ setFinalMessage(vars) {
187
+ const keys = Object.keys(vars),
188
+ values = Object.values(vars);
189
+ this.selectedTemplate["parameters"] = {};
190
+ for (let index in this.selectedTemplate) {
191
+ if (index === "components" && Array.isArray(this.selectedTemplate[index])) {
192
+ const arrComponents = this.selectedTemplate[index];
193
+ if (arrComponents && arrComponents.length) {
194
+ arrComponents.map((component) => {
195
+ if (component && component.parameters && component.parameters.length) {
196
+ component.parameters.map((message) => {
197
+ message.currentText = message.text;
198
+ let keyIndex = 0;
199
+ while (keyIndex < keys.length) {
200
+ const varName = `{{${keys[keyIndex]}}}`;
201
+ if (message.text.indexOf(varName) != -1) {
202
+ /**Gerando os obejetos de parametros da notificacao para o component */
203
+ if (
204
+ component.type === "header" &&
205
+ !this.selectedTemplate["parameters"][component.type]
206
+ ) {
207
+ this.selectedTemplate["parameters"][component.type] = {};
208
+ //Header so pode ter uma vari?vel
209
+ this.selectedTemplate["parameters"][component.type] = {
210
+ tipo: "text",
211
+ text: values[keyIndex],
212
+ };
213
+ } else if (!this.selectedTemplate["parameters"][component.type]) {
214
+ this.selectedTemplate["parameters"][component.type] = new Array();
215
+ }
216
+ //Aplicando valores das v?riaveis dentro dos outros componentes com execess?o do header
217
+ if (
218
+ this.selectedTemplate["parameters"][component.type] &&
219
+ component.type !== "header"
220
+ ) {
221
+ this.selectedTemplate["parameters"][component.type].push(
222
+ values[keyIndex]
223
+ );
224
+ }
225
+ message.currentText = message.currentText.replace(
226
+ varName,
227
+ values[keyIndex]
228
+ );
229
+ }
230
+ keyIndex++;
231
+ }
232
+ });
233
+ } else if (component.type == "header" && component.parameters.seq) {
234
+ if (this.hasFile) {
235
+ if (!this.selectedTemplate["parameters"][component.type])
236
+ this.selectedTemplate["parameters"][component.type] = new Array();
237
+
238
+ let tipo = 'image'
239
+ try {
240
+ this.selectedTemplate['components'].forEach((component) => {
241
+ if (component.type === 'header') {
242
+ tipo = component.parameters['0'].type || 'image'
243
+ }
244
+ })
245
+ } catch (err) {
246
+ console.error('Error get tipo, err: ', err)
247
+ }
248
+
249
+ this.selectedTemplate["parameters"][component.type].push({
250
+ tipo,
251
+ template: component.parameters.seq,
252
+ link: "",
253
+ });
254
+ } else {
255
+ delete this.selectedTemplate["parameters"][component.type];
256
+ }
257
+ }
258
+ });
259
+ }
260
+ }
261
+ }
262
+ this.$emit("template-data", this.selectedTemplate);
263
+ },
264
+ setFileVar(file) {
265
+ this.hasFile = file ? true : false;
266
+ this.$emit("set-file-var", file);
267
+ if (file) this.$emit("template-data", this.selectedTemplate);
268
+ },
269
+ setMessage(message) {
270
+ this.$emit("static-message", message);
271
+ },
272
+ },
273
+ };
274
+ </script>
275
+
276
+ <style>
277
+ .tg-container {
278
+ width: 100%;
279
+ max-width: 800px;
280
+ display: flex;
281
+ flex-direction: column;
282
+ overflow-x: hidden;
283
+ overflow-y: auto;
284
+ }
285
+
286
+ .tg-options {
287
+ width: 100%;
288
+ display: flex;
289
+ }
290
+
291
+ .tg-options.column {
292
+ flex-direction: column;
293
+ }
294
+
295
+ .tg-options h4 {
296
+ margin-right: 5px;
297
+ }
298
+
299
+ .ts-image-type {
300
+ display: flex;
301
+ align-items: center;
302
+ }
303
+
304
+ .ts-image-type img {
305
+ cursor: pointer;
306
+ }
307
+
308
+ .ts-image-type svg {
309
+ font-size: 25px;
310
+ cursor: pointer;
311
+ }
312
+
313
+ .ts-image-type .select-image {
314
+ color: #838383;
315
+ }
316
+
317
+ .color-red {
318
+ color: #e74c3c;
319
+ }
320
+
321
+ .color-blue {
322
+ color: #007bff;
323
+ }
324
+
325
+ .color-black {
326
+ color: #333;
327
+ }
328
+
329
+ .color-purple {
330
+ color: #a312a3;
331
+ }
332
+
333
+ .custom-tooltip-image {
334
+ display: flex;
335
+ justify-content: center;
336
+ align-items: center;
337
+ overflow: visible;
338
+ padding: 5px;
339
+ }
340
+
341
+ .custom-tooltip-image img {
342
+ max-width: 75px;
343
+ max-height: 75px;
344
+ }
345
+
346
+ .ts-button {
347
+ background-color: #fff;
348
+ border-radius: 10px;
349
+ display: flex;
350
+ justify-content: center;
351
+ align-items: center;
352
+ padding: 3px 15px;
353
+ transition: background-color 150ms ease-in-out;
354
+ }
355
+
356
+ .ts-button:hover {
357
+ background-color: rgb(253, 253, 253);
358
+ }
359
+
360
+ .tg-select {
361
+ flex: 1;
362
+ height: 34px;
363
+ overflow: hidden;
364
+ }
365
+
366
+ .tg-select .vs__dropdown-toggle {
367
+ background-color: #fff;
368
+ height: 34px;
369
+ overflow: hidden;
370
+ display: flex;
371
+ align-items: center;
372
+ }
373
+
374
+ .tg-select .vs__selected-options {
375
+ height: 34px;
376
+ overflow: hidden;
377
+ }
378
+
379
+ .tg-select .vs__selected-options>span {
380
+ white-space: nowrap;
381
+ text-overflow: ellipsis;
382
+ flex: 1;
383
+ }
384
+
385
+ .vs__dropdown-option.vs__dropdown-option--selected {
386
+ background-color: rgb(26, 95, 173) !important;
387
+ color: white;
388
+ }
389
+
390
+ .vs__dropdown-menu li {
391
+ padding: 10px 15px;
392
+ }
393
+
394
+ .vs__dropdown-option {
395
+ transition: background-color 150ms;
396
+ white-space: normal;
397
+ }
398
+
399
+ .vs__dropdown-option:nth-child(odd) {
400
+ background-color: #f1f1f1;
401
+ }
402
+
403
+ .vs__dropdown-option:hover,
404
+ .vs__dropdown-option:focus,
405
+ .vs__dropdown-option:active,
406
+ .vs__dropdown-option:focus,
407
+ .vs__dropdown-option--selected,
408
+ .vs__dropdown-option--highlight {
409
+ background-color: #5897fb !important;
410
+ color: #fff;
411
+ }
412
+
413
+ .tg-component {
414
+ width: 100%;
415
+ }
416
+
417
+ .ts-container {
418
+ width: 100%;
419
+ display: flex;
420
+ justify-content: space-between;
421
+ gap: 10px;
422
+ }
423
+
424
+ .ts-content {
425
+ --border-color: #ccc;
426
+ --background-color: #dff0d8;
427
+ --input-background-color: #fff;
428
+ --input-border-default: #007bff;
429
+ --input-border-error: #e74c3c;
430
+ --placeholder-color: #bbb;
431
+ --border-radius: 5px;
432
+
433
+ flex: 2;
434
+ font-size: 11.2px;
435
+ padding: 10px 0;
436
+ display: flex;
437
+ flex-direction: column;
438
+ }
439
+
440
+ .order-1 {
441
+ order: 1;
442
+ }
443
+
444
+ .custom-box-shadow-bottom {
445
+ box-shadow: 0px 3px 4px -3px rgba(0, 0, 0, 0.3);
446
+ }
447
+
448
+ .custom-border-gray {
449
+ border: 1px solid var(--border-color) !important;
450
+ }
451
+
452
+ .ts-content header,
453
+ .ts-content section,
454
+ .ts-content footer {
455
+ padding: 3px 5px;
456
+ background-color: var(--background-color);
457
+ }
458
+
459
+ .ts-content header,
460
+ .ts-content section {
461
+ border-right: 1px solid var(--border-color);
462
+ border-left: 1px solid var(--border-color);
463
+ }
464
+
465
+ .ts-content header {
466
+ border-top-left-radius: var(--border-radius);
467
+ border-top-right-radius: var(--border-radius);
468
+ border-top: 1px solid var(--border-color);
469
+ }
470
+
471
+ .ts-content header {
472
+ font-weight: 550;
473
+ }
474
+
475
+ .ts-content section {
476
+ line-height: 25px;
477
+ }
478
+
479
+ .ts-content section.margin-bottom {
480
+ border-bottom-left-radius: var(--border-radius);
481
+ border-bottom-right-radius: var(--border-radius);
482
+ border-bottom: 1px solid var(--border-color);
483
+ }
484
+
485
+ .ts-content footer,
486
+ .custom-footer-style {
487
+ border: 1px solid var(--border-color);
488
+ border-top: unset;
489
+ border-bottom-left-radius: var(--border-radius);
490
+ border-bottom-right-radius: var(--border-radius);
491
+ }
492
+
493
+ .ts-content input {
494
+ border: 1px solid transparent;
495
+ outline: 0;
496
+ font-size: 12.8px;
497
+ padding: 2.5px 5px;
498
+ background-color: var(--input-background-color);
499
+ }
500
+
501
+ .ts-content input::placeholder {
502
+ color: var(--placeholder-color);
503
+ }
504
+
505
+ .ts-content input.active,
506
+ .ts-content input:focus {
507
+ border: 1px solid var(--input-border-default);
508
+ }
509
+
510
+ .ts-content input.invalid {
511
+ border: 1px solid var(--input-border-error) !important;
512
+ }
513
+
514
+ .ts-content__var {
515
+ display: inline-block;
516
+ position: relative;
517
+ }
518
+
519
+ .ts-dropdown {
520
+ margin: 0;
521
+ padding: 0;
522
+ position: absolute;
523
+ top: 19px;
524
+ left: 0;
525
+ background: #eee;
526
+ width: 100%;
527
+ z-index: 1;
528
+ transition: all 150ms;
529
+ visibility: hidden;
530
+ opacity: 0;
531
+ list-style-type: none;
532
+ border: 1px solid #444;
533
+ border-top: unset;
534
+ }
535
+
536
+ .ts-dropdown li {
537
+ width: 100%;
538
+ opacity: 0.9;
539
+ cursor: pointer;
540
+ font-weight: 550;
541
+ padding: 2px 3px;
542
+ font-size: 12.8px;
543
+ transition: background-color 150ms;
544
+ }
545
+
546
+ .ts-dropdown li:hover,
547
+ .ts-dropdown li:focus-within,
548
+ .ts-dropdown li:focus {
549
+ opacity: 1;
550
+ background-color: #555;
551
+ color: #fff;
552
+ }
553
+
554
+ .ts-dropdown.visible {
555
+ visibility: visible;
556
+ opacity: 1;
557
+ }
558
+
559
+ .tg-btn {
560
+ width: auto;
561
+ display: flex;
562
+ justify-content: center;
563
+ align-items: center;
564
+ }
565
+
566
+ .tg-btn button {
567
+ border: unset;
568
+ display: block;
569
+ min-width: 180px;
570
+ height: 35px;
571
+ padding: 0 10px;
572
+ font-weight: 500;
573
+ background-color: #007bff;
574
+ color: #fff;
575
+ transition: transform 300ms ease-in-out;
576
+ user-select: none;
577
+ cursor: pointer;
578
+ box-shadow: inset 0 -2px rgba(0, 0, 0, 0.2);
579
+ opacity: 0.9;
580
+ border-radius: 2.5px;
581
+ }
582
+
583
+ .tg-btn button>svg {
584
+ margin-right: 5px;
585
+ color: #003166;
586
+ }
587
+
588
+ .tg-btn button:hover {
589
+ opacity: 1;
590
+ }
591
+
592
+ .tg-btn button:active {
593
+ opacity: 1;
594
+ box-shadow: inset 0 -1px rgba(0, 0, 0, 0.2);
595
+ -webkit-transform: translateY(1px);
596
+ -moz-transform: translateY(1px);
597
+ -o-transform: translateY(1px);
598
+ -ms-transform: translateY(1px);
599
+ transform: translateY(1px);
600
+ }
601
+
602
+ .tg-btn button:active {
603
+ opacity: 1;
604
+ box-shadow: inset 0 -1px rgba(0, 0, 0, 0.2);
605
+ -webkit-transform: translateY(1px);
606
+ -moz-transform: translateY(1px);
607
+ -o-transform: translateY(1px);
608
+ -ms-transform: translateY(1px);
609
+ transform: translateY(1px);
610
+ }
611
+
612
+ .tg-btn button:focus,
613
+ .tg-btn button:active {
614
+ outline: 2px solid black;
615
+ }
616
+
617
+ .tg-btn.small-btn {
618
+ width: auto;
619
+ margin: 0 5px;
620
+ }
621
+
622
+ .tg-btn.small-btn svg {
623
+ margin-right: 0;
624
+ }
625
+
626
+ .tg-btn.small-btn button {
627
+ min-width: 35px;
628
+ width: 35px;
629
+ padding: 0;
630
+ display: flex;
631
+ justify-content: center;
632
+ align-items: center;
633
+ }
634
+
635
+ .tm-container {
636
+ border: 1px solid var(--border-color);
637
+ border-radius: 5px;
638
+ display: flex;
639
+ }
640
+ </style>