@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.
Files changed (35) hide show
  1. package/README.md +57 -5
  2. package/dist/index.es.js +5812 -2837
  3. package/dist/index.umd.js +670 -10
  4. package/dist/src/components/DatametriaCheckbox.vue.d.ts +2 -0
  5. package/dist/src/components/DatametriaCheckboxGroup.vue.d.ts +6 -0
  6. package/dist/src/components/DatametriaFileUpload.vue.d.ts +5 -0
  7. package/dist/src/components/DatametriaFloatingBar.vue.d.ts +1 -1
  8. package/dist/src/components/DatametriaInput.vue.d.ts +2 -22
  9. package/dist/src/components/DatametriaNavbar.vue.d.ts +1 -1
  10. package/dist/src/components/DatametriaPasswordInput.vue.d.ts +2 -0
  11. package/dist/src/components/DatametriaRadio.vue.d.ts +2 -0
  12. package/dist/src/components/DatametriaRadioGroup.vue.d.ts +6 -0
  13. package/dist/src/components/DatametriaSelect.vue.d.ts +2 -3
  14. package/dist/src/components/DatametriaSidebar.vue.d.ts +1 -1
  15. package/dist/src/components/DatametriaSwitch.vue.d.ts +8 -1
  16. package/dist/src/components/DatametriaTabs.vue.d.ts +2 -2
  17. package/dist/src/components/DatametriaTextarea.vue.d.ts +6 -0
  18. package/dist/src/composables/useAnalytics.d.ts +8 -0
  19. package/dist/src/types/analytics.d.ts +50 -0
  20. package/dist/vue-components.css +1 -1
  21. package/package.json +3 -2
  22. package/src/components/DatametriaButton.vue +196 -195
  23. package/src/components/DatametriaCheckbox.vue +289 -197
  24. package/src/components/DatametriaCheckboxGroup.vue +124 -3
  25. package/src/components/DatametriaFileUpload.vue +493 -414
  26. package/src/components/DatametriaInput.vue +342 -316
  27. package/src/components/DatametriaPasswordInput.vue +433 -446
  28. package/src/components/DatametriaRadio.vue +240 -151
  29. package/src/components/DatametriaRadioGroup.vue +124 -3
  30. package/src/components/DatametriaSelect.vue +409 -313
  31. package/src/components/DatametriaSwitch.vue +319 -146
  32. package/src/components/DatametriaTabs.vue +2 -2
  33. package/src/components/DatametriaTextarea.vue +285 -213
  34. package/src/composables/useAnalytics.ts +70 -0
  35. package/src/types/analytics.ts +59 -0
@@ -1,147 +1,320 @@
1
- <template>
2
- <button
3
- type="button"
4
- role="switch"
5
- class="datametria-switch"
6
- :class="{
7
- 'is-checked': modelValue,
8
- 'is-disabled': disabled,
9
- 'is-loading': loading
10
- }"
11
- :aria-checked="modelValue"
12
- :disabled="disabled || loading"
13
- @click="handleClick"
14
- >
15
- <span class="datametria-switch__core" :style="coreStyle">
16
- <span v-if="loading" class="datametria-switch__loading">
17
- <span class="spinner"></span>
18
- </span>
19
- </span>
20
- </button>
21
- </template>
22
-
23
- <script setup lang="ts">
24
- import { computed } from 'vue'
25
-
26
- interface Props {
27
- modelValue?: boolean
28
- disabled?: boolean
29
- loading?: boolean
30
- activeColor?: string
31
- inactiveColor?: string
32
- }
33
-
34
- const props = withDefaults(defineProps<Props>(), {
35
- modelValue: false,
36
- disabled: false,
37
- loading: false,
38
- activeColor: '#0072ce',
39
- inactiveColor: '#dcdfe6'
40
- })
41
-
42
- const emit = defineEmits<{
43
- 'update:modelValue': [value: boolean]
44
- change: [value: boolean]
45
- }>()
46
-
47
- const coreStyle = computed(() => ({
48
- backgroundColor: props.modelValue ? props.activeColor : props.inactiveColor
49
- }))
50
-
51
- const handleClick = () => {
52
- if (props.disabled || props.loading) return
53
- const newValue = !props.modelValue
54
- emit('update:modelValue', newValue)
55
- emit('change', newValue)
56
- }
57
- </script>
58
-
59
- <style scoped>
60
- .datametria-switch {
61
- display: inline-flex;
62
- align-items: center;
63
- position: relative;
64
- font-size: 14px;
65
- line-height: 20px;
66
- height: 20px;
67
- vertical-align: middle;
68
- border: none;
69
- background: transparent;
70
- cursor: pointer;
71
- padding: 0;
72
- }
73
-
74
- .datametria-switch.is-disabled {
75
- cursor: not-allowed;
76
- opacity: 0.5;
77
- }
78
-
79
- .datametria-switch.is-loading {
80
- cursor: not-allowed;
81
- }
82
-
83
- .datametria-switch__core {
84
- display: inline-block;
85
- position: relative;
86
- width: 40px;
87
- height: 20px;
88
- border-radius: 10px;
89
- transition: background-color 0.3s;
90
- }
91
-
92
- .datametria-switch__core::after {
93
- content: '';
94
- position: absolute;
95
- top: 2px;
96
- left: 2px;
97
- width: 16px;
98
- height: 16px;
99
- border-radius: 50%;
100
- background-color: #fff;
101
- transition: transform 0.3s;
102
- }
103
-
104
- .datametria-switch.is-checked .datametria-switch__core::after {
105
- transform: translateX(20px);
106
- }
107
-
108
- .datametria-switch__loading {
109
- position: absolute;
110
- top: 50%;
111
- left: 50%;
112
- transform: translate(-50%, -50%);
113
- display: flex;
114
- align-items: center;
115
- justify-content: center;
116
- }
117
-
118
- .spinner {
119
- width: 12px;
120
- height: 12px;
121
- border: 2px solid #fff;
122
- border-top-color: transparent;
123
- border-radius: 50%;
124
- animation: spin 0.6s linear infinite;
125
- }
126
-
127
- @keyframes spin {
128
- to { transform: rotate(360deg); }
129
- }
130
-
131
- .datametria-switch:focus-visible {
132
- outline: 2px solid var(--dm-primary, #0072ce);
133
- outline-offset: 2px;
134
- border-radius: 10px;
135
- }
136
-
137
- /* Dark mode */
138
- @media (prefers-color-scheme: dark) {
139
- .datametria-switch__core {
140
- background-color: var(--dm-bg-color-dark, #1e1e1e);
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
- [data-theme="dark"] .datametria-switch__core {
144
- background-color: var(--dm-bg-color-dark, #1e1e1e);
145
- }
146
- }
147
- </style>
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?: 'default' | 'pills' | 'underline'
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: 'default',
67
+ variant: 'md',
68
68
  orientation: 'horizontal',
69
69
  showIndicator: true,
70
70
  ariaLabel: 'Tabs'