@datametria/vue-components 2.4.0 → 2.4.2
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/README.md +57 -5
- package/dist/index.es.js +5812 -2837
- package/dist/index.umd.js +670 -10
- package/dist/src/components/DatametriaCheckbox.vue.d.ts +2 -0
- package/dist/src/components/DatametriaCheckboxGroup.vue.d.ts +6 -0
- package/dist/src/components/DatametriaFileUpload.vue.d.ts +5 -0
- package/dist/src/components/DatametriaFloatingBar.vue.d.ts +1 -1
- package/dist/src/components/DatametriaInput.vue.d.ts +2 -22
- package/dist/src/components/DatametriaNavbar.vue.d.ts +1 -1
- package/dist/src/components/DatametriaPasswordInput.vue.d.ts +2 -0
- package/dist/src/components/DatametriaRadio.vue.d.ts +2 -0
- package/dist/src/components/DatametriaRadioGroup.vue.d.ts +6 -0
- package/dist/src/components/DatametriaSelect.vue.d.ts +2 -3
- package/dist/src/components/DatametriaSidebar.vue.d.ts +1 -1
- package/dist/src/components/DatametriaSwitch.vue.d.ts +8 -1
- package/dist/src/components/DatametriaTabs.vue.d.ts +2 -2
- package/dist/src/components/DatametriaTextarea.vue.d.ts +6 -0
- package/dist/src/composables/useAnalytics.d.ts +8 -0
- package/dist/src/types/analytics.d.ts +50 -0
- package/dist/vue-components.css +1 -1
- package/package.json +3 -2
- package/src/components/DatametriaButton.vue +196 -195
- package/src/components/DatametriaCheckbox.vue +289 -197
- package/src/components/DatametriaCheckboxGroup.vue +161 -58
- package/src/components/DatametriaFileUpload.vue +493 -414
- package/src/components/DatametriaInput.vue +342 -316
- package/src/components/DatametriaPasswordInput.vue +433 -444
- package/src/components/DatametriaRadio.vue +240 -151
- package/src/components/DatametriaRadioGroup.vue +160 -57
- package/src/components/DatametriaSelect.vue +409 -313
- package/src/components/DatametriaSortableTable.vue +35 -29
- package/src/components/DatametriaSwitch.vue +319 -146
- package/src/components/DatametriaTabs.vue +2 -2
- package/src/components/DatametriaTextarea.vue +285 -213
- package/src/composables/useAnalytics.ts +70 -0
- package/src/types/analytics.ts +59 -0
|
@@ -1,448 +1,437 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="datametria-password-input">
|
|
3
|
-
<label v-if="label" :for="inputId" class="datametria-password-input__label">
|
|
4
|
-
{{ label }}
|
|
5
|
-
<span v-if="required" class="datametria-password-input__required">*</span>
|
|
6
|
-
</label>
|
|
7
|
-
|
|
8
|
-
<div class="datametria-password-input__wrapper">
|
|
9
|
-
<input
|
|
10
|
-
:id="inputId"
|
|
11
|
-
:value="modelValue"
|
|
12
|
-
:type="showPassword ? 'text' : 'password'"
|
|
13
|
-
:placeholder="placeholder"
|
|
14
|
-
:disabled="disabled"
|
|
15
|
-
:required="required"
|
|
16
|
-
:autocomplete="autocomplete"
|
|
17
|
-
:class="inputClasses"
|
|
18
|
-
:aria-
|
|
19
|
-
:aria-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@
|
|
23
|
-
@
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<p v-if="capsLockOn" class="datametria-password-input__warning">
|
|
45
|
-
⚠️ Caps Lock está ativado
|
|
46
|
-
</p>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
'datametria-password-input__field',
|
|
193
|
-
{
|
|
194
|
-
'datametria-password-input__field--error': props.errorMessage,
|
|
195
|
-
'datametria-password-input__field--disabled': props.disabled
|
|
196
|
-
}
|
|
197
|
-
])
|
|
198
|
-
|
|
199
|
-
const ariaDescribedby = computed(() => {
|
|
200
|
-
const ids = []
|
|
201
|
-
if (props.showRequirements && isFocused.value) ids.push(`${inputId.value}-requirements`)
|
|
202
|
-
if (props.errorMessage) ids.push(`${inputId.value}-error`)
|
|
203
|
-
if (props.helpText && !props.errorMessage) ids.push(`${inputId.value}-help`)
|
|
204
|
-
return ids.length > 0 ? ids.join(' ') : undefined
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
const handleInput = (event: Event) => {
|
|
208
|
-
const value = (event.target as HTMLInputElement).value
|
|
209
|
-
emit('update:modelValue', value)
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const handleFocus = () => {
|
|
213
|
-
isFocused.value = true
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const handleBlur = () => {
|
|
217
|
-
isFocused.value = false
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const toggleVisibility = () => {
|
|
221
|
-
showPassword.value = !showPassword.value
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const checkCapsLock = (event: KeyboardEvent) => {
|
|
225
|
-
capsLockOn.value = event.getModifierState('CapsLock')
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Watch strength changes and emit
|
|
229
|
-
watch(strength, (newStrength) => {
|
|
230
|
-
if (props.modelValue) {
|
|
231
|
-
emit('strength-change', newStrength)
|
|
232
|
-
}
|
|
233
|
-
})
|
|
234
|
-
</script>
|
|
235
|
-
|
|
236
|
-
<style scoped>
|
|
237
|
-
.datametria-password-input {
|
|
238
|
-
display: flex;
|
|
239
|
-
flex-direction: column;
|
|
240
|
-
gap: var(--dm-spacing-2, 0.5rem);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
.datametria-password-input__label {
|
|
244
|
-
font-size: var(--dm-font-size-sm, 0.875rem);
|
|
245
|
-
font-weight: var(--dm-font-weight-medium, 500);
|
|
246
|
-
color: var(--dm-neutral-700, #374151);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.datametria-password-input__required {
|
|
250
|
-
color: var(--dm-error, #ef4444);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.datametria-password-input__wrapper {
|
|
254
|
-
position: relative;
|
|
255
|
-
display: flex;
|
|
256
|
-
align-items: center;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
.datametria-password-input__field {
|
|
260
|
-
width: 100%;
|
|
261
|
-
padding: var(--dm-spacing-3, 0.75rem);
|
|
262
|
-
padding-right: var(--dm-spacing-12, 3rem);
|
|
263
|
-
border: 1px solid var(--dm-neutral-300, #d1d5db);
|
|
264
|
-
border-radius: var(--dm-radius-md, 0.375rem);
|
|
265
|
-
font-size: var(--dm-font-size-base, 1rem);
|
|
266
|
-
transition: all var(--dm-transition-base, 0.2s);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
.datametria-password-input__field:focus {
|
|
270
|
-
outline: none;
|
|
271
|
-
border-color: var(--dm-primary, #0072CE);
|
|
272
|
-
box-shadow: 0 0 0 3px color-mix(in srgb, var(--dm-primary, #0072CE) 10%, transparent);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
.datametria-password-input__field--error {
|
|
276
|
-
border-color: var(--dm-error, #ef4444);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
.datametria-password-input__field--error:focus {
|
|
280
|
-
border-color: var(--dm-error, #ef4444);
|
|
281
|
-
box-shadow: 0 0 0 3px color-mix(in srgb, var(--dm-error, #ef4444) 10%, transparent);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
.datametria-password-input__field--disabled {
|
|
285
|
-
background: var(--dm-neutral-100, #f3f4f6);
|
|
286
|
-
cursor: not-allowed;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
.datametria-password-input__toggle {
|
|
290
|
-
position: absolute;
|
|
291
|
-
right: var(--dm-spacing-3, 0.75rem);
|
|
292
|
-
background: none;
|
|
293
|
-
border: none;
|
|
294
|
-
cursor: pointer;
|
|
295
|
-
padding: var(--dm-spacing-1, 0.25rem);
|
|
296
|
-
color: var(--dm-neutral-500, #6b7280);
|
|
297
|
-
transition: color var(--dm-transition-base, 0.2s);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
.datametria-password-input__toggle:hover {
|
|
301
|
-
color: var(--dm-neutral-700, #374151);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
.datametria-password-input__toggle:focus {
|
|
305
|
-
outline: 2px solid var(--dm-primary, #0072CE);
|
|
306
|
-
outline-offset: 2px;
|
|
307
|
-
border-radius: var(--dm-radius-sm, 0.25rem);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
.datametria-password-input__icon {
|
|
311
|
-
width: 1.25rem;
|
|
312
|
-
height: 1.25rem;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
.datametria-password-input__warning {
|
|
316
|
-
font-size: var(--dm-font-size-sm, 0.875rem);
|
|
317
|
-
color: var(--dm-warning, #f59e0b);
|
|
318
|
-
margin: 0;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
.datametria-password-input__strength {
|
|
322
|
-
display: flex;
|
|
323
|
-
align-items: center;
|
|
324
|
-
gap: var(--dm-spacing-3, 0.75rem);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
.datametria-password-input__strength-bar {
|
|
328
|
-
flex: 1;
|
|
329
|
-
height: var(--dm-spacing-2, 0.5rem);
|
|
330
|
-
background: var(--dm-neutral-200, #e5e7eb);
|
|
331
|
-
border-radius: var(--dm-radius-sm, 0.25rem);
|
|
332
|
-
overflow: hidden;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
.datametria-password-input__strength-fill {
|
|
336
|
-
height: 100%;
|
|
337
|
-
transition: width var(--dm-transition-slow, 0.3s) ease, background-color var(--dm-transition-slow, 0.3s) ease;
|
|
338
|
-
border-radius: var(--dm-radius-sm, 0.25rem);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
.datametria-password-input__strength-fill--weak {
|
|
342
|
-
background: var(--dm-error, #ef4444);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
.datametria-password-input__strength-fill--medium {
|
|
346
|
-
background: var(--dm-warning, #f59e0b);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
.datametria-password-input__strength-fill--good {
|
|
350
|
-
background: var(--dm-info, #3b82f6);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
.datametria-password-input__strength-fill--strong {
|
|
354
|
-
background: var(--dm-success, #10b981);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
.datametria-password-input__strength-text {
|
|
358
|
-
font-size: var(--dm-font-size-sm, 0.875rem);
|
|
359
|
-
font-weight: var(--dm-font-weight-medium, 500);
|
|
360
|
-
min-width: 4rem;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
.datametria-password-input__strength-text--weak {
|
|
364
|
-
color: var(--dm-error, #ef4444);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
.datametria-password-input__strength-text--medium {
|
|
368
|
-
color: var(--dm-warning, #f59e0b);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
.datametria-password-input__strength-text--good {
|
|
372
|
-
color: var(--dm-info, #3b82f6);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
.datametria-password-input__strength-text--strong {
|
|
376
|
-
color: var(--dm-success, #10b981);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
.datametria-password-input__requirements {
|
|
380
|
-
padding: var(--dm-spacing-3, 0.75rem);
|
|
381
|
-
background: var(--dm-neutral-50, #f9fafb);
|
|
382
|
-
border: 1px solid var(--dm-neutral-200, #e5e7eb);
|
|
383
|
-
border-radius: var(--dm-radius-md, 0.375rem);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
.datametria-password-input__requirements-title {
|
|
387
|
-
font-size: var(--dm-font-size-sm, 0.875rem);
|
|
388
|
-
font-weight: var(--dm-font-weight-medium, 500);
|
|
389
|
-
color: var(--dm-neutral-700, #374151);
|
|
390
|
-
margin: 0 0 var(--dm-spacing-2, 0.5rem) 0;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
.datametria-password-input__requirements-list {
|
|
394
|
-
list-style: none;
|
|
395
|
-
padding: 0;
|
|
396
|
-
margin: 0;
|
|
397
|
-
display: flex;
|
|
398
|
-
flex-direction: column;
|
|
399
|
-
gap: var(--dm-spacing-1, 0.25rem);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
.datametria-password-input__requirements-list li {
|
|
403
|
-
font-size: var(--dm-font-size-sm, 0.875rem);
|
|
404
|
-
color: var(--dm-neutral-500, #6b7280);
|
|
405
|
-
display: flex;
|
|
406
|
-
align-items: center;
|
|
407
|
-
gap: var(--dm-spacing-2, 0.5rem);
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
.datametria-password-input__requirements-list li.valid {
|
|
411
|
-
color: var(--dm-success, #10b981);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
.datametria-password-input__check {
|
|
415
|
-
font-weight: var(--dm-font-weight-semibold, 600);
|
|
416
|
-
min-width: 1rem;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
.datametria-password-input__error {
|
|
420
|
-
font-size: var(--dm-font-size-sm, 0.875rem);
|
|
421
|
-
color: var(--dm-error, #ef4444);
|
|
422
|
-
margin: 0;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
.datametria-password-input__help {
|
|
426
|
-
font-size: var(--dm-font-size-sm, 0.875rem);
|
|
427
|
-
color: var(--dm-neutral-500, #6b7280);
|
|
428
|
-
margin: 0;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
/* Dark Mode Support - Hybrid Approach */
|
|
432
|
-
|
|
433
|
-
/* Fallback automático (sem JS) */
|
|
434
|
-
@media (prefers-color-scheme: dark) {
|
|
435
|
-
.datametria-password-input {
|
|
436
|
-
background: var(--dm-bg-color-dark, #1e1e1e);
|
|
437
|
-
color: var(--dm-text-primary-dark, #e0e0e0);
|
|
438
|
-
border-color: var(--dm-border-color-dark, #404040);
|
|
1
|
+
<template>
|
|
2
|
+
<div class="datametria-password-input" :class="wrapperClasses">
|
|
3
|
+
<label v-if="label" :for="inputId" class="datametria-password-input__label">
|
|
4
|
+
{{ label }}
|
|
5
|
+
<span v-if="required" class="datametria-password-input__required">*</span>
|
|
6
|
+
</label>
|
|
7
|
+
|
|
8
|
+
<div class="datametria-password-input__wrapper">
|
|
9
|
+
<input
|
|
10
|
+
:id="inputId"
|
|
11
|
+
:value="modelValue"
|
|
12
|
+
:type="showPassword ? 'text' : 'password'"
|
|
13
|
+
:placeholder="placeholder"
|
|
14
|
+
:disabled="disabled"
|
|
15
|
+
:required="required"
|
|
16
|
+
:autocomplete="autocomplete"
|
|
17
|
+
:class="inputClasses"
|
|
18
|
+
:aria-label="label || placeholder"
|
|
19
|
+
:aria-required="required"
|
|
20
|
+
:aria-invalid="!!errorMessage"
|
|
21
|
+
:aria-describedby="ariaDescribedby"
|
|
22
|
+
@input="handleInput"
|
|
23
|
+
@focus="handleFocus"
|
|
24
|
+
@blur="handleBlur"
|
|
25
|
+
@keyup="checkCapsLock"
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
<button
|
|
29
|
+
type="button"
|
|
30
|
+
class="datametria-password-input__toggle"
|
|
31
|
+
:aria-label="showPassword ? 'Ocultar senha' : 'Mostrar senha'"
|
|
32
|
+
@click="toggleVisibility"
|
|
33
|
+
>
|
|
34
|
+
<svg v-if="showPassword" class="datametria-password-input__icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
35
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />
|
|
36
|
+
</svg>
|
|
37
|
+
<svg v-else class="datametria-password-input__icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
38
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
|
39
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
|
|
40
|
+
</svg>
|
|
41
|
+
</button>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<p v-if="capsLockOn" class="datametria-password-input__warning" role="alert">
|
|
45
|
+
⚠️ Caps Lock está ativado
|
|
46
|
+
</p>
|
|
47
|
+
|
|
48
|
+
<div v-if="showStrength && modelValue" class="datametria-password-input__strength">
|
|
49
|
+
<div class="datametria-password-input__strength-bar">
|
|
50
|
+
<div :class="strengthBarClasses" :style="{ width: `${strengthPercentage}%` }"></div>
|
|
51
|
+
</div>
|
|
52
|
+
<span :class="strengthTextClasses">{{ strengthText }}</span>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<div v-if="showRequirements && isFocused" :id="`${inputId}-requirements`" class="datametria-password-input__requirements">
|
|
56
|
+
<p class="datametria-password-input__requirements-title">A senha deve conter:</p>
|
|
57
|
+
<ul class="datametria-password-input__requirements-list">
|
|
58
|
+
<li :class="{ 'valid': requirements.minLength }">
|
|
59
|
+
<span class="datametria-password-input__check">{{ requirements.minLength ? '✓' : '○' }}</span>
|
|
60
|
+
Mínimo {{ minLength }} caracteres
|
|
61
|
+
</li>
|
|
62
|
+
<li :class="{ 'valid': requirements.hasUppercase }">
|
|
63
|
+
<span class="datametria-password-input__check">{{ requirements.hasUppercase ? '✓' : '○' }}</span>
|
|
64
|
+
Pelo menos 1 letra maiúscula
|
|
65
|
+
</li>
|
|
66
|
+
<li :class="{ 'valid': requirements.hasLowercase }">
|
|
67
|
+
<span class="datametria-password-input__check">{{ requirements.hasLowercase ? '✓' : '○' }}</span>
|
|
68
|
+
Pelo menos 1 letra minúscula
|
|
69
|
+
</li>
|
|
70
|
+
<li :class="{ 'valid': requirements.hasNumber }">
|
|
71
|
+
<span class="datametria-password-input__check">{{ requirements.hasNumber ? '✓' : '○' }}</span>
|
|
72
|
+
Pelo menos 1 número
|
|
73
|
+
</li>
|
|
74
|
+
<li :class="{ 'valid': requirements.hasSpecial }">
|
|
75
|
+
<span class="datametria-password-input__check">{{ requirements.hasSpecial ? '✓' : '○' }}</span>
|
|
76
|
+
Pelo menos 1 caractere especial
|
|
77
|
+
</li>
|
|
78
|
+
</ul>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<p v-if="errorMessage" :id="`${inputId}-error`" role="alert" aria-live="polite" class="datametria-password-input__error">
|
|
82
|
+
{{ errorMessage }}
|
|
83
|
+
</p>
|
|
84
|
+
|
|
85
|
+
<p v-if="helpText && !errorMessage" :id="`${inputId}-help`" class="datametria-password-input__help">
|
|
86
|
+
{{ helpText }}
|
|
87
|
+
</p>
|
|
88
|
+
</div>
|
|
89
|
+
</template>
|
|
90
|
+
|
|
91
|
+
<script setup lang="ts">
|
|
92
|
+
import { computed, ref, watch } from 'vue'
|
|
93
|
+
import { useAnalytics } from '@/composables/useAnalytics'
|
|
94
|
+
|
|
95
|
+
interface Props {
|
|
96
|
+
modelValue?: string
|
|
97
|
+
label?: string
|
|
98
|
+
placeholder?: string
|
|
99
|
+
errorMessage?: string
|
|
100
|
+
helpText?: string
|
|
101
|
+
disabled?: boolean
|
|
102
|
+
required?: boolean
|
|
103
|
+
minLength?: number
|
|
104
|
+
showStrength?: boolean
|
|
105
|
+
showRequirements?: boolean
|
|
106
|
+
autocomplete?: 'current-password' | 'new-password'
|
|
107
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
111
|
+
modelValue: '',
|
|
112
|
+
disabled: false,
|
|
113
|
+
required: false,
|
|
114
|
+
minLength: 8,
|
|
115
|
+
showStrength: true,
|
|
116
|
+
showRequirements: true,
|
|
117
|
+
autocomplete: 'current-password',
|
|
118
|
+
size: 'md'
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
const emit = defineEmits<{
|
|
122
|
+
'update:modelValue': [value: string]
|
|
123
|
+
'strength-change': [strength: number]
|
|
124
|
+
}>()
|
|
125
|
+
|
|
126
|
+
const { trackEvent } = useAnalytics()
|
|
127
|
+
const inputId = `password-${Math.random().toString(36).substr(2, 9)}`
|
|
128
|
+
const showPassword = ref(false)
|
|
129
|
+
const isFocused = ref(false)
|
|
130
|
+
const capsLockOn = ref(false)
|
|
131
|
+
|
|
132
|
+
const requirements = computed(() => ({
|
|
133
|
+
minLength: props.modelValue.length >= props.minLength,
|
|
134
|
+
hasUppercase: /[A-Z]/.test(props.modelValue),
|
|
135
|
+
hasLowercase: /[a-z]/.test(props.modelValue),
|
|
136
|
+
hasNumber: /\d/.test(props.modelValue),
|
|
137
|
+
hasSpecial: /[!@#$%^&*(),.?":{}|<>]/.test(props.modelValue)
|
|
138
|
+
}))
|
|
139
|
+
|
|
140
|
+
const strength = computed(() => {
|
|
141
|
+
if (!props.modelValue) return 0
|
|
142
|
+
let score = 0
|
|
143
|
+
const reqs = requirements.value
|
|
144
|
+
if (reqs.minLength) score += 20
|
|
145
|
+
if (reqs.hasUppercase) score += 20
|
|
146
|
+
if (reqs.hasLowercase) score += 20
|
|
147
|
+
if (reqs.hasNumber) score += 20
|
|
148
|
+
if (reqs.hasSpecial) score += 20
|
|
149
|
+
return score
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
const strengthPercentage = computed(() => strength.value)
|
|
153
|
+
|
|
154
|
+
const strengthText = computed(() => {
|
|
155
|
+
const s = strength.value
|
|
156
|
+
if (s === 0) return ''
|
|
157
|
+
if (s <= 40) return 'Fraca'
|
|
158
|
+
if (s <= 60) return 'Média'
|
|
159
|
+
if (s <= 80) return 'Boa'
|
|
160
|
+
return 'Forte'
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
const wrapperClasses = computed(() => ({
|
|
164
|
+
[`datametria-password-input--${props.size}`]: true
|
|
165
|
+
}))
|
|
166
|
+
|
|
167
|
+
const strengthBarClasses = computed(() => [
|
|
168
|
+
'datametria-password-input__strength-fill',
|
|
169
|
+
{
|
|
170
|
+
'datametria-password-input__strength-fill--weak': strength.value <= 40,
|
|
171
|
+
'datametria-password-input__strength-fill--medium': strength.value > 40 && strength.value <= 60,
|
|
172
|
+
'datametria-password-input__strength-fill--good': strength.value > 60 && strength.value <= 80,
|
|
173
|
+
'datametria-password-input__strength-fill--strong': strength.value > 80
|
|
174
|
+
}
|
|
175
|
+
])
|
|
176
|
+
|
|
177
|
+
const strengthTextClasses = computed(() => [
|
|
178
|
+
'datametria-password-input__strength-text',
|
|
179
|
+
{
|
|
180
|
+
'datametria-password-input__strength-text--weak': strength.value <= 40,
|
|
181
|
+
'datametria-password-input__strength-text--medium': strength.value > 40 && strength.value <= 60,
|
|
182
|
+
'datametria-password-input__strength-text--good': strength.value > 60 && strength.value <= 80,
|
|
183
|
+
'datametria-password-input__strength-text--strong': strength.value > 80
|
|
184
|
+
}
|
|
185
|
+
])
|
|
186
|
+
|
|
187
|
+
const inputClasses = computed(() => [
|
|
188
|
+
'datametria-password-input__field',
|
|
189
|
+
{
|
|
190
|
+
'datametria-password-input__field--error': props.errorMessage,
|
|
191
|
+
'datametria-password-input__field--disabled': props.disabled
|
|
439
192
|
}
|
|
193
|
+
])
|
|
194
|
+
|
|
195
|
+
const ariaDescribedby = computed(() => {
|
|
196
|
+
const ids = []
|
|
197
|
+
if (props.showRequirements && isFocused.value) ids.push(`${inputId}-requirements`)
|
|
198
|
+
if (props.errorMessage) ids.push(`${inputId}-error`)
|
|
199
|
+
if (props.helpText && !props.errorMessage) ids.push(`${inputId}-help`)
|
|
200
|
+
return ids.length > 0 ? ids.join(' ') : undefined
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
const handleInput = (event: Event) => {
|
|
204
|
+
const value = (event.target as HTMLInputElement).value
|
|
205
|
+
emit('update:modelValue', value)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const handleFocus = () => {
|
|
209
|
+
isFocused.value = true
|
|
210
|
+
trackEvent('password_input_focus', {
|
|
211
|
+
component: 'DatametriaPasswordInput',
|
|
212
|
+
size: props.size
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const handleBlur = () => {
|
|
217
|
+
isFocused.value = false
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const toggleVisibility = () => {
|
|
221
|
+
showPassword.value = !showPassword.value
|
|
222
|
+
trackEvent('password_visibility_toggle', {
|
|
223
|
+
component: 'DatametriaPasswordInput',
|
|
224
|
+
visible: showPassword.value
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const checkCapsLock = (event: KeyboardEvent) => {
|
|
229
|
+
capsLockOn.value = event.getModifierState('CapsLock')
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
watch(strength, (newStrength) => {
|
|
233
|
+
if (props.modelValue) {
|
|
234
|
+
emit('strength-change', newStrength)
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
</script>
|
|
238
|
+
|
|
239
|
+
<style scoped>
|
|
240
|
+
.datametria-password-input {
|
|
241
|
+
display: flex;
|
|
242
|
+
flex-direction: column;
|
|
243
|
+
gap: 8px;
|
|
244
|
+
width: 100%;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.datametria-password-input__label {
|
|
248
|
+
font-size: 14px;
|
|
249
|
+
font-weight: 500;
|
|
250
|
+
color: var(--color-text-primary, #1f2937);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.datametria-password-input__required {
|
|
254
|
+
color: var(--color-error, #ef4444);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.datametria-password-input__wrapper {
|
|
258
|
+
position: relative;
|
|
259
|
+
display: flex;
|
|
260
|
+
align-items: center;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.datametria-password-input__field {
|
|
264
|
+
width: 100%;
|
|
265
|
+
padding: 8px 40px 8px 12px;
|
|
266
|
+
border: 1px solid var(--color-border, #d1d5db);
|
|
267
|
+
border-radius: 6px;
|
|
268
|
+
background: var(--color-background, #fff);
|
|
269
|
+
color: var(--color-text-primary, #1f2937);
|
|
270
|
+
font-size: 14px;
|
|
271
|
+
transition: all 0.2s;
|
|
272
|
+
touch-action: manipulation;
|
|
273
|
+
-webkit-tap-highlight-color: transparent;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.datametria-password-input__field:hover:not(:disabled) {
|
|
277
|
+
border-color: var(--color-primary, #3b82f6);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.datametria-password-input__field:focus {
|
|
281
|
+
outline: none;
|
|
282
|
+
border-color: var(--color-primary, #3b82f6);
|
|
283
|
+
box-shadow: 0 0 0 3px var(--color-primary-alpha, rgba(59, 130, 246, 0.1));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.datametria-password-input__field--error {
|
|
287
|
+
border-color: var(--color-error, #ef4444);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.datametria-password-input__field--disabled {
|
|
291
|
+
background: var(--color-background-muted, #f3f4f6);
|
|
292
|
+
cursor: not-allowed;
|
|
293
|
+
opacity: 0.6;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.datametria-password-input__toggle {
|
|
297
|
+
position: absolute;
|
|
298
|
+
right: 8px;
|
|
299
|
+
background: none;
|
|
300
|
+
border: none;
|
|
301
|
+
cursor: pointer;
|
|
302
|
+
padding: 8px;
|
|
303
|
+
min-width: 44px;
|
|
304
|
+
min-height: 44px;
|
|
305
|
+
display: flex;
|
|
306
|
+
align-items: center;
|
|
307
|
+
justify-content: center;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.datametria-password-input__icon {
|
|
311
|
+
width: 20px;
|
|
312
|
+
height: 20px;
|
|
313
|
+
color: var(--color-text-secondary, #6b7280);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.datametria-password-input__warning {
|
|
317
|
+
font-size: 12px;
|
|
318
|
+
color: var(--color-warning, #f59e0b);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.datametria-password-input__strength {
|
|
322
|
+
display: flex;
|
|
323
|
+
align-items: center;
|
|
324
|
+
gap: 8px;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.datametria-password-input__strength-bar {
|
|
328
|
+
flex: 1;
|
|
329
|
+
height: 4px;
|
|
330
|
+
background: var(--color-background-muted, #f3f4f6);
|
|
331
|
+
border-radius: 2px;
|
|
332
|
+
overflow: hidden;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.datametria-password-input__strength-fill {
|
|
336
|
+
height: 100%;
|
|
337
|
+
transition: width 0.3s, background-color 0.3s;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.datametria-password-input__strength-fill--weak { background: var(--color-error, #ef4444); }
|
|
341
|
+
.datametria-password-input__strength-fill--medium { background: var(--color-warning, #f59e0b); }
|
|
342
|
+
.datametria-password-input__strength-fill--good { background: var(--color-info, #3b82f6); }
|
|
343
|
+
.datametria-password-input__strength-fill--strong { background: var(--color-success, #10b981); }
|
|
344
|
+
|
|
345
|
+
.datametria-password-input__strength-text {
|
|
346
|
+
font-size: 12px;
|
|
347
|
+
font-weight: 500;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.datametria-password-input__strength-text--weak { color: var(--color-error, #ef4444); }
|
|
351
|
+
.datametria-password-input__strength-text--medium { color: var(--color-warning, #f59e0b); }
|
|
352
|
+
.datametria-password-input__strength-text--good { color: var(--color-info, #3b82f6); }
|
|
353
|
+
.datametria-password-input__strength-text--strong { color: var(--color-success, #10b981); }
|
|
354
|
+
|
|
355
|
+
.datametria-password-input__requirements {
|
|
356
|
+
padding: 12px;
|
|
357
|
+
background: var(--color-background-alt, #f9fafb);
|
|
358
|
+
border-radius: 6px;
|
|
359
|
+
font-size: 12px;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.datametria-password-input__requirements-title {
|
|
363
|
+
font-weight: 500;
|
|
364
|
+
margin-bottom: 8px;
|
|
365
|
+
color: var(--color-text-primary, #1f2937);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.datametria-password-input__requirements-list {
|
|
369
|
+
list-style: none;
|
|
370
|
+
padding: 0;
|
|
371
|
+
margin: 0;
|
|
372
|
+
display: flex;
|
|
373
|
+
flex-direction: column;
|
|
374
|
+
gap: 4px;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.datametria-password-input__requirements-list li {
|
|
378
|
+
color: var(--color-text-secondary, #6b7280);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.datametria-password-input__requirements-list li.valid {
|
|
382
|
+
color: var(--color-success, #10b981);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.datametria-password-input__check {
|
|
386
|
+
margin-right: 4px;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
.datametria-password-input__error {
|
|
390
|
+
font-size: 12px;
|
|
391
|
+
color: var(--color-error, #ef4444);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.datametria-password-input__help {
|
|
395
|
+
font-size: 12px;
|
|
396
|
+
color: var(--color-text-secondary, #6b7280);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/* Tamanhos */
|
|
400
|
+
.datametria-password-input--xs .datametria-password-input__field {
|
|
401
|
+
padding: 2px 36px 2px 6px;
|
|
402
|
+
font-size: 11px;
|
|
403
|
+
min-height: 1.75rem;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.datametria-password-input--sm .datametria-password-input__field {
|
|
407
|
+
padding: 4px 38px 4px 8px;
|
|
408
|
+
font-size: 12px;
|
|
409
|
+
min-height: 2rem;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
.datametria-password-input--md .datametria-password-input__field {
|
|
413
|
+
padding: 8px 40px 8px 12px;
|
|
414
|
+
font-size: 14px;
|
|
415
|
+
min-height: 2.5rem;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.datametria-password-input--lg .datametria-password-input__field {
|
|
419
|
+
padding: 12px 44px 12px 16px;
|
|
420
|
+
font-size: 16px;
|
|
421
|
+
min-height: 3rem;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.datametria-password-input--xl .datametria-password-input__field {
|
|
425
|
+
padding: 16px 48px 16px 20px;
|
|
426
|
+
font-size: 18px;
|
|
427
|
+
min-height: 3.5rem;
|
|
440
428
|
}
|
|
441
429
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
430
|
+
@media (max-width: 640px) {
|
|
431
|
+
.datametria-password-input--xs .datametria-password-input__field { min-height: 2rem; }
|
|
432
|
+
.datametria-password-input--sm .datametria-password-input__field { min-height: 2.25rem; }
|
|
433
|
+
.datametria-password-input--md .datametria-password-input__field { min-height: 2.75rem; }
|
|
434
|
+
.datametria-password-input--lg .datametria-password-input__field { min-height: 3.25rem; }
|
|
435
|
+
.datametria-password-input--xl .datametria-password-input__field { min-height: 3.75rem; }
|
|
447
436
|
}
|
|
448
|
-
</style>
|
|
437
|
+
</style>
|