@code-coaching/vuetiful 0.25.0 → 0.27.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 (257) hide show
  1. package/README.md +47 -55
  2. package/dist/css/animations.css +2 -0
  3. package/{src → dist}/css/overrides/quasar.css +73 -58
  4. package/{src/styles → dist/css}/transitions/slide.css +6 -0
  5. package/dist/favicon.ico +0 -0
  6. package/dist/types/components/atoms/VAvatar.vue.d.ts +39 -90
  7. package/dist/types/components/atoms/VBadge.vue.d.ts +34 -21
  8. package/dist/types/components/atoms/VButton.vue.d.ts +42 -48
  9. package/dist/types/components/atoms/VChip.vue.d.ts +33 -21
  10. package/dist/types/components/atoms/VLightSwitch.vue.d.ts +5 -5
  11. package/dist/types/components/atoms/VRadio/VRadioDescription.vue.d.ts +7 -12
  12. package/dist/types/components/atoms/VRadio/VRadioGroup.vue.d.ts +53 -83
  13. package/dist/types/components/atoms/VRadio/VRadioItem.vue.d.ts +46 -12
  14. package/dist/types/components/atoms/VRadio/VRadioLabel.vue.d.ts +7 -12
  15. package/dist/types/components/atoms/VSwitch/VSwitch.vue.d.ts +51 -72
  16. package/dist/types/components/atoms/VSwitch/VSwitchDescription.vue.d.ts +32 -11
  17. package/dist/types/components/atoms/VSwitch/VSwitchGroup.vue.d.ts +32 -11
  18. package/dist/types/components/atoms/VSwitch/VSwitchLabel.vue.d.ts +33 -20
  19. package/dist/types/components/molecules/VAccordion/VAccordion.vue.d.ts +39 -28
  20. package/dist/types/components/molecules/VAccordion/VAccordionItem.vue.d.ts +35 -19
  21. package/dist/types/components/molecules/VAlert.vue.d.ts +50 -73
  22. package/dist/types/components/molecules/VCard/VCard.vue.d.ts +37 -48
  23. package/dist/types/components/molecules/VCard/VCardBody.vue.d.ts +33 -12
  24. package/dist/types/components/molecules/VCard/VCardFooter.vue.d.ts +36 -20
  25. package/dist/types/components/molecules/VCard/VCardHeader.vue.d.ts +36 -20
  26. package/dist/types/components/molecules/VCodeBlock.vue.d.ts +15 -16
  27. package/dist/types/components/molecules/VDrawer.vue.d.ts +13 -7
  28. package/dist/types/components/molecules/VListbox/VListbox.vue.d.ts +54 -132
  29. package/dist/types/components/molecules/VListbox/VListboxButton.vue.d.ts +22 -21
  30. package/dist/types/components/molecules/VListbox/VListboxItem.vue.d.ts +22 -19
  31. package/dist/types/components/molecules/VListbox/VListboxItems.vue.d.ts +19 -30
  32. package/dist/types/components/molecules/VListbox/VListboxLabel.vue.d.ts +7 -12
  33. package/dist/types/components/molecules/VPreview.vue.d.ts +57 -74
  34. package/dist/types/components/molecules/VRail/VRail.vue.d.ts +28 -13
  35. package/dist/types/components/molecules/VRail/VRailTile.vue.d.ts +49 -16
  36. package/dist/types/components/molecules/VShell.vue.d.ts +76 -44
  37. package/dist/types/components/molecules/VShellConfigurator.vue.d.ts +99 -0
  38. package/dist/types/components/molecules/VTabs/VTab.vue.d.ts +52 -20
  39. package/dist/types/components/molecules/VTabs/VTabPanel.vue.d.ts +8 -1
  40. package/dist/types/components/molecules/VTabs/VTabs.vue.d.ts +43 -101
  41. package/dist/types/components/molecules/Vuetiful.vue.d.ts +22 -0
  42. package/dist/types/components/molecules/index.d.ts +3 -4
  43. package/dist/types/directives/click-outside-group.d.ts +9 -0
  44. package/dist/types/directives/click-outside.d.ts +9 -0
  45. package/dist/types/directives/clipboard.d.ts +1 -1
  46. package/dist/types/directives/index.d.ts +3 -1
  47. package/dist/types/index.d.ts +1 -8
  48. package/dist/types/props/props.d.ts +1 -14
  49. package/dist/types/services/dark-mode.service.d.ts +1 -1
  50. package/dist/types/services/drawer.service.d.ts +3 -3
  51. package/dist/types/services/index.d.ts +2 -2
  52. package/dist/types/utils/id-generator.d.ts +1 -0
  53. package/dist/types/utils/index.d.ts +3 -4
  54. package/dist/types/utils/tailwind-merge.d.ts +1 -0
  55. package/dist/types/utils/theme/rocket.theme.d.ts +223 -0
  56. package/dist/types/utils/theme/theme-switcher.vue.d.ts +14 -5
  57. package/dist/types/utils/theme/theme.service.d.ts +6 -9
  58. package/dist/types/utils/theme/themes.d.ts +3 -39
  59. package/dist/types/utils/theme/vuetiful.theme.d.ts +224 -0
  60. package/dist/vuetiful.es.mjs +54837 -49494
  61. package/dist/vuetiful.umd.cjs +189 -0
  62. package/package.json +53 -37
  63. package/dist/style.css +0 -10
  64. package/dist/types/components/VBootstrap.vue.d.ts +0 -15
  65. package/dist/types/components/atoms/VAvatar.test.d.ts +0 -1
  66. package/dist/types/components/atoms/VBadge.test.d.ts +0 -1
  67. package/dist/types/components/atoms/VButton.test.d.ts +0 -1
  68. package/dist/types/components/atoms/VChip.test.d.ts +0 -1
  69. package/dist/types/components/atoms/VLightSwitch.test.d.ts +0 -1
  70. package/dist/types/components/atoms/VRadio/VRadioDescription.test.d.ts +0 -1
  71. package/dist/types/components/atoms/VRadio/VRadioGroup.test.d.ts +0 -1
  72. package/dist/types/components/atoms/VRadio/VRadioItem.test.d.ts +0 -1
  73. package/dist/types/components/atoms/VRadio/VRadioLabel.test.d.ts +0 -1
  74. package/dist/types/components/atoms/VSwitch/VSwitch.test.d.ts +0 -1
  75. package/dist/types/components/atoms/VSwitch/VSwitchDescription.test.d.ts +0 -1
  76. package/dist/types/components/atoms/VSwitch/VSwitchGroup.test.d.ts +0 -1
  77. package/dist/types/components/atoms/VSwitch/VSwitchLabel.test.d.ts +0 -1
  78. package/dist/types/components/molecules/VAccordion/VAccordion.test.d.ts +0 -1
  79. package/dist/types/components/molecules/VAccordion/VAccordionItem.test.d.ts +0 -1
  80. package/dist/types/components/molecules/VAlert.test.d.ts +0 -1
  81. package/dist/types/components/molecules/VCard/VCard.test.d.ts +0 -1
  82. package/dist/types/components/molecules/VCard/VCardBody.test.d.ts +0 -1
  83. package/dist/types/components/molecules/VCard/VCardFooter.test.d.ts +0 -1
  84. package/dist/types/components/molecules/VCard/VCardHeader.test.d.ts +0 -1
  85. package/dist/types/components/molecules/VCodeBlock.test.d.ts +0 -1
  86. package/dist/types/components/molecules/VDrawer.test.d.ts +0 -1
  87. package/dist/types/components/molecules/VListbox/VListbox.test.d.ts +0 -1
  88. package/dist/types/components/molecules/VListbox/VListboxButton.test.d.ts +0 -1
  89. package/dist/types/components/molecules/VListbox/VListboxItem.test.d.ts +0 -1
  90. package/dist/types/components/molecules/VListbox/VListboxItems.test.d.ts +0 -1
  91. package/dist/types/components/molecules/VListbox/VListboxLabel.test.d.ts +0 -1
  92. package/dist/types/components/molecules/VPreview.test.d.ts +0 -1
  93. package/dist/types/components/molecules/VRail/VRail.test.d.ts +0 -1
  94. package/dist/types/components/molecules/VRail/VRailTile.test.d.ts +0 -1
  95. package/dist/types/components/molecules/VShell.test.d.ts +0 -1
  96. package/dist/types/components/molecules/VTabs/VTab.test.d.ts +0 -1
  97. package/dist/types/components/molecules/VTabs/VTabPanel.test.d.ts +0 -1
  98. package/dist/types/components/molecules/VTabs/VTabs.test.d.ts +0 -1
  99. package/dist/types/directives/clipboard.test.d.ts +0 -1
  100. package/dist/types/services/dark-mode.service.test.d.ts +0 -1
  101. package/dist/types/services/drawer.service.test.d.ts +0 -1
  102. package/dist/types/services/highlight.service.test.d.ts +0 -1
  103. package/dist/types/services/rail.service.test.d.ts +0 -1
  104. package/dist/types/services/settings.service.test.d.ts +0 -1
  105. package/dist/types/types/index.d.ts +0 -54
  106. package/dist/types/types/tailwind.d.ts +0 -4
  107. package/dist/types/utils/colors/colors.service.d.ts +0 -69
  108. package/dist/types/utils/platform/platform.service.test.d.ts +0 -1
  109. package/dist/types/utils/theme/callback.test.d.ts +0 -1
  110. package/dist/types/utils/theme/remove.test.d.ts +0 -1
  111. package/dist/types/utils/theme/theme.service.test.d.ts +0 -1
  112. package/dist/vuetiful.umd.js +0 -99
  113. package/src/assets/fonts/myfont.woff +0 -0
  114. package/src/assets/main.css +0 -17
  115. package/src/components/VBootstrap.vue +0 -62
  116. package/src/components/atoms/VAvatar.test.ts +0 -175
  117. package/src/components/atoms/VAvatar.vue +0 -89
  118. package/src/components/atoms/VBadge.test.ts +0 -28
  119. package/src/components/atoms/VBadge.vue +0 -17
  120. package/src/components/atoms/VButton.test.ts +0 -180
  121. package/src/components/atoms/VButton.vue +0 -76
  122. package/src/components/atoms/VChip.test.ts +0 -33
  123. package/src/components/atoms/VChip.vue +0 -17
  124. package/src/components/atoms/VLightSwitch.test.ts +0 -69
  125. package/src/components/atoms/VLightSwitch.vue +0 -121
  126. package/src/components/atoms/VRadio/VRadioDescription.test.ts +0 -55
  127. package/src/components/atoms/VRadio/VRadioDescription.vue +0 -14
  128. package/src/components/atoms/VRadio/VRadioGroup.test.ts +0 -81
  129. package/src/components/atoms/VRadio/VRadioGroup.vue +0 -88
  130. package/src/components/atoms/VRadio/VRadioItem.test.ts +0 -183
  131. package/src/components/atoms/VRadio/VRadioItem.vue +0 -36
  132. package/src/components/atoms/VRadio/VRadioLabel.test.ts +0 -55
  133. package/src/components/atoms/VRadio/VRadioLabel.vue +0 -16
  134. package/src/components/atoms/VSwitch/VSwitch.test.ts +0 -100
  135. package/src/components/atoms/VSwitch/VSwitch.vue +0 -106
  136. package/src/components/atoms/VSwitch/VSwitchDescription.test.ts +0 -55
  137. package/src/components/atoms/VSwitch/VSwitchDescription.vue +0 -16
  138. package/src/components/atoms/VSwitch/VSwitchGroup.test.ts +0 -26
  139. package/src/components/atoms/VSwitch/VSwitchGroup.vue +0 -16
  140. package/src/components/atoms/VSwitch/VSwitchLabel.test.ts +0 -89
  141. package/src/components/atoms/VSwitch/VSwitchLabel.vue +0 -20
  142. package/src/components/atoms/index.ts +0 -31
  143. package/src/components/index.ts +0 -2
  144. package/src/components/molecules/VAccordion/VAccordion.test.ts +0 -27
  145. package/src/components/molecules/VAccordion/VAccordion.vue +0 -32
  146. package/src/components/molecules/VAccordion/VAccordionItem.test.ts +0 -134
  147. package/src/components/molecules/VAccordion/VAccordionItem.vue +0 -68
  148. package/src/components/molecules/VAlert.test.ts +0 -100
  149. package/src/components/molecules/VAlert.vue +0 -137
  150. package/src/components/molecules/VCard/VCard.test.ts +0 -47
  151. package/src/components/molecules/VCard/VCard.vue +0 -74
  152. package/src/components/molecules/VCard/VCardBody.test.ts +0 -39
  153. package/src/components/molecules/VCard/VCardBody.vue +0 -16
  154. package/src/components/molecules/VCard/VCardFooter.test.ts +0 -63
  155. package/src/components/molecules/VCard/VCardFooter.vue +0 -31
  156. package/src/components/molecules/VCard/VCardHeader.test.ts +0 -86
  157. package/src/components/molecules/VCard/VCardHeader.vue +0 -53
  158. package/src/components/molecules/VCodeBlock.test.ts +0 -133
  159. package/src/components/molecules/VCodeBlock.vue +0 -113
  160. package/src/components/molecules/VDrawer.test.ts +0 -14
  161. package/src/components/molecules/VDrawer.vue +0 -87
  162. package/src/components/molecules/VListbox/VListbox.test.ts +0 -146
  163. package/src/components/molecules/VListbox/VListbox.vue +0 -149
  164. package/src/components/molecules/VListbox/VListboxButton.test.ts +0 -66
  165. package/src/components/molecules/VListbox/VListboxButton.vue +0 -57
  166. package/src/components/molecules/VListbox/VListboxItem.test.ts +0 -51
  167. package/src/components/molecules/VListbox/VListboxItem.vue +0 -39
  168. package/src/components/molecules/VListbox/VListboxItems.test.ts +0 -44
  169. package/src/components/molecules/VListbox/VListboxItems.vue +0 -42
  170. package/src/components/molecules/VListbox/VListboxLabel.test.ts +0 -30
  171. package/src/components/molecules/VListbox/VListboxLabel.vue +0 -14
  172. package/src/components/molecules/VPreview.test.ts +0 -73
  173. package/src/components/molecules/VPreview.vue +0 -230
  174. package/src/components/molecules/VRail/VRail.test.ts +0 -14
  175. package/src/components/molecules/VRail/VRail.vue +0 -33
  176. package/src/components/molecules/VRail/VRailTile.test.ts +0 -97
  177. package/src/components/molecules/VRail/VRailTile.vue +0 -49
  178. package/src/components/molecules/VShell.test.ts +0 -14
  179. package/src/components/molecules/VShell.vue +0 -63
  180. package/src/components/molecules/VTabs/VTab.test.ts +0 -143
  181. package/src/components/molecules/VTabs/VTab.vue +0 -50
  182. package/src/components/molecules/VTabs/VTabPanel.test.ts +0 -24
  183. package/src/components/molecules/VTabs/VTabPanel.vue +0 -9
  184. package/src/components/molecules/VTabs/VTabs.test.ts +0 -92
  185. package/src/components/molecules/VTabs/VTabs.vue +0 -104
  186. package/src/components/molecules/index.ts +0 -51
  187. package/src/directives/clipboard.test.ts +0 -26
  188. package/src/directives/clipboard.ts +0 -9
  189. package/src/directives/index.ts +0 -3
  190. package/src/env.d.ts +0 -8
  191. package/src/index.ts +0 -21
  192. package/src/props/index.ts +0 -1
  193. package/src/props/props.ts +0 -62
  194. package/src/services/dark-mode.service.test.ts +0 -104
  195. package/src/services/dark-mode.service.ts +0 -75
  196. package/src/services/drawer.service.test.ts +0 -45
  197. package/src/services/drawer.service.ts +0 -46
  198. package/src/services/highlight.service.test.ts +0 -24
  199. package/src/services/highlight.service.ts +0 -19
  200. package/src/services/index.ts +0 -8
  201. package/src/services/rail.service.test.ts +0 -13
  202. package/src/services/rail.service.ts +0 -11
  203. package/src/services/settings.service.test.ts +0 -17
  204. package/src/services/settings.service.ts +0 -136
  205. package/src/styles/all.css +0 -24
  206. package/src/styles/core.css +0 -66
  207. package/src/styles/elements/alerts.css +0 -17
  208. package/src/styles/elements/badges.css +0 -31
  209. package/src/styles/elements/breadcrumbs.css +0 -26
  210. package/src/styles/elements/buttons.css +0 -103
  211. package/src/styles/elements/cards.css +0 -32
  212. package/src/styles/elements/chips.css +0 -22
  213. package/src/styles/elements/forms.css +0 -269
  214. package/src/styles/elements/lists.css +0 -48
  215. package/src/styles/elements/logo-clouds.css +0 -29
  216. package/src/styles/elements/modals.css +0 -15
  217. package/src/styles/elements/placeholders.css +0 -17
  218. package/src/styles/elements/popups.css +0 -16
  219. package/src/styles/elements/tables.css +0 -102
  220. package/src/styles/elements.css +0 -19
  221. package/src/styles/highlight-js.css +0 -116
  222. package/src/styles/tailwind.css +0 -16
  223. package/src/styles/transitions.css +0 -2
  224. package/src/styles/typography.css +0 -101
  225. package/src/styles/variants.css +0 -156
  226. package/src/tailwind/core.cjs +0 -37
  227. package/src/tailwind/generated/intellisense-classes.cjs +0 -558
  228. package/src/tailwind/intellisense.cjs +0 -21
  229. package/src/tailwind/settings.cjs +0 -20
  230. package/src/tailwind/theme/colors.cjs +0 -20
  231. package/src/tailwind/tokens/backgrounds.cjs +0 -48
  232. package/src/tailwind/tokens/border-radius.cjs +0 -21
  233. package/src/tailwind/tokens/borders.cjs +0 -24
  234. package/src/tailwind/tokens/fills.cjs +0 -20
  235. package/src/tailwind/tokens/rings.cjs +0 -50
  236. package/src/tailwind/tokens/text.cjs +0 -35
  237. package/src/tailwind/vuetiful.cjs +0 -19
  238. package/src/themes/theme-rocket.css +0 -119
  239. package/src/themes/theme-sahara.css +0 -128
  240. package/src/themes/theme-seafoam.css +0 -120
  241. package/src/themes/theme-seasonal.css +0 -115
  242. package/src/themes/theme-skeleton.css +0 -115
  243. package/src/themes/theme-vintage.css +0 -125
  244. package/src/themes/theme-vuetiful.css +0 -136
  245. package/src/types/index.ts +0 -59
  246. package/src/types/tailwind.ts +0 -7
  247. package/src/utils/colors/colors.service.ts +0 -293
  248. package/src/utils/index.ts +0 -8
  249. package/src/utils/platform/platform.service.test.ts +0 -19
  250. package/src/utils/platform/platform.service.ts +0 -8
  251. package/src/utils/theme/callback.test.ts +0 -28
  252. package/src/utils/theme/remove.test.ts +0 -27
  253. package/src/utils/theme/theme-switcher.vue +0 -74
  254. package/src/utils/theme/theme.service.test.ts +0 -269
  255. package/src/utils/theme/theme.service.ts +0 -173
  256. package/src/utils/theme/themes.ts +0 -282
  257. /package/{src/styles → dist/css}/transitions/fade.css +0 -0
@@ -1,17 +0,0 @@
1
- <script setup lang="ts">
2
- import { unstyledProp, variantProp } from '@/props';
3
- import { useSettings } from '@/services';
4
-
5
- const props = defineProps({
6
- unstyled: unstyledProp,
7
- variant: variantProp,
8
- });
9
-
10
- const { settings } = useSettings();
11
- const isUnstyled = settings.global.unstyled || settings.components.chip.unstyled || props.unstyled;
12
- </script>
13
- <template>
14
- <div :class="`vuetiful-chip ${isUnstyled ? '' : 'chip'} variant-${variant}`">
15
- <slot />
16
- </div>
17
- </template>
@@ -1,69 +0,0 @@
1
- import { mount } from '@vue/test-utils';
2
- import { describe, expect, test, vi } from 'vitest';
3
- import { ref } from 'vue';
4
- import { VLightSwitch } from '.';
5
-
6
- const applyMode = vi.fn();
7
- const chosenMode = ref('dark');
8
- const MODE = {
9
- LIGHT: 'light',
10
- DARK: 'dark',
11
- };
12
- vi.mock('../../services/dark-mode.service', () => ({
13
- useDarkMode: () => ({
14
- applyMode,
15
- chosenMode,
16
- MODE,
17
- }),
18
- }));
19
-
20
- describe('VLightSwitch', () => {
21
- test('toggle dark to light', async () => {
22
- const wrapper = mount(VLightSwitch);
23
- await wrapper.trigger('click');
24
- expect(applyMode).toHaveBeenCalledWith(MODE.LIGHT);
25
- });
26
-
27
- test('toggle light to dark', async () => {
28
- chosenMode.value = 'light';
29
- const wrapper = mount(VLightSwitch);
30
- await wrapper.trigger('click');
31
- expect(applyMode).toHaveBeenCalledWith(MODE.DARK);
32
- });
33
-
34
- test('svg dark/light', async () => {
35
- chosenMode.value = MODE.DARK;
36
- const wrapper = mount(VLightSwitch);
37
- const path = wrapper.find('path');
38
- expect(path.attributes().d).toBe(wrapper.vm.svgPath.moon);
39
-
40
- chosenMode.value = MODE.LIGHT;
41
- await wrapper.vm.$nextTick();
42
- expect(path.attributes().d).toBe(wrapper.vm.svgPath.sun);
43
- });
44
-
45
- test('keydown Enter', async () => {
46
- const wrapper = mount(VLightSwitch);
47
- const preventDefaultSpy = vi.fn();
48
- const event = { code: 'Enter', preventDefault: preventDefaultSpy };
49
- await wrapper.trigger('keydown', event);
50
- expect(applyMode).toHaveBeenCalledWith(MODE.LIGHT);
51
- expect(preventDefaultSpy).toHaveBeenCalled();
52
- });
53
-
54
- test('keydown Space', async () => {
55
- const wrapper = mount(VLightSwitch);
56
- const preventDefaultSpy = vi.fn();
57
- const event = { code: 'Space', preventDefault: preventDefaultSpy };
58
- await wrapper.trigger('keydown', event);
59
- expect(applyMode).toHaveBeenCalledWith(MODE.LIGHT);
60
- expect(preventDefaultSpy).toHaveBeenCalled();
61
- });
62
-
63
- test('keydown other', async () => {
64
- applyMode.mockClear();
65
- const wrapper = mount(VLightSwitch);
66
- await wrapper.trigger('keydown', { key: 'a' });
67
- expect(applyMode).not.toHaveBeenCalled();
68
- });
69
- });
@@ -1,121 +0,0 @@
1
- <template>
2
- <div
3
- :class="`lightswitch-track ${classesTrack}`"
4
- @click="onToggleHandler"
5
- @keydown="onKeyDown"
6
- role="switch"
7
- aria-label="Light Switch"
8
- :aria-checked="chosenMode === MODE.LIGHT"
9
- :title="`Toggle ${chosenMode === MODE.DARK ? 'Dark' : 'Light'} Mode`"
10
- tabindex="0"
11
- >
12
- <div :class="`lightswitch-thumb ${classesThumb}`">
13
- <svg
14
- :class="`lightswitch-icon ${classesIcon} ${iconFill}`"
15
- xmlns="http://www.w3.org/2000/svg"
16
- viewBox="0 0 512 512"
17
- >
18
- <path fill="currentColor" :d="chosenMode === MODE.LIGHT ? svgPath.sun : svgPath.moon" />
19
- </svg>
20
- </div>
21
- </div>
22
- </template>
23
-
24
- <script lang="ts">
25
- import { CssClasses, useDarkMode } from '@/index';
26
- import { ComputedRef, computed, defineComponent } from 'vue';
27
-
28
- export default defineComponent({
29
- props: {
30
- bgLight: {
31
- type: String as () => CssClasses,
32
- default: 'bg-surface-50',
33
- },
34
- bgDark: {
35
- type: String as () => CssClasses,
36
- default: 'bg-surface-900',
37
- },
38
- textLight: {
39
- type: String as () => CssClasses,
40
- default: 'text-surface-50',
41
- },
42
- textDark: {
43
- type: String as () => CssClasses,
44
- default: 'text-surface-900',
45
- },
46
- width: {
47
- type: String as () => CssClasses,
48
- default: 'w-12',
49
- },
50
- height: {
51
- type: String as () => CssClasses,
52
- default: 'h-6',
53
- },
54
- ring: {
55
- type: String as () => CssClasses,
56
- default: 'ring-[1px] ring-surface-500/30',
57
- },
58
- rounded: {
59
- type: String as () => CssClasses,
60
- default: 'rounded-token',
61
- },
62
- },
63
- setup(props, { attrs }) {
64
- const { applyMode, chosenMode, MODE } = useDarkMode();
65
-
66
- const cTransition = `transition-all duration-[200ms]`;
67
- const cTrack = 'cursor-pointer';
68
- const cThumb = 'aspect-square scale-[0.8] flex justify-center items-center';
69
- const cIcon = 'w-[70%] aspect-square';
70
-
71
- const svgPath = {
72
- sun: 'M361.5 1.2c5 2.1 8.6 6.6 9.6 11.9L391 121l107.9 19.8c5.3 1 9.8 4.6 11.9 9.6s1.5 10.7-1.6 15.2L446.9 256l62.3 90.3c3.1 4.5 3.7 10.2 1.6 15.2s-6.6 8.6-11.9 9.6L391 391 371.1 498.9c-1 5.3-4.6 9.8-9.6 11.9s-10.7 1.5-15.2-1.6L256 446.9l-90.3 62.3c-4.5 3.1-10.2 3.7-15.2 1.6s-8.6-6.6-9.6-11.9L121 391 13.1 371.1c-5.3-1-9.8-4.6-11.9-9.6s-1.5-10.7 1.6-15.2L65.1 256 2.8 165.7c-3.1-4.5-3.7-10.2-1.6-15.2s6.6-8.6 11.9-9.6L121 121 140.9 13.1c1-5.3 4.6-9.8 9.6-11.9s10.7-1.5 15.2 1.6L256 65.1 346.3 2.8c4.5-3.1 10.2-3.7 15.2-1.6zM352 256c0 53-43 96-96 96s-96-43-96-96s43-96 96-96s96 43 96 96zm32 0c0-70.7-57.3-128-128-128s-128 57.3-128 128s57.3 128 128 128s128-57.3 128-128z',
73
- moon: 'M223.5 32C100 32 0 132.3 0 256S100 480 223.5 480c60.6 0 115.5-24.2 155.8-63.4c5-4.9 6.3-12.5 3.1-18.7s-10.1-9.7-17-8.5c-9.8 1.7-19.8 2.6-30.1 2.6c-96.9 0-175.5-78.8-175.5-176c0-65.8 36-123.1 89.3-153.3c6.1-3.5 9.2-10.5 7.7-17.3s-7.3-11.9-14.3-12.5c-6.3-.5-12.6-.8-19-.8z',
74
- };
75
-
76
- const onToggleHandler = () => {
77
- const toggle = chosenMode.value === MODE.LIGHT ? MODE.DARK : MODE.LIGHT;
78
- applyMode(toggle);
79
- };
80
-
81
- type OnKeyDownEvent = KeyboardEvent & {
82
- currentTarget: EventTarget & HTMLDivElement;
83
- };
84
- const onKeyDown = (event: KeyboardEvent) => {
85
- if (['Enter', 'Space'].includes(event.code)) {
86
- event.preventDefault();
87
- (event as OnKeyDownEvent).currentTarget.click();
88
- }
89
- };
90
-
91
- const trackBg = computed(() => (chosenMode.value === MODE.LIGHT ? props.bgLight : props.bgDark));
92
- const thumbBg = computed(() => (chosenMode.value === MODE.LIGHT ? props.bgDark : props.bgLight));
93
- const thumbPosition = computed(() => (chosenMode.value === MODE.LIGHT ? 'translate-x-[100%]' : ''));
94
- const iconFill = computed(() => {
95
- return chosenMode.value === MODE.LIGHT ? props.textLight : props.textDark;
96
- });
97
-
98
- const classesTrack: ComputedRef<string> = computed(() => {
99
- return `${cTrack} ${cTransition} ${props.width} ${props.height} ${props.ring} ${props.rounded} ${trackBg.value} ${
100
- attrs.class ?? ''
101
- }`;
102
- });
103
- const classesThumb: ComputedRef<string> = computed(
104
- () => `${cThumb} ${cTransition} ${props.height} ${props.rounded} ${thumbBg.value} ${thumbPosition.value}`,
105
- );
106
- const classesIcon: ComputedRef<string> = computed(() => `${cIcon}`);
107
-
108
- return {
109
- classesTrack,
110
- classesThumb,
111
- classesIcon,
112
- svgPath,
113
- onToggleHandler,
114
- onKeyDown,
115
- chosenMode,
116
- iconFill,
117
- MODE,
118
- };
119
- },
120
- });
121
- </script>
@@ -1,55 +0,0 @@
1
- import { mount } from '@vue/test-utils';
2
- import { describe, expect, test } from 'vitest';
3
- import VRadioGroup from './VRadioGroup.vue';
4
- import VRadioDescription from './VRadioDescription.vue';
5
-
6
- test('VRadioDescription using slot', () => {
7
- const wrapper = mount({
8
- template: `
9
- <v-radio-group>
10
- <v-radio-description>John Duck</v-radio-description>
11
- </v-radio-group>
12
- `,
13
- components: {
14
- 'v-radio-description': VRadioDescription,
15
- 'v-radio-group': VRadioGroup,
16
- },
17
- });
18
-
19
- expect(wrapper.text()).toContain('John Duck');
20
- });
21
-
22
- describe('VRadioDescription props', () => {
23
- test("default 'as' prop", () => {
24
- const wrapper = mount({
25
- template: `
26
- <v-radio-group>
27
- <v-radio-label data-test="label">John Duck</v-radio-label>
28
- </v-radio-group>
29
- `,
30
- components: {
31
- 'v-radio-label': VRadioDescription,
32
- 'v-radio-group': VRadioGroup,
33
- },
34
- });
35
-
36
- const label = wrapper.find("[data-test='label']");
37
- expect(label.element).toBeInstanceOf(HTMLParagraphElement);
38
- });
39
- test("custom 'as' prop", () => {
40
- const wrapper = mount({
41
- template: `
42
- <v-radio-group>
43
- <v-radio-label as="div" data-test="label">John Duck</v-radio-label>
44
- </v-radio-group>
45
- `,
46
- components: {
47
- 'v-radio-label': VRadioDescription,
48
- 'v-radio-group': VRadioGroup,
49
- },
50
- });
51
-
52
- const label = wrapper.find("[data-test='label']");
53
- expect(label.element).toBeInstanceOf(HTMLDivElement);
54
- });
55
- });
@@ -1,14 +0,0 @@
1
- <script setup lang="ts">
2
- import { RadioGroupDescription } from '@headlessui/vue';
3
-
4
- defineProps({
5
- as: {
6
- type: String,
7
- default: 'p',
8
- },
9
- });
10
- </script>
11
-
12
- <template>
13
- <RadioGroupDescription :as="as" class="vuetiful-radio-group-description"><slot /></RadioGroupDescription>
14
- </template>
@@ -1,81 +0,0 @@
1
- import { mount } from '@vue/test-utils';
2
- import { describe, expect, test } from 'vitest';
3
- import VRadioGroup from './VRadioGroup.vue';
4
-
5
- test('VRadioGroup using slot', () => {
6
- const wrapper = mount(VRadioGroup, {
7
- slots: {
8
- default: 'John Duck',
9
- },
10
- });
11
-
12
- expect(wrapper.text()).toContain('John Duck');
13
- });
14
-
15
- test('VRadioGroup default props', () => {
16
- const wrapper = mount(VRadioGroup);
17
- const radioGroupEl = wrapper.find('div');
18
- expect(radioGroupEl.classes()).toEqual([
19
- 'vuetiful-radio-group',
20
- 'inline-flex',
21
- 'gap-1',
22
- 'p-1',
23
- 'border-token',
24
- 'border-surface-400-500-token',
25
- 'rounded-container-token',
26
- 'bg-surface-200-700-token',
27
- 'text-surface-900',
28
- 'dark:text-surface-50',
29
- ]);
30
-
31
- const radioGroup = wrapper.find("[data-test='radio-group']");
32
- expect(radioGroup.element.tagName).toBe('DIV');
33
- });
34
-
35
- test('VRadioGroup custom class props', () => {
36
- const wrapper = mount(VRadioGroup, {
37
- props: {
38
- background: 'custom-background-class',
39
- text: 'custom-text-class',
40
- },
41
- });
42
- const radioGroupEl = wrapper.find('div');
43
- expect(radioGroupEl.classes()).toEqual([
44
- 'vuetiful-radio-group',
45
- 'inline-flex',
46
- 'gap-1',
47
- 'p-1',
48
- 'border-token',
49
- 'border-surface-400-500-token',
50
- 'rounded-container-token',
51
- 'custom-background-class',
52
- 'custom-text-class',
53
- ]);
54
- });
55
-
56
- test("VRadioGroup custom 'as' prop", () => {
57
- const wrapper = mount(VRadioGroup, {
58
- props: {
59
- as: 'span',
60
- },
61
- });
62
-
63
- const radioGroup = wrapper.find("[data-test='radio-group']");
64
- expect(radioGroup.element.tagName).toBe('SPAN');
65
- });
66
-
67
- describe('VRadioGroup v-model', () => {
68
- describe('given value changes', () => {
69
- test('should emit update:modelValue', async () => {
70
- const wrapper = mount(VRadioGroup, {
71
- props: {
72
- modelValue: 'John Duck',
73
- },
74
- });
75
-
76
- wrapper.setProps({ modelValue: 'Jane Duck' });
77
- await wrapper.vm.$nextTick();
78
- expect(wrapper.emitted()['update:modelValue'][0]).toEqual(['Jane Duck']);
79
- });
80
- });
81
- });
@@ -1,88 +0,0 @@
1
- <script setup lang="ts">
2
- import { useSettings } from '@/index';
3
- import { RadioGroup } from '@headlessui/vue';
4
- import { provide, ref, watch } from 'vue';
5
-
6
- const emit = defineEmits(['update:modelValue']);
7
- const props = defineProps({
8
- as: {
9
- type: String,
10
- default: 'div',
11
- },
12
-
13
- disabled: {
14
- type: Boolean,
15
- default: false,
16
- },
17
- by: {
18
- type: [String, Function],
19
- },
20
-
21
- modelValue: RadioGroup.props['modelValue'],
22
-
23
- active: {
24
- type: String,
25
- default: 'variant-filled',
26
- },
27
- hover: {
28
- type: String,
29
- default: 'hover:variant-ghost hover:text-surface-900 dark:hover:text-surface-50',
30
- },
31
-
32
- background: {
33
- type: String,
34
- default: 'bg-surface-200-700-token',
35
- },
36
- text: {
37
- type: String,
38
- default: 'text-surface-900 dark:text-surface-50',
39
- },
40
-
41
- classItem: {
42
- type: String,
43
- default: '',
44
- },
45
-
46
- unstyled: {
47
- type: Boolean,
48
- default: false,
49
- },
50
- });
51
-
52
- const parentModelValue = ref(props.modelValue);
53
- watch(
54
- () => props.modelValue,
55
- (newValue) => {
56
- parentModelValue.value = newValue;
57
- },
58
- );
59
- watch(
60
- () => parentModelValue.value,
61
- (newValue) => {
62
- emit('update:modelValue', newValue);
63
- },
64
- );
65
-
66
- provide('active', props.active);
67
- provide('hover', props.hover);
68
- provide('classItem', props.classItem);
69
-
70
- const { settings } = useSettings();
71
- const isUnstyled = settings.global.unstyled || settings.components.radioGroup.unstyled || props.unstyled;
72
- </script>
73
- l
74
- <template>
75
- <!-- There is some odd behavior with test coverage, v-model must be the last property in this component -->
76
- <radio-group
77
- data-test="radio-group"
78
- :as="as"
79
- :disabled="disabled"
80
- :by="by"
81
- :class="`vuetiful-radio-group inline-flex ${
82
- isUnstyled ? '' : `gap-1 p-1 border-token border-surface-400-500-token rounded-container-token`
83
- } ${background} ${text}`"
84
- v-model="parentModelValue"
85
- >
86
- <slot></slot>
87
- </radio-group>
88
- </template>
@@ -1,183 +0,0 @@
1
- import { mount } from '@vue/test-utils';
2
- import { describe, expect, test } from 'vitest';
3
- import { ref } from 'vue';
4
- import VRadioGroup from './VRadioGroup.vue';
5
- import VRadioItem from './VRadioItem.vue';
6
-
7
- test('VRadioItem using slot', () => {
8
- const wrapper = mount({
9
- template: `
10
- <v-radio-group>
11
- <v-radio-item data-test="item" value="'John Duck'">John Duck</v-radio-item>
12
- </v-radio-group>
13
- `,
14
- components: {
15
- 'v-radio-item': VRadioItem,
16
- 'v-radio-group': VRadioGroup,
17
- },
18
- });
19
-
20
- const itemEl = wrapper.find("[data-test='item']").element;
21
- expect(itemEl.textContent).toBe('John Duck');
22
- });
23
-
24
- describe('VRadioItem slot states', () => {
25
- describe('given no injected provide', () => {
26
- test('should have the default active class', () => {
27
- const wrapper = mount({
28
- setup() {
29
- const value = ref('John Duck');
30
- return { value };
31
- },
32
- template: `
33
- <v-radio-group v-model="value">
34
- <v-radio-item data-test="item" :value="'John Duck'">John Duck</v-radio-item>
35
- </v-radio-group>
36
- `,
37
- components: {
38
- 'v-radio-item': VRadioItem,
39
- 'v-radio-group': VRadioGroup,
40
- },
41
- });
42
-
43
- const itemEl = wrapper.find("[data-test='item']").find('div');
44
- expect(itemEl.element.classList.contains('variant-filled')).toBe(true);
45
- expect(itemEl.element.classList.contains('hover:variant-ghost')).toBe(false);
46
- });
47
-
48
- test('should have the default hover class', () => {
49
- const wrapper = mount({
50
- setup() {
51
- const value = ref('not John Duck');
52
- return { value };
53
- },
54
- template: `
55
- <v-radio-group v-model="value">
56
- <v-radio-item data-test="item" :value="'John Duck'">John Duck</v-radio-item>
57
- </v-radio-group>
58
- `,
59
- components: {
60
- 'v-radio-item': VRadioItem,
61
- 'v-radio-group': VRadioGroup,
62
- },
63
- });
64
-
65
- const itemEl = wrapper.find("[data-test='item']").find('div');
66
- expect(itemEl.element.classList.contains('variant-filled')).toBe(false);
67
- expect(itemEl.element.classList.contains('hover:variant-ghost')).toBe(true);
68
- });
69
- });
70
- describe('given v-slot checked is true', () => {
71
- test('should have the active class', () => {
72
- const wrapper = mount({
73
- setup() {
74
- const value = ref('John Duck');
75
- return { value };
76
- },
77
- template: `
78
- <v-radio-group hover="custom-hover-class" active="custom-active-class" v-model="value">
79
- <v-radio-item data-test="item" :value="'John Duck'">John Duck</v-radio-item>
80
- </v-radio-group>
81
- `,
82
- components: {
83
- 'v-radio-item': VRadioItem,
84
- 'v-radio-group': VRadioGroup,
85
- },
86
- provide: {
87
- active: 'custom-active-class',
88
- hover: 'custom-hover-class',
89
- },
90
- });
91
-
92
- const itemEl = wrapper.find("[data-test='item']").find('div');
93
- expect(itemEl.element.classList.contains('custom-active-class')).toBe(true);
94
- expect(itemEl.element.classList.contains('custom-hover-class')).toBe(false);
95
- });
96
- });
97
-
98
- describe('given v-slot checked is false', () => {
99
- test('should have the hover class', () => {
100
- const wrapper = mount({
101
- setup() {
102
- const value = ref('not John Duck');
103
- return { value };
104
- },
105
- template: `
106
- <v-radio-group hover="custom-hover-class" active="custom-active-class" v-model="value">
107
- <v-radio-item data-test="item" :value="'John Duck'">John Duck</v-radio-item>
108
- </v-radio-group>
109
- `,
110
- components: {
111
- 'v-radio-item': VRadioItem,
112
- 'v-radio-group': VRadioGroup,
113
- },
114
- provide: {
115
- active: 'custom-active-class',
116
- hover: 'custom-hover-class',
117
- },
118
- });
119
-
120
- const itemEl = wrapper.find("[data-test='item']").find('div');
121
- expect(itemEl.element.classList.contains('custom-active-class')).toBe(false);
122
- expect(itemEl.element.classList.contains('custom-hover-class')).toBe(true);
123
- });
124
- });
125
-
126
- describe('given v-slot disabled is false', () => {
127
- test('should not have the disabled classes', () => {
128
- const wrapper = mount({
129
- setup() {
130
- const value = ref('John Duck');
131
- return { value };
132
- },
133
- template: `
134
- <v-radio-group hover="custom-hover-class" active="custom-active-class" v-model="value">
135
- <v-radio-item data-test="item" :value="'not John Duck'">John Duck</v-radio-item>
136
- </v-radio-group>
137
- `,
138
- components: {
139
- 'v-radio-item': VRadioItem,
140
- 'v-radio-group': VRadioGroup,
141
- },
142
- provide: {
143
- active: 'custom-active-class',
144
- hover: 'custom-hover-class',
145
- },
146
- });
147
-
148
- const itemEl = wrapper.find("[data-test='item']").find('div');
149
- expect(itemEl.element.classList.contains('cursor-pointer')).toBe(true);
150
- expect(itemEl.element.classList.contains('cursor-not-allowed')).toBe(false);
151
- expect(itemEl.element.classList.contains('opacity-50')).toBe(false);
152
- });
153
- });
154
-
155
- describe('given v-slot disabled is true', () => {
156
- test('should have the disabled classes', () => {
157
- const wrapper = mount({
158
- setup() {
159
- const value = ref('John Duck');
160
- return { value };
161
- },
162
- template: `
163
- <v-radio-group hover="custom-hover-class" active="custom-active-class" v-model="value">
164
- <v-radio-item disabled data-test="item" :value="'not John Duck'">John Duck</v-radio-item>
165
- </v-radio-group>
166
- `,
167
- components: {
168
- 'v-radio-item': VRadioItem,
169
- 'v-radio-group': VRadioGroup,
170
- },
171
- provide: {
172
- active: 'custom-active-class',
173
- hover: 'custom-hover-class',
174
- },
175
- });
176
-
177
- const itemEl = wrapper.find("[data-test='item']").find('div');
178
- expect(itemEl.element.classList.contains('cursor-pointer')).toBe(false);
179
- expect(itemEl.element.classList.contains('cursor-not-allowed')).toBe(true);
180
- expect(itemEl.element.classList.contains('opacity-50')).toBe(true);
181
- });
182
- });
183
- });
@@ -1,36 +0,0 @@
1
- <script setup lang="ts">
2
- import { useSettings } from '@/index';
3
- import { RadioGroupOption } from '@headlessui/vue';
4
- import { inject } from 'vue';
5
-
6
- const props = defineProps({
7
- value: {
8
- type: [String, Number, Boolean, Object],
9
- required: true,
10
- },
11
- unstyled: {
12
- type: Boolean,
13
- default: false,
14
- },
15
- });
16
-
17
- const active = inject('active') as string;
18
- const hover = inject('hover') as string;
19
- const classItem = inject('classItem') as string;
20
-
21
- const { settings } = useSettings();
22
- const isUnstyled = settings.global.unstyled || settings.components.radioItem.unstyled || props.unstyled;
23
- </script>
24
-
25
- <template>
26
- <RadioGroupOption v-slot="{ checked, disabled }" :value="value">
27
- <div
28
- data-test="radio-item"
29
- :class="`vuetiful-radio-item ${isUnstyled ? '' : `px-4 py-1 text-center text-base rounded-token`} ${
30
- checked ? active : hover
31
- } ${disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer'} ${classItem}`"
32
- >
33
- <slot />
34
- </div>
35
- </RadioGroupOption>
36
- </template>