air-vue-components-2 3.2.164 → 3.2.166

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
@@ -5,7 +5,7 @@
5
5
  "message": "\"Mensagem Automatica\"",
6
6
  "version_increment": "patch"
7
7
  },
8
- "version": "3.2.164",
8
+ "version": "3.2.166",
9
9
  "author": "ti.acessos@alloha.com",
10
10
  "main": "src/air-vue-components.js",
11
11
  "scripts": {
@@ -87,18 +87,30 @@
87
87
  const iniciais = (primeira + segunda).toUpperCase()
88
88
  return iniciais || '?'
89
89
  },
90
- corPastelAleatoria () {
91
- const paleta = [
92
- '#F7B7B7', // vermelho pastel
93
- '#BFE7C2', // verde pastel
94
- '#BFD7FF', // azul pastel
95
- '#FFD6A5', // laranja pastel
96
- '#FBC4E2', // rosa pastel
97
- '#D7C6FF', // roxo pastel
98
- '#BFEFEA', // teal pastel
99
- '#FFF1A8' // amarelo pastel
90
+ paletaPastel () {
91
+ return [
92
+ '#F7B7B7',
93
+ '#D7C6FF',
94
+ '#BFD7FF',
95
+ '#FFD6A5',
96
+ '#FBC4E2',
97
+ '#BFE7C2',
98
+ '#BFEFEA',
99
+ '#FFF1A8'
100
100
  ]
101
- return paleta[Math.floor(Math.random() * paleta.length)]
101
+ },
102
+ corPastelPorLetra (letra) {
103
+ const paleta = this.paletaPastel()
104
+
105
+ const ch = String(letra || '?').toUpperCase()
106
+ const code = ch.charCodeAt(0)
107
+
108
+ if (code >= 65 && code <= 90) {
109
+ const idx = (code - 65) % paleta.length
110
+ return paleta[idx]
111
+ }
112
+
113
+ return paleta[0]
102
114
  },
103
115
  hexParaRgb (hex) {
104
116
  const h = String(hex || '').replace('#', '').trim()
@@ -124,29 +136,27 @@
124
136
  },
125
137
  gerarAvatarDataUrl (email) {
126
138
  const iniciais = this.gerarIniciaisDoEmail(email)
127
-
128
- if (!this.avatarBg) this.avatarBg = this.corPastelAleatoria()
129
-
130
- const bg = this.avatarBg
139
+ const primeiraLetra = (iniciais && iniciais !== '?') ? iniciais[0] : '?'
140
+ const bg = this.corPastelPorLetra(primeiraLetra)
131
141
  const fg = this.escurecerHex(bg, 0.55)
132
142
 
133
143
  const svg = `
134
- <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
135
- <rect width="128" height="128" rx="64" ry="64" fill="${bg}"/>
136
- <text x="64" y="64"
137
- text-anchor="middle"
138
- dominant-baseline="central"
139
- font-family="Arial, Helvetica, sans-serif"
140
- font-size="56"
141
- font-weight="700"
142
- fill="${fg}">
143
- ${iniciais}
144
- </text>
145
- </svg>
146
- `.trim()
144
+ <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
145
+ <rect width="128" height="128" rx="64" ry="64" fill="${bg}"/>
146
+ <text x="64" y="64"
147
+ text-anchor="middle"
148
+ dominant-baseline="central"
149
+ font-family="Arial, Helvetica, sans-serif"
150
+ font-size="56"
151
+ font-weight="700"
152
+ fill="${fg}">
153
+ ${iniciais}
154
+ </text>
155
+ </svg>
156
+ `.trim()
147
157
 
148
158
  return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg)
149
159
  }
150
160
  }
151
161
  }
152
- </script>
162
+ </script>
@@ -99,18 +99,30 @@
99
99
  const iniciais = (primeira + segunda).toUpperCase()
100
100
  return iniciais || '?'
101
101
  },
102
- corPastelAleatoria () {
103
- const paleta = [
104
- '#F7B7B7', // vermelho pastel
105
- '#BFE7C2', // verde pastel
106
- '#BFD7FF', // azul pastel
107
- '#FFD6A5', // laranja pastel
108
- '#FBC4E2', // rosa pastel
109
- '#D7C6FF', // roxo pastel
110
- '#BFEFEA', // teal pastel
111
- '#FFF1A8' // amarelo pastel
102
+ paletaPastel () {
103
+ return [
104
+ '#F7B7B7',
105
+ '#D7C6FF',
106
+ '#BFD7FF',
107
+ '#FFD6A5',
108
+ '#FBC4E2',
109
+ '#BFE7C2',
110
+ '#BFEFEA',
111
+ '#FFF1A8'
112
112
  ]
113
- return paleta[Math.floor(Math.random() * paleta.length)]
113
+ },
114
+ corPastelPorLetra (letra) {
115
+ const paleta = this.paletaPastel()
116
+
117
+ const ch = String(letra || '?').toUpperCase()
118
+ const code = ch.charCodeAt(0)
119
+
120
+ if (code >= 65 && code <= 90) {
121
+ const idx = (code - 65) % paleta.length
122
+ return paleta[idx]
123
+ }
124
+
125
+ return paleta[0]
114
126
  },
115
127
  hexParaRgb (hex) {
116
128
  const h = String(hex || '').replace('#', '').trim()
@@ -136,26 +148,24 @@
136
148
  },
137
149
  gerarAvatarDataUrl (email) {
138
150
  const iniciais = this.gerarIniciaisDoEmail(email)
139
-
140
- if (!this.avatarBg) this.avatarBg = this.corPastelAleatoria()
141
-
142
- const bg = this.avatarBg
151
+ const primeiraLetra = (iniciais && iniciais !== '?') ? iniciais[0] : '?'
152
+ const bg = this.corPastelPorLetra(primeiraLetra)
143
153
  const fg = this.escurecerHex(bg, 0.55)
144
154
 
145
155
  const svg = `
146
- <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
147
- <rect width="128" height="128" rx="64" ry="64" fill="${bg}"/>
148
- <text x="64" y="64"
149
- text-anchor="middle"
150
- dominant-baseline="central"
151
- font-family="Arial, Helvetica, sans-serif"
152
- font-size="56"
153
- font-weight="700"
154
- fill="${fg}">
155
- ${iniciais}
156
- </text>
157
- </svg>
158
- `.trim()
156
+ <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
157
+ <rect width="128" height="128" rx="64" ry="64" fill="${bg}"/>
158
+ <text x="64" y="64"
159
+ text-anchor="middle"
160
+ dominant-baseline="central"
161
+ font-family="Arial, Helvetica, sans-serif"
162
+ font-size="56"
163
+ font-weight="700"
164
+ fill="${fg}">
165
+ ${iniciais}
166
+ </text>
167
+ </svg>
168
+ `.trim()
159
169
 
160
170
  return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg)
161
171
  }
@@ -150,18 +150,30 @@
150
150
  const iniciais = (primeira + segunda).toUpperCase()
151
151
  return iniciais || '?'
152
152
  },
153
- corPastelAleatoria () {
154
- const paleta = [
155
- '#F7B7B7', // vermelho pastel
156
- '#BFE7C2', // verde pastel
157
- '#BFD7FF', // azul pastel
158
- '#FFD6A5', // laranja pastel
159
- '#FBC4E2', // rosa pastel
160
- '#D7C6FF', // roxo pastel
161
- '#BFEFEA', // teal pastel
162
- '#FFF1A8' // amarelo pastel
153
+ paletaPastel () {
154
+ return [
155
+ '#F7B7B7',
156
+ '#D7C6FF',
157
+ '#BFD7FF',
158
+ '#FFD6A5',
159
+ '#FBC4E2',
160
+ '#BFE7C2',
161
+ '#BFEFEA',
162
+ '#FFF1A8'
163
163
  ]
164
- return paleta[Math.floor(Math.random() * paleta.length)]
164
+ },
165
+ corPastelPorLetra (letra) {
166
+ const paleta = this.paletaPastel()
167
+
168
+ const ch = String(letra || '?').toUpperCase()
169
+ const code = ch.charCodeAt(0)
170
+
171
+ if (code >= 65 && code <= 90) {
172
+ const idx = (code - 65) % paleta.length
173
+ return paleta[idx]
174
+ }
175
+
176
+ return paleta[0]
165
177
  },
166
178
  hexParaRgb (hex) {
167
179
  const h = String(hex || '').replace('#', '').trim()
@@ -187,26 +199,24 @@
187
199
  },
188
200
  gerarAvatarDataUrl (email) {
189
201
  const iniciais = this.gerarIniciaisDoEmail(email)
190
-
191
- if (!this.avatarBg) this.avatarBg = this.corPastelAleatoria()
192
-
193
- const bg = this.avatarBg
202
+ const primeiraLetra = (iniciais && iniciais !== '?') ? iniciais[0] : '?'
203
+ const bg = this.corPastelPorLetra(primeiraLetra)
194
204
  const fg = this.escurecerHex(bg, 0.55)
195
205
 
196
206
  const svg = `
197
- <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
198
- <rect width="128" height="128" rx="64" ry="64" fill="${bg}"/>
199
- <text x="64" y="64"
200
- text-anchor="middle"
201
- dominant-baseline="central"
202
- font-family="Arial, Helvetica, sans-serif"
203
- font-size="56"
204
- font-weight="700"
205
- fill="${fg}">
206
- ${iniciais}
207
- </text>
208
- </svg>
209
- `.trim()
207
+ <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
208
+ <rect width="128" height="128" rx="64" ry="64" fill="${bg}"/>
209
+ <text x="64" y="64"
210
+ text-anchor="middle"
211
+ dominant-baseline="central"
212
+ font-family="Arial, Helvetica, sans-serif"
213
+ font-size="56"
214
+ font-weight="700"
215
+ fill="${fg}">
216
+ ${iniciais}
217
+ </text>
218
+ </svg>
219
+ `.trim()
210
220
 
211
221
  return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg)
212
222
  }
@@ -87,18 +87,30 @@
87
87
  const iniciais = (primeira + segunda).toUpperCase()
88
88
  return iniciais || '?'
89
89
  },
90
- corPastelAleatoria () {
91
- const paleta = [
92
- '#F7B7B7', // vermelho pastel
93
- '#BFE7C2', // verde pastel
94
- '#BFD7FF', // azul pastel
95
- '#FFD6A5', // laranja pastel
96
- '#FBC4E2', // rosa pastel
97
- '#D7C6FF', // roxo pastel
98
- '#BFEFEA', // teal pastel
99
- '#FFF1A8' // amarelo pastel
90
+ paletaPastel () {
91
+ return [
92
+ '#F7B7B7',
93
+ '#D7C6FF',
94
+ '#BFD7FF',
95
+ '#FFD6A5',
96
+ '#FBC4E2',
97
+ '#BFE7C2',
98
+ '#BFEFEA',
99
+ '#FFF1A8'
100
100
  ]
101
- return paleta[Math.floor(Math.random() * paleta.length)]
101
+ },
102
+ corPastelPorLetra (letra) {
103
+ const paleta = this.paletaPastel()
104
+
105
+ const ch = String(letra || '?').toUpperCase()
106
+ const code = ch.charCodeAt(0)
107
+
108
+ if (code >= 65 && code <= 90) {
109
+ const idx = (code - 65) % paleta.length
110
+ return paleta[idx]
111
+ }
112
+
113
+ return paleta[0]
102
114
  },
103
115
  hexParaRgb (hex) {
104
116
  const h = String(hex || '').replace('#', '').trim()
@@ -124,26 +136,24 @@
124
136
  },
125
137
  gerarAvatarDataUrl (email) {
126
138
  const iniciais = this.gerarIniciaisDoEmail(email)
127
-
128
- if (!this.avatarBg) this.avatarBg = this.corPastelAleatoria()
129
-
130
- const bg = this.avatarBg
139
+ const primeiraLetra = (iniciais && iniciais !== '?') ? iniciais[0] : '?'
140
+ const bg = this.corPastelPorLetra(primeiraLetra)
131
141
  const fg = this.escurecerHex(bg, 0.55)
132
142
 
133
143
  const svg = `
134
- <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
135
- <rect width="128" height="128" rx="64" ry="64" fill="${bg}"/>
136
- <text x="64" y="64"
137
- text-anchor="middle"
138
- dominant-baseline="central"
139
- font-family="Arial, Helvetica, sans-serif"
140
- font-size="56"
141
- font-weight="700"
142
- fill="${fg}">
143
- ${iniciais}
144
- </text>
145
- </svg>
146
- `.trim()
144
+ <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
145
+ <rect width="128" height="128" rx="64" ry="64" fill="${bg}"/>
146
+ <text x="64" y="64"
147
+ text-anchor="middle"
148
+ dominant-baseline="central"
149
+ font-family="Arial, Helvetica, sans-serif"
150
+ font-size="56"
151
+ font-weight="700"
152
+ fill="${fg}">
153
+ ${iniciais}
154
+ </text>
155
+ </svg>
156
+ `.trim()
147
157
 
148
158
  return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg)
149
159
  }
@@ -107,18 +107,30 @@
107
107
  const iniciais = (primeira + segunda).toUpperCase()
108
108
  return iniciais || '?'
109
109
  },
110
- corPastelAleatoria () {
111
- const paleta = [
112
- '#F7B7B7', // vermelho pastel
113
- '#BFE7C2', // verde pastel
114
- '#BFD7FF', // azul pastel
115
- '#FFD6A5', // laranja pastel
116
- '#FBC4E2', // rosa pastel
117
- '#D7C6FF', // roxo pastel
118
- '#BFEFEA', // teal pastel
119
- '#FFF1A8' // amarelo pastel
110
+ paletaPastel () {
111
+ return [
112
+ '#F7B7B7',
113
+ '#D7C6FF',
114
+ '#BFD7FF',
115
+ '#FFD6A5',
116
+ '#FBC4E2',
117
+ '#BFE7C2',
118
+ '#BFEFEA',
119
+ '#FFF1A8'
120
120
  ]
121
- return paleta[Math.floor(Math.random() * paleta.length)]
121
+ },
122
+ corPastelPorLetra (letra) {
123
+ const paleta = this.paletaPastel()
124
+
125
+ const ch = String(letra || '?').toUpperCase()
126
+ const code = ch.charCodeAt(0)
127
+
128
+ if (code >= 65 && code <= 90) {
129
+ const idx = (code - 65) % paleta.length
130
+ return paleta[idx]
131
+ }
132
+
133
+ return paleta[0]
122
134
  },
123
135
  hexParaRgb (hex) {
124
136
  const h = String(hex || '').replace('#', '').trim()
@@ -144,26 +156,24 @@
144
156
  },
145
157
  gerarAvatarDataUrl (email) {
146
158
  const iniciais = this.gerarIniciaisDoEmail(email)
147
-
148
- if (!this.avatarBg) this.avatarBg = this.corPastelAleatoria()
149
-
150
- const bg = this.avatarBg
159
+ const primeiraLetra = (iniciais && iniciais !== '?') ? iniciais[0] : '?'
160
+ const bg = this.corPastelPorLetra(primeiraLetra)
151
161
  const fg = this.escurecerHex(bg, 0.55)
152
162
 
153
163
  const svg = `
154
- <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
155
- <rect width="128" height="128" rx="64" ry="64" fill="${bg}"/>
156
- <text x="64" y="64"
157
- text-anchor="middle"
158
- dominant-baseline="central"
159
- font-family="Arial, Helvetica, sans-serif"
160
- font-size="56"
161
- font-weight="700"
162
- fill="${fg}">
163
- ${iniciais}
164
- </text>
165
- </svg>
166
- `.trim()
164
+ <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
165
+ <rect width="128" height="128" rx="64" ry="64" fill="${bg}"/>
166
+ <text x="64" y="64"
167
+ text-anchor="middle"
168
+ dominant-baseline="central"
169
+ font-family="Arial, Helvetica, sans-serif"
170
+ font-size="56"
171
+ font-weight="700"
172
+ fill="${fg}">
173
+ ${iniciais}
174
+ </text>
175
+ </svg>
176
+ `.trim()
167
177
 
168
178
  return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg)
169
179
  }