@cypress-design/vue-docmenu 0.4.0 → 0.4.1
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/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +9 -0
- package/DocMenu.vue +37 -21
- package/DocMenuVue.cy.tsx +3 -3
- package/ReadMe.md +9 -10
- package/_DocGroup.vue +60 -77
- package/_DocGroupElements.vue +97 -0
- package/_DocLink.vue +46 -4
- package/dist/DocMenu.vue.d.ts +6 -1
- package/dist/DocMenu.vue.d.ts.map +1 -1
- package/dist/_DocGroup.vue.d.ts +21 -4
- package/dist/_DocGroup.vue.d.ts.map +1 -1
- package/dist/_DocGroupElements.vue.d.ts +43 -0
- package/dist/_DocGroupElements.vue.d.ts.map +1 -0
- package/dist/_DocLink.vue.d.ts +18 -3
- package/dist/_DocLink.vue.d.ts.map +1 -1
- package/dist/index.es.mjs +218 -139
- package/dist/index.es.mjs.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -4,11 +4,11 @@ $ /home/runner/work/cypress-design/cypress-design/node_modules/.bin/vite build
|
|
|
4
4
|
[33mThe CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.[39m
|
|
5
5
|
[36mvite v5.0.4 [32mbuilding for production...[36m[39m
|
|
6
6
|
transforming...
|
|
7
|
-
[32m✓[39m
|
|
7
|
+
[32m✓[39m 10 modules transformed.
|
|
8
8
|
rendering chunks...
|
|
9
9
|
computing gzip size...
|
|
10
|
-
[2mdist/[22m[36mindex.es.mjs [39m[1m[
|
|
11
|
-
[2mdist/[22m[36mindex.umd.js [39m[1m[
|
|
12
|
-
[32m✓ built in 3.
|
|
10
|
+
[2mdist/[22m[36mindex.es.mjs [39m[1m[2m9.07 kB[22m[1m[22m[2m │ gzip: 2.73 kB[22m[2m │ map: 12.03 kB[22m
|
|
11
|
+
[2mdist/[22m[36mindex.umd.js [39m[1m[2m7.15 kB[22m[1m[22m[2m │ gzip: 2.40 kB[22m[2m │ map: 11.67 kB[22m
|
|
12
|
+
[32m✓ built in 3.08s[39m
|
|
13
13
|
$ yarn vue-tsc --project ./tsconfig.build.json
|
|
14
14
|
$ /home/runner/work/cypress-design/cypress-design/node_modules/.bin/vue-tsc --project ./tsconfig.build.json
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @cypress-design/vue-docmenu
|
|
2
2
|
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#353](https://github.com/cypress-io/cypress-design/pull/353) [`b382b9e`](https://github.com/cypress-io/cypress-design/commit/b382b9ecc99e3ab6288eee406831199edb661c19) Thanks [@elevatebart](https://github.com/elevatebart)! - feat: Docgen wrapping active links
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`b382b9e`](https://github.com/cypress-io/cypress-design/commit/b382b9ecc99e3ab6288eee406831199edb661c19)]:
|
|
10
|
+
- @cypress-design/constants-docmenu@0.1.2
|
|
11
|
+
|
|
3
12
|
## 0.4.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/DocMenu.vue
CHANGED
|
@@ -1,39 +1,55 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type
|
|
2
|
+
import { ref, type DefineComponent } from 'vue'
|
|
3
3
|
import { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu'
|
|
4
|
-
import
|
|
5
|
-
import DocLink from './_DocLink.vue'
|
|
4
|
+
import DocGroupElements from './_DocGroupElements.vue'
|
|
6
5
|
|
|
7
6
|
withDefaults(
|
|
8
7
|
defineProps<{
|
|
9
8
|
items: (NavItemLink | NavGroup)[]
|
|
9
|
+
activePath?: string
|
|
10
10
|
collapsible?: boolean
|
|
11
11
|
linkComponent?: DefineComponent | 'a'
|
|
12
12
|
}>(),
|
|
13
13
|
{
|
|
14
14
|
linkComponent: 'a',
|
|
15
15
|
collapsible: true,
|
|
16
|
+
activePath: undefined,
|
|
16
17
|
},
|
|
17
18
|
)
|
|
19
|
+
|
|
20
|
+
const $container = ref<HTMLDivElement>()
|
|
21
|
+
|
|
22
|
+
const activeTop = ref(0)
|
|
23
|
+
const activeHeight = ref(36)
|
|
24
|
+
const showMarker = ref(false)
|
|
25
|
+
|
|
26
|
+
function updateActiveMarkerPosition({ top, height } = { height: 0, top: 0 }) {
|
|
27
|
+
const containerTop = $container.value?.getBoundingClientRect().top || 0
|
|
28
|
+
activeTop.value = top - containerTop
|
|
29
|
+
activeHeight.value = height
|
|
30
|
+
showMarker.value = true
|
|
31
|
+
}
|
|
18
32
|
</script>
|
|
19
33
|
|
|
20
34
|
<template>
|
|
21
|
-
<
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
<div ref="$container" class="relative">
|
|
36
|
+
<div
|
|
37
|
+
v-if="showMarker && collapsible"
|
|
38
|
+
data-cy="doc-menu-active-marker"
|
|
39
|
+
class="absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px]"
|
|
40
|
+
:style="{
|
|
41
|
+
top: `${activeTop + 4}px`,
|
|
42
|
+
height: `${activeHeight - 8}px`,
|
|
43
|
+
}"
|
|
44
|
+
/>
|
|
45
|
+
<DocGroupElements
|
|
46
|
+
:items="items"
|
|
47
|
+
:active-path="activePath"
|
|
48
|
+
:collapsible="collapsible"
|
|
49
|
+
:link-component="linkComponent"
|
|
50
|
+
:depth="-1"
|
|
51
|
+
@update-active-position="updateActiveMarkerPosition"
|
|
52
|
+
@hide-marker="showMarker = false"
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
39
55
|
</template>
|
package/DocMenuVue.cy.tsx
CHANGED
|
@@ -37,13 +37,13 @@ describe('<DocMenu/>', () => {
|
|
|
37
37
|
linkComponent={CustomLinkVue}
|
|
38
38
|
/>
|
|
39
39
|
))
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
cy.findByText('Foo + href: /foo', { selector: 'div' }).should('be.visible')
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
-
function mountStory(items: (NavItemLink | NavGroup)[] = []) {
|
|
44
|
+
function mountStory(items: (NavItemLink | NavGroup)[] = [], activePath = '') {
|
|
45
45
|
mount(() => {
|
|
46
|
-
return <DocMenu items={items} />
|
|
46
|
+
return <DocMenu items={items} activePath={activePath} />
|
|
47
47
|
})
|
|
48
48
|
}
|
|
49
49
|
assertions(mountStory)
|
package/ReadMe.md
CHANGED
|
@@ -20,22 +20,22 @@ import DocMenu from '@cypress-design/vue-docmenu'
|
|
|
20
20
|
|
|
21
21
|
```vue live
|
|
22
22
|
<DocMenu
|
|
23
|
+
activePath="#group-item-3"
|
|
23
24
|
:items="[
|
|
24
25
|
{
|
|
25
26
|
label: 'Get Started',
|
|
26
|
-
href: '#',
|
|
27
|
+
href: '#get-started',
|
|
27
28
|
},
|
|
28
29
|
{
|
|
29
30
|
label: 'Overview',
|
|
30
31
|
items: [
|
|
31
32
|
{
|
|
32
33
|
label: 'Overview Item 1',
|
|
33
|
-
href: '#',
|
|
34
|
+
href: '#overview-item-1',
|
|
34
35
|
},
|
|
35
36
|
{
|
|
36
37
|
label: 'Overview Item 2',
|
|
37
|
-
href: '#',
|
|
38
|
-
active: true,
|
|
38
|
+
href: '#overview-item-2',
|
|
39
39
|
},
|
|
40
40
|
],
|
|
41
41
|
},
|
|
@@ -44,33 +44,32 @@ import DocMenu from '@cypress-design/vue-docmenu'
|
|
|
44
44
|
items: [
|
|
45
45
|
{
|
|
46
46
|
label: 'Item 1',
|
|
47
|
-
href: '#',
|
|
47
|
+
href: '#item-1',
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
label: 'Group',
|
|
51
51
|
items: [
|
|
52
52
|
{
|
|
53
53
|
label: 'Item 1',
|
|
54
|
-
href: '#',
|
|
54
|
+
href: '#group-item-1',
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
label: 'Item 2',
|
|
58
|
-
href: '#',
|
|
58
|
+
href: '#group-item-2',
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
label: 'Item 3',
|
|
62
|
-
href: '#',
|
|
62
|
+
href: '#group-item-3',
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
label: 'Item 4',
|
|
66
|
-
href: '#',
|
|
66
|
+
href: '#group-item-4',
|
|
67
67
|
},
|
|
68
68
|
],
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
label: 'Item 5',
|
|
72
72
|
href: '#',
|
|
73
|
-
active: true,
|
|
74
73
|
},
|
|
75
74
|
],
|
|
76
75
|
},
|
package/_DocGroup.vue
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed, type DefineComponent,
|
|
2
|
+
import { computed, type DefineComponent, ref, watch, nextTick } from 'vue'
|
|
3
3
|
import { IconChevronDownSmall } from '@cypress-design/vue-icon'
|
|
4
4
|
import { NavGroup, classes } from '@cypress-design/constants-docmenu'
|
|
5
|
-
import
|
|
6
|
-
import DocGroup from './_DocGroup.vue'
|
|
5
|
+
import DocGroupElements from './_DocGroupElements.vue'
|
|
7
6
|
|
|
8
7
|
const props = withDefaults(
|
|
9
8
|
defineProps<{
|
|
10
9
|
group: NavGroup
|
|
10
|
+
activePath?: string
|
|
11
11
|
collapsible: boolean
|
|
12
12
|
linkComponent: DefineComponent | 'a'
|
|
13
13
|
depth?: number
|
|
@@ -17,48 +17,56 @@ const props = withDefaults(
|
|
|
17
17
|
},
|
|
18
18
|
)
|
|
19
19
|
|
|
20
|
-
const open = ref(props.
|
|
20
|
+
const open = ref(props.group.collapsed !== true)
|
|
21
|
+
const $groupElements = ref<typeof DocGroupElements>()
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
+
const Head = computed(() =>
|
|
24
|
+
props.collapsible ? 'button' : props.group.href ? 'a' : 'div',
|
|
25
|
+
)
|
|
23
26
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
30
|
-
: 0
|
|
31
|
-
})
|
|
27
|
+
const emit = defineEmits<{
|
|
28
|
+
(event: 'updateActivePosition', opts?: { top: number; height: number }): void
|
|
29
|
+
(event: 'hideMarker'): void
|
|
30
|
+
(event: 'updateMarkerPosition'): void
|
|
31
|
+
}>()
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
33
|
+
function hasActiveItemRecursively(items = props.group.items): boolean {
|
|
34
|
+
return items.some((item) => {
|
|
35
|
+
if ('items' in item) {
|
|
36
|
+
return hasActiveItemRecursively(item.items)
|
|
37
|
+
}
|
|
38
|
+
return item.href === props.activePath
|
|
39
|
+
})
|
|
40
|
+
}
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
)
|
|
42
|
+
function reTriggerSetActiveGroup() {
|
|
43
|
+
$groupElements.value?.reTriggerSetActiveGroup()
|
|
44
|
+
}
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
let numberOfGroups = props.group.items.filter(
|
|
46
|
-
(item, index) => !('href' in item) && index < activeIndex,
|
|
47
|
-
).length
|
|
46
|
+
const active = computed(() => props.group.href === props.activePath)
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
numberOfGroups--
|
|
54
|
-
return acc + group.height
|
|
55
|
-
}, 0)
|
|
56
|
-
return (activeIndex + groupHeight) * 44
|
|
48
|
+
watch(active, (active) => {
|
|
49
|
+
if (active) {
|
|
50
|
+
emit('hideMarker')
|
|
51
|
+
}
|
|
57
52
|
})
|
|
58
53
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
54
|
+
watch(open, async (open) => {
|
|
55
|
+
await nextTick()
|
|
56
|
+
if (hasActiveItemRecursively()) {
|
|
57
|
+
if (open) {
|
|
58
|
+
reTriggerSetActiveGroup()
|
|
59
|
+
} else {
|
|
60
|
+
emit('hideMarker')
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
emit('updateMarkerPosition')
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
defineExpose({
|
|
68
|
+
reTriggerSetActiveGroup,
|
|
69
|
+
})
|
|
62
70
|
</script>
|
|
63
71
|
|
|
64
72
|
<template>
|
|
@@ -69,14 +77,16 @@ const Head = computed(() =>
|
|
|
69
77
|
{
|
|
70
78
|
[classes.topButton]: depth === 0,
|
|
71
79
|
[classes.leafButton]: depth,
|
|
72
|
-
'text-indigo-500':
|
|
80
|
+
'text-indigo-500': active,
|
|
73
81
|
},
|
|
74
82
|
]"
|
|
75
|
-
:href="
|
|
83
|
+
:href="group.href"
|
|
76
84
|
@click="
|
|
77
85
|
() => {
|
|
78
86
|
if (collapsible) {
|
|
79
87
|
open = !open
|
|
88
|
+
} else {
|
|
89
|
+
emit('updateActivePosition')
|
|
80
90
|
}
|
|
81
91
|
}
|
|
82
92
|
"
|
|
@@ -94,43 +104,16 @@ const Head = computed(() =>
|
|
|
94
104
|
/>
|
|
95
105
|
{{ group.label }}
|
|
96
106
|
</component>
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
props.collapsible &&
|
|
100
|
-
depth >= 0 &&
|
|
101
|
-
open &&
|
|
102
|
-
group.items.some((item) => 'href' in item && item.active)
|
|
103
|
-
"
|
|
104
|
-
class="absolute h-[36px] w-[4px] z-10 rounded-full bg-indigo-500 transition-all duration-300 ml-[6px] mt-[48px]"
|
|
105
|
-
:style="{
|
|
106
|
-
top: `${activeMarkerTop}px`,
|
|
107
|
-
left: `-${depth === 0 ? 0 : depth * 7.5 + 1}px`,
|
|
108
|
-
}"
|
|
109
|
-
/>
|
|
110
|
-
<ul
|
|
107
|
+
<DocGroupElements
|
|
108
|
+
ref="$groupElements"
|
|
111
109
|
v-show="open"
|
|
112
|
-
|
|
113
|
-
:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
:group="item"
|
|
122
|
-
:depth="depth + 1"
|
|
123
|
-
:collapsible="props.collapsible"
|
|
124
|
-
:link-component="props.linkComponent"
|
|
125
|
-
/>
|
|
126
|
-
</li>
|
|
127
|
-
<DocLink
|
|
128
|
-
v-else
|
|
129
|
-
:item="item"
|
|
130
|
-
:depth="depth"
|
|
131
|
-
:collapsible="collapsible"
|
|
132
|
-
:link-component="props.linkComponent"
|
|
133
|
-
/>
|
|
134
|
-
</template>
|
|
135
|
-
</ul>
|
|
110
|
+
:depth="depth"
|
|
111
|
+
:items="group.items"
|
|
112
|
+
:active-path="activePath"
|
|
113
|
+
:collapsible="collapsible"
|
|
114
|
+
:link-component="linkComponent"
|
|
115
|
+
@hide-marker="emit('hideMarker')"
|
|
116
|
+
@update-marker-position="emit('updateMarkerPosition')"
|
|
117
|
+
@update-active-position="(opts) => emit('updateActivePosition', opts)"
|
|
118
|
+
/>
|
|
136
119
|
</template>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { DefineComponent, ref } from 'vue'
|
|
3
|
+
import { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu'
|
|
4
|
+
import DocGroup from './_DocGroup.vue'
|
|
5
|
+
import DocLink from './_DocLink.vue'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
items: (NavGroup | NavItemLink)[]
|
|
9
|
+
activePath?: string
|
|
10
|
+
collapsible: boolean
|
|
11
|
+
linkComponent: DefineComponent | 'a'
|
|
12
|
+
depth: number
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const emit = defineEmits<{
|
|
16
|
+
(event: 'updateActivePosition', opts?: { top: number; height: number }): void
|
|
17
|
+
(event: 'hideMarker'): void
|
|
18
|
+
(event: 'updateMarkerPosition'): void
|
|
19
|
+
}>()
|
|
20
|
+
|
|
21
|
+
const $items = ref<(typeof DocLink)[]>([])
|
|
22
|
+
const $groups = ref<(typeof DocGroup)[]>([])
|
|
23
|
+
|
|
24
|
+
function hasActiveItemRecursively(items = props.items): boolean {
|
|
25
|
+
return items.some((item) => {
|
|
26
|
+
if ('items' in item) {
|
|
27
|
+
return hasActiveItemRecursively(item.items)
|
|
28
|
+
}
|
|
29
|
+
return item.href === props.activePath
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function reTriggerSetActiveGroup() {
|
|
34
|
+
$items.value.forEach((item) => {
|
|
35
|
+
item.setActiveMarkerPosition()
|
|
36
|
+
})
|
|
37
|
+
$groups.value.forEach((group) => {
|
|
38
|
+
group.reTriggerSetActiveGroup()
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
defineExpose({
|
|
43
|
+
reTriggerSetActiveGroup,
|
|
44
|
+
})
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<ul
|
|
49
|
+
class="list-none p-0"
|
|
50
|
+
:class="{
|
|
51
|
+
'border-l border-gray-100': depth === 0 && collapsible,
|
|
52
|
+
'ml-[8px]': depth >= 0,
|
|
53
|
+
}"
|
|
54
|
+
>
|
|
55
|
+
<template v-for="item in items">
|
|
56
|
+
<li class="relative list-none p-0" v-if="item && 'items' in item">
|
|
57
|
+
<DocGroup
|
|
58
|
+
ref="$groups"
|
|
59
|
+
:active-path="activePath"
|
|
60
|
+
:group="item"
|
|
61
|
+
:depth="depth + 1"
|
|
62
|
+
:collapsible="collapsible"
|
|
63
|
+
:link-component="linkComponent"
|
|
64
|
+
@update-active-position="
|
|
65
|
+
(opts) => {
|
|
66
|
+
emit('updateActivePosition', opts)
|
|
67
|
+
}
|
|
68
|
+
"
|
|
69
|
+
@update-marker-position="
|
|
70
|
+
() => {
|
|
71
|
+
if (hasActiveItemRecursively()) {
|
|
72
|
+
reTriggerSetActiveGroup()
|
|
73
|
+
} else {
|
|
74
|
+
emit('updateMarkerPosition')
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
"
|
|
78
|
+
/>
|
|
79
|
+
</li>
|
|
80
|
+
<DocLink
|
|
81
|
+
v-else
|
|
82
|
+
ref="$items"
|
|
83
|
+
:item="item"
|
|
84
|
+
:active="item.href === activePath"
|
|
85
|
+
:depth="depth"
|
|
86
|
+
:collapsible="collapsible"
|
|
87
|
+
:link-component="linkComponent"
|
|
88
|
+
@update:active="
|
|
89
|
+
(_, opts) => {
|
|
90
|
+
if (!opts) return
|
|
91
|
+
emit('updateActivePosition', opts)
|
|
92
|
+
}
|
|
93
|
+
"
|
|
94
|
+
/>
|
|
95
|
+
</template>
|
|
96
|
+
</ul>
|
|
97
|
+
</template>
|
package/_DocLink.vue
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type
|
|
2
|
+
import { watch, type DefineComponent, ref, onMounted } from 'vue'
|
|
3
3
|
import type { NavItemLink } from '@cypress-design/constants-docmenu'
|
|
4
4
|
|
|
5
|
-
withDefaults(
|
|
5
|
+
const props = withDefaults(
|
|
6
6
|
defineProps<{
|
|
7
7
|
item: NavItemLink
|
|
8
|
+
active: boolean
|
|
8
9
|
collapsible: boolean
|
|
9
10
|
depth?: number
|
|
10
11
|
linkComponent: DefineComponent | 'a'
|
|
@@ -13,10 +14,51 @@ withDefaults(
|
|
|
13
14
|
depth: -1,
|
|
14
15
|
},
|
|
15
16
|
)
|
|
17
|
+
|
|
18
|
+
const emit = defineEmits<{
|
|
19
|
+
(
|
|
20
|
+
event: 'update:active',
|
|
21
|
+
active: boolean,
|
|
22
|
+
opts?: { top: number; height: number },
|
|
23
|
+
): void
|
|
24
|
+
}>()
|
|
25
|
+
|
|
26
|
+
const $container = ref<HTMLLIElement>()
|
|
27
|
+
|
|
28
|
+
function setActiveMarkerPosition() {
|
|
29
|
+
if (props.active) {
|
|
30
|
+
const { top = 0, height = 36 } =
|
|
31
|
+
$container.value?.getBoundingClientRect() ?? {}
|
|
32
|
+
|
|
33
|
+
emit('update:active', props.active, {
|
|
34
|
+
top,
|
|
35
|
+
height,
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
onMounted(() => {
|
|
41
|
+
watch(
|
|
42
|
+
() => props.active,
|
|
43
|
+
(active) => {
|
|
44
|
+
if (active) {
|
|
45
|
+
setActiveMarkerPosition()
|
|
46
|
+
} else {
|
|
47
|
+
emit('update:active', active)
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{ immediate: true },
|
|
51
|
+
)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
defineExpose({
|
|
55
|
+
setActiveMarkerPosition,
|
|
56
|
+
})
|
|
16
57
|
</script>
|
|
17
58
|
|
|
18
59
|
<template>
|
|
19
60
|
<li
|
|
61
|
+
ref="$container"
|
|
20
62
|
class="list-none p-0"
|
|
21
63
|
:class="{
|
|
22
64
|
'pl-[16px]': depth >= 0,
|
|
@@ -26,7 +68,7 @@ withDefaults(
|
|
|
26
68
|
:is="linkComponent"
|
|
27
69
|
class="group relative block w-full pl-[24px]"
|
|
28
70
|
:class="{
|
|
29
|
-
'text-indigo-500':
|
|
71
|
+
'text-indigo-500': active,
|
|
30
72
|
'py-[8px] text-[16px] leading-[24px]': depth < 0,
|
|
31
73
|
'leading-[20px] text-[14px] py-[12px]': depth >= 0,
|
|
32
74
|
}"
|
|
@@ -36,7 +78,7 @@ withDefaults(
|
|
|
36
78
|
v-if="depth >= 0"
|
|
37
79
|
class="absolute h-[80%] top-[10%] w-[4px] z-10 rounded-full hidden"
|
|
38
80
|
:class="{
|
|
39
|
-
'group-hover:block bg-gray-300': !
|
|
81
|
+
'group-hover:block bg-gray-300': !active && collapsible,
|
|
40
82
|
}"
|
|
41
83
|
:style="{
|
|
42
84
|
left: `-${18.5 + depth * 7.5}px`,
|
package/dist/DocMenu.vue.d.ts
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DefineComponent } from 'vue';
|
|
2
2
|
import { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu';
|
|
3
3
|
declare const _default: DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
4
4
|
items: (NavItemLink | NavGroup)[];
|
|
5
|
+
activePath?: string | undefined;
|
|
5
6
|
collapsible?: boolean | undefined;
|
|
6
7
|
linkComponent?: DefineComponent | "a" | undefined;
|
|
7
8
|
}>, {
|
|
8
9
|
linkComponent: string;
|
|
9
10
|
collapsible: boolean;
|
|
11
|
+
activePath: undefined;
|
|
10
12
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
11
13
|
items: (NavItemLink | NavGroup)[];
|
|
14
|
+
activePath?: string | undefined;
|
|
12
15
|
collapsible?: boolean | undefined;
|
|
13
16
|
linkComponent?: DefineComponent | "a" | undefined;
|
|
14
17
|
}>, {
|
|
15
18
|
linkComponent: string;
|
|
16
19
|
collapsible: boolean;
|
|
20
|
+
activePath: undefined;
|
|
17
21
|
}>>>, {
|
|
22
|
+
activePath: string;
|
|
18
23
|
collapsible: boolean;
|
|
19
24
|
linkComponent: DefineComponent | 'a';
|
|
20
25
|
}, {}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocMenu.vue.d.ts","sourceRoot":"","sources":["../DocMenu.vue.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"DocMenu.vue.d.ts","sourceRoot":"","sources":["../DocMenu.vue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAO,KAAK,eAAe,EAAE,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;;WAyI9D,CAAC,WAAW,GAAG,QAAQ,CAAC,EAAE;;;;;;;;;WAA1B,CAAC,WAAW,GAAG,QAAQ,CAAC,EAAE;;;;;;;;;gBACpB,MAAM;iBACL,OAAO;mBACL,eAAe,GAAG,GAAG;;AATzC,wBAWG;AACH,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC;AAC9M,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAE1B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QACxE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KACb,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AACN,KAAK,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|
package/dist/_DocGroup.vue.d.ts
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
|
-
import { type DefineComponent
|
|
1
|
+
import { type DefineComponent } from 'vue';
|
|
2
2
|
import { NavGroup } from '@cypress-design/constants-docmenu';
|
|
3
|
+
declare function reTriggerSetActiveGroup(): void;
|
|
3
4
|
declare const _default: DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
4
5
|
group: NavGroup;
|
|
6
|
+
activePath?: string | undefined;
|
|
5
7
|
collapsible: boolean;
|
|
6
8
|
linkComponent: DefineComponent | 'a';
|
|
7
9
|
depth?: number | undefined;
|
|
8
10
|
}>, {
|
|
9
11
|
depth: number;
|
|
10
12
|
}>, {
|
|
11
|
-
|
|
12
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
|
+
reTriggerSetActiveGroup: typeof reTriggerSetActiveGroup;
|
|
14
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
|
+
updateActivePosition: (opts?: {
|
|
16
|
+
top: number;
|
|
17
|
+
height: number;
|
|
18
|
+
} | undefined) => void;
|
|
19
|
+
hideMarker: () => void;
|
|
20
|
+
updateMarkerPosition: () => void;
|
|
21
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
13
22
|
group: NavGroup;
|
|
23
|
+
activePath?: string | undefined;
|
|
14
24
|
collapsible: boolean;
|
|
15
25
|
linkComponent: DefineComponent | 'a';
|
|
16
26
|
depth?: number | undefined;
|
|
17
27
|
}>, {
|
|
18
28
|
depth: number;
|
|
19
|
-
}
|
|
29
|
+
}>>> & {
|
|
30
|
+
onUpdateActivePosition?: ((opts?: {
|
|
31
|
+
top: number;
|
|
32
|
+
height: number;
|
|
33
|
+
} | undefined) => any) | undefined;
|
|
34
|
+
onHideMarker?: (() => any) | undefined;
|
|
35
|
+
onUpdateMarkerPosition?: (() => any) | undefined;
|
|
36
|
+
}, {
|
|
20
37
|
depth: number;
|
|
21
38
|
}, {}>;
|
|
22
39
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_DocGroup.vue.d.ts","sourceRoot":"","sources":["../_DocGroup.vue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"_DocGroup.vue.d.ts","sourceRoot":"","sources":["../_DocGroup.vue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,eAAe,EAAwB,MAAM,KAAK,CAAA;AAE1E,OAAO,EAAE,QAAQ,EAAW,MAAM,mCAAmC,CAAA;AAwCrE,iBAAS,uBAAuB,SAE/B;;WAuLU,QAAQ;;iBAEF,OAAO;mBACL,eAAe,GAAG,GAAG;;;;;;;;;;;;;;WAH7B,QAAQ;;iBAEF,OAAO;mBACL,eAAe,GAAG,GAAG;;;;;;;;;;;;WAC5B,MAAM;;AAXlB,wBAcG;AACH,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC;AAC9M,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAE1B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QACxE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KACb,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AACN,KAAK,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|