@code-coaching/vuetiful 0.23.0 → 0.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +2 -2
- 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 +1 -1
- package/dist/types/services/drawer.service.d.ts +1 -1
- package/dist/types/services/index.d.ts +5 -5
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/utils/index.d.ts +2 -2
- package/dist/types/utils/theme/theme-switcher.vue.d.ts +23 -63
- package/dist/types/utils/theme/theme.service.d.ts +1 -1
- package/dist/vuetiful.es.mjs +82 -150
- package/dist/vuetiful.umd.js +7 -15
- 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 +6 -6
- package/src/components/atoms/VLightSwitch.vue +26 -31
- 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.test.ts +3 -3
- 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 +48 -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.test.ts +6 -6
- 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 +115 -93
- package/src/services/dark-mode.service.ts +9 -9
- 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 +5 -5
- 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/index.test.ts +3 -3
- package/src/utils/index.ts +2 -2
- 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 +6 -6
- package/src/utils/theme/remove.test.ts +8 -8
- package/src/utils/theme/theme-switcher.vue +58 -131
- package/src/utils/theme/theme.service.test.ts +69 -61
- package/src/utils/theme/theme.service.ts +19 -20
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { CssClasses, VButton, useSettings, vClipboard } from
|
|
3
|
-
import { unstyledProp } from
|
|
4
|
-
import { useHighlight } from
|
|
5
|
-
import
|
|
6
|
-
import { ref } from
|
|
2
|
+
import { CssClasses, VButton, useSettings, vClipboard } from '@/index';
|
|
3
|
+
import { unstyledProp } from '@/props';
|
|
4
|
+
import { useHighlight } from '@/services/highlight.service';
|
|
5
|
+
import 'highlight.js/styles/github-dark.css';
|
|
6
|
+
import { ref } from 'vue';
|
|
7
7
|
|
|
8
8
|
const { highlight } = useHighlight();
|
|
9
9
|
|
|
10
10
|
const props = defineProps({
|
|
11
11
|
language: {
|
|
12
12
|
type: String,
|
|
13
|
-
default:
|
|
13
|
+
default: 'plaintext',
|
|
14
14
|
},
|
|
15
15
|
code: {
|
|
16
16
|
type: String,
|
|
17
|
-
default:
|
|
17
|
+
default: '',
|
|
18
18
|
},
|
|
19
19
|
|
|
20
20
|
preventOverflow: {
|
|
@@ -24,48 +24,48 @@ const props = defineProps({
|
|
|
24
24
|
|
|
25
25
|
classHeader: {
|
|
26
26
|
type: String as () => CssClasses,
|
|
27
|
-
default:
|
|
27
|
+
default: '',
|
|
28
28
|
},
|
|
29
29
|
classLanguage: {
|
|
30
30
|
type: String as () => CssClasses,
|
|
31
|
-
default:
|
|
31
|
+
default: '',
|
|
32
32
|
},
|
|
33
33
|
classPre: {
|
|
34
34
|
type: String as () => CssClasses,
|
|
35
|
-
default:
|
|
35
|
+
default: '',
|
|
36
36
|
},
|
|
37
37
|
classCode: {
|
|
38
38
|
type: String as () => CssClasses,
|
|
39
|
-
default:
|
|
39
|
+
default: '',
|
|
40
40
|
},
|
|
41
41
|
|
|
42
42
|
classButton: {
|
|
43
43
|
type: String as () => CssClasses,
|
|
44
|
-
default:
|
|
44
|
+
default: '',
|
|
45
45
|
},
|
|
46
46
|
buttonText: {
|
|
47
47
|
type: String,
|
|
48
|
-
default:
|
|
48
|
+
default: 'Copy',
|
|
49
49
|
},
|
|
50
50
|
buttonCopiedText: {
|
|
51
51
|
type: String,
|
|
52
|
-
default:
|
|
52
|
+
default: '👍',
|
|
53
53
|
},
|
|
54
54
|
|
|
55
55
|
unstyled: unstyledProp,
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
const emit = defineEmits<{
|
|
59
|
-
(event:
|
|
59
|
+
(event: 'copy'): void;
|
|
60
60
|
}>();
|
|
61
61
|
|
|
62
62
|
const copyState = ref(false);
|
|
63
63
|
|
|
64
64
|
// Allow shorthand alias, but show full text in UI
|
|
65
65
|
function languageFormatter(lang: string): string {
|
|
66
|
-
if (lang ===
|
|
67
|
-
if (lang ===
|
|
68
|
-
if ([
|
|
66
|
+
if (lang === 'js') return 'javascript';
|
|
67
|
+
if (lang === 'ts') return 'typescript';
|
|
68
|
+
if (['sh', 'bash', 'zsh', 'shell'].includes(lang)) return 'console';
|
|
69
69
|
return lang;
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -74,36 +74,29 @@ function onCopyClick() {
|
|
|
74
74
|
setTimeout(() => {
|
|
75
75
|
copyState.value = false;
|
|
76
76
|
}, 2000);
|
|
77
|
-
emit(
|
|
77
|
+
emit('copy');
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
const { settings } = useSettings();
|
|
81
|
-
const isUnstyled =
|
|
82
|
-
settings.global.unstyled || settings.components.codeBlock.unstyled || props.unstyled;
|
|
81
|
+
const isUnstyled = settings.global.unstyled || settings.components.codeBlock.unstyled || props.unstyled;
|
|
83
82
|
</script>
|
|
84
83
|
|
|
85
84
|
<template v-if="language && code">
|
|
86
85
|
<div
|
|
87
86
|
:class="`vuetiful-code-block code-block ${
|
|
88
|
-
isUnstyled
|
|
89
|
-
? ''
|
|
90
|
-
: 'max-w-full bg-[#171717] text-sm text-white shadow rounded-container-token'
|
|
87
|
+
isUnstyled ? '' : 'max-w-full bg-[#171717] text-sm text-white shadow rounded-container-token'
|
|
91
88
|
}`"
|
|
92
89
|
>
|
|
93
90
|
<header
|
|
94
91
|
:class="`vuetiful-code-block-header ${
|
|
95
|
-
isUnstyled
|
|
96
|
-
? ''
|
|
97
|
-
: 'flex items-center justify-between p-2 pb-0 pl-4 text-xs uppercase text-[#a4a4a4]'
|
|
92
|
+
isUnstyled ? '' : 'flex items-center justify-between p-2 pb-0 pl-4 text-xs uppercase text-[#a4a4a4]'
|
|
98
93
|
} ${classHeader}`"
|
|
99
94
|
>
|
|
100
|
-
<span :class="`vuetiful-code-block-language ${classLanguage}`">{{
|
|
101
|
-
languageFormatter(language)
|
|
102
|
-
}}</span>
|
|
95
|
+
<span :class="`vuetiful-code-block-language ${classLanguage}`">{{ languageFormatter(language) }}</span>
|
|
103
96
|
<v-button
|
|
104
97
|
size="sm"
|
|
105
98
|
:class="`vuetiful-code-block-button ${
|
|
106
|
-
classButton ? classButton : 'bg-[#171717]
|
|
99
|
+
classButton ? classButton : 'bg-[#171717] text-[#a4a4a4] dark:bg-[#171717] dark:text-[#a4a4a4]'
|
|
107
100
|
}`"
|
|
108
101
|
@click="onCopyClick()"
|
|
109
102
|
v-clipboard="code"
|
|
@@ -112,9 +105,9 @@ const isUnstyled =
|
|
|
112
105
|
</v-button>
|
|
113
106
|
</header>
|
|
114
107
|
<pre
|
|
115
|
-
:class="`vuetiful-code-block-pre ${
|
|
116
|
-
|
|
117
|
-
} ${
|
|
108
|
+
:class="`vuetiful-code-block-pre ${isUnstyled ? '' : '!rounded-t-none bg-transparent p-4 !pt-0'} ${
|
|
109
|
+
preventOverflow ? 'whitespace-pre-wrap break-all' : 'overflow-auto'
|
|
110
|
+
} ${classPre}`"
|
|
118
111
|
><code :class="`vuetiful-code-block-code language-${language} ${classCode}`" v-html="highlight(code, language)"></code></pre>
|
|
119
112
|
</div>
|
|
120
113
|
</template>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { expect, test } from
|
|
3
|
-
import { VDrawer } from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { expect, test } from 'vitest';
|
|
3
|
+
import { VDrawer } from '.';
|
|
4
4
|
|
|
5
|
-
test(
|
|
5
|
+
test('VDrawer', () => {
|
|
6
6
|
expect(VDrawer).toBeTruthy();
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
// TODO: add tests
|
|
10
|
-
test(
|
|
10
|
+
test('VDrawer using slot', () => {
|
|
11
11
|
const wrapper = mount(VDrawer);
|
|
12
12
|
|
|
13
13
|
expect(wrapper).toBeTruthy();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { CssClasses } from
|
|
3
|
-
import { useDrawer } from
|
|
4
|
-
import { Ref, computed, onMounted, ref, toRefs } from
|
|
2
|
+
import type { CssClasses } from '@/index';
|
|
3
|
+
import { useDrawer } from '@/services';
|
|
4
|
+
import { Ref, computed, onMounted, ref, toRefs } from 'vue';
|
|
5
5
|
|
|
6
6
|
const { drawer, close } = useDrawer();
|
|
7
7
|
|
|
@@ -10,21 +10,21 @@ const props = defineProps({
|
|
|
10
10
|
// Regions
|
|
11
11
|
regionBackdrop: {
|
|
12
12
|
type: String as () => CssClasses,
|
|
13
|
-
default:
|
|
13
|
+
default: '',
|
|
14
14
|
},
|
|
15
15
|
regionDrawer: {
|
|
16
16
|
type: String as () => CssClasses,
|
|
17
|
-
default:
|
|
17
|
+
default: '',
|
|
18
18
|
},
|
|
19
19
|
|
|
20
20
|
// a11y
|
|
21
21
|
labelledby: {
|
|
22
22
|
type: String,
|
|
23
|
-
default:
|
|
23
|
+
default: '',
|
|
24
24
|
},
|
|
25
25
|
describedby: {
|
|
26
26
|
type: String,
|
|
27
|
-
default:
|
|
27
|
+
default: '',
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -37,7 +37,7 @@ const presets = {
|
|
|
37
37
|
right: { alignment: 'right-0', width: 'w-[90%]', height: 'h-full', rounded: 'rounded-tl-container-token rounded-bl-container-token' }
|
|
38
38
|
};
|
|
39
39
|
const preset = computed(() => {
|
|
40
|
-
const position = drawer.position ||
|
|
40
|
+
const position = drawer.position || 'left';
|
|
41
41
|
return presets[position];
|
|
42
42
|
});
|
|
43
43
|
// #endregion
|
|
@@ -53,10 +53,10 @@ const onBackdropInteraction = (event: Event) => {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
const onKeydownWindow = (event: KeyboardEvent) => {
|
|
56
|
-
if (event.code ===
|
|
56
|
+
if (event.code === 'Escape') close();
|
|
57
57
|
};
|
|
58
58
|
onMounted(() => {
|
|
59
|
-
window.addEventListener(
|
|
59
|
+
window.addEventListener('keydown', onKeydownWindow);
|
|
60
60
|
});
|
|
61
61
|
// #endregion
|
|
62
62
|
</script>
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { mount } from
|
|
2
|
-
import { describe, expect, test } from
|
|
3
|
-
import { ref } from
|
|
4
|
-
import { VListboxItem } from
|
|
5
|
-
import VListbox from
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { ref } from 'vue';
|
|
4
|
+
import { VListboxItem } from '..';
|
|
5
|
+
import VListbox from './VListbox.vue';
|
|
6
6
|
|
|
7
|
-
describe(
|
|
8
|
-
test(
|
|
7
|
+
describe('VListbox', () => {
|
|
8
|
+
test('default props', () => {
|
|
9
9
|
const wrapper = mount(VListbox);
|
|
10
10
|
|
|
11
11
|
expect(wrapper.props()).toEqual({
|
|
12
12
|
modelValue: undefined,
|
|
13
|
-
classLabel:
|
|
14
|
-
textButton:
|
|
15
|
-
classButton:
|
|
16
|
-
classItem:
|
|
17
|
-
classItems:
|
|
13
|
+
classLabel: '',
|
|
14
|
+
textButton: 'Select an option',
|
|
15
|
+
classButton: '',
|
|
16
|
+
classItem: '',
|
|
17
|
+
classItems: '',
|
|
18
18
|
horizontal: false,
|
|
19
19
|
multiple: false,
|
|
20
|
-
active:
|
|
21
|
-
hover:
|
|
22
|
-
background:
|
|
23
|
-
text:
|
|
20
|
+
active: 'variant-filled',
|
|
21
|
+
hover: 'hover:variant-ghost',
|
|
22
|
+
background: 'bg-surface-200-700-token',
|
|
23
|
+
text: 'text-surface-900 dark:text-surface-50',
|
|
24
24
|
unstyled: false,
|
|
25
25
|
by: undefined,
|
|
26
26
|
display: undefined,
|
|
@@ -28,8 +28,8 @@ describe("VListbox", () => {
|
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
describe(
|
|
32
|
-
test(
|
|
31
|
+
describe('modelValue', () => {
|
|
32
|
+
test('should update modelValue', async () => {
|
|
33
33
|
const choice = ref();
|
|
34
34
|
const wrapper = mount({
|
|
35
35
|
setup() {
|
|
@@ -43,20 +43,20 @@ describe("VListbox", () => {
|
|
|
43
43
|
</v-listbox>
|
|
44
44
|
`,
|
|
45
45
|
components: {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
'v-listbox': VListbox,
|
|
47
|
+
'v-listbox-item': VListboxItem,
|
|
48
48
|
},
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
const listbox = wrapper.find("[data-test='listbox']");
|
|
52
|
-
await listbox.find("[data-test='listbox-button']").trigger(
|
|
53
|
-
await listbox.find("[data-test='vuetiful']").trigger(
|
|
54
|
-
expect(choice.value).toBe(
|
|
52
|
+
await listbox.find("[data-test='listbox-button']").trigger('click');
|
|
53
|
+
await listbox.find("[data-test='vuetiful']").trigger('click');
|
|
54
|
+
expect(choice.value).toBe('vuetiful');
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
describe(
|
|
59
|
-
test(
|
|
58
|
+
describe('object modelValue', () => {
|
|
59
|
+
test('should use display prop', async () => {
|
|
60
60
|
const choice = ref();
|
|
61
61
|
const wrapper = mount({
|
|
62
62
|
setup() {
|
|
@@ -70,24 +70,24 @@ describe("VListbox", () => {
|
|
|
70
70
|
</v-listbox>
|
|
71
71
|
`,
|
|
72
72
|
components: {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
'v-listbox': VListbox,
|
|
74
|
+
'v-listbox-item': VListboxItem,
|
|
75
75
|
},
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
const listbox = wrapper.find("[data-test='listbox']");
|
|
79
79
|
const button = listbox.find("[data-test='listbox-button']");
|
|
80
|
-
expect(button.text()).toBe(
|
|
81
|
-
await button.trigger(
|
|
82
|
-
await listbox.find("[data-test='vuetiful']").trigger(
|
|
80
|
+
expect(button.text()).toBe('Select an option');
|
|
81
|
+
await button.trigger('click');
|
|
82
|
+
await listbox.find("[data-test='vuetiful']").trigger('click');
|
|
83
83
|
|
|
84
|
-
expect(choice.value).toEqual({ name:
|
|
85
|
-
expect(button.text()).toBe(
|
|
84
|
+
expect(choice.value).toEqual({ name: 'vuetiful', id: 0 });
|
|
85
|
+
expect(button.text()).toBe('vuetiful');
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
describe(
|
|
90
|
-
test(
|
|
89
|
+
describe('multiple', () => {
|
|
90
|
+
test('should update modelValue and button text', async () => {
|
|
91
91
|
const choice = ref([]);
|
|
92
92
|
const wrapper = mount({
|
|
93
93
|
setup() {
|
|
@@ -101,28 +101,28 @@ describe("VListbox", () => {
|
|
|
101
101
|
</v-listbox>
|
|
102
102
|
`,
|
|
103
103
|
components: {
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
'v-listbox': VListbox,
|
|
105
|
+
'v-listbox-item': VListboxItem,
|
|
106
106
|
},
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
const listbox = wrapper.find("[data-test='listbox']");
|
|
110
110
|
const button = listbox.find("[data-test='listbox-button']");
|
|
111
|
-
expect(button.text()).toBe(
|
|
111
|
+
expect(button.text()).toBe('Select an option');
|
|
112
112
|
|
|
113
|
-
await button.trigger(
|
|
114
|
-
await listbox.find("[data-test='vuetiful']").trigger(
|
|
115
|
-
expect(choice.value).toEqual([
|
|
116
|
-
expect(button.text()).toBe(
|
|
113
|
+
await button.trigger('click');
|
|
114
|
+
await listbox.find("[data-test='vuetiful']").trigger('click');
|
|
115
|
+
expect(choice.value).toEqual(['vuetiful']);
|
|
116
|
+
expect(button.text()).toBe('vuetiful');
|
|
117
117
|
|
|
118
|
-
await listbox.find("[data-test='is']").trigger(
|
|
119
|
-
expect(choice.value).toEqual([
|
|
120
|
-
expect(button.text()).toBe(
|
|
118
|
+
await listbox.find("[data-test='is']").trigger('click');
|
|
119
|
+
expect(choice.value).toEqual(['vuetiful', 'is']);
|
|
120
|
+
expect(button.text()).toBe('2 options selected');
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
-
describe(
|
|
125
|
-
test(
|
|
124
|
+
describe('unstyled', () => {
|
|
125
|
+
test('should only have vuetiful- classes', async () => {
|
|
126
126
|
const wrapper = mount(VListbox, {
|
|
127
127
|
props: {
|
|
128
128
|
unstyled: true,
|
|
@@ -130,16 +130,16 @@ describe("VListbox", () => {
|
|
|
130
130
|
});
|
|
131
131
|
|
|
132
132
|
const listbox = wrapper.find("[data-test='listbox']");
|
|
133
|
-
await listbox.find("[data-test='listbox-button']").trigger(
|
|
133
|
+
await listbox.find("[data-test='listbox-button']").trigger('click');
|
|
134
134
|
const listboxItems = wrapper.find("[data-test='listbox-items']");
|
|
135
135
|
|
|
136
|
-
expect(listbox.classes()).toEqual([
|
|
136
|
+
expect(listbox.classes()).toEqual(['vuetiful-listbox']);
|
|
137
137
|
expect(listboxItems.classes()).toEqual([
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
'z-10',
|
|
139
|
+
'bg-surface-200-700-token',
|
|
140
|
+
'text-surface-900',
|
|
141
|
+
'dark:text-surface-50',
|
|
142
|
+
'flex-col',
|
|
143
143
|
]);
|
|
144
144
|
});
|
|
145
145
|
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { CssClasses, useSettings } from
|
|
3
|
-
import { Listbox } from
|
|
4
|
-
import { computed, provide, ref, watch } from
|
|
5
|
-
import VListboxButton from
|
|
6
|
-
import VListboxItems from
|
|
7
|
-
import VListboxLabel from
|
|
8
|
-
import { unstyledProp } from
|
|
9
|
-
|
|
10
|
-
const emit = defineEmits([
|
|
2
|
+
import { CssClasses, useSettings } from '@/index';
|
|
3
|
+
import { Listbox } from '@headlessui/vue';
|
|
4
|
+
import { computed, provide, ref, watch } from 'vue';
|
|
5
|
+
import VListboxButton from './VListboxButton.vue';
|
|
6
|
+
import VListboxItems from './VListboxItems.vue';
|
|
7
|
+
import VListboxLabel from './VListboxLabel.vue';
|
|
8
|
+
import { unstyledProp } from '@/props';
|
|
9
|
+
|
|
10
|
+
const emit = defineEmits(['update:modelValue']);
|
|
11
11
|
const props = defineProps({
|
|
12
|
-
modelValue: Listbox.props[
|
|
12
|
+
modelValue: Listbox.props['modelValue'],
|
|
13
13
|
|
|
14
14
|
by: {
|
|
15
15
|
type: String,
|
|
@@ -23,25 +23,25 @@ const props = defineProps({
|
|
|
23
23
|
},
|
|
24
24
|
classLabel: {
|
|
25
25
|
type: String as () => CssClasses,
|
|
26
|
-
default:
|
|
26
|
+
default: '',
|
|
27
27
|
},
|
|
28
28
|
|
|
29
29
|
textButton: {
|
|
30
30
|
type: String,
|
|
31
|
-
default:
|
|
31
|
+
default: 'Select an option',
|
|
32
32
|
},
|
|
33
33
|
classButton: {
|
|
34
34
|
type: String as () => CssClasses,
|
|
35
|
-
default:
|
|
35
|
+
default: '',
|
|
36
36
|
},
|
|
37
37
|
|
|
38
38
|
classItem: {
|
|
39
39
|
type: String as () => CssClasses,
|
|
40
|
-
default:
|
|
40
|
+
default: '',
|
|
41
41
|
},
|
|
42
42
|
classItems: {
|
|
43
43
|
type: String as () => CssClasses,
|
|
44
|
-
default:
|
|
44
|
+
default: '',
|
|
45
45
|
},
|
|
46
46
|
|
|
47
47
|
horizontal: {
|
|
@@ -55,20 +55,20 @@ const props = defineProps({
|
|
|
55
55
|
|
|
56
56
|
active: {
|
|
57
57
|
type: String,
|
|
58
|
-
default:
|
|
58
|
+
default: 'variant-filled',
|
|
59
59
|
},
|
|
60
60
|
hover: {
|
|
61
61
|
type: String,
|
|
62
|
-
default:
|
|
62
|
+
default: 'hover:variant-ghost',
|
|
63
63
|
},
|
|
64
64
|
|
|
65
65
|
background: {
|
|
66
66
|
type: String,
|
|
67
|
-
default:
|
|
67
|
+
default: 'bg-surface-200-700-token',
|
|
68
68
|
},
|
|
69
69
|
text: {
|
|
70
70
|
type: String,
|
|
71
|
-
default:
|
|
71
|
+
default: 'text-surface-900 dark:text-surface-50',
|
|
72
72
|
},
|
|
73
73
|
|
|
74
74
|
unstyled: unstyledProp,
|
|
@@ -79,23 +79,23 @@ watch(
|
|
|
79
79
|
() => props.modelValue,
|
|
80
80
|
(newValue) => {
|
|
81
81
|
parentModelValue.value = newValue;
|
|
82
|
-
}
|
|
82
|
+
},
|
|
83
83
|
);
|
|
84
84
|
watch(
|
|
85
85
|
() => parentModelValue.value,
|
|
86
86
|
(newValue) => {
|
|
87
|
-
emit(
|
|
88
|
-
}
|
|
87
|
+
emit('update:modelValue', newValue);
|
|
88
|
+
},
|
|
89
89
|
);
|
|
90
90
|
|
|
91
|
-
provide(
|
|
92
|
-
provide(
|
|
93
|
-
provide(
|
|
94
|
-
provide(
|
|
95
|
-
provide(
|
|
96
|
-
provide(
|
|
97
|
-
provide(
|
|
98
|
-
provide(
|
|
91
|
+
provide('active', props.active);
|
|
92
|
+
provide('hover', props.hover);
|
|
93
|
+
provide('background', props.background);
|
|
94
|
+
provide('text', props.text);
|
|
95
|
+
provide('horizontal', props.horizontal);
|
|
96
|
+
provide('unstyled', props.unstyled);
|
|
97
|
+
provide('classItem', props.classItem);
|
|
98
|
+
provide('classItems', props.classItems);
|
|
99
99
|
|
|
100
100
|
const showText = computed(() => {
|
|
101
101
|
if (props.display && parentModelValue.value) return parentModelValue.value[props.display];
|
|
@@ -111,8 +111,7 @@ const showText = computed(() => {
|
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
const { settings } = useSettings();
|
|
114
|
-
const isUnstyled =
|
|
115
|
-
settings.global.unstyled || settings.components.listbox.unstyled || props.unstyled;
|
|
114
|
+
const isUnstyled = settings.global.unstyled || settings.components.listbox.unstyled || props.unstyled;
|
|
116
115
|
</script>
|
|
117
116
|
|
|
118
117
|
<template>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Listbox } from
|
|
2
|
-
import { mount } from
|
|
3
|
-
import { describe, expect, test } from
|
|
4
|
-
import VListboxButton from
|
|
1
|
+
import { Listbox } from '@headlessui/vue';
|
|
2
|
+
import { mount } from '@vue/test-utils';
|
|
3
|
+
import { describe, expect, test } from 'vitest';
|
|
4
|
+
import VListboxButton from './VListboxButton.vue';
|
|
5
5
|
|
|
6
|
-
describe(
|
|
7
|
-
test(
|
|
6
|
+
describe('VListboxButton props', () => {
|
|
7
|
+
test('defaults', () => {
|
|
8
8
|
const wrapper = mount({
|
|
9
9
|
provide: {
|
|
10
10
|
unstyled: false,
|
|
@@ -15,13 +15,13 @@ describe("VListboxButton props", () => {
|
|
|
15
15
|
</Listbox>
|
|
16
16
|
`,
|
|
17
17
|
components: {
|
|
18
|
-
|
|
18
|
+
'v-listbox-button': VListboxButton,
|
|
19
19
|
Listbox: Listbox,
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
const listboxButton = wrapper.find("[data-test='listbox-button']");
|
|
24
|
-
expect(listboxButton.element.tagName).toBe(
|
|
24
|
+
expect(listboxButton.element.tagName).toBe('BUTTON');
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
test("custom 'as' prop", () => {
|
|
@@ -35,16 +35,16 @@ describe("VListboxButton props", () => {
|
|
|
35
35
|
</Listbox>
|
|
36
36
|
`,
|
|
37
37
|
components: {
|
|
38
|
-
|
|
38
|
+
'v-listbox-button': VListboxButton,
|
|
39
39
|
Listbox: Listbox,
|
|
40
40
|
},
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
const listboxButton = wrapper.find("[data-test='listbox-button']");
|
|
44
|
-
expect(listboxButton.element.tagName).toBe(
|
|
44
|
+
expect(listboxButton.element.tagName).toBe('DIV');
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
test(
|
|
47
|
+
test('should hide icon', () => {
|
|
48
48
|
const wrapper = mount({
|
|
49
49
|
provide: {
|
|
50
50
|
unstyled: false,
|
|
@@ -55,12 +55,12 @@ describe("VListboxButton props", () => {
|
|
|
55
55
|
</Listbox>
|
|
56
56
|
`,
|
|
57
57
|
components: {
|
|
58
|
-
|
|
58
|
+
'v-listbox-button': VListboxButton,
|
|
59
59
|
Listbox: Listbox,
|
|
60
60
|
},
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
const listboxButton = wrapper.find("[data-test='listbox-button']");
|
|
64
|
-
expect(listboxButton.find(
|
|
64
|
+
expect(listboxButton.find('svg').exists()).toBe(false);
|
|
65
65
|
});
|
|
66
66
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { useSettings } from
|
|
3
|
-
import { ListboxButton } from
|
|
4
|
-
import { inject } from
|
|
2
|
+
import { useSettings } from '@/index';
|
|
3
|
+
import { ListboxButton } from '@headlessui/vue';
|
|
4
|
+
import { inject } from 'vue';
|
|
5
5
|
|
|
6
6
|
defineProps({
|
|
7
7
|
as: {
|
|
8
8
|
type: String,
|
|
9
|
-
default:
|
|
9
|
+
default: 'button',
|
|
10
10
|
},
|
|
11
11
|
hideIcon: {
|
|
12
12
|
type: Boolean,
|
|
@@ -14,7 +14,7 @@ defineProps({
|
|
|
14
14
|
},
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
const unstyled = inject(
|
|
17
|
+
const unstyled = inject('unstyled') as boolean;
|
|
18
18
|
|
|
19
19
|
const { settings } = useSettings();
|
|
20
20
|
const isUnstyled = settings.global.unstyled || settings.components.listbox.unstyled || unstyled;
|