vue-intergrall-plugins 0.0.300 → 0.0.500

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