@code-coaching/vuetiful 0.23.1 → 0.24.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.
- package/dist/style.css +1 -1
- package/dist/types/components/VBootstrap.vue.d.ts +1 -1
- package/dist/types/components/atoms/VAvatar.vue.d.ts +1 -1
- package/dist/types/components/atoms/VLightSwitch.vue.d.ts +7 -3
- package/dist/types/components/atoms/index.d.ts +13 -13
- package/dist/types/components/index.d.ts +2 -2
- package/dist/types/components/molecules/VAlert.vue.d.ts +1 -1
- package/dist/types/components/molecules/VCodeBlock.vue.d.ts +2 -2
- package/dist/types/components/molecules/VDrawer.vue.d.ts +1 -1
- package/dist/types/components/molecules/VListbox/VListbox.vue.d.ts +1 -1
- package/dist/types/components/molecules/VRail/VRail.vue.d.ts +1 -1
- package/dist/types/components/molecules/VRail/VRailTile.vue.d.ts +1 -1
- package/dist/types/components/molecules/index.d.ts +21 -21
- package/dist/types/directives/clipboard.d.ts +1 -1
- package/dist/types/directives/index.d.ts +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/props/props.d.ts +1 -1
- package/dist/types/services/dark-mode.service.d.ts +13 -13
- package/dist/types/services/drawer.service.d.ts +1 -1
- package/dist/types/services/index.d.ts +6 -6
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/utils/colors/colors.service.d.ts +69 -0
- package/dist/types/utils/index.d.ts +7 -3
- package/dist/types/utils/theme/theme-switcher.vue.d.ts +1 -1
- package/dist/types/utils/theme/theme.service.d.ts +9 -24
- package/dist/types/utils/theme/themes.d.ts +35 -0
- package/dist/vuetiful.es.mjs +456 -161
- package/dist/vuetiful.umd.js +71 -16
- package/package.json +1 -1
- package/src/assets/main.css +6 -6
- package/src/components/VBootstrap.vue +43 -43
- package/src/components/atoms/VAvatar.test.ts +71 -71
- package/src/components/atoms/VAvatar.vue +22 -23
- package/src/components/atoms/VBadge.test.ts +11 -11
- package/src/components/atoms/VBadge.vue +2 -2
- package/src/components/atoms/VButton.test.ts +82 -82
- package/src/components/atoms/VButton.vue +20 -21
- package/src/components/atoms/VChip.test.ts +11 -11
- package/src/components/atoms/VChip.vue +3 -3
- package/src/components/atoms/VLightSwitch.test.ts +63 -14
- package/src/components/atoms/VLightSwitch.vue +35 -46
- package/src/components/atoms/VRadio/VRadioDescription.test.ts +13 -13
- package/src/components/atoms/VRadio/VRadioDescription.vue +2 -2
- package/src/components/atoms/VRadio/VRadioGroup.test.ts +40 -40
- package/src/components/atoms/VRadio/VRadioGroup.vue +19 -22
- package/src/components/atoms/VRadio/VRadioItem.test.ts +67 -67
- package/src/components/atoms/VRadio/VRadioItem.vue +10 -13
- package/src/components/atoms/VRadio/VRadioLabel.test.ts +13 -13
- package/src/components/atoms/VRadio/VRadioLabel.vue +5 -3
- package/src/components/atoms/VSwitch/VSwitch.test.ts +33 -33
- package/src/components/atoms/VSwitch/VSwitch.vue +24 -27
- package/src/components/atoms/VSwitch/VSwitchDescription.test.ts +13 -13
- package/src/components/atoms/VSwitch/VSwitchDescription.vue +2 -2
- package/src/components/atoms/VSwitch/VSwitchGroup.test.ts +9 -9
- package/src/components/atoms/VSwitch/VSwitchGroup.vue +2 -2
- package/src/components/atoms/VSwitch/VSwitchLabel.test.ts +19 -19
- package/src/components/atoms/VSwitch/VSwitchLabel.vue +2 -2
- package/src/components/atoms/index.ts +13 -13
- package/src/components/index.ts +2 -2
- package/src/components/molecules/VAccordion/VAccordion.test.ts +11 -17
- package/src/components/molecules/VAccordion/VAccordion.vue +3 -3
- package/src/components/molecules/VAccordion/VAccordionItem.test.ts +55 -55
- package/src/components/molecules/VAccordion/VAccordionItem.vue +9 -22
- package/src/components/molecules/VAlert.test.ts +38 -38
- package/src/components/molecules/VAlert.vue +25 -47
- package/src/components/molecules/VCard/VCard.test.ts +25 -25
- package/src/components/molecules/VCard/VCard.vue +13 -15
- package/src/components/molecules/VCard/VCardBody.test.ts +14 -14
- package/src/components/molecules/VCard/VCardBody.vue +4 -8
- package/src/components/molecules/VCard/VCardFooter.test.ts +22 -22
- package/src/components/molecules/VCard/VCardFooter.vue +10 -8
- package/src/components/molecules/VCard/VCardHeader.test.ts +25 -25
- package/src/components/molecules/VCard/VCardHeader.vue +7 -8
- package/src/components/molecules/VCodeBlock.test.ts +63 -63
- package/src/components/molecules/VCodeBlock.vue +27 -34
- package/src/components/molecules/VDrawer.test.ts +5 -5
- package/src/components/molecules/VDrawer.vue +10 -10
- package/src/components/molecules/VListbox/VListbox.test.ts +53 -53
- package/src/components/molecules/VListbox/VListbox.vue +31 -32
- package/src/components/molecules/VListbox/VListboxButton.test.ts +13 -13
- package/src/components/molecules/VListbox/VListboxButton.vue +5 -5
- package/src/components/molecules/VListbox/VListboxItem.test.ts +25 -25
- package/src/components/molecules/VListbox/VListboxItem.vue +7 -8
- package/src/components/molecules/VListbox/VListboxItems.test.ts +14 -14
- package/src/components/molecules/VListbox/VListboxItems.vue +9 -11
- package/src/components/molecules/VListbox/VListboxLabel.test.ts +10 -10
- package/src/components/molecules/VListbox/VListboxLabel.vue +2 -2
- package/src/components/molecules/VPreview.test.ts +26 -26
- package/src/components/molecules/VPreview.vue +22 -27
- package/src/components/molecules/VRail/VRail.test.ts +5 -5
- package/src/components/molecules/VRail/VRail.vue +7 -7
- package/src/components/molecules/VRail/VRailTile.test.ts +26 -28
- package/src/components/molecules/VRail/VRailTile.vue +13 -11
- package/src/components/molecules/VShell.test.ts +5 -5
- package/src/components/molecules/VShell.vue +11 -20
- package/src/components/molecules/VTabs/VTab.test.ts +69 -52
- package/src/components/molecules/VTabs/VTab.vue +13 -17
- package/src/components/molecules/VTabs/VTabPanel.test.ts +8 -8
- package/src/components/molecules/VTabs/VTabPanel.vue +1 -1
- package/src/components/molecules/VTabs/VTabs.test.ts +36 -36
- package/src/components/molecules/VTabs/VTabs.vue +18 -22
- package/src/components/molecules/index.ts +21 -21
- package/src/directives/clipboard.test.ts +9 -9
- package/src/directives/clipboard.ts +2 -2
- package/src/directives/index.ts +1 -1
- package/src/env.d.ts +2 -2
- package/src/index.ts +7 -7
- package/src/props/index.ts +1 -1
- package/src/props/props.ts +44 -44
- package/src/services/dark-mode.service.test.ts +64 -194
- package/src/services/dark-mode.service.ts +35 -54
- package/src/services/drawer.service.test.ts +21 -21
- package/src/services/drawer.service.ts +10 -10
- package/src/services/highlight.service.test.ts +12 -12
- package/src/services/highlight.service.ts +1 -1
- package/src/services/index.ts +6 -6
- package/src/services/rail.service.test.ts +7 -7
- package/src/services/rail.service.ts +2 -2
- package/src/services/settings.service.test.ts +5 -5
- package/src/services/settings.service.ts +1 -1
- package/src/styles/all.css +7 -7
- package/src/styles/elements/buttons.css +1 -1
- package/src/styles/elements/forms.css +7 -7
- package/src/styles/elements.css +13 -13
- package/src/styles/transitions.css +2 -2
- package/src/styles/typography.css +5 -5
- package/src/themes/theme-rocket.css +10 -10
- package/src/themes/theme-sahara.css +13 -13
- package/src/themes/theme-seafoam.css +13 -13
- package/src/themes/theme-seasonal.css +4 -4
- package/src/themes/theme-skeleton.css +7 -7
- package/src/themes/theme-vintage.css +12 -12
- package/src/themes/theme-vuetiful-0.0.1.css +13 -13
- package/src/types/index.ts +46 -46
- package/src/types/tailwind.ts +2 -21
- package/src/utils/colors/colors.service.ts +293 -0
- package/src/utils/index.ts +7 -3
- package/src/utils/platform/platform.service.test.ts +6 -6
- package/src/utils/platform/platform.service.ts +1 -1
- package/src/utils/theme/callback.test.ts +11 -7
- package/src/utils/theme/remove.test.ts +11 -9
- package/src/utils/theme/theme-switcher.vue +43 -49
- package/src/utils/theme/theme.service.test.ts +194 -84
- package/src/utils/theme/theme.service.ts +141 -81
- package/src/utils/theme/themes.ts +122 -0
- package/dist/types/components/index.test.d.ts +0 -1
- package/dist/types/index.test.d.ts +0 -1
- package/dist/types/utils/index.test.d.ts +0 -1
- package/src/components/index.test.ts +0 -10
- package/src/index.test.ts +0 -26
- package/src/utils/index.test.ts +0 -11
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import VRadioGroup from
|
|
4
|
-
import VRadioDescription from
|
|
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
5
|
|
|
6
|
-
test(
|
|
6
|
+
test('VRadioDescription using slot', () => {
|
|
7
7
|
const wrapper = mount({
|
|
8
8
|
template: `
|
|
9
9
|
<v-radio-group>
|
|
@@ -11,15 +11,15 @@ test("VRadioDescription using slot", () => {
|
|
|
11
11
|
</v-radio-group>
|
|
12
12
|
`,
|
|
13
13
|
components: {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
'v-radio-description': VRadioDescription,
|
|
15
|
+
'v-radio-group': VRadioGroup,
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
expect(wrapper.text()).toContain(
|
|
19
|
+
expect(wrapper.text()).toContain('John Duck');
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
describe(
|
|
22
|
+
describe('VRadioDescription props', () => {
|
|
23
23
|
test("default 'as' prop", () => {
|
|
24
24
|
const wrapper = mount({
|
|
25
25
|
template: `
|
|
@@ -28,8 +28,8 @@ describe("VRadioDescription props", () => {
|
|
|
28
28
|
</v-radio-group>
|
|
29
29
|
`,
|
|
30
30
|
components: {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
'v-radio-label': VRadioDescription,
|
|
32
|
+
'v-radio-group': VRadioGroup,
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
35
|
|
|
@@ -44,8 +44,8 @@ describe("VRadioDescription props", () => {
|
|
|
44
44
|
</v-radio-group>
|
|
45
45
|
`,
|
|
46
46
|
components: {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
'v-radio-label': VRadioDescription,
|
|
48
|
+
'v-radio-group': VRadioGroup,
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import VRadioGroup from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import VRadioGroup from './VRadioGroup.vue';
|
|
4
4
|
|
|
5
|
-
test(
|
|
5
|
+
test('VRadioGroup using slot', () => {
|
|
6
6
|
const wrapper = mount(VRadioGroup, {
|
|
7
7
|
slots: {
|
|
8
|
-
default:
|
|
8
|
+
default: 'John Duck',
|
|
9
9
|
},
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
expect(wrapper.text()).toContain(
|
|
12
|
+
expect(wrapper.text()).toContain('John Duck');
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
test(
|
|
15
|
+
test('VRadioGroup default props', () => {
|
|
16
16
|
const wrapper = mount(VRadioGroup);
|
|
17
|
-
const radioGroupEl = wrapper.find(
|
|
17
|
+
const radioGroupEl = wrapper.find('div');
|
|
18
18
|
expect(radioGroupEl.classes()).toEqual([
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
29
|
]);
|
|
30
30
|
|
|
31
31
|
const radioGroup = wrapper.find("[data-test='radio-group']");
|
|
32
|
-
expect(radioGroup.element.tagName).toBe(
|
|
32
|
+
expect(radioGroup.element.tagName).toBe('DIV');
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
test(
|
|
35
|
+
test('VRadioGroup custom class props', () => {
|
|
36
36
|
const wrapper = mount(VRadioGroup, {
|
|
37
37
|
props: {
|
|
38
|
-
background:
|
|
39
|
-
text:
|
|
38
|
+
background: 'custom-background-class',
|
|
39
|
+
text: 'custom-text-class',
|
|
40
40
|
},
|
|
41
41
|
});
|
|
42
|
-
const radioGroupEl = wrapper.find(
|
|
42
|
+
const radioGroupEl = wrapper.find('div');
|
|
43
43
|
expect(radioGroupEl.classes()).toEqual([
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
53
|
]);
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
test("VRadioGroup custom 'as' prop", () => {
|
|
57
57
|
const wrapper = mount(VRadioGroup, {
|
|
58
58
|
props: {
|
|
59
|
-
as:
|
|
59
|
+
as: 'span',
|
|
60
60
|
},
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
const radioGroup = wrapper.find("[data-test='radio-group']");
|
|
64
|
-
expect(radioGroup.element.tagName).toBe(
|
|
64
|
+
expect(radioGroup.element.tagName).toBe('SPAN');
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
describe(
|
|
68
|
-
describe(
|
|
69
|
-
test(
|
|
67
|
+
describe('VRadioGroup v-model', () => {
|
|
68
|
+
describe('given value changes', () => {
|
|
69
|
+
test('should emit update:modelValue', async () => {
|
|
70
70
|
const wrapper = mount(VRadioGroup, {
|
|
71
71
|
props: {
|
|
72
|
-
modelValue:
|
|
72
|
+
modelValue: 'John Duck',
|
|
73
73
|
},
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
wrapper.setProps({ modelValue:
|
|
76
|
+
wrapper.setProps({ modelValue: 'Jane Duck' });
|
|
77
77
|
await wrapper.vm.$nextTick();
|
|
78
|
-
expect(wrapper.emitted()[
|
|
78
|
+
expect(wrapper.emitted()['update:modelValue'][0]).toEqual(['Jane Duck']);
|
|
79
79
|
});
|
|
80
80
|
});
|
|
81
81
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useSettings } from
|
|
3
|
-
import { RadioGroup } from
|
|
4
|
-
import { provide, ref, watch } from
|
|
2
|
+
import { useSettings } from '@/index';
|
|
3
|
+
import { RadioGroup } from '@headlessui/vue';
|
|
4
|
+
import { provide, ref, watch } from 'vue';
|
|
5
5
|
|
|
6
|
-
const emit = defineEmits([
|
|
6
|
+
const emit = defineEmits(['update:modelValue']);
|
|
7
7
|
const props = defineProps({
|
|
8
8
|
as: {
|
|
9
9
|
type: String,
|
|
10
|
-
default:
|
|
10
|
+
default: 'div',
|
|
11
11
|
},
|
|
12
12
|
|
|
13
13
|
disabled: {
|
|
@@ -18,29 +18,29 @@ const props = defineProps({
|
|
|
18
18
|
type: [String, Function],
|
|
19
19
|
},
|
|
20
20
|
|
|
21
|
-
modelValue: RadioGroup.props[
|
|
21
|
+
modelValue: RadioGroup.props['modelValue'],
|
|
22
22
|
|
|
23
23
|
active: {
|
|
24
24
|
type: String,
|
|
25
|
-
default:
|
|
25
|
+
default: 'variant-filled',
|
|
26
26
|
},
|
|
27
27
|
hover: {
|
|
28
28
|
type: String,
|
|
29
|
-
default:
|
|
29
|
+
default: 'hover:variant-ghost hover:text-surface-900 dark:hover:text-surface-50',
|
|
30
30
|
},
|
|
31
31
|
|
|
32
32
|
background: {
|
|
33
33
|
type: String,
|
|
34
|
-
default:
|
|
34
|
+
default: 'bg-surface-200-700-token',
|
|
35
35
|
},
|
|
36
36
|
text: {
|
|
37
37
|
type: String,
|
|
38
|
-
default:
|
|
38
|
+
default: 'text-surface-900 dark:text-surface-50',
|
|
39
39
|
},
|
|
40
40
|
|
|
41
41
|
classItem: {
|
|
42
42
|
type: String,
|
|
43
|
-
default:
|
|
43
|
+
default: '',
|
|
44
44
|
},
|
|
45
45
|
|
|
46
46
|
unstyled: {
|
|
@@ -54,22 +54,21 @@ watch(
|
|
|
54
54
|
() => props.modelValue,
|
|
55
55
|
(newValue) => {
|
|
56
56
|
parentModelValue.value = newValue;
|
|
57
|
-
}
|
|
57
|
+
},
|
|
58
58
|
);
|
|
59
59
|
watch(
|
|
60
60
|
() => parentModelValue.value,
|
|
61
61
|
(newValue) => {
|
|
62
|
-
emit(
|
|
63
|
-
}
|
|
62
|
+
emit('update:modelValue', newValue);
|
|
63
|
+
},
|
|
64
64
|
);
|
|
65
65
|
|
|
66
|
-
provide(
|
|
67
|
-
provide(
|
|
68
|
-
provide(
|
|
66
|
+
provide('active', props.active);
|
|
67
|
+
provide('hover', props.hover);
|
|
68
|
+
provide('classItem', props.classItem);
|
|
69
69
|
|
|
70
70
|
const { settings } = useSettings();
|
|
71
|
-
const isUnstyled =
|
|
72
|
-
settings.global.unstyled || settings.components.radioGroup.unstyled || props.unstyled;
|
|
71
|
+
const isUnstyled = settings.global.unstyled || settings.components.radioGroup.unstyled || props.unstyled;
|
|
73
72
|
</script>
|
|
74
73
|
l
|
|
75
74
|
<template>
|
|
@@ -80,9 +79,7 @@ l
|
|
|
80
79
|
:disabled="disabled"
|
|
81
80
|
:by="by"
|
|
82
81
|
:class="`vuetiful-radio-group inline-flex ${
|
|
83
|
-
isUnstyled
|
|
84
|
-
? ''
|
|
85
|
-
: `gap-1 p-1 border-token border-surface-400-500-token rounded-container-token`
|
|
82
|
+
isUnstyled ? '' : `gap-1 p-1 border-token border-surface-400-500-token rounded-container-token`
|
|
86
83
|
} ${background} ${text}`"
|
|
87
84
|
v-model="parentModelValue"
|
|
88
85
|
>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import { ref } from
|
|
4
|
-
import VRadioGroup from
|
|
5
|
-
import VRadioItem from
|
|
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
6
|
|
|
7
|
-
test(
|
|
7
|
+
test('VRadioItem using slot', () => {
|
|
8
8
|
const wrapper = mount({
|
|
9
9
|
template: `
|
|
10
10
|
<v-radio-group>
|
|
@@ -12,21 +12,21 @@ test("VRadioItem using slot", () => {
|
|
|
12
12
|
</v-radio-group>
|
|
13
13
|
`,
|
|
14
14
|
components: {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
'v-radio-item': VRadioItem,
|
|
16
|
+
'v-radio-group': VRadioGroup,
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
const itemEl = wrapper.find("[data-test='item']").element;
|
|
21
|
-
expect(itemEl.textContent).toBe(
|
|
21
|
+
expect(itemEl.textContent).toBe('John Duck');
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
describe(
|
|
25
|
-
describe(
|
|
26
|
-
test(
|
|
24
|
+
describe('VRadioItem slot states', () => {
|
|
25
|
+
describe('given no injected provide', () => {
|
|
26
|
+
test('should have the default active class', () => {
|
|
27
27
|
const wrapper = mount({
|
|
28
28
|
setup() {
|
|
29
|
-
const value = ref(
|
|
29
|
+
const value = ref('John Duck');
|
|
30
30
|
return { value };
|
|
31
31
|
},
|
|
32
32
|
template: `
|
|
@@ -35,20 +35,20 @@ describe("VRadioItem slot states", () => {
|
|
|
35
35
|
</v-radio-group>
|
|
36
36
|
`,
|
|
37
37
|
components: {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
'v-radio-item': VRadioItem,
|
|
39
|
+
'v-radio-group': VRadioGroup,
|
|
40
40
|
},
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
const itemEl = wrapper.find("[data-test='item']").find(
|
|
44
|
-
expect(itemEl.element.classList.contains(
|
|
45
|
-
expect(itemEl.element.classList.contains(
|
|
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
46
|
});
|
|
47
47
|
|
|
48
|
-
test(
|
|
48
|
+
test('should have the default hover class', () => {
|
|
49
49
|
const wrapper = mount({
|
|
50
50
|
setup() {
|
|
51
|
-
const value = ref(
|
|
51
|
+
const value = ref('not John Duck');
|
|
52
52
|
return { value };
|
|
53
53
|
},
|
|
54
54
|
template: `
|
|
@@ -57,21 +57,21 @@ describe("VRadioItem slot states", () => {
|
|
|
57
57
|
</v-radio-group>
|
|
58
58
|
`,
|
|
59
59
|
components: {
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
'v-radio-item': VRadioItem,
|
|
61
|
+
'v-radio-group': VRadioGroup,
|
|
62
62
|
},
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
const itemEl = wrapper.find("[data-test='item']").find(
|
|
66
|
-
expect(itemEl.element.classList.contains(
|
|
67
|
-
expect(itemEl.element.classList.contains(
|
|
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
68
|
});
|
|
69
69
|
});
|
|
70
|
-
describe(
|
|
71
|
-
test(
|
|
70
|
+
describe('given v-slot checked is true', () => {
|
|
71
|
+
test('should have the active class', () => {
|
|
72
72
|
const wrapper = mount({
|
|
73
73
|
setup() {
|
|
74
|
-
const value = ref(
|
|
74
|
+
const value = ref('John Duck');
|
|
75
75
|
return { value };
|
|
76
76
|
},
|
|
77
77
|
template: `
|
|
@@ -80,26 +80,26 @@ describe("VRadioItem slot states", () => {
|
|
|
80
80
|
</v-radio-group>
|
|
81
81
|
`,
|
|
82
82
|
components: {
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
'v-radio-item': VRadioItem,
|
|
84
|
+
'v-radio-group': VRadioGroup,
|
|
85
85
|
},
|
|
86
86
|
provide: {
|
|
87
|
-
active:
|
|
88
|
-
hover:
|
|
87
|
+
active: 'custom-active-class',
|
|
88
|
+
hover: 'custom-hover-class',
|
|
89
89
|
},
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
const itemEl = wrapper.find("[data-test='item']").find(
|
|
93
|
-
expect(itemEl.element.classList.contains(
|
|
94
|
-
expect(itemEl.element.classList.contains(
|
|
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
95
|
});
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
describe(
|
|
99
|
-
test(
|
|
98
|
+
describe('given v-slot checked is false', () => {
|
|
99
|
+
test('should have the hover class', () => {
|
|
100
100
|
const wrapper = mount({
|
|
101
101
|
setup() {
|
|
102
|
-
const value = ref(
|
|
102
|
+
const value = ref('not John Duck');
|
|
103
103
|
return { value };
|
|
104
104
|
},
|
|
105
105
|
template: `
|
|
@@ -108,26 +108,26 @@ describe("VRadioItem slot states", () => {
|
|
|
108
108
|
</v-radio-group>
|
|
109
109
|
`,
|
|
110
110
|
components: {
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
'v-radio-item': VRadioItem,
|
|
112
|
+
'v-radio-group': VRadioGroup,
|
|
113
113
|
},
|
|
114
114
|
provide: {
|
|
115
|
-
active:
|
|
116
|
-
hover:
|
|
115
|
+
active: 'custom-active-class',
|
|
116
|
+
hover: 'custom-hover-class',
|
|
117
117
|
},
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
const itemEl = wrapper.find("[data-test='item']").find(
|
|
121
|
-
expect(itemEl.element.classList.contains(
|
|
122
|
-
expect(itemEl.element.classList.contains(
|
|
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
123
|
});
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
describe(
|
|
127
|
-
test(
|
|
126
|
+
describe('given v-slot disabled is false', () => {
|
|
127
|
+
test('should not have the disabled classes', () => {
|
|
128
128
|
const wrapper = mount({
|
|
129
129
|
setup() {
|
|
130
|
-
const value = ref(
|
|
130
|
+
const value = ref('John Duck');
|
|
131
131
|
return { value };
|
|
132
132
|
},
|
|
133
133
|
template: `
|
|
@@ -136,27 +136,27 @@ describe("VRadioItem slot states", () => {
|
|
|
136
136
|
</v-radio-group>
|
|
137
137
|
`,
|
|
138
138
|
components: {
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
'v-radio-item': VRadioItem,
|
|
140
|
+
'v-radio-group': VRadioGroup,
|
|
141
141
|
},
|
|
142
142
|
provide: {
|
|
143
|
-
active:
|
|
144
|
-
hover:
|
|
143
|
+
active: 'custom-active-class',
|
|
144
|
+
hover: 'custom-hover-class',
|
|
145
145
|
},
|
|
146
146
|
});
|
|
147
147
|
|
|
148
|
-
const itemEl = wrapper.find("[data-test='item']").find(
|
|
149
|
-
expect(itemEl.element.classList.contains(
|
|
150
|
-
expect(itemEl.element.classList.contains(
|
|
151
|
-
expect(itemEl.element.classList.contains(
|
|
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
152
|
});
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
-
describe(
|
|
156
|
-
test(
|
|
155
|
+
describe('given v-slot disabled is true', () => {
|
|
156
|
+
test('should have the disabled classes', () => {
|
|
157
157
|
const wrapper = mount({
|
|
158
158
|
setup() {
|
|
159
|
-
const value = ref(
|
|
159
|
+
const value = ref('John Duck');
|
|
160
160
|
return { value };
|
|
161
161
|
},
|
|
162
162
|
template: `
|
|
@@ -165,19 +165,19 @@ describe("VRadioItem slot states", () => {
|
|
|
165
165
|
</v-radio-group>
|
|
166
166
|
`,
|
|
167
167
|
components: {
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
'v-radio-item': VRadioItem,
|
|
169
|
+
'v-radio-group': VRadioGroup,
|
|
170
170
|
},
|
|
171
171
|
provide: {
|
|
172
|
-
active:
|
|
173
|
-
hover:
|
|
172
|
+
active: 'custom-active-class',
|
|
173
|
+
hover: 'custom-hover-class',
|
|
174
174
|
},
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
-
const itemEl = wrapper.find("[data-test='item']").find(
|
|
178
|
-
expect(itemEl.element.classList.contains(
|
|
179
|
-
expect(itemEl.element.classList.contains(
|
|
180
|
-
expect(itemEl.element.classList.contains(
|
|
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
181
|
});
|
|
182
182
|
});
|
|
183
183
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useSettings } from
|
|
3
|
-
import { RadioGroupOption } from
|
|
4
|
-
import { inject } from
|
|
2
|
+
import { useSettings } from '@/index';
|
|
3
|
+
import { RadioGroupOption } from '@headlessui/vue';
|
|
4
|
+
import { inject } from 'vue';
|
|
5
5
|
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
value: {
|
|
@@ -14,24 +14,21 @@ const props = defineProps({
|
|
|
14
14
|
},
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
const active = inject(
|
|
18
|
-
const hover = inject(
|
|
19
|
-
const classItem = inject(
|
|
17
|
+
const active = inject('active') as string;
|
|
18
|
+
const hover = inject('hover') as string;
|
|
19
|
+
const classItem = inject('classItem') as string;
|
|
20
20
|
|
|
21
21
|
const { settings } = useSettings();
|
|
22
|
-
const isUnstyled =
|
|
23
|
-
settings.global.unstyled || settings.components.radioItem.unstyled || props.unstyled;
|
|
22
|
+
const isUnstyled = settings.global.unstyled || settings.components.radioItem.unstyled || props.unstyled;
|
|
24
23
|
</script>
|
|
25
24
|
|
|
26
25
|
<template>
|
|
27
26
|
<RadioGroupOption v-slot="{ checked, disabled }" :value="value">
|
|
28
27
|
<div
|
|
29
28
|
data-test="radio-item"
|
|
30
|
-
:class="`vuetiful-radio-item ${
|
|
31
|
-
|
|
32
|
-
} ${
|
|
33
|
-
disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer'
|
|
34
|
-
} ${classItem}`"
|
|
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}`"
|
|
35
32
|
>
|
|
36
33
|
<slot />
|
|
37
34
|
</div>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import VRadioGroup from
|
|
4
|
-
import VRadioLabel from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import VRadioGroup from './VRadioGroup.vue';
|
|
4
|
+
import VRadioLabel from './VRadioLabel.vue';
|
|
5
5
|
|
|
6
|
-
test(
|
|
6
|
+
test('VRadioLabel using slot', () => {
|
|
7
7
|
const wrapper = mount({
|
|
8
8
|
template: `
|
|
9
9
|
<v-radio-group>
|
|
@@ -11,15 +11,15 @@ test("VRadioLabel using slot", () => {
|
|
|
11
11
|
</v-radio-group>
|
|
12
12
|
`,
|
|
13
13
|
components: {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
'v-radio-label': VRadioLabel,
|
|
15
|
+
'v-radio-group': VRadioGroup,
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
expect(wrapper.text()).toContain(
|
|
19
|
+
expect(wrapper.text()).toContain('John Duck');
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
describe(
|
|
22
|
+
describe('VRadioLabel props', () => {
|
|
23
23
|
test("default 'as' prop", () => {
|
|
24
24
|
const wrapper = mount({
|
|
25
25
|
template: `
|
|
@@ -28,8 +28,8 @@ describe("VRadioLabel props", () => {
|
|
|
28
28
|
</v-radio-group>
|
|
29
29
|
`,
|
|
30
30
|
components: {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
'v-radio-label': VRadioLabel,
|
|
32
|
+
'v-radio-group': VRadioGroup,
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
35
|
|
|
@@ -44,8 +44,8 @@ describe("VRadioLabel props", () => {
|
|
|
44
44
|
</v-radio-group>
|
|
45
45
|
`,
|
|
46
46
|
components: {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
'v-radio-label': VRadioLabel,
|
|
48
|
+
'v-radio-group': VRadioGroup,
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { RadioGroupLabel } from
|
|
2
|
+
import { RadioGroupLabel } from '@headlessui/vue';
|
|
3
3
|
|
|
4
4
|
defineProps({
|
|
5
5
|
as: {
|
|
6
6
|
type: String,
|
|
7
|
-
default:
|
|
7
|
+
default: 'p',
|
|
8
8
|
},
|
|
9
9
|
});
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
12
|
<template>
|
|
13
|
-
<RadioGroupLabel :as="as" class="vuetiful-radio-label"
|
|
13
|
+
<RadioGroupLabel :as="as" class="vuetiful-radio-label">
|
|
14
|
+
<slot />
|
|
15
|
+
</RadioGroupLabel>
|
|
14
16
|
</template>
|