@datametria/vue-components 2.3.0 → 2.4.0

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 (128) hide show
  1. package/README.md +625 -594
  2. package/dist/index.es.js +1962 -1887
  3. package/dist/index.umd.js +6 -6
  4. package/dist/src/components/DatametriaForm.vue.d.ts +1 -1
  5. package/dist/src/components/DatametriaInput.vue.d.ts +9 -1
  6. package/dist/src/components/DatametriaSelect.vue.d.ts +10 -1
  7. package/dist/vue-components.css +1 -1
  8. package/package.json +103 -105
  9. package/src/components/DatametriaAlert.vue +151 -133
  10. package/src/components/DatametriaAutocomplete.vue +250 -229
  11. package/src/components/DatametriaAvatar.vue +256 -238
  12. package/src/components/DatametriaBadge.vue +101 -96
  13. package/src/components/DatametriaBreadcrumb.vue +132 -128
  14. package/src/components/DatametriaButton.vue +191 -173
  15. package/src/components/DatametriaCard.vue +84 -66
  16. package/src/components/DatametriaCheckbox.vue +197 -193
  17. package/src/components/DatametriaCheckboxGroup.vue +56 -38
  18. package/src/components/DatametriaChip.vue +159 -141
  19. package/src/components/DatametriaContainer.vue +70 -52
  20. package/src/components/DatametriaDataTable.vue +318 -300
  21. package/src/components/DatametriaDatePicker.vue +396 -378
  22. package/src/components/DatametriaDialog.vue +297 -293
  23. package/src/components/DatametriaDivider.vue +105 -98
  24. package/src/components/DatametriaDropdown.vue +356 -350
  25. package/src/components/DatametriaEmpty.vue +155 -151
  26. package/src/components/DatametriaFileUpload.vue +413 -395
  27. package/src/components/DatametriaFloatingBar.vue +144 -126
  28. package/src/components/DatametriaForm.vue +174 -156
  29. package/src/components/DatametriaFormItem.vue +183 -179
  30. package/src/components/DatametriaGrid.vue +55 -37
  31. package/src/components/DatametriaInput.vue +314 -263
  32. package/src/components/DatametriaMenu.vue +618 -600
  33. package/src/components/DatametriaModal.vue +147 -129
  34. package/src/components/DatametriaNavbar.vue +277 -223
  35. package/src/components/DatametriaPagination.vue +375 -371
  36. package/src/components/DatametriaPasswordInput.vue +444 -426
  37. package/src/components/DatametriaPopconfirm.vue +240 -234
  38. package/src/components/DatametriaProgress.vue +228 -224
  39. package/src/components/DatametriaRadio.vue +151 -147
  40. package/src/components/DatametriaRadioGroup.vue +55 -37
  41. package/src/components/DatametriaResult.vue +135 -131
  42. package/src/components/DatametriaSelect.vue +311 -211
  43. package/src/components/DatametriaSidebar.vue +294 -222
  44. package/src/components/DatametriaSkeleton.vue +257 -234
  45. package/src/components/DatametriaSlider.vue +409 -391
  46. package/src/components/DatametriaSortableTable.vue +820 -802
  47. package/src/components/DatametriaSpinner.vue +114 -110
  48. package/src/components/DatametriaSteps.vue +318 -312
  49. package/src/components/DatametriaSwitch.vue +146 -142
  50. package/src/components/DatametriaTabPane.vue +94 -76
  51. package/src/components/DatametriaTable.vue +118 -100
  52. package/src/components/DatametriaTabs.vue +315 -297
  53. package/src/components/DatametriaTextarea.vue +213 -195
  54. package/src/components/DatametriaTimePicker.vue +317 -299
  55. package/src/components/DatametriaToast.vue +176 -176
  56. package/src/components/DatametriaTooltip.vue +421 -400
  57. package/src/components/DatametriaTree.vue +126 -122
  58. package/src/components/DatametriaTreeNode.vue +176 -172
  59. package/src/components/DatametriaUpload.vue +379 -361
  60. package/src/components/__tests__/DatametriaAlert.test.js +35 -35
  61. package/src/components/__tests__/DatametriaAlert.test.ts +190 -190
  62. package/src/components/__tests__/DatametriaAvatar.test.ts +151 -151
  63. package/src/components/__tests__/DatametriaBadge.test.js +29 -29
  64. package/src/components/__tests__/DatametriaBadge.test.ts +167 -167
  65. package/src/components/__tests__/DatametriaBreadcrumb.test.ts +187 -0
  66. package/src/components/__tests__/DatametriaButton.test.js +30 -30
  67. package/src/components/__tests__/DatametriaButton.test.ts +283 -283
  68. package/src/components/__tests__/DatametriaCard.test.ts +201 -201
  69. package/src/components/__tests__/DatametriaCheckbox.test.ts +204 -0
  70. package/src/components/__tests__/DatametriaChip.test.js +38 -38
  71. package/src/components/__tests__/DatametriaContainer.test.ts +52 -52
  72. package/src/components/__tests__/DatametriaDialog.test.ts +338 -0
  73. package/src/components/__tests__/DatametriaDivider.test.ts +54 -54
  74. package/src/components/__tests__/DatametriaDropdown.test.ts +357 -0
  75. package/src/components/__tests__/DatametriaEmpty.test.ts +261 -0
  76. package/src/components/__tests__/DatametriaFileUpload.test.ts +290 -290
  77. package/src/components/__tests__/DatametriaFloatingBar.test.ts +137 -137
  78. package/src/components/__tests__/DatametriaForm.test.ts +96 -0
  79. package/src/components/__tests__/DatametriaFormItem.test.ts +58 -0
  80. package/src/components/__tests__/DatametriaGrid.test.ts +31 -31
  81. package/src/components/__tests__/DatametriaInput.test.ts +72 -72
  82. package/src/components/__tests__/DatametriaMenu.test.ts +366 -366
  83. package/src/components/__tests__/DatametriaModal.test.ts +86 -86
  84. package/src/components/__tests__/DatametriaNavbar.test.js +48 -48
  85. package/src/components/__tests__/DatametriaNavbar.test.ts +203 -203
  86. package/src/components/__tests__/DatametriaPasswordInput.test.js +305 -305
  87. package/src/components/__tests__/DatametriaRadio.test.ts +195 -0
  88. package/src/components/__tests__/DatametriaSelect.test.ts +77 -77
  89. package/src/components/__tests__/DatametriaSidebar.test.ts +169 -169
  90. package/src/components/__tests__/DatametriaSlider.test.ts +261 -261
  91. package/src/components/__tests__/DatametriaSortableTable.test.js +168 -168
  92. package/src/components/__tests__/DatametriaSpinner.test.ts +156 -156
  93. package/src/components/__tests__/DatametriaSteps.test.ts +211 -0
  94. package/src/components/__tests__/DatametriaSwitch.test.ts +129 -0
  95. package/src/components/__tests__/DatametriaTabPane.test.ts +205 -0
  96. package/src/components/__tests__/DatametriaTable.test.ts +97 -97
  97. package/src/components/__tests__/DatametriaTabs.test.ts +232 -232
  98. package/src/components/__tests__/DatametriaToast.test.js +48 -48
  99. package/src/components/__tests__/DatametriaToast.test.ts +99 -99
  100. package/src/components/__tests__/DatametriaTree.test.ts +376 -0
  101. package/src/components/__tests__/index.test.ts +48 -0
  102. package/src/composables/useAccessibilityScale.ts +94 -94
  103. package/src/composables/useBreakpoints.ts +82 -82
  104. package/src/composables/useHapticFeedback.ts +439 -439
  105. package/src/composables/useRipple.ts +218 -218
  106. package/src/composables/useTheme.ts +5 -1
  107. package/src/index.ts +84 -84
  108. package/src/stories/Variants.stories.js +95 -95
  109. package/src/styles/design-tokens.css +623 -623
  110. package/src/theme/ThemeProvider.vue +96 -96
  111. package/src/theme/__tests__/ThemeProvider.test.ts +208 -208
  112. package/src/theme/__tests__/constants.test.ts +31 -31
  113. package/src/theme/__tests__/presets.test.ts +166 -166
  114. package/src/theme/__tests__/tokens.test.ts +155 -155
  115. package/src/theme/__tests__/types.test.ts +153 -153
  116. package/src/theme/__tests__/useTheme.test.ts +146 -146
  117. package/src/theme/constants.ts +14 -14
  118. package/src/theme/index.ts +12 -12
  119. package/src/theme/presets/datametria.ts +94 -94
  120. package/src/theme/presets/default.ts +94 -94
  121. package/src/theme/presets/index.ts +8 -8
  122. package/src/theme/tokens/colors.ts +28 -28
  123. package/src/theme/tokens/index.ts +47 -47
  124. package/src/theme/tokens/spacing.ts +21 -21
  125. package/src/theme/tokens/typography.ts +35 -35
  126. package/src/theme/types.ts +111 -111
  127. package/src/theme/useTheme.ts +28 -28
  128. package/src/types/index.ts +55 -55
@@ -1,96 +1,96 @@
1
- <!--
2
- Theme Provider Component
3
- @author Vander Loto - CTO DATAMETRIA
4
- @date 13/11/2025
5
- -->
6
-
7
- <template>
8
- <div :class="themeClass" :style="cssVariables">
9
- <slot />
10
- </div>
11
- </template>
12
-
13
- <script setup lang="ts">
14
- import { computed, provide } from 'vue'
15
- import type { Theme } from './types'
16
- import { THEME_INJECTION_KEY, DEFAULT_THEME_PREFIX, CSS_VARIABLE_PREFIX } from './constants'
17
-
18
- interface Props {
19
- theme: Theme
20
- prefix?: string
21
- }
22
-
23
- const props = withDefaults(defineProps<Props>(), {
24
- prefix: DEFAULT_THEME_PREFIX
25
- })
26
-
27
- // Provide theme to child components
28
- const themeRef = computed(() => props.theme)
29
- provide(THEME_INJECTION_KEY, themeRef)
30
-
31
- const themeClass = computed(() => `${props.prefix}-theme`)
32
-
33
- const cssVariables = computed(() => {
34
- const vars: Record<string, string> = {}
35
- const { tokens } = props.theme
36
- const prefix = `${CSS_VARIABLE_PREFIX}${props.prefix}`
37
-
38
- // Colors
39
- vars[`${prefix}-primary`] = tokens.colors.primary
40
- vars[`${prefix}-secondary`] = tokens.colors.secondary
41
- vars[`${prefix}-success`] = tokens.colors.success
42
- vars[`${prefix}-warning`] = tokens.colors.warning
43
- vars[`${prefix}-error`] = tokens.colors.error
44
- vars[`${prefix}-info`] = tokens.colors.info
45
-
46
- // Neutral colors
47
- Object.entries(tokens.colors.neutral).forEach(([key, value]) => {
48
- vars[`${prefix}-neutral-${key}`] = value
49
- })
50
-
51
- // Typography - Font Family
52
- vars[`${prefix}-font-sans`] = tokens.typography.fontFamily.sans
53
- vars[`${prefix}-font-mono`] = tokens.typography.fontFamily.mono
54
-
55
- // Typography - Font Size
56
- Object.entries(tokens.typography.fontSize).forEach(([key, value]) => {
57
- vars[`${prefix}-text-${key}`] = value
58
- })
59
-
60
- // Typography - Font Weight
61
- Object.entries(tokens.typography.fontWeight).forEach(([key, value]) => {
62
- vars[`${prefix}-font-${key}`] = value.toString()
63
- })
64
-
65
- // Typography - Line Height
66
- Object.entries(tokens.typography.lineHeight).forEach(([key, value]) => {
67
- vars[`${prefix}-leading-${key}`] = value.toString()
68
- })
69
-
70
- // Spacing
71
- Object.entries(tokens.spacing).forEach(([key, value]) => {
72
- vars[`${prefix}-space-${key}`] = value
73
- })
74
-
75
- // Radius
76
- Object.entries(tokens.radius).forEach(([key, value]) => {
77
- vars[`${prefix}-radius-${key}`] = value
78
- })
79
-
80
- // Shadows
81
- Object.entries(tokens.shadows).forEach(([key, value]) => {
82
- vars[`${prefix}-shadow-${key}`] = value
83
- })
84
-
85
- // Transitions
86
- Object.entries(tokens.transitions).forEach(([key, value]) => {
87
- vars[`${prefix}-transition-${key}`] = value
88
- })
89
-
90
- return vars
91
- })
92
- </script>
93
-
94
- <style scoped>
95
- /* Theme container - no additional styles needed */
96
- </style>
1
+ <!--
2
+ Theme Provider Component
3
+ @author Vander Loto - CTO DATAMETRIA
4
+ @date 13/11/2025
5
+ -->
6
+
7
+ <template>
8
+ <div :class="themeClass" :style="cssVariables">
9
+ <slot />
10
+ </div>
11
+ </template>
12
+
13
+ <script setup lang="ts">
14
+ import { computed, provide } from 'vue'
15
+ import type { Theme } from './types'
16
+ import { THEME_INJECTION_KEY, DEFAULT_THEME_PREFIX, CSS_VARIABLE_PREFIX } from './constants'
17
+
18
+ interface Props {
19
+ theme: Theme
20
+ prefix?: string
21
+ }
22
+
23
+ const props = withDefaults(defineProps<Props>(), {
24
+ prefix: DEFAULT_THEME_PREFIX
25
+ })
26
+
27
+ // Provide theme to child components
28
+ const themeRef = computed(() => props.theme)
29
+ provide(THEME_INJECTION_KEY, themeRef)
30
+
31
+ const themeClass = computed(() => `${props.prefix}-theme`)
32
+
33
+ const cssVariables = computed(() => {
34
+ const vars: Record<string, string> = {}
35
+ const { tokens } = props.theme
36
+ const prefix = `${CSS_VARIABLE_PREFIX}${props.prefix}`
37
+
38
+ // Colors
39
+ vars[`${prefix}-primary`] = tokens.colors.primary
40
+ vars[`${prefix}-secondary`] = tokens.colors.secondary
41
+ vars[`${prefix}-success`] = tokens.colors.success
42
+ vars[`${prefix}-warning`] = tokens.colors.warning
43
+ vars[`${prefix}-error`] = tokens.colors.error
44
+ vars[`${prefix}-info`] = tokens.colors.info
45
+
46
+ // Neutral colors
47
+ Object.entries(tokens.colors.neutral).forEach(([key, value]) => {
48
+ vars[`${prefix}-neutral-${key}`] = value
49
+ })
50
+
51
+ // Typography - Font Family
52
+ vars[`${prefix}-font-sans`] = tokens.typography.fontFamily.sans
53
+ vars[`${prefix}-font-mono`] = tokens.typography.fontFamily.mono
54
+
55
+ // Typography - Font Size
56
+ Object.entries(tokens.typography.fontSize).forEach(([key, value]) => {
57
+ vars[`${prefix}-text-${key}`] = value
58
+ })
59
+
60
+ // Typography - Font Weight
61
+ Object.entries(tokens.typography.fontWeight).forEach(([key, value]) => {
62
+ vars[`${prefix}-font-${key}`] = value.toString()
63
+ })
64
+
65
+ // Typography - Line Height
66
+ Object.entries(tokens.typography.lineHeight).forEach(([key, value]) => {
67
+ vars[`${prefix}-leading-${key}`] = value.toString()
68
+ })
69
+
70
+ // Spacing
71
+ Object.entries(tokens.spacing).forEach(([key, value]) => {
72
+ vars[`${prefix}-space-${key}`] = value
73
+ })
74
+
75
+ // Radius
76
+ Object.entries(tokens.radius).forEach(([key, value]) => {
77
+ vars[`${prefix}-radius-${key}`] = value
78
+ })
79
+
80
+ // Shadows
81
+ Object.entries(tokens.shadows).forEach(([key, value]) => {
82
+ vars[`${prefix}-shadow-${key}`] = value
83
+ })
84
+
85
+ // Transitions
86
+ Object.entries(tokens.transitions).forEach(([key, value]) => {
87
+ vars[`${prefix}-transition-${key}`] = value
88
+ })
89
+
90
+ return vars
91
+ })
92
+ </script>
93
+
94
+ <style scoped>
95
+ /* Theme container - no additional styles needed */
96
+ </style>
@@ -1,208 +1,208 @@
1
- /**
2
- * ThemeProvider Tests
3
- * @author Vander Loto - CTO DATAMETRIA
4
- * @date 13/11/2025
5
- */
6
-
7
- import { describe, it, expect } from 'vitest'
8
- import { mount } from '@vue/test-utils'
9
- import { h } from 'vue'
10
- import ThemeProvider from '../ThemeProvider.vue'
11
- import { useTheme } from '../useTheme'
12
- import { defaultTokens } from '../tokens'
13
- import type { Theme } from '../types'
14
-
15
- const testTheme: Theme = {
16
- name: 'Test Theme',
17
- tokens: defaultTokens
18
- }
19
-
20
- const customTheme: Theme = {
21
- name: 'Custom Theme',
22
- tokens: {
23
- ...defaultTokens,
24
- colors: {
25
- ...defaultTokens.colors,
26
- primary: '#FF0000',
27
- secondary: '#00FF00'
28
- }
29
- }
30
- }
31
-
32
- describe('ThemeProvider', () => {
33
- it('should render children', () => {
34
- const wrapper = mount(ThemeProvider, {
35
- props: { theme: testTheme },
36
- slots: {
37
- default: '<div class="test-child">Child Content</div>'
38
- }
39
- })
40
-
41
- expect(wrapper.text()).toContain('Child Content')
42
- expect(wrapper.find('.test-child').exists()).toBe(true)
43
- })
44
-
45
- it('should apply default theme class', () => {
46
- const wrapper = mount(ThemeProvider, {
47
- props: { theme: testTheme },
48
- slots: { default: '<div>Content</div>' }
49
- })
50
-
51
- expect(wrapper.classes()).toContain('dm-theme')
52
- })
53
-
54
- it('should apply custom prefix class', () => {
55
- const wrapper = mount(ThemeProvider, {
56
- props: { theme: testTheme, prefix: 'custom' },
57
- slots: { default: '<div>Content</div>' }
58
- })
59
-
60
- expect(wrapper.classes()).toContain('custom-theme')
61
- })
62
-
63
- it('should generate CSS variables for colors', () => {
64
- const wrapper = mount(ThemeProvider, {
65
- props: { theme: testTheme },
66
- slots: { default: '<div>Content</div>' }
67
- })
68
-
69
- const style = wrapper.attributes('style')
70
- expect(style).toContain('--dm-primary')
71
- expect(style).toContain('#0072CE')
72
- expect(style).toContain('--dm-secondary')
73
- expect(style).toContain('#4B0078')
74
- })
75
-
76
- it('should generate CSS variables for neutral colors', () => {
77
- const wrapper = mount(ThemeProvider, {
78
- props: { theme: testTheme },
79
- slots: { default: '<div>Content</div>' }
80
- })
81
-
82
- const style = wrapper.attributes('style')
83
- expect(style).toContain('--dm-neutral-50')
84
- expect(style).toContain('--dm-neutral-900')
85
- })
86
-
87
- it('should generate CSS variables for typography', () => {
88
- const wrapper = mount(ThemeProvider, {
89
- props: { theme: testTheme },
90
- slots: { default: '<div>Content</div>' }
91
- })
92
-
93
- const style = wrapper.attributes('style')
94
- expect(style).toContain('--dm-font-sans')
95
- expect(style).toContain('--dm-text-base')
96
- expect(style).toContain('--dm-font-bold')
97
- })
98
-
99
- it('should generate CSS variables for spacing', () => {
100
- const wrapper = mount(ThemeProvider, {
101
- props: { theme: testTheme },
102
- slots: { default: '<div>Content</div>' }
103
- })
104
-
105
- const style = wrapper.attributes('style')
106
- expect(style).toContain('--dm-space-4')
107
- expect(style).toContain('1rem')
108
- })
109
-
110
- it('should generate CSS variables for radius', () => {
111
- const wrapper = mount(ThemeProvider, {
112
- props: { theme: testTheme },
113
- slots: { default: '<div>Content</div>' }
114
- })
115
-
116
- const style = wrapper.attributes('style')
117
- expect(style).toContain('--dm-radius-md')
118
- })
119
-
120
- it('should generate CSS variables for shadows', () => {
121
- const wrapper = mount(ThemeProvider, {
122
- props: { theme: testTheme },
123
- slots: { default: '<div>Content</div>' }
124
- })
125
-
126
- const style = wrapper.attributes('style')
127
- expect(style).toContain('--dm-shadow-md')
128
- })
129
-
130
- it('should generate CSS variables for transitions', () => {
131
- const wrapper = mount(ThemeProvider, {
132
- props: { theme: testTheme },
133
- slots: { default: '<div>Content</div>' }
134
- })
135
-
136
- const style = wrapper.attributes('style')
137
- expect(style).toContain('--dm-transition-base')
138
- })
139
-
140
- it('should use custom prefix for CSS variables', () => {
141
- const wrapper = mount(ThemeProvider, {
142
- props: { theme: testTheme, prefix: 'custom' },
143
- slots: { default: '<div>Content</div>' }
144
- })
145
-
146
- const style = wrapper.attributes('style')
147
- expect(style).toContain('--custom-primary')
148
- expect(style).not.toContain('--dm-primary')
149
- })
150
-
151
- it('should update CSS variables when theme changes', async () => {
152
- const wrapper = mount(ThemeProvider, {
153
- props: { theme: testTheme },
154
- slots: { default: '<div>Content</div>' }
155
- })
156
-
157
- let style = wrapper.attributes('style')
158
- expect(style).toContain('#0072CE')
159
-
160
- await wrapper.setProps({ theme: customTheme })
161
-
162
- style = wrapper.attributes('style')
163
- expect(style).toContain('#FF0000')
164
- })
165
-
166
- it('should provide theme to child components', () => {
167
- const ChildComponent = {
168
- setup() {
169
- const theme = useTheme()
170
- return () => h('div', { class: 'child' }, theme.value.name)
171
- }
172
- }
173
-
174
- const wrapper = mount(ThemeProvider, {
175
- props: { theme: testTheme },
176
- slots: {
177
- default: h(ChildComponent)
178
- }
179
- })
180
-
181
- expect(wrapper.text()).toContain('Test Theme')
182
- })
183
-
184
- it('should provide updated theme when changed', async () => {
185
- const ChildComponent = {
186
- setup() {
187
- const theme = useTheme()
188
- return () => h('div', { class: 'child' }, `${theme.value.name}-${theme.value.tokens.colors.primary}`)
189
- }
190
- }
191
-
192
- const wrapper = mount(ThemeProvider, {
193
- props: { theme: testTheme },
194
- slots: {
195
- default: h(ChildComponent)
196
- }
197
- })
198
-
199
- expect(wrapper.text()).toContain('Test Theme')
200
- expect(wrapper.text()).toContain('#0072CE')
201
-
202
- await wrapper.setProps({ theme: customTheme })
203
- await wrapper.vm.$nextTick()
204
-
205
- expect(wrapper.text()).toContain('Custom Theme')
206
- expect(wrapper.text()).toContain('#FF0000')
207
- })
208
- })
1
+ /**
2
+ * ThemeProvider Tests
3
+ * @author Vander Loto - CTO DATAMETRIA
4
+ * @date 13/11/2025
5
+ */
6
+
7
+ import { describe, it, expect } from 'vitest'
8
+ import { mount } from '@vue/test-utils'
9
+ import { h } from 'vue'
10
+ import ThemeProvider from '../ThemeProvider.vue'
11
+ import { useTheme } from '../useTheme'
12
+ import { defaultTokens } from '../tokens'
13
+ import type { Theme } from '../types'
14
+
15
+ const testTheme: Theme = {
16
+ name: 'Test Theme',
17
+ tokens: defaultTokens
18
+ }
19
+
20
+ const customTheme: Theme = {
21
+ name: 'Custom Theme',
22
+ tokens: {
23
+ ...defaultTokens,
24
+ colors: {
25
+ ...defaultTokens.colors,
26
+ primary: '#FF0000',
27
+ secondary: '#00FF00'
28
+ }
29
+ }
30
+ }
31
+
32
+ describe('ThemeProvider', () => {
33
+ it('should render children', () => {
34
+ const wrapper = mount(ThemeProvider, {
35
+ props: { theme: testTheme },
36
+ slots: {
37
+ default: '<div class="test-child">Child Content</div>'
38
+ }
39
+ })
40
+
41
+ expect(wrapper.text()).toContain('Child Content')
42
+ expect(wrapper.find('.test-child').exists()).toBe(true)
43
+ })
44
+
45
+ it('should apply default theme class', () => {
46
+ const wrapper = mount(ThemeProvider, {
47
+ props: { theme: testTheme },
48
+ slots: { default: '<div>Content</div>' }
49
+ })
50
+
51
+ expect(wrapper.classes()).toContain('dm-theme')
52
+ })
53
+
54
+ it('should apply custom prefix class', () => {
55
+ const wrapper = mount(ThemeProvider, {
56
+ props: { theme: testTheme, prefix: 'custom' },
57
+ slots: { default: '<div>Content</div>' }
58
+ })
59
+
60
+ expect(wrapper.classes()).toContain('custom-theme')
61
+ })
62
+
63
+ it('should generate CSS variables for colors', () => {
64
+ const wrapper = mount(ThemeProvider, {
65
+ props: { theme: testTheme },
66
+ slots: { default: '<div>Content</div>' }
67
+ })
68
+
69
+ const style = wrapper.attributes('style')
70
+ expect(style).toContain('--dm-primary')
71
+ expect(style).toContain('#0072CE')
72
+ expect(style).toContain('--dm-secondary')
73
+ expect(style).toContain('#4B0078')
74
+ })
75
+
76
+ it('should generate CSS variables for neutral colors', () => {
77
+ const wrapper = mount(ThemeProvider, {
78
+ props: { theme: testTheme },
79
+ slots: { default: '<div>Content</div>' }
80
+ })
81
+
82
+ const style = wrapper.attributes('style')
83
+ expect(style).toContain('--dm-neutral-50')
84
+ expect(style).toContain('--dm-neutral-900')
85
+ })
86
+
87
+ it('should generate CSS variables for typography', () => {
88
+ const wrapper = mount(ThemeProvider, {
89
+ props: { theme: testTheme },
90
+ slots: { default: '<div>Content</div>' }
91
+ })
92
+
93
+ const style = wrapper.attributes('style')
94
+ expect(style).toContain('--dm-font-sans')
95
+ expect(style).toContain('--dm-text-base')
96
+ expect(style).toContain('--dm-font-bold')
97
+ })
98
+
99
+ it('should generate CSS variables for spacing', () => {
100
+ const wrapper = mount(ThemeProvider, {
101
+ props: { theme: testTheme },
102
+ slots: { default: '<div>Content</div>' }
103
+ })
104
+
105
+ const style = wrapper.attributes('style')
106
+ expect(style).toContain('--dm-space-4')
107
+ expect(style).toContain('1rem')
108
+ })
109
+
110
+ it('should generate CSS variables for radius', () => {
111
+ const wrapper = mount(ThemeProvider, {
112
+ props: { theme: testTheme },
113
+ slots: { default: '<div>Content</div>' }
114
+ })
115
+
116
+ const style = wrapper.attributes('style')
117
+ expect(style).toContain('--dm-radius-md')
118
+ })
119
+
120
+ it('should generate CSS variables for shadows', () => {
121
+ const wrapper = mount(ThemeProvider, {
122
+ props: { theme: testTheme },
123
+ slots: { default: '<div>Content</div>' }
124
+ })
125
+
126
+ const style = wrapper.attributes('style')
127
+ expect(style).toContain('--dm-shadow-md')
128
+ })
129
+
130
+ it('should generate CSS variables for transitions', () => {
131
+ const wrapper = mount(ThemeProvider, {
132
+ props: { theme: testTheme },
133
+ slots: { default: '<div>Content</div>' }
134
+ })
135
+
136
+ const style = wrapper.attributes('style')
137
+ expect(style).toContain('--dm-transition-base')
138
+ })
139
+
140
+ it('should use custom prefix for CSS variables', () => {
141
+ const wrapper = mount(ThemeProvider, {
142
+ props: { theme: testTheme, prefix: 'custom' },
143
+ slots: { default: '<div>Content</div>' }
144
+ })
145
+
146
+ const style = wrapper.attributes('style')
147
+ expect(style).toContain('--custom-primary')
148
+ expect(style).not.toContain('--dm-primary')
149
+ })
150
+
151
+ it('should update CSS variables when theme changes', async () => {
152
+ const wrapper = mount(ThemeProvider, {
153
+ props: { theme: testTheme },
154
+ slots: { default: '<div>Content</div>' }
155
+ })
156
+
157
+ let style = wrapper.attributes('style')
158
+ expect(style).toContain('#0072CE')
159
+
160
+ await wrapper.setProps({ theme: customTheme })
161
+
162
+ style = wrapper.attributes('style')
163
+ expect(style).toContain('#FF0000')
164
+ })
165
+
166
+ it('should provide theme to child components', () => {
167
+ const ChildComponent = {
168
+ setup() {
169
+ const theme = useTheme()
170
+ return () => h('div', { class: 'child' }, theme.value.name)
171
+ }
172
+ }
173
+
174
+ const wrapper = mount(ThemeProvider, {
175
+ props: { theme: testTheme },
176
+ slots: {
177
+ default: h(ChildComponent)
178
+ }
179
+ })
180
+
181
+ expect(wrapper.text()).toContain('Test Theme')
182
+ })
183
+
184
+ it('should provide updated theme when changed', async () => {
185
+ const ChildComponent = {
186
+ setup() {
187
+ const theme = useTheme()
188
+ return () => h('div', { class: 'child' }, `${theme.value.name}-${theme.value.tokens.colors.primary}`)
189
+ }
190
+ }
191
+
192
+ const wrapper = mount(ThemeProvider, {
193
+ props: { theme: testTheme },
194
+ slots: {
195
+ default: h(ChildComponent)
196
+ }
197
+ })
198
+
199
+ expect(wrapper.text()).toContain('Test Theme')
200
+ expect(wrapper.text()).toContain('#0072CE')
201
+
202
+ await wrapper.setProps({ theme: customTheme })
203
+ await wrapper.vm.$nextTick()
204
+
205
+ expect(wrapper.text()).toContain('Custom Theme')
206
+ expect(wrapper.text()).toContain('#FF0000')
207
+ })
208
+ })
@@ -1,31 +1,31 @@
1
- /**
2
- * Theme Constants Tests
3
- * @author Vander Loto - CTO DATAMETRIA
4
- * @date 13/11/2025
5
- */
6
-
7
- import { describe, it, expect } from 'vitest'
8
- import { THEME_INJECTION_KEY, DEFAULT_THEME_PREFIX, CSS_VARIABLE_PREFIX } from '../constants'
9
-
10
- describe('Theme Constants', () => {
11
- it('should have THEME_INJECTION_KEY as Symbol', () => {
12
- expect(typeof THEME_INJECTION_KEY).toBe('symbol')
13
- expect(THEME_INJECTION_KEY.toString()).toContain('theme')
14
- })
15
-
16
- it('should have DEFAULT_THEME_PREFIX', () => {
17
- expect(DEFAULT_THEME_PREFIX).toBe('dm')
18
- expect(typeof DEFAULT_THEME_PREFIX).toBe('string')
19
- })
20
-
21
- it('should have CSS_VARIABLE_PREFIX', () => {
22
- expect(CSS_VARIABLE_PREFIX).toBe('--')
23
- expect(typeof CSS_VARIABLE_PREFIX).toBe('string')
24
- })
25
-
26
- it('should have unique injection key', () => {
27
- const key1 = THEME_INJECTION_KEY
28
- const key2 = Symbol('theme')
29
- expect(key1).not.toBe(key2)
30
- })
31
- })
1
+ /**
2
+ * Theme Constants Tests
3
+ * @author Vander Loto - CTO DATAMETRIA
4
+ * @date 13/11/2025
5
+ */
6
+
7
+ import { describe, it, expect } from 'vitest'
8
+ import { THEME_INJECTION_KEY, DEFAULT_THEME_PREFIX, CSS_VARIABLE_PREFIX } from '../constants'
9
+
10
+ describe('Theme Constants', () => {
11
+ it('should have THEME_INJECTION_KEY as Symbol', () => {
12
+ expect(typeof THEME_INJECTION_KEY).toBe('symbol')
13
+ expect(THEME_INJECTION_KEY.toString()).toContain('theme')
14
+ })
15
+
16
+ it('should have DEFAULT_THEME_PREFIX', () => {
17
+ expect(DEFAULT_THEME_PREFIX).toBe('dm')
18
+ expect(typeof DEFAULT_THEME_PREFIX).toBe('string')
19
+ })
20
+
21
+ it('should have CSS_VARIABLE_PREFIX', () => {
22
+ expect(CSS_VARIABLE_PREFIX).toBe('--')
23
+ expect(typeof CSS_VARIABLE_PREFIX).toBe('string')
24
+ })
25
+
26
+ it('should have unique injection key', () => {
27
+ const key1 = THEME_INJECTION_KEY
28
+ const key2 = Symbol('theme')
29
+ expect(key1).not.toBe(key2)
30
+ })
31
+ })