@cypress-design/vue-docmenu 0.4.1 → 0.5.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/.turbo/turbo-build.log +3 -3
- package/CHANGELOG.md +20 -0
- package/DocMenu.vue +7 -3
- package/DocMenuVue.cy.tsx +27 -17
- package/_DocGroup.vue +77 -34
- package/_DocGroupElements.vue +66 -25
- package/_DocLink.vue +11 -12
- package/dist/DocMenu.vue.d.ts.map +1 -1
- package/dist/_DocGroup.vue.d.ts +2 -2
- package/dist/_DocGroup.vue.d.ts.map +1 -1
- package/dist/_DocGroupElements.vue.d.ts +23 -4
- package/dist/_DocGroupElements.vue.d.ts.map +1 -1
- package/dist/_DocLink.vue.d.ts.map +1 -1
- package/dist/index.es.mjs +179 -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
|
@@ -7,8 +7,8 @@ transforming...
|
|
|
7
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[2m11.16 kB[22m[1m[22m[2m │ gzip: 3.23 kB[22m[2m │ map: 15.79 kB[22m
|
|
11
|
+
[2mdist/[22m[36mindex.umd.js [39m[1m[2m8.74 kB[22m[1m[22m[2m │ gzip: 2.80 kB[22m[2m │ map: 15.34 kB[22m
|
|
12
|
+
[32m✓ built in 3.61s[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,25 @@
|
|
|
1
1
|
# @cypress-design/vue-docmenu
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#357](https://github.com/cypress-io/cypress-design/pull/357) [`d0ed7c5`](https://github.com/cypress-io/cypress-design/commit/d0ed7c513df09d24639895ae1c7f2633eab8c254) Thanks [@elevatebart](https://github.com/elevatebart)! - feat: add transition when open/close collapsible menu
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`d0ed7c5`](https://github.com/cypress-io/cypress-design/commit/d0ed7c513df09d24639895ae1c7f2633eab8c254)]:
|
|
12
|
+
- @cypress-design/constants-docmenu@0.2.0
|
|
13
|
+
|
|
14
|
+
## 0.4.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`a58be93`](https://github.com/cypress-io/cypress-design/commit/a58be9322cfc64c64533ff8f8414a45ba90be751) Thanks [@elevatebart](https://github.com/elevatebart)! - fix(docgen): make buttons left-aligned (logical)
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`a58be93`](https://github.com/cypress-io/cypress-design/commit/a58be9322cfc64c64533ff8f8414a45ba90be751)]:
|
|
21
|
+
- @cypress-design/constants-docmenu@0.1.3
|
|
22
|
+
|
|
3
23
|
## 0.4.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/DocMenu.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { ref, type DefineComponent } from 'vue'
|
|
2
|
+
import { ref, type DefineComponent, provide } from 'vue'
|
|
3
3
|
import { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu'
|
|
4
4
|
import DocGroupElements from './_DocGroupElements.vue'
|
|
5
5
|
|
|
@@ -29,16 +29,20 @@ function updateActiveMarkerPosition({ top, height } = { height: 0, top: 0 }) {
|
|
|
29
29
|
activeHeight.value = height
|
|
30
30
|
showMarker.value = true
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
const markerIsMoving = ref(false)
|
|
34
|
+
|
|
35
|
+
provide('transition-is-moving', markerIsMoving)
|
|
32
36
|
</script>
|
|
33
37
|
|
|
34
38
|
<template>
|
|
35
39
|
<div ref="$container" class="relative">
|
|
36
40
|
<div
|
|
37
|
-
v-if="showMarker && collapsible"
|
|
41
|
+
v-if="showMarker && collapsible && !markerIsMoving"
|
|
38
42
|
data-cy="doc-menu-active-marker"
|
|
39
43
|
class="absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px]"
|
|
40
44
|
:style="{
|
|
41
|
-
top: `${activeTop
|
|
45
|
+
top: `${activeTop}px`,
|
|
42
46
|
height: `${activeHeight - 8}px`,
|
|
43
47
|
}"
|
|
44
48
|
/>
|
package/DocMenuVue.cy.tsx
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
/// <reference types="cypress" />
|
|
2
|
-
import { type DefineComponent, defineComponent } from 'vue'
|
|
2
|
+
import { type DefineComponent, defineComponent, ref } from 'vue'
|
|
3
3
|
import { mount } from 'cypress/vue'
|
|
4
4
|
import assertions from '../assertions'
|
|
5
5
|
import type { NavGroup, NavItemLink } from '../constants'
|
|
6
6
|
import DocMenu from './DocMenu.vue'
|
|
7
7
|
|
|
8
|
-
const CustomLinkVue: DefineComponent<{ href: StringConstructor }> =
|
|
9
|
-
defineComponent({
|
|
10
|
-
props: {
|
|
11
|
-
href: String,
|
|
12
|
-
},
|
|
13
|
-
setup(props, { slots }) {
|
|
14
|
-
return () => (
|
|
15
|
-
<div>
|
|
16
|
-
{slots.default?.()} + href: {props.href}
|
|
17
|
-
</div>
|
|
18
|
-
)
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
|
|
22
8
|
describe('<DocMenu/>', () => {
|
|
23
9
|
it('renders', () => {
|
|
24
10
|
mount(() => <DocMenu items={[{ href: '/foo', label: 'Foo' }]} />)
|
|
@@ -26,19 +12,43 @@ describe('<DocMenu/>', () => {
|
|
|
26
12
|
})
|
|
27
13
|
|
|
28
14
|
it('renders the custom link components', () => {
|
|
15
|
+
const selectedHref = ref<string | undefined>()
|
|
16
|
+
const CustomLinkVue: DefineComponent<{ href: StringConstructor }> =
|
|
17
|
+
defineComponent({
|
|
18
|
+
props: {
|
|
19
|
+
href: String,
|
|
20
|
+
},
|
|
21
|
+
setup(props, { slots, emit }) {
|
|
22
|
+
return () => (
|
|
23
|
+
<span onClick={() => (selectedHref.value = props.href)}>
|
|
24
|
+
{slots.default?.()} + href: {props.href}
|
|
25
|
+
</span>
|
|
26
|
+
)
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
29
|
mount(() => (
|
|
30
30
|
<DocMenu
|
|
31
|
+
activePath={selectedHref.value}
|
|
31
32
|
items={[
|
|
32
33
|
{
|
|
33
34
|
label: 'Baaaaaaz',
|
|
34
|
-
items: [
|
|
35
|
+
items: [
|
|
36
|
+
{
|
|
37
|
+
label: 'Bar',
|
|
38
|
+
items: [
|
|
39
|
+
{ href: '/foo', label: 'Foo' },
|
|
40
|
+
{ href: '/box', label: 'Box' },
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{ label: 'Baz', href: '/baz' },
|
|
44
|
+
],
|
|
35
45
|
},
|
|
36
46
|
]}
|
|
37
47
|
linkComponent={CustomLinkVue}
|
|
38
48
|
/>
|
|
39
49
|
))
|
|
40
50
|
|
|
41
|
-
cy.findByText('Foo + href: /foo'
|
|
51
|
+
cy.findByText('Foo + href: /foo').should('be.visible')
|
|
42
52
|
})
|
|
43
53
|
|
|
44
54
|
function mountStory(items: (NavItemLink | NavGroup)[] = [], activePath = '') {
|
package/_DocGroup.vue
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed, type DefineComponent, ref, watch,
|
|
2
|
+
import { computed, type DefineComponent, ref, watch, inject } from 'vue'
|
|
3
3
|
import { IconChevronDownSmall } from '@cypress-design/vue-icon'
|
|
4
4
|
import { NavGroup, classes } from '@cypress-design/constants-docmenu'
|
|
5
|
-
import DocGroupElements
|
|
5
|
+
import DocGroupElements, {
|
|
6
|
+
hasActiveItemRecursively,
|
|
7
|
+
type DocGroupEventsEmitted,
|
|
8
|
+
} from './_DocGroupElements.vue'
|
|
6
9
|
|
|
7
10
|
const props = withDefaults(
|
|
8
11
|
defineProps<{
|
|
@@ -19,25 +22,22 @@ const props = withDefaults(
|
|
|
19
22
|
|
|
20
23
|
const open = ref(props.group.collapsed !== true)
|
|
21
24
|
const $groupElements = ref<typeof DocGroupElements>()
|
|
25
|
+
const $listWrapper = ref<HTMLDivElement>()
|
|
22
26
|
|
|
23
27
|
const Head = computed(() =>
|
|
24
28
|
props.collapsible ? 'button' : props.group.href ? 'a' : 'div',
|
|
25
29
|
)
|
|
26
30
|
|
|
27
|
-
const emit = defineEmits<
|
|
28
|
-
(event: 'updateActivePosition', opts?: { top: number; height: number }): void
|
|
29
|
-
(event: 'hideMarker'): void
|
|
30
|
-
(event: 'updateMarkerPosition'): void
|
|
31
|
-
}>()
|
|
31
|
+
const emit = defineEmits<DocGroupEventsEmitted>()
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const hasActiveItem = computed(() =>
|
|
34
|
+
props.group.items.some((item) => {
|
|
35
35
|
if ('items' in item) {
|
|
36
|
-
return hasActiveItemRecursively(item.items)
|
|
36
|
+
return hasActiveItemRecursively(item.items, props.activePath)
|
|
37
37
|
}
|
|
38
38
|
return item.href === props.activePath
|
|
39
|
-
})
|
|
40
|
-
|
|
39
|
+
}),
|
|
40
|
+
)
|
|
41
41
|
|
|
42
42
|
function reTriggerSetActiveGroup() {
|
|
43
43
|
$groupElements.value?.reTriggerSetActiveGroup()
|
|
@@ -45,15 +45,37 @@ function reTriggerSetActiveGroup() {
|
|
|
45
45
|
|
|
46
46
|
const active = computed(() => props.group.href === props.activePath)
|
|
47
47
|
|
|
48
|
+
const markerIsMoving = inject('transition-is-moving', ref(false))
|
|
49
|
+
|
|
50
|
+
watch(open, () => {
|
|
51
|
+
$listWrapper.value?.addEventListener(
|
|
52
|
+
'transitionstart',
|
|
53
|
+
() => {
|
|
54
|
+
markerIsMoving.value = true
|
|
55
|
+
},
|
|
56
|
+
{ once: true },
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
$listWrapper.value?.addEventListener(
|
|
60
|
+
'transitionend',
|
|
61
|
+
() => {
|
|
62
|
+
markerIsMoving.value = false
|
|
63
|
+
if (open.value || !hasActiveItem.value) {
|
|
64
|
+
emit('updateMarkerPosition')
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{ once: true },
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
|
+
|
|
48
71
|
watch(active, (active) => {
|
|
49
72
|
if (active) {
|
|
50
73
|
emit('hideMarker')
|
|
51
74
|
}
|
|
52
75
|
})
|
|
53
76
|
|
|
54
|
-
watch(open,
|
|
55
|
-
|
|
56
|
-
if (hasActiveItemRecursively()) {
|
|
77
|
+
watch(open, (open) => {
|
|
78
|
+
if (hasActiveItem.value) {
|
|
57
79
|
if (open) {
|
|
58
80
|
reTriggerSetActiveGroup()
|
|
59
81
|
} else {
|
|
@@ -78,6 +100,10 @@ defineExpose({
|
|
|
78
100
|
[classes.topButton]: depth === 0,
|
|
79
101
|
[classes.leafButton]: depth,
|
|
80
102
|
'text-indigo-500': active,
|
|
103
|
+
'text-gray-900 dark:text-gray-200':
|
|
104
|
+
!hasActiveItem && !active && depth === 0,
|
|
105
|
+
'text-gray-700 dark:text-gray-500':
|
|
106
|
+
!hasActiveItem && !active && depth >= 0,
|
|
81
107
|
},
|
|
82
108
|
]"
|
|
83
109
|
:href="group.href"
|
|
@@ -93,27 +119,44 @@ defineExpose({
|
|
|
93
119
|
>
|
|
94
120
|
<IconChevronDownSmall
|
|
95
121
|
v-if="props.collapsible"
|
|
96
|
-
stroke-color="
|
|
122
|
+
stroke-color="current"
|
|
97
123
|
:size="depth ? '8' : '16'"
|
|
98
|
-
class="
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
124
|
+
:class="[
|
|
125
|
+
classes.expandedIcon,
|
|
126
|
+
{
|
|
127
|
+
'rotate-0': open,
|
|
128
|
+
'-rotate-90': !open,
|
|
129
|
+
'ml-[28px]': depth,
|
|
130
|
+
},
|
|
131
|
+
]"
|
|
104
132
|
/>
|
|
105
133
|
{{ group.label }}
|
|
106
134
|
</component>
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
135
|
+
<div
|
|
136
|
+
class="grid transition-all relative"
|
|
137
|
+
ref="$listWrapper"
|
|
138
|
+
:class="{
|
|
139
|
+
'grid-rows-[0fr]': !open && collapsible,
|
|
140
|
+
'grid-rows-[1fr]': open || !collapsible,
|
|
141
|
+
}"
|
|
142
|
+
>
|
|
143
|
+
<div
|
|
144
|
+
v-if="open && collapsible && depth === 0"
|
|
145
|
+
:class="classes.openListBorderLeft"
|
|
146
|
+
/>
|
|
147
|
+
<DocGroupElements
|
|
148
|
+
ref="$groupElements"
|
|
149
|
+
class="overflow-hidden"
|
|
150
|
+
:depth="depth"
|
|
151
|
+
:items="group.items"
|
|
152
|
+
:active-path="activePath"
|
|
153
|
+
:collapsible="collapsible"
|
|
154
|
+
:link-component="linkComponent"
|
|
155
|
+
@hide-marker="emit('hideMarker')"
|
|
156
|
+
@update-marker-position="() => emit('updateMarkerPosition')"
|
|
157
|
+
@update-active-position="
|
|
158
|
+
(opts) => (open ? emit('updateActivePosition', opts) : null)
|
|
159
|
+
"
|
|
160
|
+
/>
|
|
161
|
+
</div>
|
|
119
162
|
</template>
|
package/_DocGroupElements.vue
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
export function hasActiveItemRecursively(
|
|
3
|
+
items: (NavGroup | NavItemLink)[],
|
|
4
|
+
activePath?: string,
|
|
5
|
+
): boolean {
|
|
6
|
+
return items.some((item) => {
|
|
7
|
+
if ('items' in item) {
|
|
8
|
+
return hasActiveItemRecursively(item.items, activePath)
|
|
9
|
+
}
|
|
10
|
+
return item.href === activePath
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface DocGroupEventsEmitted {
|
|
15
|
+
/**
|
|
16
|
+
* If the group is not collapsed, this event will emit the
|
|
17
|
+
* active marker position all the way to the menu component
|
|
18
|
+
*/
|
|
19
|
+
(event: 'updateActivePosition', opts?: { top: number; height: number }): void
|
|
20
|
+
/**
|
|
21
|
+
* This event will trigger a re-render of the active marker
|
|
22
|
+
* to update its position if not in the current subtree
|
|
23
|
+
*/
|
|
24
|
+
(event: 'updateMarkerPosition'): void
|
|
25
|
+
/**
|
|
26
|
+
* This event will bubble-up and hide the active marker
|
|
27
|
+
*/
|
|
28
|
+
(event: 'hideMarker'): void
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
|
|
1
32
|
<script lang="ts" setup>
|
|
2
|
-
import { DefineComponent, ref } from 'vue'
|
|
33
|
+
import { DefineComponent, computed, ref } from 'vue'
|
|
3
34
|
import { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu'
|
|
4
35
|
import DocGroup from './_DocGroup.vue'
|
|
5
36
|
import DocLink from './_DocLink.vue'
|
|
@@ -12,29 +43,39 @@ const props = defineProps<{
|
|
|
12
43
|
depth: number
|
|
13
44
|
}>()
|
|
14
45
|
|
|
15
|
-
const emit = defineEmits<
|
|
16
|
-
(event: 'updateActivePosition', opts?: { top: number; height: number }): void
|
|
17
|
-
(event: 'hideMarker'): void
|
|
18
|
-
(event: 'updateMarkerPosition'): void
|
|
19
|
-
}>()
|
|
46
|
+
const emit = defineEmits<DocGroupEventsEmitted>()
|
|
20
47
|
|
|
21
48
|
const $items = ref<(typeof DocLink)[]>([])
|
|
22
49
|
const $groups = ref<(typeof DocGroup)[]>([])
|
|
23
50
|
|
|
24
|
-
|
|
25
|
-
|
|
51
|
+
const hasActiveItem = computed(() =>
|
|
52
|
+
props.items.some((item) => {
|
|
26
53
|
if ('items' in item) {
|
|
27
|
-
return hasActiveItemRecursively(item.items)
|
|
54
|
+
return hasActiveItemRecursively(item.items, props.activePath)
|
|
28
55
|
}
|
|
29
56
|
return item.href === props.activePath
|
|
30
|
-
})
|
|
31
|
-
|
|
57
|
+
}),
|
|
58
|
+
)
|
|
32
59
|
|
|
33
|
-
|
|
60
|
+
/**
|
|
61
|
+
* update the position of the marker when opening a group
|
|
62
|
+
* @param index
|
|
63
|
+
*/
|
|
64
|
+
function reTriggerSetActiveGroup(index = -1) {
|
|
34
65
|
$items.value.forEach((item) => {
|
|
35
66
|
item.setActiveMarkerPosition()
|
|
36
67
|
})
|
|
37
|
-
|
|
68
|
+
|
|
69
|
+
// calculate the index of the calling group in the list of groups
|
|
70
|
+
const indexGroup =
|
|
71
|
+
index -
|
|
72
|
+
// remove all the items that are not groups from the array and count them
|
|
73
|
+
props.items.slice(0, index).filter((item) => !('items' in item)).length
|
|
74
|
+
|
|
75
|
+
// only update groups that come after the toggled one
|
|
76
|
+
// others will not need to update the marker
|
|
77
|
+
// since they are "before" in the rendering tree
|
|
78
|
+
$groups.value.slice(indexGroup + 1).forEach((group) => {
|
|
38
79
|
group.reTriggerSetActiveGroup()
|
|
39
80
|
})
|
|
40
81
|
}
|
|
@@ -45,14 +86,8 @@ defineExpose({
|
|
|
45
86
|
</script>
|
|
46
87
|
|
|
47
88
|
<template>
|
|
48
|
-
<ul
|
|
49
|
-
|
|
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">
|
|
89
|
+
<ul class="list-none p-0">
|
|
90
|
+
<template v-for="(item, index) in items">
|
|
56
91
|
<li class="relative list-none p-0" v-if="item && 'items' in item">
|
|
57
92
|
<DocGroup
|
|
58
93
|
ref="$groups"
|
|
@@ -68,13 +103,14 @@ defineExpose({
|
|
|
68
103
|
"
|
|
69
104
|
@update-marker-position="
|
|
70
105
|
() => {
|
|
71
|
-
if (
|
|
72
|
-
reTriggerSetActiveGroup()
|
|
106
|
+
if (hasActiveItem) {
|
|
107
|
+
reTriggerSetActiveGroup(index)
|
|
73
108
|
} else {
|
|
74
109
|
emit('updateMarkerPosition')
|
|
75
110
|
}
|
|
76
111
|
}
|
|
77
112
|
"
|
|
113
|
+
@hide-marker="emit('hideMarker')"
|
|
78
114
|
/>
|
|
79
115
|
</li>
|
|
80
116
|
<DocLink
|
|
@@ -87,8 +123,13 @@ defineExpose({
|
|
|
87
123
|
:link-component="linkComponent"
|
|
88
124
|
@update:active="
|
|
89
125
|
(_, opts) => {
|
|
90
|
-
if (!opts)
|
|
91
|
-
|
|
126
|
+
if (!opts) {
|
|
127
|
+
return
|
|
128
|
+
} else if (depth < 0) {
|
|
129
|
+
emit('hideMarker')
|
|
130
|
+
} else {
|
|
131
|
+
emit('updateActivePosition', opts)
|
|
132
|
+
}
|
|
92
133
|
}
|
|
93
134
|
"
|
|
94
135
|
/>
|
package/_DocLink.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { watch, type DefineComponent, ref, onMounted } from 'vue'
|
|
2
|
+
import { watch, type DefineComponent, ref, onMounted, inject } from 'vue'
|
|
3
3
|
import type { NavItemLink } from '@cypress-design/constants-docmenu'
|
|
4
4
|
|
|
5
5
|
const props = withDefaults(
|
|
@@ -25,6 +25,8 @@ const emit = defineEmits<{
|
|
|
25
25
|
|
|
26
26
|
const $container = ref<HTMLLIElement>()
|
|
27
27
|
|
|
28
|
+
const markerIsMoving = inject('transition-is-moving', ref(false))
|
|
29
|
+
|
|
28
30
|
function setActiveMarkerPosition() {
|
|
29
31
|
if (props.active) {
|
|
30
32
|
const { top = 0, height = 36 } =
|
|
@@ -57,31 +59,28 @@ defineExpose({
|
|
|
57
59
|
</script>
|
|
58
60
|
|
|
59
61
|
<template>
|
|
60
|
-
<li
|
|
61
|
-
ref="$container"
|
|
62
|
-
class="list-none p-0"
|
|
63
|
-
:class="{
|
|
64
|
-
'pl-[16px]': depth >= 0,
|
|
65
|
-
}"
|
|
66
|
-
>
|
|
62
|
+
<li ref="$container" class="list-none p-0">
|
|
67
63
|
<component
|
|
68
64
|
:is="linkComponent"
|
|
69
65
|
class="group relative block w-full pl-[24px]"
|
|
70
66
|
:class="{
|
|
71
67
|
'text-indigo-500': active,
|
|
68
|
+
'text-gray-700 dark:text-gray-500': !active,
|
|
72
69
|
'py-[8px] text-[16px] leading-[24px]': depth < 0,
|
|
73
70
|
'leading-[20px] text-[14px] py-[12px]': depth >= 0,
|
|
74
71
|
}"
|
|
72
|
+
:style="{
|
|
73
|
+
paddingLeft: depth >= 0 ? `${depth * 12 + 48}px` : undefined,
|
|
74
|
+
}"
|
|
75
75
|
:href="item.href"
|
|
76
76
|
>
|
|
77
77
|
<div
|
|
78
78
|
v-if="depth >= 0"
|
|
79
|
-
class="absolute
|
|
79
|
+
class="left-[6.5px] absolute top-[4px] bottom-[4px] w-[4px] z-10 rounded-full"
|
|
80
80
|
:class="{
|
|
81
|
+
hidden: !markerIsMoving || !active,
|
|
81
82
|
'group-hover:block bg-gray-300': !active && collapsible,
|
|
82
|
-
|
|
83
|
-
:style="{
|
|
84
|
-
left: `-${18.5 + depth * 7.5}px`,
|
|
83
|
+
'bg-indigo-500': active && markerIsMoving,
|
|
85
84
|
}"
|
|
86
85
|
/>
|
|
87
86
|
{{ item.label }}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocMenu.vue.d.ts","sourceRoot":"","sources":["../DocMenu.vue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAO,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"DocMenu.vue.d.ts","sourceRoot":"","sources":["../DocMenu.vue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAO,KAAK,eAAe,EAAW,MAAM,KAAK,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;;WA8I9D,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
|
@@ -16,8 +16,8 @@ declare const _default: DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRunt
|
|
|
16
16
|
top: number;
|
|
17
17
|
height: number;
|
|
18
18
|
} | undefined) => void;
|
|
19
|
-
hideMarker: () => void;
|
|
20
19
|
updateMarkerPosition: () => void;
|
|
20
|
+
hideMarker: () => void;
|
|
21
21
|
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
22
22
|
group: NavGroup;
|
|
23
23
|
activePath?: string | undefined;
|
|
@@ -31,8 +31,8 @@ declare const _default: DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRunt
|
|
|
31
31
|
top: number;
|
|
32
32
|
height: number;
|
|
33
33
|
} | undefined) => any) | undefined;
|
|
34
|
-
onHideMarker?: (() => any) | undefined;
|
|
35
34
|
onUpdateMarkerPosition?: (() => any) | undefined;
|
|
35
|
+
onHideMarker?: (() => any) | undefined;
|
|
36
36
|
}, {
|
|
37
37
|
depth: number;
|
|
38
38
|
}, {}>;
|
|
@@ -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,EAAsB,MAAM,KAAK,CAAA;AAExE,OAAO,EAAE,QAAQ,EAAW,MAAM,mCAAmC,CAAA;AAwCrE,iBAAS,uBAAuB,SAE/B;;WAmQU,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"}
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { DefineComponent } from 'vue';
|
|
2
2
|
import { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu';
|
|
3
|
-
declare function
|
|
3
|
+
export declare function hasActiveItemRecursively(items: (NavGroup | NavItemLink)[], activePath?: string): boolean;
|
|
4
|
+
export interface DocGroupEventsEmitted {
|
|
5
|
+
/**
|
|
6
|
+
* If the group is not collapsed, this event will emit the
|
|
7
|
+
* active marker position all the way to the menu component
|
|
8
|
+
*/
|
|
9
|
+
(event: 'updateActivePosition', opts?: {
|
|
10
|
+
top: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}): void;
|
|
13
|
+
/**
|
|
14
|
+
* This event will trigger a re-render of the active marker
|
|
15
|
+
* to update its position if not in the current subtree
|
|
16
|
+
*/
|
|
17
|
+
(event: 'updateMarkerPosition'): void;
|
|
18
|
+
/**
|
|
19
|
+
* This event will bubble-up and hide the active marker
|
|
20
|
+
*/
|
|
21
|
+
(event: 'hideMarker'): void;
|
|
22
|
+
}
|
|
4
23
|
declare const _default: DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
5
24
|
items: (NavGroup | NavItemLink)[];
|
|
6
25
|
activePath?: string | undefined;
|
|
@@ -8,14 +27,14 @@ declare const _default: DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
|
8
27
|
linkComponent: DefineComponent | 'a';
|
|
9
28
|
depth: number;
|
|
10
29
|
}>, {
|
|
11
|
-
reTriggerSetActiveGroup:
|
|
30
|
+
reTriggerSetActiveGroup: (index?: number) => void;
|
|
12
31
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
32
|
updateActivePosition: (opts?: {
|
|
14
33
|
top: number;
|
|
15
34
|
height: number;
|
|
16
35
|
} | undefined) => void;
|
|
17
|
-
hideMarker: () => void;
|
|
18
36
|
updateMarkerPosition: () => void;
|
|
37
|
+
hideMarker: () => void;
|
|
19
38
|
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
20
39
|
items: (NavGroup | NavItemLink)[];
|
|
21
40
|
activePath?: string | undefined;
|
|
@@ -27,8 +46,8 @@ declare const _default: DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
|
27
46
|
top: number;
|
|
28
47
|
height: number;
|
|
29
48
|
} | undefined) => any) | undefined;
|
|
30
|
-
onHideMarker?: (() => any) | undefined;
|
|
31
49
|
onUpdateMarkerPosition?: (() => any) | undefined;
|
|
50
|
+
onHideMarker?: (() => any) | undefined;
|
|
32
51
|
}, {}, {}>;
|
|
33
52
|
export default _default;
|
|
34
53
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_DocGroupElements.vue.d.ts","sourceRoot":"","sources":["../_DocGroupElements.vue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"_DocGroupElements.vue.d.ts","sourceRoot":"","sources":["../_DocGroupElements.vue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAiB,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAMzE,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,CAAC,QAAQ,GAAG,WAAW,CAAC,EAAE,EACjC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAOT;AAED,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,CAAC,KAAK,EAAE,sBAAsB,EAAE,IAAI,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC7E;;;OAGG;IACH,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAA;IACrC;;OAEG;IACH,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAA;CAC5B;;WAyMQ,CAAC,QAAQ,GAAG,WAAW,CAAC,EAAE;;iBAEpB,OAAO;mBACL,eAAe,GAAG,GAAG;WAC7B,MAAM;;;;;;;;;;;WAJN,CAAC,QAAQ,GAAG,WAAW,CAAC,EAAE;;iBAEpB,OAAO;mBACL,eAAe,GAAG,GAAG;WAC7B,MAAM;;;;;;;;;AA5Mf,wBAgNI;AAAA,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACrE,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_DocLink.vue.d.ts","sourceRoot":"","sources":["../_DocLink.vue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"_DocLink.vue.d.ts","sourceRoot":"","sources":["../_DocLink.vue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,eAAe,EAA0B,MAAM,KAAK,CAAA;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AA6BpE,iBAAS,uBAAuB,SAU/B;;UA+HS,WAAW;YACT,OAAO;iBACF,OAAO;;mBAEL,eAAe,GAAG,GAAG;;;;;;;;;;;UAJ9B,WAAW;YACT,OAAO;iBACF,OAAO;;mBAEL,eAAe,GAAG,GAAG;;;;;;;;;WAD5B,MAAM;;AAVlB,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"}
|