@volverjs/ui-vue 0.0.10-beta.2 → 0.0.10-beta.4
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/components/VvAccordion/VvAccordion.es.js +9 -2
- package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +9 -2
- package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
- package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +1 -1
- package/dist/components/VvAction/VvAction.es.js +9 -1
- package/dist/components/VvAction/VvAction.umd.js +1 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +3 -0
- package/dist/components/VvAction/index.d.ts +1 -0
- package/dist/components/VvAlert/VvAlert.es.js +9 -2
- package/dist/components/VvAlert/VvAlert.umd.js +1 -1
- package/dist/components/VvAlertGroup/VvAlertGroup.es.js +9 -2
- package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
- package/dist/components/VvAvatar/VvAvatar.es.js +7 -0
- package/dist/components/VvAvatar/VvAvatar.umd.js +1 -1
- package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +9 -2
- package/dist/components/VvAvatarGroup/VvAvatarGroup.umd.js +1 -1
- package/dist/components/VvBadge/VvBadge.es.js +7 -0
- package/dist/components/VvBadge/VvBadge.umd.js +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +7 -0
- package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
- package/dist/components/VvButton/VvButton.es.js +11 -3
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +6 -3
- package/dist/components/VvButton/index.d.ts +1 -0
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +7 -0
- package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
- package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +2 -2
- package/dist/components/VvCard/VvCard.es.js +7 -0
- package/dist/components/VvCard/VvCard.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.es.js +9 -2
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +3 -3
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +9 -2
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +3 -3
- package/dist/components/VvCombobox/VvCombobox.es.js +18 -4
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +37 -37
- package/dist/components/VvCombobox/index.d.ts +13 -11
- package/dist/components/VvDialog/VvDialog.es.js +7 -0
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +9 -2
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +31 -31
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +3 -0
- package/dist/components/VvDropdown/index.d.ts +10 -10
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +9 -1
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +7 -0
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.umd.js +1 -1
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +7 -0
- package/dist/components/VvDropdownOption/VvDropdownOption.umd.js +1 -1
- package/dist/components/VvInputText/VvInputClearAction.d.ts +1 -1
- package/dist/components/VvInputText/VvInputText.es.js +9 -2
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +4 -4
- package/dist/components/VvNav/VvNav.es.js +69 -56
- package/dist/components/VvNav/VvNav.umd.js +1 -1
- package/dist/components/VvNav/VvNav.vue.d.ts +12 -8
- package/dist/components/VvNav/VvNavItem.vue.d.ts +9 -0
- package/dist/components/VvNav/index.d.ts +1 -12
- package/dist/components/VvNavItem/VvNavItem.es.js +392 -0
- package/dist/components/VvNavItem/VvNavItem.umd.js +1 -0
- package/dist/components/VvNavSeparator/VvNavSeparator.es.js +24 -0
- package/dist/components/VvNavSeparator/VvNavSeparator.umd.js +1 -0
- package/dist/components/VvProgress/VvProgress.es.js +7 -0
- package/dist/components/VvProgress/VvProgress.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.es.js +9 -2
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +3 -3
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +9 -2
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +3 -3
- package/dist/components/VvSelect/VvSelect.es.js +9 -2
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +7 -7
- package/dist/components/VvTab/VvTab.es.js +127 -87
- package/dist/components/VvTab/VvTab.umd.js +1 -1
- package/dist/components/VvTab/VvTab.vue.d.ts +19 -6
- package/dist/components/VvTab/index.d.ts +9 -3
- package/dist/components/VvTextarea/VvTextarea.es.js +9 -2
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +3 -3
- package/dist/components/VvTooltip/VvTooltip.es.js +7 -0
- package/dist/components/VvTooltip/VvTooltip.umd.js +1 -1
- package/dist/components/index.es.js +249 -203
- package/dist/components/index.umd.js +1 -1
- package/dist/directives/index.es.js +7 -0
- package/dist/directives/index.umd.js +1 -1
- package/dist/directives/v-tooltip.es.js +7 -0
- package/dist/directives/v-tooltip.umd.js +1 -1
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +29 -12
- package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +5 -5
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +31 -31
- package/dist/stories/Tab/Tab.settings.d.ts +3 -23
- package/dist/types/alert.d.ts +13 -0
- package/dist/types/floating-ui.d.ts +6 -0
- package/dist/types/generic.d.ts +5 -0
- package/dist/types/group.d.ts +37 -0
- package/dist/types/nav.d.ts +17 -0
- package/package.json +51 -43
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvAccordion/VvAccordion.vue +2 -2
- package/src/components/VvAction/VvAction.vue +1 -0
- package/src/components/VvCombobox/VvCombobox.vue +11 -4
- package/src/components/VvNav/VvNav.vue +29 -51
- package/src/components/VvNav/VvNavItem.vue +18 -0
- package/src/components/VvNav/VvNavSeparator.vue +11 -0
- package/src/components/VvNav/index.ts +2 -15
- package/src/components/VvTab/VvTab.vue +60 -36
- package/src/components/VvTab/index.ts +10 -4
- package/src/composables/useUniqueId.ts +2 -2
- package/src/props/index.ts +19 -3
- package/src/stories/Nav/Nav.settings.ts +3 -4
- package/src/stories/Nav/Nav.test.ts +4 -15
- package/src/stories/Tab/Tab.settings.ts +8 -8
- package/src/stories/Tab/Tab.stories.ts +2 -2
- package/src/stories/Tab/Tab.test.ts +6 -14
- package/src/stories/argTypes.ts +1 -1
- package/src/types/nav.ts +19 -0
- package/dist/components/VvNav/VvNavItemTitle.vue.d.ts +0 -6
- package/dist/components/VvNavItemTitle/VvNavItemTitle.es.js +0 -19
- package/dist/components/VvNavItemTitle/VvNavItemTitle.umd.js +0 -1
- package/src/components/VvNav/VvNavItemTitle.vue +0 -11
- package/src/components/VvNav/VvNavSeparator.ts +0 -8
- /package/dist/components/VvNav/{VvNavSeparator.d.ts → VvNavSeparator.vue.d.ts} +0 -0
- /package/src/types/{alert.d.ts → alert.ts} +0 -0
- /package/src/types/{floating-ui.d.ts → floating-ui.ts} +0 -0
- /package/src/types/{generic.d.ts → generic.ts} +0 -0
- /package/src/types/{group.d.ts → group.ts} +0 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
|
-
import {
|
|
8
|
+
import { uid } from 'uid'
|
|
9
9
|
import { VvAccordionEvents, VvAccordionProps, useGroupProps } from '.'
|
|
10
10
|
|
|
11
11
|
// props, attrs and emit
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
// data
|
|
17
17
|
const accordionName = computed(
|
|
18
|
-
() => props.name || (attrs?.id as string) ||
|
|
18
|
+
() => props.name || (attrs?.id as string) || uid(),
|
|
19
19
|
)
|
|
20
20
|
const {
|
|
21
21
|
modifiers,
|
|
@@ -266,12 +266,13 @@
|
|
|
266
266
|
return
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
+
// get option value
|
|
269
270
|
const value = getOptionValue(option)
|
|
270
|
-
|
|
271
271
|
let toReturn: string | string[] | Option | Option[] | undefined = value
|
|
272
|
-
|
|
272
|
+
|
|
273
|
+
// check multiple prop, override value with array and remove or add the value
|
|
273
274
|
if (props.multiple) {
|
|
274
|
-
// check
|
|
275
|
+
// check max-values prop and block check new values
|
|
275
276
|
if (Array.isArray(props.modelValue)) {
|
|
276
277
|
const maxValues = Number(props.maxValues)
|
|
277
278
|
if (
|
|
@@ -294,7 +295,13 @@
|
|
|
294
295
|
if (!props.keepOpen) {
|
|
295
296
|
collapse()
|
|
296
297
|
}
|
|
297
|
-
if (
|
|
298
|
+
if (Array.isArray(props.modelValue)) {
|
|
299
|
+
if (props.unselectable && props.modelValue.includes(value)) {
|
|
300
|
+
toReturn = []
|
|
301
|
+
} else {
|
|
302
|
+
toReturn = [value]
|
|
303
|
+
}
|
|
304
|
+
} else if (props.unselectable && value === props.modelValue) {
|
|
298
305
|
toReturn = undefined
|
|
299
306
|
}
|
|
300
307
|
}
|
|
@@ -1,66 +1,44 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { VvNavProps, VvNavEvents
|
|
3
|
-
import
|
|
2
|
+
import { VvNavProps, VvNavEvents } from '@/components/VvNav'
|
|
3
|
+
import VvNavItem from './VvNavItem.vue'
|
|
4
4
|
|
|
5
5
|
const props = defineProps(VvNavProps)
|
|
6
|
-
const
|
|
7
|
-
const { modifiers, items } = toRefs(props)
|
|
8
|
-
const activeItem: Ref<string | null> = ref(null)
|
|
6
|
+
const { modifiers } = toRefs(props)
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
const emit = defineEmits(VvNavEvents)
|
|
9
|
+
const onClick = (event: Event) => {
|
|
10
|
+
const target = event.target as HTMLElement
|
|
11
|
+
if (target?.dataset.index) {
|
|
12
|
+
const index = parseInt(target.dataset.index)
|
|
13
|
+
const item = props.items?.[index]
|
|
14
|
+
if (!item || item?.disabled) {
|
|
15
|
+
return
|
|
18
16
|
}
|
|
19
|
-
})
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Triggers when the item is clicked.
|
|
24
|
-
* @private
|
|
25
|
-
* @event click
|
|
26
|
-
* @param [NavItem, string] item - the clicked item
|
|
27
|
-
*/
|
|
28
|
-
function onClick(item: NavItem) {
|
|
29
|
-
if (!item.disabled) {
|
|
30
17
|
emit('click', item)
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
32
|
-
activeItem.value = item.id!
|
|
33
18
|
}
|
|
34
19
|
}
|
|
20
|
+
|
|
21
|
+
// bem css classes
|
|
22
|
+
const bemCssClasses = useModifiers('vv-nav', modifiers)
|
|
35
23
|
</script>
|
|
36
24
|
|
|
37
25
|
<template>
|
|
38
26
|
<nav :class="bemCssClasses">
|
|
39
|
-
<ul
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
>
|
|
46
|
-
<
|
|
47
|
-
v-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
current: activeItem == navItem.id,
|
|
55
|
-
disabled: navItem.disabled,
|
|
56
|
-
}"
|
|
57
|
-
class="vv-nav__item-label"
|
|
58
|
-
v-on="navItem.on"
|
|
59
|
-
@click="onClick(navItem)"
|
|
60
|
-
>
|
|
61
|
-
{{ navItem.title }}
|
|
62
|
-
</VvAction>
|
|
63
|
-
</li>
|
|
27
|
+
<ul
|
|
28
|
+
class="vv-nav__menu"
|
|
29
|
+
role="menu"
|
|
30
|
+
aria-busy="true"
|
|
31
|
+
@click.stop="onClick"
|
|
32
|
+
>
|
|
33
|
+
<slot>
|
|
34
|
+
<VvNavItem
|
|
35
|
+
v-for="({ on = {}, ...item }, index) in items"
|
|
36
|
+
:key="index"
|
|
37
|
+
:data-index="index"
|
|
38
|
+
v-bind="item"
|
|
39
|
+
v-on="on"
|
|
40
|
+
/>
|
|
41
|
+
</slot>
|
|
64
42
|
</ul>
|
|
65
43
|
</nav>
|
|
66
44
|
</template>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
export default {
|
|
3
|
+
name: 'VvNavItem',
|
|
4
|
+
inheritAttrs: false,
|
|
5
|
+
}
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import VvAction from '@/components/VvAction/VvAction.vue'
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<li class="vv-nav__item" role="presentation">
|
|
14
|
+
<VvAction v-bind="$attrs" class="vv-nav__item-label">
|
|
15
|
+
<slot />
|
|
16
|
+
</VvAction>
|
|
17
|
+
</li>
|
|
18
|
+
</template>
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import { ModifiersProps } from '@/props'
|
|
2
|
-
|
|
3
|
-
export type NavItem = {
|
|
4
|
-
id?: string
|
|
5
|
-
title: string
|
|
6
|
-
to?: string | { [key: string]: unknown }
|
|
7
|
-
href?: string
|
|
8
|
-
disabled?: boolean
|
|
9
|
-
on?: Record<string, () => void>
|
|
10
|
-
}
|
|
1
|
+
import { ModifiersProps, NavProps } from '@/props'
|
|
11
2
|
|
|
12
3
|
export const VvNavProps = {
|
|
13
4
|
...ModifiersProps,
|
|
14
|
-
|
|
15
|
-
type: Array as PropType<NavItem[]>,
|
|
16
|
-
required: true,
|
|
17
|
-
default: () => [],
|
|
18
|
-
},
|
|
5
|
+
...NavProps,
|
|
19
6
|
}
|
|
20
7
|
|
|
21
8
|
export const VvNavEvents = ['click']
|
|
@@ -1,53 +1,77 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { VvTabProps, VvTabEvents } from '@/components/VvTab'
|
|
3
|
-
import type { NavItem } from '@/components/VvNav'
|
|
4
3
|
import VvNav from '@/components/VvNav/VvNav.vue'
|
|
4
|
+
import type { NavItemTab } from '@/types/nav'
|
|
5
5
|
|
|
6
6
|
const props = defineProps(VvTabProps)
|
|
7
7
|
const emit = defineEmits(VvTabEvents)
|
|
8
8
|
const { modifiers, items } = toRefs(props)
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const localItems = computed(() => {
|
|
15
|
-
return items.value.map((item, index) => {
|
|
16
|
-
return {
|
|
17
|
-
...item,
|
|
18
|
-
id: item.id || `tab-item_${index}`,
|
|
9
|
+
const tabKeys = computed(() => {
|
|
10
|
+
return items.value.reduce<string[]>((acc, item) => {
|
|
11
|
+
if (item.tab) {
|
|
12
|
+
acc.push(item.tab)
|
|
19
13
|
}
|
|
20
|
-
|
|
14
|
+
return acc
|
|
15
|
+
}, [])
|
|
21
16
|
})
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
emit('
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
const localModelValue = ref<string | undefined>()
|
|
18
|
+
const activeTabKey = computed({
|
|
19
|
+
get: () => {
|
|
20
|
+
return (
|
|
21
|
+
props.modelValue || localModelValue.value || tabKeys.value?.[0]
|
|
22
|
+
)
|
|
23
|
+
},
|
|
24
|
+
set: (newValue) => {
|
|
25
|
+
localModelValue.value = newValue
|
|
26
|
+
emit('update:modelValue', newValue)
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
const hasNavModifiers = computed(() => {
|
|
30
|
+
return [
|
|
31
|
+
'tabs',
|
|
32
|
+
...(Array.isArray(props.navModifiers)
|
|
33
|
+
? props.navModifiers
|
|
34
|
+
: props.navModifiers?.split(' ') ?? []),
|
|
35
|
+
]
|
|
36
|
+
})
|
|
37
|
+
const onNavClick = (item: NavItemTab) => {
|
|
38
|
+
if (item.tab) {
|
|
39
|
+
activeTabKey.value = item.tab
|
|
34
40
|
}
|
|
35
41
|
}
|
|
42
|
+
const navItems = computed(() =>
|
|
43
|
+
props.items.map((item) => ({
|
|
44
|
+
current: item.tab === activeTabKey.value,
|
|
45
|
+
...item,
|
|
46
|
+
})),
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
// bem css classes
|
|
50
|
+
const bemCssClasses = useModifiers('vv-tab', modifiers)
|
|
36
51
|
</script>
|
|
37
52
|
|
|
38
53
|
<template>
|
|
39
54
|
<div :class="bemCssClasses">
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
<!-- #region nav -->
|
|
56
|
+
<VvNav
|
|
57
|
+
v-bind="{
|
|
58
|
+
items: navItems,
|
|
59
|
+
modifiers: hasNavModifiers,
|
|
60
|
+
}"
|
|
61
|
+
@click="onNavClick"
|
|
62
|
+
/>
|
|
63
|
+
<!-- #endregion -->
|
|
64
|
+
|
|
65
|
+
<!-- #region panels -->
|
|
66
|
+
<template v-for="(item, index) in items" :key="index">
|
|
67
|
+
<article
|
|
68
|
+
v-if="item.tab"
|
|
69
|
+
:class="{ target: activeTabKey === item.tab }"
|
|
70
|
+
class="vv-tab__panel"
|
|
71
|
+
>
|
|
72
|
+
<slot :name="`panel::${item.tab}`" />
|
|
73
|
+
</article>
|
|
74
|
+
</template>
|
|
75
|
+
<!-- #endregion -->
|
|
52
76
|
</div>
|
|
53
77
|
</template>
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { ModifiersProps } from '@/props'
|
|
2
|
-
import type {
|
|
2
|
+
import type { NavItemTab } from '@/types/nav'
|
|
3
3
|
|
|
4
4
|
export const VvTabProps = {
|
|
5
5
|
...ModifiersProps,
|
|
6
|
+
navModifiers: {
|
|
7
|
+
type: [String, Array] as PropType<string | string[]>,
|
|
8
|
+
},
|
|
9
|
+
modelValue: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: '',
|
|
12
|
+
},
|
|
6
13
|
items: {
|
|
7
|
-
type: Array as PropType<
|
|
8
|
-
required: true,
|
|
14
|
+
type: Array as PropType<NavItemTab[]>,
|
|
9
15
|
default: () => [],
|
|
10
16
|
},
|
|
11
17
|
}
|
|
12
18
|
|
|
13
|
-
export const VvTabEvents = ['
|
|
19
|
+
export const VvTabEvents = ['update:modelValue']
|
package/src/props/index.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { PropType } from 'vue'
|
|
2
|
-
import type { Option } from '
|
|
2
|
+
import type { Option } from '@/types/generic'
|
|
3
|
+
import type { NavItem } from '@/types/nav'
|
|
3
4
|
import type {
|
|
4
5
|
AutoPlacementOptions,
|
|
5
6
|
FlipOptions,
|
|
6
7
|
OffsetOptions,
|
|
7
8
|
ShiftOptions,
|
|
8
9
|
SizeOptions,
|
|
9
|
-
} from '
|
|
10
|
+
} from '@/types/floating-ui'
|
|
10
11
|
import {
|
|
11
12
|
Placement,
|
|
12
13
|
Strategy,
|
|
@@ -14,7 +15,7 @@ import {
|
|
|
14
15
|
Side,
|
|
15
16
|
AnchorTarget,
|
|
16
17
|
ButtonType,
|
|
17
|
-
} from '
|
|
18
|
+
} from '@/constants'
|
|
18
19
|
|
|
19
20
|
export const LinkProps = {
|
|
20
21
|
/**
|
|
@@ -102,6 +103,13 @@ export const ActiveProps = {
|
|
|
102
103
|
active: Boolean,
|
|
103
104
|
}
|
|
104
105
|
|
|
106
|
+
export const CurrentProps = {
|
|
107
|
+
/**
|
|
108
|
+
* Whether the item is current
|
|
109
|
+
*/
|
|
110
|
+
current: Boolean,
|
|
111
|
+
}
|
|
112
|
+
|
|
105
113
|
export const PressedProps = {
|
|
106
114
|
/**
|
|
107
115
|
* Whether the item is pressed
|
|
@@ -443,6 +451,7 @@ export const ActionProps = {
|
|
|
443
451
|
...LabelProps,
|
|
444
452
|
...PressedProps,
|
|
445
453
|
...ActiveProps,
|
|
454
|
+
...CurrentProps,
|
|
446
455
|
...LinkProps,
|
|
447
456
|
/**
|
|
448
457
|
* Button type
|
|
@@ -461,3 +470,10 @@ export const ActionProps = {
|
|
|
461
470
|
default: undefined,
|
|
462
471
|
},
|
|
463
472
|
}
|
|
473
|
+
|
|
474
|
+
export const NavProps = {
|
|
475
|
+
items: {
|
|
476
|
+
type: Array as PropType<NavItem[]>,
|
|
477
|
+
default: () => [],
|
|
478
|
+
},
|
|
479
|
+
}
|
|
@@ -7,16 +7,15 @@ export const defaultArgs: Meta<typeof VvNav>['args'] = {
|
|
|
7
7
|
...propsToObject(VvNavProps),
|
|
8
8
|
items: [
|
|
9
9
|
{
|
|
10
|
-
|
|
10
|
+
label: 'Item 1',
|
|
11
11
|
href: 'javascript:void(0)',
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
label: 'Item 2',
|
|
15
15
|
to: 'about',
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
|
-
|
|
19
|
-
to: 'contacts',
|
|
18
|
+
label: 'Item 3',
|
|
20
19
|
on: {
|
|
21
20
|
click: () => {
|
|
22
21
|
// eslint-disable-next-line no-console
|
|
@@ -1,31 +1,20 @@
|
|
|
1
1
|
import type { PlayAttributes } from '@/test/types'
|
|
2
2
|
import { expect } from '@/test/expect'
|
|
3
|
-
import { within
|
|
3
|
+
import { within } from '@storybook/testing-library'
|
|
4
4
|
|
|
5
5
|
export async function defaultTest({ canvasElement, args }: PlayAttributes) {
|
|
6
6
|
const element = (await within(canvasElement).findByTestId(
|
|
7
7
|
'element',
|
|
8
8
|
)) as HTMLElement
|
|
9
9
|
|
|
10
|
+
const menuEl = element.getElementsByClassName('vv-nav__menu')[0]
|
|
11
|
+
|
|
10
12
|
if (!args.items || !args.items?.length) {
|
|
11
13
|
throw new Error('No items passed')
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
// check children number the same of items prop
|
|
15
|
-
expect(
|
|
16
|
-
|
|
17
|
-
// take firse and second elements
|
|
18
|
-
const firstEl = await element.getElementsByTagName('a')?.[0]
|
|
19
|
-
const secondEl = await element.getElementsByTagName('router-link')?.[1]
|
|
20
|
-
// check they have not current class
|
|
21
|
-
const secondElHasCurrentClass = secondEl.classList.contains('current')
|
|
22
|
-
const firstElHasCurrentClass = firstEl.classList.contains('current')
|
|
23
|
-
|
|
24
|
-
await expect(firstElHasCurrentClass).toBe(false)
|
|
25
|
-
await expect(secondElHasCurrentClass).toBe(false)
|
|
26
|
-
// click first item and check "current" css class
|
|
27
|
-
await userEvent.click(firstEl)
|
|
28
|
-
await expect(firstEl).toHaveClass('current')
|
|
17
|
+
expect(menuEl.children.length).toEqual(args.items?.length)
|
|
29
18
|
|
|
30
19
|
// check accessibility
|
|
31
20
|
await expect(element).toHaveNoViolations()
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
import type { Meta } from '@storybook/vue3'
|
|
2
|
+
import type { VvTab } from '@/components'
|
|
1
3
|
import { VvTabProps } from '@/components/VvTab'
|
|
2
4
|
|
|
3
|
-
export const defaultArgs = {
|
|
5
|
+
export const defaultArgs: Meta<typeof VvTab>['args'] = {
|
|
4
6
|
...propsToObject(VvTabProps),
|
|
5
7
|
items: [
|
|
6
8
|
{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
tab: 'tab-1',
|
|
10
|
+
label: 'Item 1',
|
|
9
11
|
},
|
|
10
12
|
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
tab: 'tab-2',
|
|
14
|
+
label: 'Item 2',
|
|
13
15
|
},
|
|
14
16
|
{
|
|
15
|
-
|
|
16
|
-
title: 'Item 3',
|
|
17
|
-
to: 'contacts',
|
|
17
|
+
label: 'Item 3',
|
|
18
18
|
on: {
|
|
19
19
|
click: () => {
|
|
20
20
|
// eslint-disable-next-line no-console
|
|
@@ -27,7 +27,7 @@ export const Default: Story = {
|
|
|
27
27
|
template: /* html */ `
|
|
28
28
|
<div class="m-md w-1/2">
|
|
29
29
|
<vv-tab v-bind="args" data-testId="element">
|
|
30
|
-
<template #tab-
|
|
30
|
+
<template #panel::tab-1>
|
|
31
31
|
<span class="text-20 font-semibold">Tab 1</span>
|
|
32
32
|
<p>
|
|
33
33
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla
|
|
@@ -39,7 +39,7 @@ export const Default: Story = {
|
|
|
39
39
|
elit libero, a pharetra augue.
|
|
40
40
|
</p>
|
|
41
41
|
</template>
|
|
42
|
-
<template #tab-
|
|
42
|
+
<template #panel::tab-2>
|
|
43
43
|
<span class="text-20 font-semibold">Tab 2</span>
|
|
44
44
|
<p>
|
|
45
45
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PlayAttributes } from '@/test/types'
|
|
2
2
|
import { expect } from '@/test/expect'
|
|
3
|
-
import { within
|
|
3
|
+
import { within } from '@storybook/testing-library'
|
|
4
4
|
|
|
5
5
|
export async function defaultTest({ canvasElement, args }: PlayAttributes) {
|
|
6
6
|
const element = (await within(canvasElement).findByTestId(
|
|
@@ -16,21 +16,13 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
|
|
|
16
16
|
expect(childrenEls?.children[0].children.length).toEqual(args.items?.length)
|
|
17
17
|
|
|
18
18
|
// take firse and second elements
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const secondElHasCurrentClass = secondEl.classList.contains('current')
|
|
23
|
-
const firstElHasCurrentClass = firstEl.classList.contains('current')
|
|
24
|
-
|
|
25
|
-
await expect(firstElHasCurrentClass).toBe(false)
|
|
26
|
-
await expect(secondElHasCurrentClass).toBe(false)
|
|
27
|
-
// click first item and check "current" css class
|
|
28
|
-
await userEvent.click(firstEl)
|
|
29
|
-
await expect(firstEl).toHaveClass('current')
|
|
19
|
+
const firstNavItemLabelEl =
|
|
20
|
+
await element.getElementsByClassName('vv-nav__item-label')?.[0]
|
|
21
|
+
await expect(firstNavItemLabelEl.classList.contains('current')).toBe(true)
|
|
30
22
|
|
|
31
23
|
// check tab content to include "Tab 1"
|
|
32
|
-
const
|
|
33
|
-
await expect(
|
|
24
|
+
const firstTabPanelEl = element.getElementsByClassName('vv-tab__panel')?.[0]
|
|
25
|
+
await expect(firstTabPanelEl.classList.contains('target')).toBe(true)
|
|
34
26
|
|
|
35
27
|
// check accessibility
|
|
36
28
|
await expect(element).toHaveNoViolations()
|
package/src/stories/argTypes.ts
CHANGED
package/src/types/nav.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AnchorTarget } from '@/constants'
|
|
2
|
+
|
|
3
|
+
export type NavItem = {
|
|
4
|
+
label: string
|
|
5
|
+
ariaLabel?: string
|
|
6
|
+
title?: string
|
|
7
|
+
to?: string | Record<string, unknown>
|
|
8
|
+
href?: string
|
|
9
|
+
target?: `${AnchorTarget}`
|
|
10
|
+
rel?: string
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
current?: boolean
|
|
13
|
+
class?: string | string[]
|
|
14
|
+
on?: Record<'click' | string, () => void>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type NavItemTab = NavItem & {
|
|
18
|
+
tab?: string
|
|
19
|
+
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{
|
|
2
|
-
title: StringConstructor;
|
|
3
|
-
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
4
|
-
title: StringConstructor;
|
|
5
|
-
}>>, {}, {}>;
|
|
6
|
-
export default _default;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { defineComponent, openBlock, createElementBlock, toDisplayString } from "vue";
|
|
2
|
-
const _hoisted_1 = {
|
|
3
|
-
class: "vv-nav__heading-label",
|
|
4
|
-
"aria-hidden": "true"
|
|
5
|
-
};
|
|
6
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
|
-
__name: "VvNavItemTitle",
|
|
8
|
-
props: {
|
|
9
|
-
title: String
|
|
10
|
-
},
|
|
11
|
-
setup(__props) {
|
|
12
|
-
return (_ctx, _cache) => {
|
|
13
|
-
return openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(__props.title), 1);
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
export {
|
|
18
|
-
_sfc_main as default
|
|
19
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue")):"function"==typeof define&&define.amd?define(["vue"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvNavItemTitle=t(e.vue)}(this,(function(e){"use strict";const t={class:"vv-nav__heading-label","aria-hidden":"true"};return e.defineComponent({__name:"VvNavItemTitle",props:{title:String},setup:n=>(i,o)=>(e.openBlock(),e.createElementBlock("span",t,e.toDisplayString(n.title),1))})}));
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|