vue-intergrall-plugins 0.0.97 → 0.0.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-intergrall-plugins",
3
- "version": "0.0.97",
3
+ "version": "0.0.103",
4
4
  "description": "",
5
5
  "main": "dist/vue-intergrall-plugins.ssr.js",
6
6
  "browser": "dist/vue-intergrall-plugins.esm.js",
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <div class="text-footer-actions--btn" @click="$emit('expand-textarea')" :title="dictionary.title_expandir_textarea">
3
+ <fa-icon :icon="['fas', 'expand-alt']" />
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ props: {
10
+ dictionary: {
11
+ type: Object,
12
+ default: {},
13
+ required: false
14
+ }
15
+ }
16
+ }
17
+ </script>
@@ -59,14 +59,14 @@
59
59
 
60
60
  .files-counter {
61
61
  position: absolute;
62
- top: 0px;
62
+ top: unset;
63
+ transform: translate(17.5px, -15px);
64
+ background-color: #888;
63
65
  z-index: 1;
64
- right: 0px;
65
66
  font-size: .5rem;
66
67
  width: 15px;
67
68
  height: 15px;
68
69
  border-radius: 50%;
69
- background: #a4ac86;
70
70
  display: flex;
71
71
  justify-content: center;
72
72
  align-items: center;
@@ -204,7 +204,7 @@ export default {
204
204
  }else{
205
205
  file.invalid = true
206
206
  this.fileFormatError = true
207
- this.validFileFormats = `${file.imgOrDoc === "img" ? this.fileSettings.imagesExtensions.split("|").join(", ") : this.fileSettings.docsExtensions.split("|").join(", ")} ${this.dictionary.msg_extensoes_aceitas}`
207
+ this.validFileFormats = `Imgs: ${this.fileSettings.imagesExtensions.split("|").join(", ")} <br> Docs: ${this.fileSettings.docsExtensions.split("|").join(", ")} ${this.dictionary.msg_extensoes_aceitas}`
208
208
  }
209
209
  })
210
210
 
@@ -224,7 +224,7 @@ export default {
224
224
  this.fileFormatError = false
225
225
  }else {
226
226
  this.fileFormatError = true
227
- this.validFileFormats = `${type === "img" ? this.fileSettings.imagesExtensions.split("|").join(", ") : this.fileSettings.docsExtensions.split("|").join(", ")} ${this.dictionary.msg_extensoes_aceitas}`
227
+ this.validFileFormats = `Imgs: ${this.fileSettings.imagesExtensions.split("|").join(", ")} <br> Docs: ${this.fileSettings.docsExtensions.split("|").join(", ")} ${this.dictionary.msg_extensoes_aceitas}`
228
228
  }
229
229
 
230
230
  if(this.isDoc) this.emitFileVars()
@@ -51,6 +51,11 @@ export default {
51
51
  type: Boolean,
52
52
  default: false,
53
53
  required: false
54
+ },
55
+ left: {
56
+ type: Boolean,
57
+ default: true,
58
+ required: false
54
59
  }
55
60
  },
56
61
  computed: {
@@ -93,7 +98,7 @@ export default {
93
98
  if(this.$refs[this.emojiId] && this.$refs[this.emojiId].$el){
94
99
  this.$refs[this.emojiId].$el.style.position = "absolute"
95
100
  this.$refs[this.emojiId].$el.style.top = `${this.top}px`
96
- this.$refs[this.emojiId].$el.style.left = "0"
101
+ this.left ? this.$refs[this.emojiId].$el.style.left = "0" : this.$refs[this.emojiId].$el.style.right = "0"
97
102
  this.$refs[this.emojiId].$el.style.height = `${this.height}px`
98
103
  }
99
104
  },
@@ -0,0 +1,400 @@
1
+ <template>
2
+ <div class="expand-textarea" @drop.stop="dropFile" @dragenter.prevent @dragover.prevent v-on-clickaway="away">
3
+ <fa-icon :icon="['fas', 'times-circle']" class="sc-icone-fechar sc-icone-fechar--externo" @click="$emit('fechar-expand')" />
4
+ <div class="expand-textarea-content">
5
+ <h1 class="expand-textarea-title" v-text="textareaSettings.title"></h1>
6
+ <textarea
7
+ :ref="identifier"
8
+ :placeholder="textareaSettings.placeholderMessage"
9
+ v-model="message"
10
+ @input="sendFinalMessage"
11
+ @paste="pasteImage"
12
+ >
13
+ </textarea>
14
+ <div class="expand-textarea-footer">
15
+ <EmojisTextFooter
16
+ v-show="buttons.hasEmojis"
17
+ :ref="`${identifier}-emojis`"
18
+ :emojiId="`${identifier}-em`"
19
+ :left="false"
20
+ @insert-emoji="insertEmoji"
21
+ />
22
+ <BtnFiles
23
+ v-if="buttons.hasFiles"
24
+ :textId="identifier"
25
+ :dictionary="dictionary"
26
+ :fileSettings="fileSettings"
27
+ :ref="`${identifier}-file`"
28
+ @set-file-vars="setFileVars"
29
+ @open-image="openImage"
30
+ />
31
+ <slot name="btn-1"></slot>
32
+ <slot name="btn-2"></slot>
33
+ <!-- "expand-textarea-button" -->
34
+ </div>
35
+ </div>
36
+ </div>
37
+ </template>
38
+
39
+ <script>
40
+ import { mixin as clickaway } from "vue-clickaway"
41
+ import EmojisTextFooter from "./EmojisTextFooter"
42
+ import BtnFiles from "./BtnFiles"
43
+ import { returnMessageWithHexa } from "@/services/textFormatting"
44
+
45
+ export default {
46
+ components: { EmojisTextFooter, BtnFiles },
47
+ mixins: [ clickaway ],
48
+ props: {
49
+ identifier: {
50
+ type: String,
51
+ required: true
52
+ },
53
+ dictionary: {
54
+ type: Object,
55
+ required: true
56
+ },
57
+ envioEmAndamento: {
58
+ type: Boolean,
59
+ required: false
60
+ },
61
+ buttons: {
62
+ type: Object,
63
+ default: () => { return { hasEmojis: false, hasSendButton: true, hasFiles: true } },
64
+ required: false
65
+ },
66
+ fileSettings: {
67
+ type: Object,
68
+ default: () => { return { docsExtensions: "", imagesExtensions: "", multiple: false } },
69
+ required: false
70
+ },
71
+ textareaSettings: {
72
+ type: Object,
73
+ default: () => { return { placeholderMessage: "", title: "Nova mensagem" } },
74
+ required: false
75
+ }
76
+ },
77
+ data() {
78
+ return {
79
+ message: "",
80
+ file: [],
81
+ hasAnyFile: false,
82
+ imagePreview: "",
83
+ isDoc: false,
84
+ fileFormatError: false
85
+ }
86
+ },
87
+ methods: {
88
+ away() {
89
+ if(this.$refs[`${this.identifier}-file`]) this.$refs[`${this.identifier}-file`].openFiles = false
90
+ },
91
+ removeHTMLElementsFromMessage(message) {
92
+ const regexTags = /<\/?[\d\w\s=\-:./'";]+>/gi
93
+ if(message.match(regexTags)) message = message.replace(regexTags, ' ')
94
+ return message
95
+ },
96
+ formatMessage(message) {
97
+ if(!message) return ""
98
+ message = message.trim()
99
+ message = message.replace(/\n$/, "", message)
100
+ message = returnMessageWithHexa(message)
101
+ message = this.removeHTMLElementsFromMessage(message)
102
+ return message
103
+ },
104
+ sendFinalMessage() {
105
+ const messageAux = this.formatMessage(this.message)
106
+ this.$emit("final-message", messageAux)
107
+ },
108
+ emitirEnvio() {
109
+ if(this.envioEmAndamento) return
110
+ if(!this.buttons.hasSendButton) return
111
+ try {
112
+ if(this.verifyMessage()) {
113
+ const messageAux = this.formatMessage(this.message)
114
+ if(messageAux || this.hasAnyFile) {
115
+ const objMessage = this.returnObjectMessage(messageAux)
116
+ this.$emit("send-message", messageAux)
117
+ this.$emit("obj-message", objMessage)
118
+
119
+ // this.reset() // Deve ser chamada de fora do plugin
120
+ }
121
+ }
122
+ }catch(e) {
123
+ console.error("Erro ao emitir envio da mensagem")
124
+ console.error(e)
125
+ }
126
+ },
127
+ verifyMessage() {
128
+ if((!this.message || !this.message.trim()) && !this.hasAnyFile) return false
129
+
130
+ if(this.fileFormatError) {
131
+ if (!document.querySelector(".toasted.toasted-primary.error")) this.$toasted.global.defaultError({ msg: this.dictionary.msg_formato_invalido })
132
+ const str = {
133
+ img: this.fileSettings.imagesExtensions.split("|").join(", "),
134
+ doc: this.fileSettings.docsExtensions.split("|").join(", ")
135
+ }
136
+ if (!document.querySelector(".toasted.toasted-primary.info")) this.$toasted.global.showValidFormats({ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}` })
137
+ return false
138
+ }
139
+
140
+ return true
141
+ },
142
+ returnObjectMessage(message) {
143
+ return {
144
+ message,
145
+ attachment: this.hasAnyFile ? this.file : false,
146
+ isDoc: this.isDoc,
147
+ imagePreview: this.imagePreview
148
+ }
149
+ },
150
+ reset() {
151
+ if(this.buttons.hasEmojis && this.$refs[`emoji-text-${this.identifier}-emoji`].showEmojis) this.$refs[`emoji-text-${this.identifier}-emoji`].toggleEmojiSelection()
152
+ if(this.hasAnyFile) this.$refs[`${this.identifier}-file`].deleteFile()
153
+ this.message = ""
154
+ this.sendFinalMessage()
155
+ this.focusTextarea()
156
+ },
157
+ dropFile(e) {
158
+ try {
159
+ e.stopPropagation()
160
+ e.preventDefault()
161
+ const files = e.dataTransfer.files.length ? e.dataTransfer.files : ""
162
+ this.filesHandler(files)
163
+ }catch(e) {
164
+ console.error("Erro drop file")
165
+ console.error(e)
166
+ }
167
+ },
168
+ returnFileType(file, stopAlert) {
169
+ const imgRegex = new RegExp("\.("+this.fileSettings.imagesExtensions+")", "i")
170
+ if(imgRegex.test(file.name)) return "img"
171
+
172
+ const docRegex = new RegExp("\.("+this.fileSettings.docsExtensions+")", "i")
173
+ if(docRegex.test(file.name)) return "doc"
174
+
175
+ if(!stopAlert) return
176
+ if (!document.querySelector(".toasted.toasted-primary.error")) this.$toasted.global.defaultError({ msg: this.dictionary.msg_formato_invalido })
177
+ const str = {
178
+ img: this.fileSettings.imagesExtensions.split("|").join(", "),
179
+ doc: this.fileSettings.docsExtensions.split("|").join(", ")
180
+ }
181
+ if (!document.querySelector(".toasted.toasted-primary.info")) this.$toasted.global.showValidFormats({ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}` })
182
+ return false
183
+ },
184
+ filesHandler(files) {
185
+ if(!Array.isArray(files)) files = Array.from(files)
186
+ const fileType = this.returnFileType(files[0], true)
187
+ let invalidFile = false
188
+ try {
189
+ files.forEach(file => {
190
+ const singleFileType = this.returnFileType(file, true)
191
+ if(!singleFileType) {
192
+ invalidFile = true
193
+ file.invalid = true
194
+ }
195
+ file.imgOrDoc = singleFileType ? singleFileType : ""
196
+ })
197
+ }catch(e) {
198
+ console.error("Erro ao tentar percorrer os arquivos")
199
+ console.error(e)
200
+ invalidFile = true
201
+ }
202
+
203
+ if(!invalidFile) {
204
+ this.$refs[`${this.identifier}-file`].fileUpload(files, fileType, true)
205
+ }else {
206
+ if (!document.querySelector(".toasted.toasted-primary.error")) this.$toasted.global.defaultError({ msg: this.dictionary.msg_formato_invalido })
207
+ const str = {
208
+ img: this.fileSettings.imagesExtensions.split("|").join(", "),
209
+ doc: this.fileSettings.docsExtensions.split("|").join(", ")
210
+ }
211
+ if (!document.querySelector(".toasted.toasted-primary.info")) this.$toasted.global.showValidFormats({ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}` })
212
+ }
213
+ },
214
+ focusTextarea() {
215
+ this.$refs[`${this.identifier}`].focus()
216
+ },
217
+ setFileVars(fileObj) {
218
+ const { file, imagePreview, isDoc, fileFormatError, hasAnyFile } = fileObj;
219
+
220
+ this.file = file
221
+ this.imagePreview = imagePreview ? imagePreview : ""
222
+ this.isDoc = isDoc
223
+ this.fileFormatError = fileFormatError
224
+ this.hasAnyFile = hasAnyFile
225
+
226
+ this.$emit("set-file-vars", fileObj)
227
+ },
228
+ openImage(imagePreview) {
229
+ this.$emit("open-image", imagePreview)
230
+ },
231
+ pasteImage(e) {
232
+ try {
233
+ if(e.clipboardData.files.length && !this.buttons.hasFiles) {
234
+ e.preventDefault()
235
+ return
236
+ }else if(e.clipboardData.files.length && this.buttons.hasFiles) {
237
+ const files = e.clipboardData.files
238
+ this.filesHandler(files)
239
+ }
240
+ }catch(e) {
241
+ console.error("Nao foi possivel colar a/o imagem/documento")
242
+ console.error(e)
243
+ }
244
+ },
245
+ insertEmoji(emoji) {
246
+ try {
247
+ const textarea = this.$refs[`${this.identifier}`]
248
+ console.log(textarea)
249
+ this.focusTextarea()
250
+ const cursorStart = textarea.selectionStart
251
+ const cursorEnd = textarea.selectionEnd
252
+ this.message = this.message.slice(0, cursorStart) + emoji.native + this.message.slice(cursorEnd)
253
+ this.sendFinalMessage()
254
+ }catch(e) {
255
+ console.error("Erro na insercao de emojis")
256
+ console.error(e)
257
+ }
258
+ }
259
+ }
260
+ }
261
+ </script>
262
+
263
+ <style>
264
+ .sc-icone-fechar {
265
+ cursor: pointer;
266
+ position: absolute;
267
+ top: 0;
268
+ right: 0;
269
+ background-color: #FFF;
270
+ border-radius: 50%;
271
+ z-index: 1;
272
+ color: #E74C3C;
273
+ font-size: 1.3rem;
274
+ }
275
+ .sc-icone-fechar.sc-icone-fechar--externo {
276
+ top: -10px;
277
+ right: -10px;
278
+ }
279
+ .sc-icone-fechar.sc-icone-fechar--interno {
280
+ top: 10px;
281
+ right: 10px;
282
+ }
283
+
284
+ .expand-textarea {
285
+ position: relative;
286
+ width: 90%;
287
+ height: 90%;
288
+ z-index: 1;
289
+ }
290
+
291
+ .expand-textarea-content {
292
+ overflow-x: hidden;
293
+ overflow-y: auto;
294
+ background-color: #FFF;
295
+ width: 100%;
296
+ height: 100%;
297
+ display: flex;
298
+ flex-direction: column;
299
+ }
300
+ .expand-textarea-title {
301
+ padding: 2.5px 8px;
302
+ min-height: 38px;
303
+ display: flex;
304
+ align-items: center;
305
+ width: 100%;
306
+ font-size: 1.3rem;
307
+ background-color: #222;
308
+ color: #FFF;
309
+ }
310
+ .expand-textarea-content textarea{
311
+ padding: 10px;
312
+ flex: 1;
313
+ width: 100%;
314
+ border: unset;
315
+ resize: none;
316
+ outline: none;
317
+ overflow-x: hidden;
318
+ }
319
+ .expand-textarea-content textarea:hover, .expand-textarea-content textarea:active {
320
+ outline: none;
321
+ }
322
+ .expand-textarea-footer {
323
+ display: flex;
324
+ justify-content: flex-end;
325
+ align-items: center;
326
+ padding: 10px;
327
+ background-color: #F7F7F7;
328
+ position: relative;
329
+ }
330
+ .expand-textarea-footer .text-footer-preview-container {
331
+ position: absolute;
332
+ top: -200px;
333
+ right: 145px;
334
+ height: 200px;
335
+ background: #F7F7F7;
336
+ }
337
+ .expand-textarea-footer .text-footer-actions--btn {
338
+ width: 36px;
339
+ height: 36px;
340
+ border-radius: 50%;
341
+ background-color: rgba(255, 255, 255, 0);
342
+ color: #333;
343
+ padding: 2.5px;
344
+ margin: 0 15px 0 10px;
345
+ display: flex;
346
+ justify-content: center;
347
+ align-items: center;
348
+ font-size: 1.3rem;
349
+ cursor: pointer;
350
+ opacity: .9;
351
+ transition: all 300ms;
352
+ }
353
+ .expand-textarea-footer .text-footer-actions--btn:hover {
354
+ opacity: 1;
355
+ background-color: rgba(30, 30, 30, .1);
356
+ }
357
+
358
+ .expand-textarea-button {
359
+ width: 125px;
360
+ height: 30px;
361
+ display: flex;
362
+ justify-content: center;
363
+ align-items: center;
364
+
365
+ transition-duration: 300ms;
366
+ user-select: none;
367
+ cursor: pointer;
368
+ box-shadow: inset 0 -2px rgba(0, 0, 0, 0.2);
369
+ opacity: .9;
370
+ border-radius: 5px;
371
+
372
+ padding: 5px 10px;
373
+ border-radius: 2.5px;
374
+ position: relative;
375
+ }
376
+ .expand-textarea-button.green {
377
+ background-color: #2A963A;
378
+ color: #FFF;
379
+ margin-right: 10px;
380
+ }
381
+ .expand-textarea-button.red {
382
+ background-color: #E74C3C;
383
+ color: #FFF;
384
+ }
385
+ .expand-textarea-button:hover{
386
+ opacity: 1;
387
+ }
388
+ .expand-textarea-button:active{
389
+ opacity: 1;
390
+ box-shadow: inset 0 -1px rgba(0, 0, 0, 0.2);
391
+ -webkit-transform: translateY(1px);
392
+ -moz-transform: translateY(1px);
393
+ -o-transform: translateY(1px);
394
+ -ms-transform: translateY(1px);
395
+ transform: translateY(1px);
396
+ }
397
+ .expand-textarea-button.carregando {
398
+ background-color: #777;
399
+ }
400
+ </style>
@@ -8,7 +8,7 @@
8
8
  </span>
9
9
  <div class="text-footer-invalid-format" v-if="fileFormatError" key="mfp-invalid-format">
10
10
  <h3 v-text="dictionary.titulo_msg_formato_invalido"></h3>
11
- <h4 v-text="validFileFormats"></h4>
11
+ <h4 v-html="validFileFormats"></h4>
12
12
  </div>
13
13
  </template>
14
14
  <template v-else>
@@ -129,6 +129,38 @@ export default {
129
129
  background-color: #555
130
130
  }
131
131
 
132
+ .text-footer-invalid-format {
133
+ color: #222;
134
+ padding: 10px;
135
+ }
136
+ .text-footer-invalid-format h3 {
137
+ font-weight: 500;
138
+ }
139
+ .text-footer-invalid-format h4 {
140
+ font-size: .9rem;
141
+ }
142
+
143
+ .text-footer-exclude-file {
144
+ position: absolute;
145
+ top: 5px;
146
+ right: 5px;
147
+ cursor: pointer;
148
+ display: flex;
149
+ justify-content: center;
150
+ align-items: center;
151
+ min-width: 1rem;
152
+ min-height: 1rem;
153
+ background-color: #FFF;
154
+ border-radius: 50%;
155
+ }
156
+ .text-footer-exclude-file svg {
157
+ transition: color 200ms;
158
+ color: #e9594a;
159
+ }
160
+ .text-footer-exclude-file svg:hover {
161
+ color: #E74C3C;
162
+ }
163
+
132
164
  .file-preview {
133
165
  display: flex;
134
166
  width: 100%;
@@ -42,5 +42,33 @@ export default {
42
42
  </script>
43
43
 
44
44
  <style>
45
-
45
+ .text-footer-invalid-format {
46
+ color: #222;
47
+ padding: 10px;
48
+ }
49
+ .text-footer-invalid-format h3 {
50
+ font-weight: 500;
51
+ }
52
+ .text-footer-invalid-format h4 {
53
+ font-size: .9rem;
54
+ }
55
+ .text-footer-preview-title {
56
+ font-size: 1rem;
57
+ padding: 10px 0 0 10px;
58
+ white-space: nowrap;
59
+ overflow: hidden;
60
+ text-overflow: ellipsis;
61
+ }
62
+ .text-footer-image-preview {
63
+ display: flex;
64
+ justify-content: center;
65
+ align-items: center;
66
+ width: 100%;
67
+ }
68
+ .text-footer-image-preview img {
69
+ cursor: pointer;
70
+ max-width: 98%;
71
+ max-height: 98%;
72
+ padding: 2%;
73
+ }
46
74
  </style>