@datametria/vue-components 2.4.1 → 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 +124 -3
- package/src/components/DatametriaFileUpload.vue +493 -414
- package/src/components/DatametriaInput.vue +342 -316
- package/src/components/DatametriaPasswordInput.vue +433 -446
- package/src/components/DatametriaRadio.vue +240 -151
- package/src/components/DatametriaRadioGroup.vue +124 -3
- package/src/components/DatametriaSelect.vue +409 -313
- 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,147 +1,320 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
border
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.datametria-switch:focus-visible {
|
|
132
|
-
outline:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="datametria-switch-wrapper" :class="wrapperClasses">
|
|
3
|
+
<label v-if="label" :for="switchId" class="datametria-switch__label-text">
|
|
4
|
+
{{ label }}
|
|
5
|
+
<span v-if="required" class="datametria-switch__required">*</span>
|
|
6
|
+
</label>
|
|
7
|
+
|
|
8
|
+
<button
|
|
9
|
+
:id="switchId"
|
|
10
|
+
type="button"
|
|
11
|
+
role="switch"
|
|
12
|
+
class="datametria-switch"
|
|
13
|
+
:aria-checked="modelValue"
|
|
14
|
+
:aria-disabled="disabled || loading"
|
|
15
|
+
:aria-label="label || ariaLabel"
|
|
16
|
+
:disabled="disabled || loading"
|
|
17
|
+
@click="handleClick"
|
|
18
|
+
>
|
|
19
|
+
<span class="datametria-switch__core" :style="coreStyle">
|
|
20
|
+
<span v-if="loading" class="datametria-switch__loading">
|
|
21
|
+
<span class="spinner" role="status" aria-label="Carregando"></span>
|
|
22
|
+
</span>
|
|
23
|
+
</span>
|
|
24
|
+
</button>
|
|
25
|
+
|
|
26
|
+
<div
|
|
27
|
+
v-if="errorMessage"
|
|
28
|
+
:id="`${switchId}-error`"
|
|
29
|
+
role="alert"
|
|
30
|
+
aria-live="polite"
|
|
31
|
+
class="datametria-switch__error"
|
|
32
|
+
>
|
|
33
|
+
{{ errorMessage }}
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<script setup lang="ts">
|
|
39
|
+
import { computed } from 'vue'
|
|
40
|
+
import { useAnalytics } from '@/composables/useAnalytics'
|
|
41
|
+
|
|
42
|
+
interface Props {
|
|
43
|
+
modelValue?: boolean
|
|
44
|
+
disabled?: boolean
|
|
45
|
+
loading?: boolean
|
|
46
|
+
label?: string
|
|
47
|
+
ariaLabel?: string
|
|
48
|
+
required?: boolean
|
|
49
|
+
errorMessage?: string
|
|
50
|
+
activeColor?: string
|
|
51
|
+
inactiveColor?: string
|
|
52
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
56
|
+
modelValue: false,
|
|
57
|
+
disabled: false,
|
|
58
|
+
loading: false,
|
|
59
|
+
required: false,
|
|
60
|
+
activeColor: '#3b82f6',
|
|
61
|
+
inactiveColor: '#d1d5db',
|
|
62
|
+
size: 'md'
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const emit = defineEmits<{
|
|
66
|
+
'update:modelValue': [value: boolean]
|
|
67
|
+
change: [value: boolean]
|
|
68
|
+
}>()
|
|
69
|
+
|
|
70
|
+
const { trackEvent } = useAnalytics()
|
|
71
|
+
const switchId = `datametria-switch-${Math.random().toString(36).substr(2, 9)}`
|
|
72
|
+
|
|
73
|
+
const wrapperClasses = computed(() => ({
|
|
74
|
+
'is-checked': props.modelValue,
|
|
75
|
+
'is-disabled': props.disabled,
|
|
76
|
+
'is-loading': props.loading,
|
|
77
|
+
'is-error': !!props.errorMessage,
|
|
78
|
+
[`datametria-switch-wrapper--${props.size}`]: true
|
|
79
|
+
}))
|
|
80
|
+
|
|
81
|
+
const coreStyle = computed(() => ({
|
|
82
|
+
backgroundColor: props.modelValue ? props.activeColor : props.inactiveColor
|
|
83
|
+
}))
|
|
84
|
+
|
|
85
|
+
const handleClick = () => {
|
|
86
|
+
if (props.disabled || props.loading) return
|
|
87
|
+
const newValue = !props.modelValue
|
|
88
|
+
emit('update:modelValue', newValue)
|
|
89
|
+
emit('change', newValue)
|
|
90
|
+
|
|
91
|
+
trackEvent('switch_change', {
|
|
92
|
+
component: 'DatametriaSwitch',
|
|
93
|
+
checked: newValue,
|
|
94
|
+
size: props.size
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<style scoped>
|
|
100
|
+
.datametria-switch-wrapper {
|
|
101
|
+
display: inline-flex;
|
|
102
|
+
flex-direction: column;
|
|
103
|
+
width: 100%;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.datametria-switch__label-text {
|
|
107
|
+
display: block;
|
|
108
|
+
margin-bottom: 4px;
|
|
109
|
+
font-size: 14px;
|
|
110
|
+
font-weight: 500;
|
|
111
|
+
color: var(--color-text-primary, #1f2937);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.datametria-switch__required {
|
|
115
|
+
color: var(--color-error, #ef4444);
|
|
116
|
+
margin-left: 2px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.datametria-switch {
|
|
120
|
+
display: inline-flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
position: relative;
|
|
123
|
+
border: none;
|
|
124
|
+
background: transparent;
|
|
125
|
+
cursor: pointer;
|
|
126
|
+
padding: 0;
|
|
127
|
+
touch-action: manipulation;
|
|
128
|
+
-webkit-tap-highlight-color: transparent;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.datametria-switch:focus-visible {
|
|
132
|
+
outline: none;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.datametria-switch:focus-visible .datametria-switch__core {
|
|
136
|
+
box-shadow: 0 0 0 3px var(--color-primary-alpha, rgba(59, 130, 246, 0.1));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.datametria-switch-wrapper.is-disabled .datametria-switch {
|
|
140
|
+
cursor: not-allowed;
|
|
141
|
+
opacity: 0.6;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.datametria-switch-wrapper.is-loading .datametria-switch {
|
|
145
|
+
cursor: not-allowed;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.datametria-switch__core {
|
|
149
|
+
display: inline-block;
|
|
150
|
+
position: relative;
|
|
151
|
+
border-radius: 10px;
|
|
152
|
+
transition: background-color 0.3s;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.datametria-switch__core::after {
|
|
156
|
+
content: '';
|
|
157
|
+
position: absolute;
|
|
158
|
+
top: 2px;
|
|
159
|
+
left: 2px;
|
|
160
|
+
border-radius: 50%;
|
|
161
|
+
background-color: #fff;
|
|
162
|
+
transition: transform 0.3s;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.datametria-switch__loading {
|
|
166
|
+
position: absolute;
|
|
167
|
+
top: 50%;
|
|
168
|
+
left: 50%;
|
|
169
|
+
transform: translate(-50%, -50%);
|
|
170
|
+
display: flex;
|
|
171
|
+
align-items: center;
|
|
172
|
+
justify-content: center;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.spinner {
|
|
176
|
+
border: 2px solid #fff;
|
|
177
|
+
border-top-color: transparent;
|
|
178
|
+
border-radius: 50%;
|
|
179
|
+
animation: spin 0.6s linear infinite;
|
|
180
|
+
}
|
|
142
181
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
182
|
+
@keyframes spin {
|
|
183
|
+
to { transform: rotate(360deg); }
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.datametria-switch__error {
|
|
187
|
+
margin-top: 4px;
|
|
188
|
+
font-size: 12px;
|
|
189
|
+
color: var(--color-error, #ef4444);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/* Tamanhos */
|
|
193
|
+
.datametria-switch-wrapper--xs .datametria-switch__core {
|
|
194
|
+
width: 32px;
|
|
195
|
+
height: 16px;
|
|
196
|
+
border-radius: 8px;
|
|
197
|
+
min-width: 44px;
|
|
198
|
+
min-height: 44px;
|
|
199
|
+
display: flex;
|
|
200
|
+
align-items: center;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.datametria-switch-wrapper--xs .datametria-switch__core::after {
|
|
204
|
+
width: 12px;
|
|
205
|
+
height: 12px;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.datametria-switch-wrapper--xs.is-checked .datametria-switch__core::after {
|
|
209
|
+
transform: translateX(16px);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.datametria-switch-wrapper--xs .spinner {
|
|
213
|
+
width: 8px;
|
|
214
|
+
height: 8px;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.datametria-switch-wrapper--sm .datametria-switch__core {
|
|
218
|
+
width: 36px;
|
|
219
|
+
height: 18px;
|
|
220
|
+
border-radius: 9px;
|
|
221
|
+
min-width: 44px;
|
|
222
|
+
min-height: 44px;
|
|
223
|
+
display: flex;
|
|
224
|
+
align-items: center;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.datametria-switch-wrapper--sm .datametria-switch__core::after {
|
|
228
|
+
width: 14px;
|
|
229
|
+
height: 14px;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.datametria-switch-wrapper--sm.is-checked .datametria-switch__core::after {
|
|
233
|
+
transform: translateX(18px);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.datametria-switch-wrapper--sm .spinner {
|
|
237
|
+
width: 10px;
|
|
238
|
+
height: 10px;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.datametria-switch-wrapper--md .datametria-switch__core {
|
|
242
|
+
width: 40px;
|
|
243
|
+
height: 20px;
|
|
244
|
+
border-radius: 10px;
|
|
245
|
+
min-width: 44px;
|
|
246
|
+
min-height: 44px;
|
|
247
|
+
display: flex;
|
|
248
|
+
align-items: center;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.datametria-switch-wrapper--md .datametria-switch__core::after {
|
|
252
|
+
width: 16px;
|
|
253
|
+
height: 16px;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.datametria-switch-wrapper--md.is-checked .datametria-switch__core::after {
|
|
257
|
+
transform: translateX(20px);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.datametria-switch-wrapper--md .spinner {
|
|
261
|
+
width: 12px;
|
|
262
|
+
height: 12px;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.datametria-switch-wrapper--lg .datametria-switch__core {
|
|
266
|
+
width: 44px;
|
|
267
|
+
height: 22px;
|
|
268
|
+
border-radius: 11px;
|
|
269
|
+
min-width: 44px;
|
|
270
|
+
min-height: 44px;
|
|
271
|
+
display: flex;
|
|
272
|
+
align-items: center;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.datametria-switch-wrapper--lg .datametria-switch__core::after {
|
|
276
|
+
width: 18px;
|
|
277
|
+
height: 18px;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.datametria-switch-wrapper--lg.is-checked .datametria-switch__core::after {
|
|
281
|
+
transform: translateX(22px);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.datametria-switch-wrapper--lg .spinner {
|
|
285
|
+
width: 14px;
|
|
286
|
+
height: 14px;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.datametria-switch-wrapper--xl .datametria-switch__core {
|
|
290
|
+
width: 48px;
|
|
291
|
+
height: 24px;
|
|
292
|
+
border-radius: 12px;
|
|
293
|
+
min-width: 48px;
|
|
294
|
+
min-height: 48px;
|
|
295
|
+
display: flex;
|
|
296
|
+
align-items: center;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.datametria-switch-wrapper--xl .datametria-switch__core::after {
|
|
300
|
+
width: 20px;
|
|
301
|
+
height: 20px;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.datametria-switch-wrapper--xl.is-checked .datametria-switch__core::after {
|
|
305
|
+
transform: translateX(24px);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.datametria-switch-wrapper--xl .spinner {
|
|
309
|
+
width: 16px;
|
|
310
|
+
height: 16px;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* Responsividade mobile */
|
|
314
|
+
@media (max-width: 640px) {
|
|
315
|
+
.datametria-switch__core {
|
|
316
|
+
min-width: 48px;
|
|
317
|
+
min-height: 48px;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
</style>
|
|
@@ -56,7 +56,7 @@ interface Tab {
|
|
|
56
56
|
interface Props {
|
|
57
57
|
tabs: (string | Tab)[]
|
|
58
58
|
modelValue?: number
|
|
59
|
-
variant?: '
|
|
59
|
+
variant?: 'md' | 'pills' | 'underline'
|
|
60
60
|
orientation?: 'horizontal' | 'vertical'
|
|
61
61
|
showIndicator?: boolean
|
|
62
62
|
ariaLabel?: string
|
|
@@ -64,7 +64,7 @@ interface Props {
|
|
|
64
64
|
|
|
65
65
|
const props = withDefaults(defineProps<Props>(), {
|
|
66
66
|
modelValue: 0,
|
|
67
|
-
variant: '
|
|
67
|
+
variant: 'md',
|
|
68
68
|
orientation: 'horizontal',
|
|
69
69
|
showIndicator: true,
|
|
70
70
|
ariaLabel: 'Tabs'
|