@cypress-design/vue-docmenu 1.0.0 → 2.0.0-next.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 +5 -3
- package/CHANGELOG.md +11 -0
- package/_DocGroup.vue +6 -6
- package/_DocLink.vue +19 -15
- package/dist/_DocGroup.vue.d.ts.map +1 -1
- package/dist/_DocLink.vue.d.ts +1 -1
- package/dist/_DocLink.vue.d.ts.map +1 -1
- package/dist/index.es.mjs +149 -135
- 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 +4 -4
- package/vite.config.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
yarn run v1.22.22
|
|
1
2
|
$ yarn build:module && yarn build:types
|
|
2
3
|
$ yarn vite build
|
|
3
4
|
$ /home/runner/work/cypress-design/cypress-design/node_modules/.bin/vite build
|
|
@@ -7,8 +8,9 @@ transforming...
|
|
|
7
8
|
[32m✓[39m 10 modules transformed.
|
|
8
9
|
rendering chunks...
|
|
9
10
|
computing gzip size...
|
|
10
|
-
[2mdist/[22m[36mindex.es.mjs [39m[1m[2m11.
|
|
11
|
-
[2mdist/[22m[36mindex.umd.js [39m[1m[
|
|
12
|
-
[32m✓ built in
|
|
11
|
+
[2mdist/[22m[36mindex.es.mjs [39m[1m[2m11.64 kB[22m[1m[22m[2m │ gzip: 3.41 kB[22m[2m │ map: 17.54 kB[22m
|
|
12
|
+
[2mdist/[22m[36mindex.umd.js [39m[1m[2m8.89 kB[22m[1m[22m[2m │ gzip: 2.91 kB[22m[2m │ map: 17.04 kB[22m
|
|
13
|
+
[32m✓ built in 5.45s[39m
|
|
13
14
|
$ yarn vue-tsc --project ./tsconfig.build.json
|
|
14
15
|
$ /home/runner/work/cypress-design/cypress-design/node_modules/.bin/vue-tsc --project ./tsconfig.build.json
|
|
16
|
+
Done in 23.23s.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @cypress-design/vue-docmenu
|
|
2
2
|
|
|
3
|
+
## 2.0.0-next.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#468](https://github.com/cypress-io/cypress-design/pull/468) [`3236662`](https://github.com/cypress-io/cypress-design/commit/3236662fdecd5abbceadce750098a75301d48f88) Thanks [@elevatebart](https://github.com/elevatebart)! - refactor: use tailwind components to manage specificity of styles
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`3236662`](https://github.com/cypress-io/cypress-design/commit/3236662fdecd5abbceadce750098a75301d48f88)]:
|
|
12
|
+
- @cypress-design/vue-icon@2.0.0-next.0
|
|
13
|
+
|
|
3
14
|
## 1.0.0
|
|
4
15
|
|
|
5
16
|
### Major Changes
|
package/_DocGroup.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { computed, type DefineComponent, ref, watch, inject } from 'vue'
|
|
3
3
|
import { IconChevronDownSmall } from '@cypress-design/vue-icon'
|
|
4
|
-
import { NavGroup,
|
|
4
|
+
import { NavGroup, CssClasses } from '@cypress-design/constants-docmenu'
|
|
5
5
|
import DocGroupElements, {
|
|
6
6
|
hasActiveItemRecursively,
|
|
7
7
|
type DocGroupEventsEmitted,
|
|
@@ -83,10 +83,10 @@ defineExpose({
|
|
|
83
83
|
<component
|
|
84
84
|
:is="Head"
|
|
85
85
|
:class="[
|
|
86
|
-
|
|
86
|
+
CssClasses.button,
|
|
87
87
|
{
|
|
88
|
-
[
|
|
89
|
-
[
|
|
88
|
+
[CssClasses.topButton]: depth === 0,
|
|
89
|
+
[CssClasses.leafButton]: depth,
|
|
90
90
|
'text-indigo-500 dark:text-indigo-400': active,
|
|
91
91
|
'text-gray-900 dark:text-gray-100': hasActiveItem && !active,
|
|
92
92
|
'text-gray-800 dark:text-gray-200': !hasActiveItem && !active,
|
|
@@ -111,7 +111,7 @@ defineExpose({
|
|
|
111
111
|
stroke-color="current"
|
|
112
112
|
:size="depth ? '8' : '16'"
|
|
113
113
|
:class="[
|
|
114
|
-
|
|
114
|
+
CssClasses.expandedIcon,
|
|
115
115
|
{
|
|
116
116
|
'rotate-0': open,
|
|
117
117
|
'-rotate-90': !open,
|
|
@@ -146,7 +146,7 @@ defineExpose({
|
|
|
146
146
|
>
|
|
147
147
|
<div
|
|
148
148
|
v-if="open && collapsible && depth === 0"
|
|
149
|
-
:class="
|
|
149
|
+
:class="CssClasses.openListBorderLeft"
|
|
150
150
|
/>
|
|
151
151
|
<DocGroupElements
|
|
152
152
|
ref="$groupElements"
|
package/_DocLink.vue
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
nextTick,
|
|
9
9
|
computed,
|
|
10
10
|
} from 'vue'
|
|
11
|
-
import type
|
|
11
|
+
import { type NavItemLink, CssLink } from '@cypress-design/constants-docmenu'
|
|
12
12
|
|
|
13
13
|
const props = withDefaults(
|
|
14
14
|
defineProps<{
|
|
@@ -102,29 +102,33 @@ const itemWithoutLabel = computed(() => {
|
|
|
102
102
|
</script>
|
|
103
103
|
|
|
104
104
|
<template>
|
|
105
|
-
<li ref="$container" class="
|
|
105
|
+
<li ref="$container" :class="CssLink.wrapper">
|
|
106
106
|
<component
|
|
107
107
|
:is="linkComponent"
|
|
108
108
|
v-bind="itemWithoutLabel"
|
|
109
|
-
class="
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
:class="[
|
|
110
|
+
CssLink.static,
|
|
111
|
+
{
|
|
112
|
+
[CssLink.active]: active,
|
|
113
|
+
[CssLink.inactive]: !active,
|
|
114
|
+
[CssLink.negativeDepth]: depth < 0,
|
|
115
|
+
[CssLink.positiveDepth]: depth >= 0,
|
|
116
|
+
},
|
|
117
|
+
]"
|
|
116
118
|
:style="{
|
|
117
119
|
paddingLeft: depth >= 0 ? `${depth * 12 + 48}px` : undefined,
|
|
118
120
|
}"
|
|
119
121
|
>
|
|
120
122
|
<div
|
|
121
123
|
v-if="depth >= 0"
|
|
122
|
-
class="
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
:class="[
|
|
125
|
+
CssLink.markerStatic,
|
|
126
|
+
{
|
|
127
|
+
hidden: !markerIsMoving || !active,
|
|
128
|
+
'group-hover:block bg-gray-300': !active && collapsible,
|
|
129
|
+
'bg-indigo-500': active && markerIsMoving,
|
|
130
|
+
},
|
|
131
|
+
]"
|
|
128
132
|
/>
|
|
129
133
|
{{ item.label }}
|
|
130
134
|
</component>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_DocGroup.vue.d.ts","sourceRoot":"","sources":["../_DocGroup.vue"],"names":[],"mappings":"AAwKA,OAAO,EAAY,KAAK,eAAe,EAAsB,MAAM,KAAK,CAAA;AAExE,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"_DocGroup.vue.d.ts","sourceRoot":"","sources":["../_DocGroup.vue"],"names":[],"mappings":"AAwKA,OAAO,EAAY,KAAK,eAAe,EAAsB,MAAM,KAAK,CAAA;AAExE,OAAO,EAAE,QAAQ,EAAc,MAAM,mCAAmC,CAAA;AAyCxE,iBAAS,uBAAuB,SAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2SD,wBAQG;AAOH,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAC7C,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KAAC,CAAC,GACvC,CAAC,CAAC,CAAC,CAAC;CACP,CAAC;AAEN,KAAK,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC;AAExD,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AAC5D,KAAK,uBAAuB,CAAC,CAAC,IAAI;KAChC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACpC;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAC9D;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CACzD,CAAC"}
|
package/dist/_DocLink.vue.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DefineComponent } from 'vue';
|
|
2
|
-
import type
|
|
2
|
+
import { type NavItemLink } from '@cypress-design/constants-docmenu';
|
|
3
3
|
declare function setActiveMarkerPosition(): void;
|
|
4
4
|
declare const _default: DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
5
5
|
item: NavItemLink;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_DocLink.vue.d.ts","sourceRoot":"","sources":["../_DocLink.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_DocLink.vue.d.ts","sourceRoot":"","sources":["../_DocLink.vue"],"names":[],"mappings":"AA0IA,OAAO,EAEL,KAAK,eAAe,EAMrB,MAAM,KAAK,CAAA;AACZ,OAAO,EAAE,KAAK,WAAW,EAAW,MAAM,mCAAmC,CAAA;AA8B7E,iBAAS,uBAAuB,SAY/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwKD,wBAQG;AAOH,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAC7C,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KAAC,CAAC,GACvC,CAAC,CAAC,CAAC,CAAC;CACP,CAAC;AAEN,KAAK,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC;AAExD,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AAC5D,KAAK,uBAAuB,CAAC,CAAC,IAAI;KAChC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACpC;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAC9D;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CACzD,CAAC"}
|
package/dist/index.es.mjs
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { IconChevronDownSmall as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as B, ref as c, computed as P, inject as S, watch as M, openBlock as u, createElementBlock as k, Fragment as w, createBlock as C, resolveDynamicComponent as E, normalizeClass as y, unref as s, normalizeStyle as D, withCtx as G, createCommentVNode as A, createTextVNode as U, toDisplayString as H, createElementVNode as V, createVNode as L, onMounted as N, mergeProps as R, nextTick as W, renderList as j, provide as F } from "vue";
|
|
2
|
+
import { IconChevronDownSmall as q } from "@cypress-design/vue-icon";
|
|
3
|
+
const b = {
|
|
4
4
|
expandedIcon: "absolute left-0 transform transition-transform text-gray-400 dark:text-gray-700",
|
|
5
|
-
button: "
|
|
6
|
-
topButton: "
|
|
7
|
-
leafButton: "
|
|
8
|
-
openListBorderLeft: "
|
|
9
|
-
},
|
|
5
|
+
button: "cyds-docmenu-button",
|
|
6
|
+
topButton: "cyds-docmenu-topbutton",
|
|
7
|
+
leafButton: "cyds-docmenu-leafbutton",
|
|
8
|
+
openListBorderLeft: "cyds-docmenu-openlistborderleft"
|
|
9
|
+
}, g = {
|
|
10
|
+
wrapper: "cyds-docmenu-link-wrapper",
|
|
11
|
+
static: "cyds-docmenu-link-static group",
|
|
12
|
+
active: "cyds-docmenu-link-active",
|
|
13
|
+
inactive: "cyds-docmenu-link-inactive",
|
|
14
|
+
negativeDepth: "cyds-docmenu-link-negativedepth",
|
|
15
|
+
positiveDepth: "cyds-docmenu-link-positivedepth",
|
|
16
|
+
markerStatic: "cyds-docmenu-link-markerstatic"
|
|
17
|
+
}, J = /* @__PURE__ */ B({
|
|
10
18
|
__name: "_DocGroup",
|
|
11
19
|
props: {
|
|
12
20
|
group: {},
|
|
@@ -16,103 +24,103 @@ const k = {
|
|
|
16
24
|
depth: { default: 0 }
|
|
17
25
|
},
|
|
18
26
|
emits: ["updateActivePosition", "updateMarkerPosition", "hideMarker"],
|
|
19
|
-
setup(
|
|
20
|
-
const o =
|
|
27
|
+
setup(h, { expose: m, emit: v }) {
|
|
28
|
+
const o = h, i = c(o.group.collapsed !== !0), d = c(), f = c(), p = P(
|
|
21
29
|
() => o.collapsible ? "button" : o.group.href ? "a" : "div"
|
|
22
|
-
),
|
|
30
|
+
), r = v, e = P(
|
|
23
31
|
() => o.group.items.some((t) => "items" in t ? T(t.items, o.activePath) : t.href === o.activePath)
|
|
24
32
|
);
|
|
25
33
|
function n() {
|
|
26
34
|
var t;
|
|
27
|
-
(t =
|
|
35
|
+
(t = d.value) == null || t.reTriggerSetActiveGroup();
|
|
28
36
|
}
|
|
29
|
-
const
|
|
30
|
-
return
|
|
31
|
-
t &&
|
|
32
|
-
}),
|
|
33
|
-
e.value ? t ? n() :
|
|
34
|
-
}),
|
|
37
|
+
const a = P(() => o.group.href === o.activePath), $ = S("transition-is-moving", c(!1));
|
|
38
|
+
return M(a, (t) => {
|
|
39
|
+
t && r("hideMarker");
|
|
40
|
+
}), M(i, (t) => {
|
|
41
|
+
e.value ? t ? n() : r("hideMarker") : r("updateMarkerPosition");
|
|
42
|
+
}), M(
|
|
35
43
|
() => o.activePath,
|
|
36
44
|
() => {
|
|
37
45
|
e.value && !i.value && (i.value = !0);
|
|
38
46
|
}
|
|
39
|
-
),
|
|
47
|
+
), m({
|
|
40
48
|
reTriggerSetActiveGroup: n
|
|
41
|
-
}), (t,
|
|
42
|
-
(
|
|
43
|
-
class:
|
|
44
|
-
|
|
49
|
+
}), (t, l) => (u(), k(w, null, [
|
|
50
|
+
(u(), C(E(p.value), {
|
|
51
|
+
class: y([
|
|
52
|
+
s(b).button,
|
|
45
53
|
{
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
"text-indigo-500 dark:text-indigo-400":
|
|
49
|
-
"text-gray-900 dark:text-gray-100": e.value && !
|
|
50
|
-
"text-gray-800 dark:text-gray-200": !e.value && !
|
|
54
|
+
[s(b).topButton]: t.depth === 0,
|
|
55
|
+
[s(b).leafButton]: t.depth,
|
|
56
|
+
"text-indigo-500 dark:text-indigo-400": a.value,
|
|
57
|
+
"text-gray-900 dark:text-gray-100": e.value && !a.value,
|
|
58
|
+
"text-gray-800 dark:text-gray-200": !e.value && !a.value
|
|
51
59
|
}
|
|
52
60
|
]),
|
|
53
|
-
style:
|
|
61
|
+
style: D({
|
|
54
62
|
paddingLeft: t.depth >= 1 ? `${(t.depth - 1) * 12 + 48}px` : void 0
|
|
55
63
|
}),
|
|
56
64
|
href: t.group.href,
|
|
57
|
-
onClick:
|
|
58
|
-
t.collapsible ? i.value = !i.value :
|
|
65
|
+
onClick: l[0] || (l[0] = () => {
|
|
66
|
+
t.collapsible ? i.value = !i.value : r("updateActivePosition");
|
|
59
67
|
})
|
|
60
68
|
}, {
|
|
61
|
-
default:
|
|
62
|
-
o.collapsible ? (
|
|
69
|
+
default: G(() => [
|
|
70
|
+
o.collapsible ? (u(), C(s(q), {
|
|
63
71
|
key: 0,
|
|
64
72
|
"stroke-color": "current",
|
|
65
73
|
size: t.depth ? "8" : "16",
|
|
66
|
-
class:
|
|
67
|
-
|
|
74
|
+
class: y([
|
|
75
|
+
s(b).expandedIcon,
|
|
68
76
|
{
|
|
69
77
|
"rotate-0": i.value,
|
|
70
78
|
"-rotate-90": !i.value
|
|
71
79
|
}
|
|
72
80
|
]),
|
|
73
|
-
style:
|
|
81
|
+
style: D({
|
|
74
82
|
marginLeft: t.depth >= 1 ? `${(t.depth - 1) * 12 + 28}px` : void 0
|
|
75
83
|
})
|
|
76
84
|
}, null, 8, ["size", "class", "style"])) : A("", !0),
|
|
77
|
-
|
|
85
|
+
U(" " + H(t.group.label), 1)
|
|
78
86
|
]),
|
|
79
87
|
_: 1
|
|
80
88
|
}, 8, ["class", "style", "href"])),
|
|
81
|
-
|
|
89
|
+
V("div", {
|
|
82
90
|
ref_key: "$listWrapper",
|
|
83
|
-
ref:
|
|
84
|
-
class:
|
|
91
|
+
ref: f,
|
|
92
|
+
class: y(["grid transition-all relative", {
|
|
85
93
|
"grid-rows-[0fr]": !i.value && t.collapsible,
|
|
86
94
|
"grid-rows-[1fr]": i.value || !t.collapsible
|
|
87
95
|
}]),
|
|
88
|
-
onTransitionstart:
|
|
89
|
-
|
|
96
|
+
onTransitionstart: l[4] || (l[4] = () => {
|
|
97
|
+
$.value = !0;
|
|
90
98
|
}),
|
|
91
|
-
onTransitionend:
|
|
92
|
-
|
|
99
|
+
onTransitionend: l[5] || (l[5] = () => {
|
|
100
|
+
$.value = !1, (i.value || !e.value) && r("updateMarkerPosition");
|
|
93
101
|
})
|
|
94
102
|
}, [
|
|
95
|
-
i.value && t.collapsible && t.depth === 0 ? (
|
|
103
|
+
i.value && t.collapsible && t.depth === 0 ? (u(), k("div", {
|
|
96
104
|
key: 0,
|
|
97
|
-
class:
|
|
105
|
+
class: y(s(b).openListBorderLeft)
|
|
98
106
|
}, null, 2)) : A("", !0),
|
|
99
|
-
|
|
107
|
+
L(z, {
|
|
100
108
|
ref_key: "$groupElements",
|
|
101
|
-
ref:
|
|
109
|
+
ref: d,
|
|
102
110
|
class: "overflow-hidden",
|
|
103
111
|
depth: t.depth,
|
|
104
112
|
items: t.group.items,
|
|
105
113
|
"active-path": t.activePath,
|
|
106
114
|
collapsible: t.collapsible,
|
|
107
115
|
"link-component": t.linkComponent,
|
|
108
|
-
onHideMarker:
|
|
109
|
-
onUpdateMarkerPosition:
|
|
110
|
-
onUpdateActivePosition:
|
|
116
|
+
onHideMarker: l[1] || (l[1] = (I) => r("hideMarker")),
|
|
117
|
+
onUpdateMarkerPosition: l[2] || (l[2] = () => r("updateMarkerPosition")),
|
|
118
|
+
onUpdateActivePosition: l[3] || (l[3] = (I) => i.value ? r("updateActivePosition", I) : null)
|
|
111
119
|
}, null, 8, ["depth", "items", "active-path", "collapsible", "link-component"])
|
|
112
120
|
], 34)
|
|
113
121
|
], 64));
|
|
114
122
|
}
|
|
115
|
-
}),
|
|
123
|
+
}), K = /* @__PURE__ */ B({
|
|
116
124
|
__name: "_DocLink",
|
|
117
125
|
props: {
|
|
118
126
|
item: {},
|
|
@@ -122,37 +130,37 @@ const k = {
|
|
|
122
130
|
linkComponent: {}
|
|
123
131
|
},
|
|
124
132
|
emits: ["update:active"],
|
|
125
|
-
setup(
|
|
126
|
-
const o =
|
|
127
|
-
function
|
|
128
|
-
o.active &&
|
|
129
|
-
var
|
|
130
|
-
const { top: e = 0, height: n = 36 } = ((
|
|
133
|
+
setup(h, { expose: m, emit: v }) {
|
|
134
|
+
const o = h, i = v, d = c(), f = S("transition-is-moving", c(!1));
|
|
135
|
+
function p() {
|
|
136
|
+
o.active && W(() => {
|
|
137
|
+
var a;
|
|
138
|
+
const { top: e = 0, height: n = 36 } = ((a = d.value) == null ? void 0 : a.getBoundingClientRect()) ?? {};
|
|
131
139
|
i("update:active", o.active, {
|
|
132
140
|
top: e,
|
|
133
141
|
height: n
|
|
134
142
|
});
|
|
135
143
|
});
|
|
136
144
|
}
|
|
137
|
-
|
|
138
|
-
|
|
145
|
+
N(() => {
|
|
146
|
+
M(
|
|
139
147
|
() => o.active,
|
|
140
148
|
(e) => {
|
|
141
|
-
e ?
|
|
149
|
+
e ? p() : i("update:active", e);
|
|
142
150
|
},
|
|
143
151
|
{ immediate: !0 }
|
|
144
152
|
);
|
|
145
|
-
}),
|
|
146
|
-
setActiveMarkerPosition:
|
|
147
|
-
}),
|
|
153
|
+
}), m({
|
|
154
|
+
setActiveMarkerPosition: p
|
|
155
|
+
}), M(
|
|
148
156
|
() => o.active,
|
|
149
157
|
(e) => {
|
|
150
158
|
setTimeout(() => {
|
|
151
|
-
if (e &&
|
|
152
|
-
const n =
|
|
159
|
+
if (e && d.value) {
|
|
160
|
+
const n = d.value.getBoundingClientRect();
|
|
153
161
|
if (n.top > 0 && n.bottom < window.innerHeight && n.left > 0 && n.right < window.innerWidth)
|
|
154
162
|
return;
|
|
155
|
-
|
|
163
|
+
d.value.scrollIntoView({
|
|
156
164
|
block: "nearest",
|
|
157
165
|
inline: "nearest"
|
|
158
166
|
});
|
|
@@ -160,49 +168,55 @@ const k = {
|
|
|
160
168
|
}, 200);
|
|
161
169
|
}
|
|
162
170
|
);
|
|
163
|
-
const
|
|
171
|
+
const r = P(() => {
|
|
164
172
|
const { label: e, ...n } = o.item;
|
|
165
173
|
return n;
|
|
166
174
|
});
|
|
167
|
-
return (e, n) => (
|
|
175
|
+
return (e, n) => (u(), k("li", {
|
|
168
176
|
ref_key: "$container",
|
|
169
|
-
ref:
|
|
170
|
-
class:
|
|
177
|
+
ref: d,
|
|
178
|
+
class: y(s(g).wrapper)
|
|
171
179
|
}, [
|
|
172
|
-
(
|
|
173
|
-
class: [
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
180
|
+
(u(), C(E(e.linkComponent), R(r.value, {
|
|
181
|
+
class: [
|
|
182
|
+
s(g).static,
|
|
183
|
+
{
|
|
184
|
+
[s(g).active]: e.active,
|
|
185
|
+
[s(g).inactive]: !e.active,
|
|
186
|
+
[s(g).negativeDepth]: e.depth < 0,
|
|
187
|
+
[s(g).positiveDepth]: e.depth >= 0
|
|
188
|
+
}
|
|
189
|
+
],
|
|
179
190
|
style: {
|
|
180
191
|
paddingLeft: e.depth >= 0 ? `${e.depth * 12 + 48}px` : void 0
|
|
181
192
|
}
|
|
182
193
|
}), {
|
|
183
|
-
default:
|
|
184
|
-
e.depth >= 0 ? (
|
|
194
|
+
default: G(() => [
|
|
195
|
+
e.depth >= 0 ? (u(), k("div", {
|
|
185
196
|
key: 0,
|
|
186
|
-
class:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
197
|
+
class: y([
|
|
198
|
+
s(g).markerStatic,
|
|
199
|
+
{
|
|
200
|
+
hidden: !s(f) || !e.active,
|
|
201
|
+
"group-hover:block bg-gray-300": !e.active && e.collapsible,
|
|
202
|
+
"bg-indigo-500": e.active && s(f)
|
|
203
|
+
}
|
|
204
|
+
])
|
|
191
205
|
}, null, 2)) : A("", !0),
|
|
192
|
-
|
|
206
|
+
U(" " + H(e.item.label), 1)
|
|
193
207
|
]),
|
|
194
208
|
_: 1
|
|
195
209
|
}, 16, ["class", "style"]))
|
|
196
|
-
],
|
|
210
|
+
], 2));
|
|
197
211
|
}
|
|
198
|
-
}),
|
|
212
|
+
}), O = { class: "list-none p-0" }, Q = {
|
|
199
213
|
key: 0,
|
|
200
214
|
class: "relative list-none p-0"
|
|
201
215
|
};
|
|
202
|
-
function T(
|
|
203
|
-
return
|
|
216
|
+
function T(h, m) {
|
|
217
|
+
return h.some((v) => "items" in v ? T(v.items, m) : v.href === m);
|
|
204
218
|
}
|
|
205
|
-
const
|
|
219
|
+
const z = /* @__PURE__ */ B({
|
|
206
220
|
__name: "_DocGroupElements",
|
|
207
221
|
props: {
|
|
208
222
|
items: {},
|
|
@@ -212,31 +226,31 @@ const U = /* @__PURE__ */ C({
|
|
|
212
226
|
depth: {}
|
|
213
227
|
},
|
|
214
228
|
emits: ["updateActivePosition", "updateMarkerPosition", "hideMarker"],
|
|
215
|
-
setup(
|
|
216
|
-
const o =
|
|
229
|
+
setup(h, { expose: m, emit: v }) {
|
|
230
|
+
const o = h, i = v, d = c([]), f = c([]), p = P(
|
|
217
231
|
() => o.items.some((e) => "items" in e ? T(e.items, o.activePath) : e.href === o.activePath)
|
|
218
232
|
);
|
|
219
|
-
function
|
|
220
|
-
|
|
221
|
-
|
|
233
|
+
function r(e = -1) {
|
|
234
|
+
d.value.forEach((a) => {
|
|
235
|
+
a.setActiveMarkerPosition();
|
|
222
236
|
});
|
|
223
237
|
const n = e - // remove all the items that are not groups from the array and count them
|
|
224
|
-
o.items.slice(0, e).filter((
|
|
225
|
-
|
|
226
|
-
|
|
238
|
+
o.items.slice(0, e).filter((a) => !("items" in a)).length;
|
|
239
|
+
f.value.slice(n + 1).forEach((a) => {
|
|
240
|
+
a.reTriggerSetActiveGroup();
|
|
227
241
|
});
|
|
228
242
|
}
|
|
229
|
-
return
|
|
230
|
-
reTriggerSetActiveGroup:
|
|
231
|
-
}), (e, n) => (
|
|
232
|
-
(
|
|
233
|
-
|
|
234
|
-
|
|
243
|
+
return m({
|
|
244
|
+
reTriggerSetActiveGroup: r
|
|
245
|
+
}), (e, n) => (u(), k("ul", O, [
|
|
246
|
+
(u(!0), k(w, null, j(e.items, (a, $) => (u(), k(w, null, [
|
|
247
|
+
a && "items" in a ? (u(), k("li", Q, [
|
|
248
|
+
L(J, {
|
|
235
249
|
ref_for: !0,
|
|
236
250
|
ref_key: "$groups",
|
|
237
|
-
ref:
|
|
251
|
+
ref: f,
|
|
238
252
|
"active-path": e.activePath,
|
|
239
|
-
group:
|
|
253
|
+
group: a,
|
|
240
254
|
depth: e.depth + 1,
|
|
241
255
|
collapsible: e.collapsible,
|
|
242
256
|
"link-component": e.linkComponent,
|
|
@@ -244,23 +258,23 @@ const U = /* @__PURE__ */ C({
|
|
|
244
258
|
i("updateActivePosition", t);
|
|
245
259
|
}),
|
|
246
260
|
onUpdateMarkerPosition: () => {
|
|
247
|
-
|
|
261
|
+
p.value ? r($) : i("updateMarkerPosition");
|
|
248
262
|
},
|
|
249
263
|
onHideMarker: n[1] || (n[1] = (t) => i("hideMarker"))
|
|
250
264
|
}, null, 8, ["active-path", "group", "depth", "collapsible", "link-component", "onUpdateMarkerPosition"])
|
|
251
|
-
])) : (
|
|
265
|
+
])) : (u(), C(K, {
|
|
252
266
|
key: 1,
|
|
253
267
|
ref_for: !0,
|
|
254
268
|
ref_key: "$items",
|
|
255
|
-
ref:
|
|
256
|
-
item:
|
|
257
|
-
active:
|
|
269
|
+
ref: d,
|
|
270
|
+
item: a,
|
|
271
|
+
active: a.href === e.activePath,
|
|
258
272
|
depth: e.depth,
|
|
259
273
|
collapsible: e.collapsible,
|
|
260
274
|
"link-component": e.linkComponent,
|
|
261
|
-
"onUpdate:active": n[2] || (n[2] = (t,
|
|
262
|
-
if (
|
|
263
|
-
e.depth < 0 ? i("hideMarker") : i("updateActivePosition",
|
|
275
|
+
"onUpdate:active": n[2] || (n[2] = (t, l) => {
|
|
276
|
+
if (l)
|
|
277
|
+
e.depth < 0 ? i("hideMarker") : i("updateActivePosition", l);
|
|
264
278
|
else
|
|
265
279
|
return;
|
|
266
280
|
})
|
|
@@ -268,7 +282,7 @@ const U = /* @__PURE__ */ C({
|
|
|
268
282
|
], 64))), 256))
|
|
269
283
|
]));
|
|
270
284
|
}
|
|
271
|
-
}),
|
|
285
|
+
}), Z = /* @__PURE__ */ B({
|
|
272
286
|
__name: "DocMenu",
|
|
273
287
|
props: {
|
|
274
288
|
items: {},
|
|
@@ -276,43 +290,43 @@ const U = /* @__PURE__ */ C({
|
|
|
276
290
|
collapsible: { type: Boolean, default: !0 },
|
|
277
291
|
linkComponent: { default: "a" }
|
|
278
292
|
},
|
|
279
|
-
setup(
|
|
280
|
-
const
|
|
281
|
-
function
|
|
293
|
+
setup(h) {
|
|
294
|
+
const m = c(), v = c(0), o = c(36), i = c(!1);
|
|
295
|
+
function d({ top: p, height: r } = { height: 0, top: 0 }) {
|
|
282
296
|
var n;
|
|
283
|
-
const e = ((n =
|
|
284
|
-
v.value =
|
|
297
|
+
const e = ((n = m.value) == null ? void 0 : n.getBoundingClientRect().top) || 0;
|
|
298
|
+
v.value = p - e, o.value = r, i.value = !0;
|
|
285
299
|
}
|
|
286
|
-
const
|
|
287
|
-
return
|
|
300
|
+
const f = c(!1);
|
|
301
|
+
return F("transition-is-moving", f), (p, r) => (u(), k("div", {
|
|
288
302
|
ref_key: "$container",
|
|
289
|
-
ref:
|
|
303
|
+
ref: m,
|
|
290
304
|
class: "relative"
|
|
291
305
|
}, [
|
|
292
|
-
i.value &&
|
|
306
|
+
i.value && p.collapsible && !f.value ? (u(), k("div", {
|
|
293
307
|
key: 0,
|
|
294
308
|
"data-cy": "doc-menu-active-marker",
|
|
295
309
|
class: "absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px]",
|
|
296
|
-
style:
|
|
310
|
+
style: D({
|
|
297
311
|
top: `${v.value}px`,
|
|
298
312
|
height: `${o.value - 8}px`
|
|
299
313
|
})
|
|
300
314
|
}, null, 4)) : A("", !0),
|
|
301
|
-
|
|
302
|
-
items:
|
|
303
|
-
"active-path":
|
|
304
|
-
collapsible:
|
|
305
|
-
"link-component":
|
|
315
|
+
L(z, {
|
|
316
|
+
items: p.items,
|
|
317
|
+
"active-path": p.activePath,
|
|
318
|
+
collapsible: p.collapsible,
|
|
319
|
+
"link-component": p.linkComponent,
|
|
306
320
|
depth: -1,
|
|
307
|
-
onUpdateActivePosition:
|
|
308
|
-
onHideMarker:
|
|
321
|
+
onUpdateActivePosition: d,
|
|
322
|
+
onHideMarker: r[0] || (r[0] = (e) => i.value = !1)
|
|
309
323
|
}, null, 8, ["items", "active-path", "collapsible", "link-component"])
|
|
310
324
|
], 512));
|
|
311
325
|
}
|
|
312
326
|
});
|
|
313
327
|
export {
|
|
314
|
-
|
|
328
|
+
Z as default
|
|
315
329
|
};
|
|
316
330
|
//# sourceMappingURL=index.es.mjs.map
|
|
317
331
|
|
|
318
|
-
/* <wind-keep class="container relative absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px] filter list-none p-0 text-indigo-500 dark:text-indigo-400 text-gray-900 dark:text-gray-100 text-gray-800 dark:text-gray-200 rotate-0 -rotate-90 grid grid-rows-[0fr] grid-rows-[1fr] overflow-hidden text-indigo-400 text-gray-100 text-gray-200 icon-dark-current visible block inline
|
|
332
|
+
/* <wind-keep class="container relative absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px] filter list-none p-0 text-indigo-500 dark:text-indigo-400 text-gray-900 dark:text-gray-100 text-gray-800 dark:text-gray-200 rotate-0 -rotate-90 grid grid-rows-[0fr] grid-rows-[1fr] overflow-hidden text-indigo-400 text-gray-100 text-gray-200 icon-dark-current visible block inline static hidden group-hover:block bg-gray-300"> */
|
package/dist/index.es.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.mjs","sources":["../../constants/dist/index.js","../_DocGroup.vue","../_DocLink.vue","../_DocGroupElements.vue","../DocMenu.vue"],"sourcesContent":["export const classes = {\n expandedIcon: 'absolute left-0 transform transition-transform text-gray-400 dark:text-gray-700',\n button: 'flex leading-[24px] py-[10px] items-center relative w-full text-start',\n topButton: 'leading-[24px] text-[16px] pl-[24px] font-medium',\n leafButton: 'leading-[20px] text-[14px] pl-[48px]',\n openListBorderLeft: 'absolute left-[8px] top-0 w-[1px] h-full bg-gray-100 dark:bg-gray-900',\n};\n","<script lang=\"ts\" setup>\nimport { computed, type DefineComponent, ref, watch, inject } from 'vue'\nimport { IconChevronDownSmall } from '@cypress-design/vue-icon'\nimport { NavGroup, classes } from '@cypress-design/constants-docmenu'\nimport DocGroupElements, {\n hasActiveItemRecursively,\n type DocGroupEventsEmitted,\n} from './_DocGroupElements.vue'\n\nconst props = withDefaults(\n defineProps<{\n group: NavGroup\n activePath?: string\n collapsible: boolean\n linkComponent: DefineComponent | 'a'\n depth?: number\n }>(),\n {\n depth: 0,\n },\n)\n\nconst open = ref(props.group.collapsed !== true)\nconst $groupElements = ref<typeof DocGroupElements>()\nconst $listWrapper = ref<HTMLDivElement>()\n\nconst Head = computed(() =>\n props.collapsible ? 'button' : props.group.href ? 'a' : 'div',\n)\n\nconst emit = defineEmits<DocGroupEventsEmitted>()\n\nconst hasActiveItem = computed(() =>\n props.group.items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items, props.activePath)\n }\n return item.href === props.activePath\n }),\n)\n\nfunction reTriggerSetActiveGroup() {\n $groupElements.value?.reTriggerSetActiveGroup()\n}\n\nconst active = computed(() => props.group.href === props.activePath)\n\nconst markerIsMoving = inject('transition-is-moving', ref(false))\n\nwatch(active, (active) => {\n if (active) {\n emit('hideMarker')\n }\n})\n\nwatch(open, (open) => {\n if (hasActiveItem.value) {\n if (open) {\n reTriggerSetActiveGroup()\n } else {\n emit('hideMarker')\n }\n } else {\n emit('updateMarkerPosition')\n }\n})\n\nwatch(\n () => props.activePath,\n () => {\n if (hasActiveItem.value && !open.value) {\n open.value = true\n }\n },\n)\n\ndefineExpose({\n reTriggerSetActiveGroup,\n})\n</script>\n\n<template>\n <component\n :is=\"Head\"\n :class=\"[\n classes.button,\n {\n [classes.topButton]: depth === 0,\n [classes.leafButton]: depth,\n 'text-indigo-500 dark:text-indigo-400': active,\n 'text-gray-900 dark:text-gray-100': hasActiveItem && !active,\n 'text-gray-800 dark:text-gray-200': !hasActiveItem && !active,\n },\n ]\"\n :style=\"{\n paddingLeft: depth >= 1 ? `${(depth - 1) * 12 + 48}px` : undefined,\n }\"\n :href=\"group.href\"\n @click=\"\n () => {\n if (collapsible) {\n open = !open\n } else {\n emit('updateActivePosition')\n }\n }\n \"\n >\n <IconChevronDownSmall\n v-if=\"props.collapsible\"\n stroke-color=\"current\"\n :size=\"depth ? '8' : '16'\"\n :class=\"[\n classes.expandedIcon,\n {\n 'rotate-0': open,\n '-rotate-90': !open,\n },\n ]\"\n :style=\"{\n marginLeft: depth >= 1 ? `${(depth - 1) * 12 + 28}px` : undefined,\n }\"\n />\n {{ group.label }}\n </component>\n <div\n ref=\"$listWrapper\"\n class=\"grid transition-all relative\"\n :class=\"{\n 'grid-rows-[0fr]': !open && collapsible,\n 'grid-rows-[1fr]': open || !collapsible,\n }\"\n @transitionstart=\"\n () => {\n markerIsMoving = true\n }\n \"\n @transitionend=\"\n () => {\n markerIsMoving = false\n if (open || !hasActiveItem) {\n emit('updateMarkerPosition')\n }\n }\n \"\n >\n <div\n v-if=\"open && collapsible && depth === 0\"\n :class=\"classes.openListBorderLeft\"\n />\n <DocGroupElements\n ref=\"$groupElements\"\n class=\"overflow-hidden\"\n :depth=\"depth\"\n :items=\"group.items\"\n :active-path=\"activePath\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n @hide-marker=\"emit('hideMarker')\"\n @update-marker-position=\"() => emit('updateMarkerPosition')\"\n @update-active-position=\"\n (opts) => (open ? emit('updateActivePosition', opts) : null)\n \"\n />\n </div>\n</template>\n","<script lang=\"ts\" setup>\nimport {\n watch,\n type DefineComponent,\n ref,\n onMounted,\n inject,\n nextTick,\n computed,\n} from 'vue'\nimport type { NavItemLink } from '@cypress-design/constants-docmenu'\n\nconst props = withDefaults(\n defineProps<{\n item: NavItemLink\n active: boolean\n collapsible: boolean\n depth?: number\n linkComponent: DefineComponent | 'a'\n }>(),\n {\n depth: -1,\n },\n)\n\nconst emit = defineEmits<{\n (\n event: 'update:active',\n active: boolean,\n opts?: { top: number; height: number },\n ): void\n}>()\n\nconst $container = ref<HTMLLIElement>()\n\nconst markerIsMoving = inject('transition-is-moving', ref(false))\n\nfunction setActiveMarkerPosition() {\n if (props.active) {\n nextTick(() => {\n const { top = 0, height = 36 } =\n $container.value?.getBoundingClientRect() ?? {}\n\n emit('update:active', props.active, {\n top,\n height,\n })\n })\n }\n}\n\nonMounted(() => {\n watch(\n () => props.active,\n (active) => {\n if (active) {\n setActiveMarkerPosition()\n } else {\n emit('update:active', active)\n }\n },\n { immediate: true },\n )\n})\n\ndefineExpose({\n setActiveMarkerPosition,\n})\n\nwatch(\n () => props.active,\n (active) => {\n setTimeout(() => {\n if (active && $container.value) {\n // if active check if the item is visible in the\n // viewport and scrollIntoView if not\n const rect = $container.value.getBoundingClientRect()\n\n if (\n rect.top > 0 &&\n rect.bottom < window.innerHeight &&\n rect.left > 0 &&\n rect.right < window.innerWidth\n ) {\n return\n }\n\n $container.value.scrollIntoView({\n block: 'nearest',\n inline: 'nearest',\n })\n }\n }, 200)\n },\n)\n\nconst itemWithoutLabel = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { label, ...rest } = props.item\n return rest\n})\n</script>\n\n<template>\n <li ref=\"$container\" class=\"list-none p-0 scroll-my-10\">\n <component\n :is=\"linkComponent\"\n v-bind=\"itemWithoutLabel\"\n class=\"group relative block w-full pl-[24px]\"\n :class=\"{\n 'text-indigo-500 dark:text-indigo-400': active,\n 'text-gray-700 dark:text-gray-500': !active,\n 'py-[8px] text-[16px] leading-[24px]': depth < 0,\n 'leading-[20px] text-[14px] py-[12px]': depth >= 0,\n }\"\n :style=\"{\n paddingLeft: depth >= 0 ? `${depth * 12 + 48}px` : undefined,\n }\"\n >\n <div\n v-if=\"depth >= 0\"\n class=\"left-[6.5px] absolute top-[4px] bottom-[4px] w-[4px] z-10 rounded-full\"\n :class=\"{\n hidden: !markerIsMoving || !active,\n 'group-hover:block bg-gray-300': !active && collapsible,\n 'bg-indigo-500': active && markerIsMoving,\n }\"\n />\n {{ item.label }}\n </component>\n </li>\n</template>\n","<script lang=\"ts\">\nexport function hasActiveItemRecursively(\n items: (NavGroup | NavItemLink)[],\n activePath?: string,\n): boolean {\n return items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items, activePath)\n }\n return item.href === activePath\n })\n}\n\nexport interface DocGroupEventsEmitted {\n /**\n * If the group is not collapsed, this event will emit the\n * active marker position all the way to the menu component\n */\n (event: 'updateActivePosition', opts?: { top: number; height: number }): void\n /**\n * This event will trigger a re-render of the active marker\n * to update its position if not in the current subtree\n */\n (event: 'updateMarkerPosition'): void\n /**\n * This event will bubble-up and hide the active marker\n */\n (event: 'hideMarker'): void\n}\n</script>\n\n<script lang=\"ts\" setup>\nimport { DefineComponent, computed, ref } from 'vue'\nimport { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu'\nimport DocGroup from './_DocGroup.vue'\nimport DocLink from './_DocLink.vue'\n\nconst props = defineProps<{\n items: (NavGroup | NavItemLink)[]\n activePath?: string\n collapsible: boolean\n linkComponent: DefineComponent | 'a'\n depth: number\n}>()\n\nconst emit = defineEmits<DocGroupEventsEmitted>()\n\nconst $items = ref<(typeof DocLink)[]>([])\nconst $groups = ref<(typeof DocGroup)[]>([])\n\nconst hasActiveItem = computed(() =>\n props.items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items, props.activePath)\n }\n return item.href === props.activePath\n }),\n)\n\n/**\n * update the position of the marker when opening a group\n * @param index\n */\nfunction reTriggerSetActiveGroup(index = -1) {\n $items.value.forEach((item) => {\n item.setActiveMarkerPosition()\n })\n\n // calculate the index of the calling group in the list of groups\n const indexGroup =\n index -\n // remove all the items that are not groups from the array and count them\n props.items.slice(0, index).filter((item) => !('items' in item)).length\n\n // only update groups that come after the toggled one\n // others will not need to update the marker\n // since they are \"before\" in the rendering tree\n $groups.value.slice(indexGroup + 1).forEach((group) => {\n group.reTriggerSetActiveGroup()\n })\n}\n\ndefineExpose({\n reTriggerSetActiveGroup,\n})\n</script>\n\n<template>\n <ul class=\"list-none p-0\">\n <template v-for=\"(item, index) in items\">\n <li v-if=\"item && 'items' in item\" class=\"relative list-none p-0\">\n <DocGroup\n ref=\"$groups\"\n :active-path=\"activePath\"\n :group=\"item\"\n :depth=\"depth + 1\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n @update-active-position=\"\n (opts) => {\n emit('updateActivePosition', opts)\n }\n \"\n @update-marker-position=\"\n () => {\n if (hasActiveItem) {\n reTriggerSetActiveGroup(index)\n } else {\n emit('updateMarkerPosition')\n }\n }\n \"\n @hide-marker=\"emit('hideMarker')\"\n />\n </li>\n <DocLink\n v-else\n ref=\"$items\"\n :item=\"item\"\n :active=\"item.href === activePath\"\n :depth=\"depth\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n @update:active=\"\n (_, opts) => {\n if (!opts) {\n return\n } else if (depth < 0) {\n emit('hideMarker')\n } else {\n emit('updateActivePosition', opts)\n }\n }\n \"\n />\n </template>\n </ul>\n</template>\n","<script lang=\"ts\" setup>\nimport { ref, type DefineComponent, provide } from 'vue'\nimport { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu'\nimport DocGroupElements from './_DocGroupElements.vue'\n\nwithDefaults(\n defineProps<{\n items: (NavItemLink | NavGroup)[]\n activePath?: string\n collapsible?: boolean\n linkComponent?: DefineComponent | 'a'\n }>(),\n {\n linkComponent: 'a',\n collapsible: true,\n activePath: undefined,\n },\n)\n\nconst $container = ref<HTMLDivElement>()\n\nconst activeTop = ref(0)\nconst activeHeight = ref(36)\nconst showMarker = ref(false)\n\nfunction updateActiveMarkerPosition({ top, height } = { height: 0, top: 0 }) {\n const containerTop = $container.value?.getBoundingClientRect().top || 0\n activeTop.value = top - containerTop\n activeHeight.value = height\n showMarker.value = true\n}\n\nconst markerIsMoving = ref(false)\n\nprovide('transition-is-moving', markerIsMoving)\n</script>\n\n<template>\n <div ref=\"$container\" class=\"relative\">\n <div\n v-if=\"showMarker && collapsible && !markerIsMoving\"\n data-cy=\"doc-menu-active-marker\"\n class=\"absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px]\"\n :style=\"{\n top: `${activeTop}px`,\n height: `${activeHeight - 8}px`,\n }\"\n />\n <DocGroupElements\n :items=\"items\"\n :active-path=\"activePath\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n :depth=\"-1\"\n @update-active-position=\"updateActiveMarkerPosition\"\n @hide-marker=\"showMarker = false\"\n />\n </div>\n</template>\n"],"names":["classes","props","__props","open","ref","$groupElements","$listWrapper","Head","computed","emit","__emit","hasActiveItem","item","hasActiveItemRecursively","reTriggerSetActiveGroup","_a","active","markerIsMoving","inject","watch","__expose","$container","setActiveMarkerPosition","nextTick","top","height","onMounted","rect","itemWithoutLabel","label","rest","items","activePath","$items","$groups","index","indexGroup","group","activeTop","activeHeight","showMarker","updateActiveMarkerPosition","containerTop","provide"],"mappings":";;AAAO,MAAMA,IAAU;AAAA,EACnB,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,oBAAoB;AACxB;;;;;;;;;;;ACGA,UAAMC,IAAQC,GAaRC,IAAOC,EAAIH,EAAM,MAAM,cAAc,EAAI,GACzCI,IAAiBD,KACjBE,IAAeF,KAEfG,IAAOC;AAAA,MAAS,MACpBP,EAAM,cAAc,WAAWA,EAAM,MAAM,OAAO,MAAM;AAAA,IAAA,GAGpDQ,IAAOC,GAEPC,IAAgBH;AAAA,MAAS,MAC7BP,EAAM,MAAM,MAAM,KAAK,CAACW,MAClB,WAAWA,IACNC,EAAyBD,EAAK,OAAOX,EAAM,UAAU,IAEvDW,EAAK,SAASX,EAAM,UAC5B;AAAA,IAAA;AAGH,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D;AAAA,MAEAlC,EAAM,MAAM,MAAM,GAAGkC,CAAK,EAAE,OAAO,CAACvB,MAAS,EAAE,WAAWA,EAAK,EAAE;AAKnE,MAAAsB,EAAQ,MAAM,MAAME,IAAa,CAAC,EAAE,QAAQ,CAACC,MAAU;AACrD,QAAAA,EAAM,wBAAwB;AAAA,MAAA,CAC/B;AAAA,IACH;AAEa,WAAAjB,EAAA;AAAA,MACX,yBAAAN;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjED,UAAMO,IAAajB,KAEbkC,IAAYlC,EAAI,CAAC,GACjBmC,IAAenC,EAAI,EAAE,GACrBoC,IAAapC,EAAI,EAAK;AAEnB,aAAAqC,EAA2B,EAAE,KAAAjB,GAAK,QAAAC,EAAO,IAAI,EAAE,QAAQ,GAAG,KAAK,KAAK;;AAC3E,YAAMiB,MAAe3B,IAAAM,EAAW,UAAX,gBAAAN,EAAkB,wBAAwB,QAAO;AACtE,MAAAuB,EAAU,QAAQd,IAAMkB,GACxBH,EAAa,QAAQd,GACrBe,EAAW,QAAQ;AAAA,IACrB;AAEM,UAAAvB,IAAiBb,EAAI,EAAK;AAEhC,WAAAuC,EAAQ,wBAAwB1B,CAAc;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.es.mjs","sources":["../../constants/dist/index.es.mjs","../_DocGroup.vue","../_DocLink.vue","../_DocGroupElements.vue","../DocMenu.vue"],"sourcesContent":["const CssClasses = {\n expandedIcon: \"absolute left-0 transform transition-transform text-gray-400 dark:text-gray-700\",\n button: \"cyds-docmenu-button\",\n topButton: \"cyds-docmenu-topbutton\",\n leafButton: \"cyds-docmenu-leafbutton\",\n openListBorderLeft: \"cyds-docmenu-openlistborderleft\"\n};\n\nconst CssLink = {\n wrapper: \"cyds-docmenu-link-wrapper\",\n static: \"cyds-docmenu-link-static group\",\n active: \"cyds-docmenu-link-active\",\n inactive: \"cyds-docmenu-link-inactive\",\n negativeDepth: \"cyds-docmenu-link-negativedepth\",\n positiveDepth: \"cyds-docmenu-link-positivedepth\",\n markerStatic: \"cyds-docmenu-link-markerstatic\"\n};\n\nexport { CssClasses, CssLink };\n//# sourceMappingURL=index.es.mjs.map\n","<script lang=\"ts\" setup>\nimport { computed, type DefineComponent, ref, watch, inject } from 'vue'\nimport { IconChevronDownSmall } from '@cypress-design/vue-icon'\nimport { NavGroup, CssClasses } from '@cypress-design/constants-docmenu'\nimport DocGroupElements, {\n hasActiveItemRecursively,\n type DocGroupEventsEmitted,\n} from './_DocGroupElements.vue'\n\nconst props = withDefaults(\n defineProps<{\n group: NavGroup\n activePath?: string\n collapsible: boolean\n linkComponent: DefineComponent | 'a'\n depth?: number\n }>(),\n {\n depth: 0,\n },\n)\n\nconst open = ref(props.group.collapsed !== true)\nconst $groupElements = ref<typeof DocGroupElements>()\nconst $listWrapper = ref<HTMLDivElement>()\n\nconst Head = computed(() =>\n props.collapsible ? 'button' : props.group.href ? 'a' : 'div',\n)\n\nconst emit = defineEmits<DocGroupEventsEmitted>()\n\nconst hasActiveItem = computed(() =>\n props.group.items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items, props.activePath)\n }\n return item.href === props.activePath\n }),\n)\n\nfunction reTriggerSetActiveGroup() {\n $groupElements.value?.reTriggerSetActiveGroup()\n}\n\nconst active = computed(() => props.group.href === props.activePath)\n\nconst markerIsMoving = inject('transition-is-moving', ref(false))\n\nwatch(active, (active) => {\n if (active) {\n emit('hideMarker')\n }\n})\n\nwatch(open, (open) => {\n if (hasActiveItem.value) {\n if (open) {\n reTriggerSetActiveGroup()\n } else {\n emit('hideMarker')\n }\n } else {\n emit('updateMarkerPosition')\n }\n})\n\nwatch(\n () => props.activePath,\n () => {\n if (hasActiveItem.value && !open.value) {\n open.value = true\n }\n },\n)\n\ndefineExpose({\n reTriggerSetActiveGroup,\n})\n</script>\n\n<template>\n <component\n :is=\"Head\"\n :class=\"[\n CssClasses.button,\n {\n [CssClasses.topButton]: depth === 0,\n [CssClasses.leafButton]: depth,\n 'text-indigo-500 dark:text-indigo-400': active,\n 'text-gray-900 dark:text-gray-100': hasActiveItem && !active,\n 'text-gray-800 dark:text-gray-200': !hasActiveItem && !active,\n },\n ]\"\n :style=\"{\n paddingLeft: depth >= 1 ? `${(depth - 1) * 12 + 48}px` : undefined,\n }\"\n :href=\"group.href\"\n @click=\"\n () => {\n if (collapsible) {\n open = !open\n } else {\n emit('updateActivePosition')\n }\n }\n \"\n >\n <IconChevronDownSmall\n v-if=\"props.collapsible\"\n stroke-color=\"current\"\n :size=\"depth ? '8' : '16'\"\n :class=\"[\n CssClasses.expandedIcon,\n {\n 'rotate-0': open,\n '-rotate-90': !open,\n },\n ]\"\n :style=\"{\n marginLeft: depth >= 1 ? `${(depth - 1) * 12 + 28}px` : undefined,\n }\"\n />\n {{ group.label }}\n </component>\n <div\n ref=\"$listWrapper\"\n class=\"grid transition-all relative\"\n :class=\"{\n 'grid-rows-[0fr]': !open && collapsible,\n 'grid-rows-[1fr]': open || !collapsible,\n }\"\n @transitionstart=\"\n () => {\n markerIsMoving = true\n }\n \"\n @transitionend=\"\n () => {\n markerIsMoving = false\n if (open || !hasActiveItem) {\n emit('updateMarkerPosition')\n }\n }\n \"\n >\n <div\n v-if=\"open && collapsible && depth === 0\"\n :class=\"CssClasses.openListBorderLeft\"\n />\n <DocGroupElements\n ref=\"$groupElements\"\n class=\"overflow-hidden\"\n :depth=\"depth\"\n :items=\"group.items\"\n :active-path=\"activePath\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n @hide-marker=\"emit('hideMarker')\"\n @update-marker-position=\"() => emit('updateMarkerPosition')\"\n @update-active-position=\"\n (opts) => (open ? emit('updateActivePosition', opts) : null)\n \"\n />\n </div>\n</template>\n","<script lang=\"ts\" setup>\nimport {\n watch,\n type DefineComponent,\n ref,\n onMounted,\n inject,\n nextTick,\n computed,\n} from 'vue'\nimport { type NavItemLink, CssLink } from '@cypress-design/constants-docmenu'\n\nconst props = withDefaults(\n defineProps<{\n item: NavItemLink\n active: boolean\n collapsible: boolean\n depth?: number\n linkComponent: DefineComponent | 'a'\n }>(),\n {\n depth: -1,\n },\n)\n\nconst emit = defineEmits<{\n (\n event: 'update:active',\n active: boolean,\n opts?: { top: number; height: number },\n ): void\n}>()\n\nconst $container = ref<HTMLLIElement>()\n\nconst markerIsMoving = inject('transition-is-moving', ref(false))\n\nfunction setActiveMarkerPosition() {\n if (props.active) {\n nextTick(() => {\n const { top = 0, height = 36 } =\n $container.value?.getBoundingClientRect() ?? {}\n\n emit('update:active', props.active, {\n top,\n height,\n })\n })\n }\n}\n\nonMounted(() => {\n watch(\n () => props.active,\n (active) => {\n if (active) {\n setActiveMarkerPosition()\n } else {\n emit('update:active', active)\n }\n },\n { immediate: true },\n )\n})\n\ndefineExpose({\n setActiveMarkerPosition,\n})\n\nwatch(\n () => props.active,\n (active) => {\n setTimeout(() => {\n if (active && $container.value) {\n // if active check if the item is visible in the\n // viewport and scrollIntoView if not\n const rect = $container.value.getBoundingClientRect()\n\n if (\n rect.top > 0 &&\n rect.bottom < window.innerHeight &&\n rect.left > 0 &&\n rect.right < window.innerWidth\n ) {\n return\n }\n\n $container.value.scrollIntoView({\n block: 'nearest',\n inline: 'nearest',\n })\n }\n }, 200)\n },\n)\n\nconst itemWithoutLabel = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { label, ...rest } = props.item\n return rest\n})\n</script>\n\n<template>\n <li ref=\"$container\" :class=\"CssLink.wrapper\">\n <component\n :is=\"linkComponent\"\n v-bind=\"itemWithoutLabel\"\n :class=\"[\n CssLink.static,\n {\n [CssLink.active]: active,\n [CssLink.inactive]: !active,\n [CssLink.negativeDepth]: depth < 0,\n [CssLink.positiveDepth]: depth >= 0,\n },\n ]\"\n :style=\"{\n paddingLeft: depth >= 0 ? `${depth * 12 + 48}px` : undefined,\n }\"\n >\n <div\n v-if=\"depth >= 0\"\n :class=\"[\n CssLink.markerStatic,\n {\n hidden: !markerIsMoving || !active,\n 'group-hover:block bg-gray-300': !active && collapsible,\n 'bg-indigo-500': active && markerIsMoving,\n },\n ]\"\n />\n {{ item.label }}\n </component>\n </li>\n</template>\n","<script lang=\"ts\">\nexport function hasActiveItemRecursively(\n items: (NavGroup | NavItemLink)[],\n activePath?: string,\n): boolean {\n return items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items, activePath)\n }\n return item.href === activePath\n })\n}\n\nexport interface DocGroupEventsEmitted {\n /**\n * If the group is not collapsed, this event will emit the\n * active marker position all the way to the menu component\n */\n (event: 'updateActivePosition', opts?: { top: number; height: number }): void\n /**\n * This event will trigger a re-render of the active marker\n * to update its position if not in the current subtree\n */\n (event: 'updateMarkerPosition'): void\n /**\n * This event will bubble-up and hide the active marker\n */\n (event: 'hideMarker'): void\n}\n</script>\n\n<script lang=\"ts\" setup>\nimport { DefineComponent, computed, ref } from 'vue'\nimport { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu'\nimport DocGroup from './_DocGroup.vue'\nimport DocLink from './_DocLink.vue'\n\nconst props = defineProps<{\n items: (NavGroup | NavItemLink)[]\n activePath?: string\n collapsible: boolean\n linkComponent: DefineComponent | 'a'\n depth: number\n}>()\n\nconst emit = defineEmits<DocGroupEventsEmitted>()\n\nconst $items = ref<(typeof DocLink)[]>([])\nconst $groups = ref<(typeof DocGroup)[]>([])\n\nconst hasActiveItem = computed(() =>\n props.items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items, props.activePath)\n }\n return item.href === props.activePath\n }),\n)\n\n/**\n * update the position of the marker when opening a group\n * @param index\n */\nfunction reTriggerSetActiveGroup(index = -1) {\n $items.value.forEach((item) => {\n item.setActiveMarkerPosition()\n })\n\n // calculate the index of the calling group in the list of groups\n const indexGroup =\n index -\n // remove all the items that are not groups from the array and count them\n props.items.slice(0, index).filter((item) => !('items' in item)).length\n\n // only update groups that come after the toggled one\n // others will not need to update the marker\n // since they are \"before\" in the rendering tree\n $groups.value.slice(indexGroup + 1).forEach((group) => {\n group.reTriggerSetActiveGroup()\n })\n}\n\ndefineExpose({\n reTriggerSetActiveGroup,\n})\n</script>\n\n<template>\n <ul class=\"list-none p-0\">\n <template v-for=\"(item, index) in items\">\n <li v-if=\"item && 'items' in item\" class=\"relative list-none p-0\">\n <DocGroup\n ref=\"$groups\"\n :active-path=\"activePath\"\n :group=\"item\"\n :depth=\"depth + 1\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n @update-active-position=\"\n (opts) => {\n emit('updateActivePosition', opts)\n }\n \"\n @update-marker-position=\"\n () => {\n if (hasActiveItem) {\n reTriggerSetActiveGroup(index)\n } else {\n emit('updateMarkerPosition')\n }\n }\n \"\n @hide-marker=\"emit('hideMarker')\"\n />\n </li>\n <DocLink\n v-else\n ref=\"$items\"\n :item=\"item\"\n :active=\"item.href === activePath\"\n :depth=\"depth\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n @update:active=\"\n (_, opts) => {\n if (!opts) {\n return\n } else if (depth < 0) {\n emit('hideMarker')\n } else {\n emit('updateActivePosition', opts)\n }\n }\n \"\n />\n </template>\n </ul>\n</template>\n","<script lang=\"ts\" setup>\nimport { ref, type DefineComponent, provide } from 'vue'\nimport { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu'\nimport DocGroupElements from './_DocGroupElements.vue'\n\nwithDefaults(\n defineProps<{\n items: (NavItemLink | NavGroup)[]\n activePath?: string\n collapsible?: boolean\n linkComponent?: DefineComponent | 'a'\n }>(),\n {\n linkComponent: 'a',\n collapsible: true,\n activePath: undefined,\n },\n)\n\nconst $container = ref<HTMLDivElement>()\n\nconst activeTop = ref(0)\nconst activeHeight = ref(36)\nconst showMarker = ref(false)\n\nfunction updateActiveMarkerPosition({ top, height } = { height: 0, top: 0 }) {\n const containerTop = $container.value?.getBoundingClientRect().top || 0\n activeTop.value = top - containerTop\n activeHeight.value = height\n showMarker.value = true\n}\n\nconst markerIsMoving = ref(false)\n\nprovide('transition-is-moving', markerIsMoving)\n</script>\n\n<template>\n <div ref=\"$container\" class=\"relative\">\n <div\n v-if=\"showMarker && collapsible && !markerIsMoving\"\n data-cy=\"doc-menu-active-marker\"\n class=\"absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px]\"\n :style=\"{\n top: `${activeTop}px`,\n height: `${activeHeight - 8}px`,\n }\"\n />\n <DocGroupElements\n :items=\"items\"\n :active-path=\"activePath\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n :depth=\"-1\"\n @update-active-position=\"updateActiveMarkerPosition\"\n @hide-marker=\"showMarker = false\"\n />\n </div>\n</template>\n"],"names":["CssClasses","CssLink","props","__props","open","ref","$groupElements","$listWrapper","Head","computed","emit","__emit","hasActiveItem","item","hasActiveItemRecursively","reTriggerSetActiveGroup","_a","active","markerIsMoving","inject","watch","__expose","$container","setActiveMarkerPosition","nextTick","top","height","onMounted","rect","itemWithoutLabel","label","rest","items","activePath","$items","$groups","index","indexGroup","group","activeTop","activeHeight","showMarker","updateActiveMarkerPosition","containerTop","provide"],"mappings":";;AAAA,MAAMA,IAAa;AAAA,EACf,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,oBAAoB;AACxB,GAEMC,IAAU;AAAA,EACZ,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAClB;;;;;;;;;;;ACPA,UAAMC,IAAQC,GAaRC,IAAOC,EAAIH,EAAM,MAAM,cAAc,EAAI,GACzCI,IAAiBD,KACjBE,IAAeF,KAEfG,IAAOC;AAAA,MAAS,MACpBP,EAAM,cAAc,WAAWA,EAAM,MAAM,OAAO,MAAM;AAAA,IAAA,GAGpDQ,IAAOC,GAEPC,IAAgBH;AAAA,MAAS,MAC7BP,EAAM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a,EAAwBqB,IAAQ,IAAI;AACpC,MAAAF,EAAA,MAAM,QAAQ,CAACrB,MAAS;AAC7B,QAAAA,EAAK,wBAAwB;AAAA,MAAA,CAC9B;AAGD,YAAMwB,IACJD;AAAA,MAEAlC,EAAM,MAAM,MAAM,GAAGkC,CAAK,EAAE,OAAO,CAACvB,MAAS,EAAE,WAAWA,EAAK,EAAE;AAKnE,MAAAsB,EAAQ,MAAM,MAAME,IAAa,CAAC,EAAE,QAAQ,CAACC,MAAU;AACrD,QAAAA,EAAM,wBAAwB;AAAA,MAAA,CAC/B;AAAA,IACH;AAEa,WAAAjB,EAAA;AAAA,MACX,yBAAAN;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjED,UAAMO,IAAajB,KAEbkC,IAAYlC,EAAI,CAAC,GACjBmC,IAAenC,EAAI,EAAE,GACrBoC,IAAapC,EAAI,EAAK;AAEnB,aAAAqC,EAA2B,EAAE,KAAAjB,GAAK,QAAAC,EAAO,IAAI,EAAE,QAAQ,GAAG,KAAK,KAAK;;AAC3E,YAAMiB,MAAe3B,IAAAM,EAAW,UAAX,gBAAAN,EAAkB,wBAAwB,QAAO;AACtE,MAAAuB,EAAU,QAAQd,IAAMkB,GACxBH,EAAa,QAAQd,GACrBe,EAAW,QAAQ;AAAA,IACrB;AAEM,UAAAvB,IAAiBb,EAAI,EAAK;AAEhC,WAAAuC,EAAQ,wBAAwB1B,CAAc;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,
|
|
1
|
+
(function(e,h){typeof exports=="object"&&typeof module<"u"?module.exports=h(require("vue"),require("@cypress-design/vue-icon")):typeof define=="function"&&define.amd?define(["vue","@cypress-design/vue-icon"],h):(e=typeof globalThis<"u"?globalThis:e||self,e.DocMenu=h(e.Vue,e.CyIcon))})(this,function(e,h){"use strict";const g={expandedIcon:"absolute left-0 transform transition-transform text-gray-400 dark:text-gray-700",button:"cyds-docmenu-button",topButton:"cyds-docmenu-topbutton",leafButton:"cyds-docmenu-leafbutton",openListBorderLeft:"cyds-docmenu-openlistborderleft"},k={wrapper:"cyds-docmenu-link-wrapper",static:"cyds-docmenu-link-static group",active:"cyds-docmenu-link-active",inactive:"cyds-docmenu-link-inactive",negativeDepth:"cyds-docmenu-link-negativedepth",positiveDepth:"cyds-docmenu-link-positivedepth",markerStatic:"cyds-docmenu-link-markerstatic"},C=e.defineComponent({__name:"_DocGroup",props:{group:{},activePath:{},collapsible:{type:Boolean},linkComponent:{},depth:{default:0}},emits:["updateActivePosition","updateMarkerPosition","hideMarker"],setup(u,{expose:m,emit:d}){const i=u,n=e.ref(i.group.collapsed!==!0),c=e.ref(),f=e.ref(),p=e.computed(()=>i.collapsible?"button":i.group.href?"a":"div"),l=d,t=e.computed(()=>i.group.items.some(o=>"items"in o?b(o.items,i.activePath):o.href===i.activePath));function r(){var o;(o=c.value)==null||o.reTriggerSetActiveGroup()}const a=e.computed(()=>i.group.href===i.activePath),y=e.inject("transition-is-moving",e.ref(!1));return e.watch(a,o=>{o&&l("hideMarker")}),e.watch(n,o=>{t.value?o?r():l("hideMarker"):l("updateMarkerPosition")}),e.watch(()=>i.activePath,()=>{t.value&&!n.value&&(n.value=!0)}),m({reTriggerSetActiveGroup:r}),(o,s)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(p.value),{class:e.normalizeClass([e.unref(g).button,{[e.unref(g).topButton]:o.depth===0,[e.unref(g).leafButton]:o.depth,"text-indigo-500 dark:text-indigo-400":a.value,"text-gray-900 dark:text-gray-100":t.value&&!a.value,"text-gray-800 dark:text-gray-200":!t.value&&!a.value}]),style:e.normalizeStyle({paddingLeft:o.depth>=1?`${(o.depth-1)*12+48}px`:void 0}),href:o.group.href,onClick:s[0]||(s[0]=()=>{o.collapsible?n.value=!n.value:l("updateActivePosition")})},{default:e.withCtx(()=>[i.collapsible?(e.openBlock(),e.createBlock(e.unref(h.IconChevronDownSmall),{key:0,"stroke-color":"current",size:o.depth?"8":"16",class:e.normalizeClass([e.unref(g).expandedIcon,{"rotate-0":n.value,"-rotate-90":!n.value}]),style:e.normalizeStyle({marginLeft:o.depth>=1?`${(o.depth-1)*12+28}px`:void 0})},null,8,["size","class","style"])):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(o.group.label),1)]),_:1},8,["class","style","href"])),e.createElementVNode("div",{ref_key:"$listWrapper",ref:f,class:e.normalizeClass(["grid transition-all relative",{"grid-rows-[0fr]":!n.value&&o.collapsible,"grid-rows-[1fr]":n.value||!o.collapsible}]),onTransitionstart:s[4]||(s[4]=()=>{y.value=!0}),onTransitionend:s[5]||(s[5]=()=>{y.value=!1,(n.value||!t.value)&&l("updateMarkerPosition")})},[n.value&&o.collapsible&&o.depth===0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(g).openListBorderLeft)},null,2)):e.createCommentVNode("",!0),e.createVNode(B,{ref_key:"$groupElements",ref:c,class:"overflow-hidden",depth:o.depth,items:o.group.items,"active-path":o.activePath,collapsible:o.collapsible,"link-component":o.linkComponent,onHideMarker:s[1]||(s[1]=v=>l("hideMarker")),onUpdateMarkerPosition:s[2]||(s[2]=()=>l("updateMarkerPosition")),onUpdateActivePosition:s[3]||(s[3]=v=>n.value?l("updateActivePosition",v):null)},null,8,["depth","items","active-path","collapsible","link-component"])],34)],64))}}),P=e.defineComponent({__name:"_DocLink",props:{item:{},active:{type:Boolean},collapsible:{type:Boolean},depth:{default:-1},linkComponent:{}},emits:["update:active"],setup(u,{expose:m,emit:d}){const i=u,n=d,c=e.ref(),f=e.inject("transition-is-moving",e.ref(!1));function p(){i.active&&e.nextTick(()=>{var a;const{top:t=0,height:r=36}=((a=c.value)==null?void 0:a.getBoundingClientRect())??{};n("update:active",i.active,{top:t,height:r})})}e.onMounted(()=>{e.watch(()=>i.active,t=>{t?p():n("update:active",t)},{immediate:!0})}),m({setActiveMarkerPosition:p}),e.watch(()=>i.active,t=>{setTimeout(()=>{if(t&&c.value){const r=c.value.getBoundingClientRect();if(r.top>0&&r.bottom<window.innerHeight&&r.left>0&&r.right<window.innerWidth)return;c.value.scrollIntoView({block:"nearest",inline:"nearest"})}},200)});const l=e.computed(()=>{const{label:t,...r}=i.item;return r});return(t,r)=>(e.openBlock(),e.createElementBlock("li",{ref_key:"$container",ref:c,class:e.normalizeClass(e.unref(k).wrapper)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.linkComponent),e.mergeProps(l.value,{class:[e.unref(k).static,{[e.unref(k).active]:t.active,[e.unref(k).inactive]:!t.active,[e.unref(k).negativeDepth]:t.depth<0,[e.unref(k).positiveDepth]:t.depth>=0}],style:{paddingLeft:t.depth>=0?`${t.depth*12+48}px`:void 0}}),{default:e.withCtx(()=>[t.depth>=0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([e.unref(k).markerStatic,{hidden:!e.unref(f)||!t.active,"group-hover:block bg-gray-300":!t.active&&t.collapsible,"bg-indigo-500":t.active&&e.unref(f)}])},null,2)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(t.item.label),1)]),_:1},16,["class","style"]))],2))}}),M={class:"list-none p-0"},$={key:0,class:"relative list-none p-0"};function b(u,m){return u.some(d=>"items"in d?b(d.items,m):d.href===m)}const B=e.defineComponent({__name:"_DocGroupElements",props:{items:{},activePath:{},collapsible:{type:Boolean},linkComponent:{},depth:{}},emits:["updateActivePosition","updateMarkerPosition","hideMarker"],setup(u,{expose:m,emit:d}){const i=u,n=d,c=e.ref([]),f=e.ref([]),p=e.computed(()=>i.items.some(t=>"items"in t?b(t.items,i.activePath):t.href===i.activePath));function l(t=-1){c.value.forEach(a=>{a.setActiveMarkerPosition()});const r=t-i.items.slice(0,t).filter(a=>!("items"in a)).length;f.value.slice(r+1).forEach(a=>{a.reTriggerSetActiveGroup()})}return m({reTriggerSetActiveGroup:l}),(t,r)=>(e.openBlock(),e.createElementBlock("ul",M,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.items,(a,y)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[a&&"items"in a?(e.openBlock(),e.createElementBlock("li",$,[e.createVNode(C,{ref_for:!0,ref_key:"$groups",ref:f,"active-path":t.activePath,group:a,depth:t.depth+1,collapsible:t.collapsible,"link-component":t.linkComponent,onUpdateActivePosition:r[0]||(r[0]=o=>{n("updateActivePosition",o)}),onUpdateMarkerPosition:()=>{p.value?l(y):n("updateMarkerPosition")},onHideMarker:r[1]||(r[1]=o=>n("hideMarker"))},null,8,["active-path","group","depth","collapsible","link-component","onUpdateMarkerPosition"])])):(e.openBlock(),e.createBlock(P,{key:1,ref_for:!0,ref_key:"$items",ref:c,item:a,active:a.href===t.activePath,depth:t.depth,collapsible:t.collapsible,"link-component":t.linkComponent,"onUpdate:active":r[2]||(r[2]=(o,s)=>{if(s)t.depth<0?n("hideMarker"):n("updateActivePosition",s);else return})},null,8,["item","active","depth","collapsible","link-component"]))],64))),256))]))}});return e.defineComponent({__name:"DocMenu",props:{items:{},activePath:{default:void 0},collapsible:{type:Boolean,default:!0},linkComponent:{default:"a"}},setup(u){const m=e.ref(),d=e.ref(0),i=e.ref(36),n=e.ref(!1);function c({top:p,height:l}={height:0,top:0}){var r;const t=((r=m.value)==null?void 0:r.getBoundingClientRect().top)||0;d.value=p-t,i.value=l,n.value=!0}const f=e.ref(!1);return e.provide("transition-is-moving",f),(p,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"$container",ref:m,class:"relative"},[n.value&&p.collapsible&&!f.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-cy":"doc-menu-active-marker",class:"absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px]",style:e.normalizeStyle({top:`${d.value}px`,height:`${i.value-8}px`})},null,4)):e.createCommentVNode("",!0),e.createVNode(B,{items:p.items,"active-path":p.activePath,collapsible:p.collapsible,"link-component":p.linkComponent,depth:-1,onUpdateActivePosition:c,onHideMarker:l[0]||(l[0]=t=>n.value=!1)},null,8,["items","active-path","collapsible","link-component"])],512))}})});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
|
3
3
|
|
|
4
|
-
/* <wind-keep class="container relative absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px] filter list-none p-0 text-indigo-500 dark:text-indigo-400 text-gray-900 dark:text-gray-100 text-gray-800 dark:text-gray-200 rotate-0 -rotate-90 grid grid-rows-[0fr] grid-rows-[1fr] overflow-hidden text-indigo-400 text-gray-100 text-gray-200 icon-dark-current visible block inline
|
|
4
|
+
/* <wind-keep class="container relative absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px] filter list-none p-0 text-indigo-500 dark:text-indigo-400 text-gray-900 dark:text-gray-100 text-gray-800 dark:text-gray-200 rotate-0 -rotate-90 grid grid-rows-[0fr] grid-rows-[1fr] overflow-hidden text-indigo-400 text-gray-100 text-gray-200 icon-dark-current visible block inline static hidden group-hover:block bg-gray-300"> */
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../../constants/dist/index.js","../_DocGroup.vue","../_DocLink.vue","../_DocGroupElements.vue","../DocMenu.vue"],"sourcesContent":["export const classes = {\n expandedIcon: 'absolute left-0 transform transition-transform text-gray-400 dark:text-gray-700',\n button: 'flex leading-[24px] py-[10px] items-center relative w-full text-start',\n topButton: 'leading-[24px] text-[16px] pl-[24px] font-medium',\n leafButton: 'leading-[20px] text-[14px] pl-[48px]',\n openListBorderLeft: 'absolute left-[8px] top-0 w-[1px] h-full bg-gray-100 dark:bg-gray-900',\n};\n","<script lang=\"ts\" setup>\nimport { computed, type DefineComponent, ref, watch, inject } from 'vue'\nimport { IconChevronDownSmall } from '@cypress-design/vue-icon'\nimport { NavGroup, classes } from '@cypress-design/constants-docmenu'\nimport DocGroupElements, {\n hasActiveItemRecursively,\n type DocGroupEventsEmitted,\n} from './_DocGroupElements.vue'\n\nconst props = withDefaults(\n defineProps<{\n group: NavGroup\n activePath?: string\n collapsible: boolean\n linkComponent: DefineComponent | 'a'\n depth?: number\n }>(),\n {\n depth: 0,\n },\n)\n\nconst open = ref(props.group.collapsed !== true)\nconst $groupElements = ref<typeof DocGroupElements>()\nconst $listWrapper = ref<HTMLDivElement>()\n\nconst Head = computed(() =>\n props.collapsible ? 'button' : props.group.href ? 'a' : 'div',\n)\n\nconst emit = defineEmits<DocGroupEventsEmitted>()\n\nconst hasActiveItem = computed(() =>\n props.group.items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items, props.activePath)\n }\n return item.href === props.activePath\n }),\n)\n\nfunction reTriggerSetActiveGroup() {\n $groupElements.value?.reTriggerSetActiveGroup()\n}\n\nconst active = computed(() => props.group.href === props.activePath)\n\nconst markerIsMoving = inject('transition-is-moving', ref(false))\n\nwatch(active, (active) => {\n if (active) {\n emit('hideMarker')\n }\n})\n\nwatch(open, (open) => {\n if (hasActiveItem.value) {\n if (open) {\n reTriggerSetActiveGroup()\n } else {\n emit('hideMarker')\n }\n } else {\n emit('updateMarkerPosition')\n }\n})\n\nwatch(\n () => props.activePath,\n () => {\n if (hasActiveItem.value && !open.value) {\n open.value = true\n }\n },\n)\n\ndefineExpose({\n reTriggerSetActiveGroup,\n})\n</script>\n\n<template>\n <component\n :is=\"Head\"\n :class=\"[\n classes.button,\n {\n [classes.topButton]: depth === 0,\n [classes.leafButton]: depth,\n 'text-indigo-500 dark:text-indigo-400': active,\n 'text-gray-900 dark:text-gray-100': hasActiveItem && !active,\n 'text-gray-800 dark:text-gray-200': !hasActiveItem && !active,\n },\n ]\"\n :style=\"{\n paddingLeft: depth >= 1 ? `${(depth - 1) * 12 + 48}px` : undefined,\n }\"\n :href=\"group.href\"\n @click=\"\n () => {\n if (collapsible) {\n open = !open\n } else {\n emit('updateActivePosition')\n }\n }\n \"\n >\n <IconChevronDownSmall\n v-if=\"props.collapsible\"\n stroke-color=\"current\"\n :size=\"depth ? '8' : '16'\"\n :class=\"[\n classes.expandedIcon,\n {\n 'rotate-0': open,\n '-rotate-90': !open,\n },\n ]\"\n :style=\"{\n marginLeft: depth >= 1 ? `${(depth - 1) * 12 + 28}px` : undefined,\n }\"\n />\n {{ group.label }}\n </component>\n <div\n ref=\"$listWrapper\"\n class=\"grid transition-all relative\"\n :class=\"{\n 'grid-rows-[0fr]': !open && collapsible,\n 'grid-rows-[1fr]': open || !collapsible,\n }\"\n @transitionstart=\"\n () => {\n markerIsMoving = true\n }\n \"\n @transitionend=\"\n () => {\n markerIsMoving = false\n if (open || !hasActiveItem) {\n emit('updateMarkerPosition')\n }\n }\n \"\n >\n <div\n v-if=\"open && collapsible && depth === 0\"\n :class=\"classes.openListBorderLeft\"\n />\n <DocGroupElements\n ref=\"$groupElements\"\n class=\"overflow-hidden\"\n :depth=\"depth\"\n :items=\"group.items\"\n :active-path=\"activePath\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n @hide-marker=\"emit('hideMarker')\"\n @update-marker-position=\"() => emit('updateMarkerPosition')\"\n @update-active-position=\"\n (opts) => (open ? emit('updateActivePosition', opts) : null)\n \"\n />\n </div>\n</template>\n","<script lang=\"ts\" setup>\nimport {\n watch,\n type DefineComponent,\n ref,\n onMounted,\n inject,\n nextTick,\n computed,\n} from 'vue'\nimport type { NavItemLink } from '@cypress-design/constants-docmenu'\n\nconst props = withDefaults(\n defineProps<{\n item: NavItemLink\n active: boolean\n collapsible: boolean\n depth?: number\n linkComponent: DefineComponent | 'a'\n }>(),\n {\n depth: -1,\n },\n)\n\nconst emit = defineEmits<{\n (\n event: 'update:active',\n active: boolean,\n opts?: { top: number; height: number },\n ): void\n}>()\n\nconst $container = ref<HTMLLIElement>()\n\nconst markerIsMoving = inject('transition-is-moving', ref(false))\n\nfunction setActiveMarkerPosition() {\n if (props.active) {\n nextTick(() => {\n const { top = 0, height = 36 } =\n $container.value?.getBoundingClientRect() ?? {}\n\n emit('update:active', props.active, {\n top,\n height,\n })\n })\n }\n}\n\nonMounted(() => {\n watch(\n () => props.active,\n (active) => {\n if (active) {\n setActiveMarkerPosition()\n } else {\n emit('update:active', active)\n }\n },\n { immediate: true },\n )\n})\n\ndefineExpose({\n setActiveMarkerPosition,\n})\n\nwatch(\n () => props.active,\n (active) => {\n setTimeout(() => {\n if (active && $container.value) {\n // if active check if the item is visible in the\n // viewport and scrollIntoView if not\n const rect = $container.value.getBoundingClientRect()\n\n if (\n rect.top > 0 &&\n rect.bottom < window.innerHeight &&\n rect.left > 0 &&\n rect.right < window.innerWidth\n ) {\n return\n }\n\n $container.value.scrollIntoView({\n block: 'nearest',\n inline: 'nearest',\n })\n }\n }, 200)\n },\n)\n\nconst itemWithoutLabel = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { label, ...rest } = props.item\n return rest\n})\n</script>\n\n<template>\n <li ref=\"$container\" class=\"list-none p-0 scroll-my-10\">\n <component\n :is=\"linkComponent\"\n v-bind=\"itemWithoutLabel\"\n class=\"group relative block w-full pl-[24px]\"\n :class=\"{\n 'text-indigo-500 dark:text-indigo-400': active,\n 'text-gray-700 dark:text-gray-500': !active,\n 'py-[8px] text-[16px] leading-[24px]': depth < 0,\n 'leading-[20px] text-[14px] py-[12px]': depth >= 0,\n }\"\n :style=\"{\n paddingLeft: depth >= 0 ? `${depth * 12 + 48}px` : undefined,\n }\"\n >\n <div\n v-if=\"depth >= 0\"\n class=\"left-[6.5px] absolute top-[4px] bottom-[4px] w-[4px] z-10 rounded-full\"\n :class=\"{\n hidden: !markerIsMoving || !active,\n 'group-hover:block bg-gray-300': !active && collapsible,\n 'bg-indigo-500': active && markerIsMoving,\n }\"\n />\n {{ item.label }}\n </component>\n </li>\n</template>\n","<script lang=\"ts\">\nexport function hasActiveItemRecursively(\n items: (NavGroup | NavItemLink)[],\n activePath?: string,\n): boolean {\n return items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items, activePath)\n }\n return item.href === activePath\n })\n}\n\nexport interface DocGroupEventsEmitted {\n /**\n * If the group is not collapsed, this event will emit the\n * active marker position all the way to the menu component\n */\n (event: 'updateActivePosition', opts?: { top: number; height: number }): void\n /**\n * This event will trigger a re-render of the active marker\n * to update its position if not in the current subtree\n */\n (event: 'updateMarkerPosition'): void\n /**\n * This event will bubble-up and hide the active marker\n */\n (event: 'hideMarker'): void\n}\n</script>\n\n<script lang=\"ts\" setup>\nimport { DefineComponent, computed, ref } from 'vue'\nimport { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu'\nimport DocGroup from './_DocGroup.vue'\nimport DocLink from './_DocLink.vue'\n\nconst props = defineProps<{\n items: (NavGroup | NavItemLink)[]\n activePath?: string\n collapsible: boolean\n linkComponent: DefineComponent | 'a'\n depth: number\n}>()\n\nconst emit = defineEmits<DocGroupEventsEmitted>()\n\nconst $items = ref<(typeof DocLink)[]>([])\nconst $groups = ref<(typeof DocGroup)[]>([])\n\nconst hasActiveItem = computed(() =>\n props.items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items, props.activePath)\n }\n return item.href === props.activePath\n }),\n)\n\n/**\n * update the position of the marker when opening a group\n * @param index\n */\nfunction reTriggerSetActiveGroup(index = -1) {\n $items.value.forEach((item) => {\n item.setActiveMarkerPosition()\n })\n\n // calculate the index of the calling group in the list of groups\n const indexGroup =\n index -\n // remove all the items that are not groups from the array and count them\n props.items.slice(0, index).filter((item) => !('items' in item)).length\n\n // only update groups that come after the toggled one\n // others will not need to update the marker\n // since they are \"before\" in the rendering tree\n $groups.value.slice(indexGroup + 1).forEach((group) => {\n group.reTriggerSetActiveGroup()\n })\n}\n\ndefineExpose({\n reTriggerSetActiveGroup,\n})\n</script>\n\n<template>\n <ul class=\"list-none p-0\">\n <template v-for=\"(item, index) in items\">\n <li v-if=\"item && 'items' in item\" class=\"relative list-none p-0\">\n <DocGroup\n ref=\"$groups\"\n :active-path=\"activePath\"\n :group=\"item\"\n :depth=\"depth + 1\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n @update-active-position=\"\n (opts) => {\n emit('updateActivePosition', opts)\n }\n \"\n @update-marker-position=\"\n () => {\n if (hasActiveItem) {\n reTriggerSetActiveGroup(index)\n } else {\n emit('updateMarkerPosition')\n }\n }\n \"\n @hide-marker=\"emit('hideMarker')\"\n />\n </li>\n <DocLink\n v-else\n ref=\"$items\"\n :item=\"item\"\n :active=\"item.href === activePath\"\n :depth=\"depth\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n @update:active=\"\n (_, opts) => {\n if (!opts) {\n return\n } else if (depth < 0) {\n emit('hideMarker')\n } else {\n emit('updateActivePosition', opts)\n }\n }\n \"\n />\n </template>\n </ul>\n</template>\n","<script lang=\"ts\" setup>\nimport { ref, type DefineComponent, provide } from 'vue'\nimport { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu'\nimport DocGroupElements from './_DocGroupElements.vue'\n\nwithDefaults(\n defineProps<{\n items: (NavItemLink | NavGroup)[]\n activePath?: string\n collapsible?: boolean\n linkComponent?: DefineComponent | 'a'\n }>(),\n {\n linkComponent: 'a',\n collapsible: true,\n activePath: undefined,\n },\n)\n\nconst $container = ref<HTMLDivElement>()\n\nconst activeTop = ref(0)\nconst activeHeight = ref(36)\nconst showMarker = ref(false)\n\nfunction updateActiveMarkerPosition({ top, height } = { height: 0, top: 0 }) {\n const containerTop = $container.value?.getBoundingClientRect().top || 0\n activeTop.value = top - containerTop\n activeHeight.value = height\n showMarker.value = true\n}\n\nconst markerIsMoving = ref(false)\n\nprovide('transition-is-moving', markerIsMoving)\n</script>\n\n<template>\n <div ref=\"$container\" class=\"relative\">\n <div\n v-if=\"showMarker && collapsible && !markerIsMoving\"\n data-cy=\"doc-menu-active-marker\"\n class=\"absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px]\"\n :style=\"{\n top: `${activeTop}px`,\n height: `${activeHeight - 8}px`,\n }\"\n />\n <DocGroupElements\n :items=\"items\"\n :active-path=\"activePath\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n :depth=\"-1\"\n @update-active-position=\"updateActiveMarkerPosition\"\n @hide-marker=\"showMarker = false\"\n />\n </div>\n</template>\n"],"names":["classes","props","__props","open","ref","$groupElements","$listWrapper","Head","computed","emit","__emit","hasActiveItem","item","hasActiveItemRecursively","reTriggerSetActiveGroup","_a","active","markerIsMoving","inject","watch","__expose","$container","setActiveMarkerPosition","nextTick","top","height","onMounted","rect","itemWithoutLabel","label","rest","items","activePath","$items","$groups","index","indexGroup","group","activeTop","activeHeight","showMarker","updateActiveMarkerPosition","containerTop","provide"],"mappings":"8TAAO,MAAMA,EAAU,CACnB,aAAc,kFACd,OAAQ,wEACR,UAAW,mDACX,WAAY,uCACZ,mBAAoB,uEACxB,qOCGA,MAAMC,EAAQC,EAaRC,EAAOC,EAAAA,IAAIH,EAAM,MAAM,YAAc,EAAI,EACzCI,EAAiBD,EAAAA,MACjBE,EAAeF,EAAAA,MAEfG,EAAOC,EAAA,SAAS,IACpBP,EAAM,YAAc,SAAWA,EAAM,MAAM,KAAO,IAAM,KAAA,EAGpDQ,EAAOC,EAEPC,EAAgBH,EAAA,SAAS,IAC7BP,EAAM,MAAM,MAAM,KAAMW,GAClB,UAAWA,EACNC,EAAyBD,EAAK,MAAOX,EAAM,UAAU,EAEvDW,EAAK,OAASX,EAAM,UAC5B,CAAA,EAGH,SAASa,GAA0B,QACjCC,EAAAV,EAAe,QAAf,MAAAU,EAAsB,yBACxB,CAEA,MAAMC,EAASR,EAAS,SAAA,IAAMP,EAAM,MAAM,OAASA,EAAM,UAAU,EAE7DgB,EAAiBC,EAAAA,OAAO,uBAAwBd,EAAAA,IAAI,EAAK,CAAC,EAE1De,OAAAA,QAAAH,EAASA,G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EAAK,EAEhCuC,OAAAA,UAAQ,uBAAwB1B,CAAc"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../../constants/dist/index.es.mjs","../_DocGroup.vue","../_DocLink.vue","../_DocGroupElements.vue","../DocMenu.vue"],"sourcesContent":["const CssClasses = {\n expandedIcon: \"absolute left-0 transform transition-transform text-gray-400 dark:text-gray-700\",\n button: \"cyds-docmenu-button\",\n topButton: \"cyds-docmenu-topbutton\",\n leafButton: \"cyds-docmenu-leafbutton\",\n openListBorderLeft: \"cyds-docmenu-openlistborderleft\"\n};\n\nconst CssLink = {\n wrapper: \"cyds-docmenu-link-wrapper\",\n static: \"cyds-docmenu-link-static group\",\n active: \"cyds-docmenu-link-active\",\n inactive: \"cyds-docmenu-link-inactive\",\n negativeDepth: \"cyds-docmenu-link-negativedepth\",\n positiveDepth: \"cyds-docmenu-link-positivedepth\",\n markerStatic: \"cyds-docmenu-link-markerstatic\"\n};\n\nexport { CssClasses, CssLink };\n//# sourceMappingURL=index.es.mjs.map\n","<script lang=\"ts\" setup>\nimport { computed, type DefineComponent, ref, watch, inject } from 'vue'\nimport { IconChevronDownSmall } from '@cypress-design/vue-icon'\nimport { NavGroup, CssClasses } from '@cypress-design/constants-docmenu'\nimport DocGroupElements, {\n hasActiveItemRecursively,\n type DocGroupEventsEmitted,\n} from './_DocGroupElements.vue'\n\nconst props = withDefaults(\n defineProps<{\n group: NavGroup\n activePath?: string\n collapsible: boolean\n linkComponent: DefineComponent | 'a'\n depth?: number\n }>(),\n {\n depth: 0,\n },\n)\n\nconst open = ref(props.group.collapsed !== true)\nconst $groupElements = ref<typeof DocGroupElements>()\nconst $listWrapper = ref<HTMLDivElement>()\n\nconst Head = computed(() =>\n props.collapsible ? 'button' : props.group.href ? 'a' : 'div',\n)\n\nconst emit = defineEmits<DocGroupEventsEmitted>()\n\nconst hasActiveItem = computed(() =>\n props.group.items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items, props.activePath)\n }\n return item.href === props.activePath\n }),\n)\n\nfunction reTriggerSetActiveGroup() {\n $groupElements.value?.reTriggerSetActiveGroup()\n}\n\nconst active = computed(() => props.group.href === props.activePath)\n\nconst markerIsMoving = inject('transition-is-moving', ref(false))\n\nwatch(active, (active) => {\n if (active) {\n emit('hideMarker')\n }\n})\n\nwatch(open, (open) => {\n if (hasActiveItem.value) {\n if (open) {\n reTriggerSetActiveGroup()\n } else {\n emit('hideMarker')\n }\n } else {\n emit('updateMarkerPosition')\n }\n})\n\nwatch(\n () => props.activePath,\n () => {\n if (hasActiveItem.value && !open.value) {\n open.value = true\n }\n },\n)\n\ndefineExpose({\n reTriggerSetActiveGroup,\n})\n</script>\n\n<template>\n <component\n :is=\"Head\"\n :class=\"[\n CssClasses.button,\n {\n [CssClasses.topButton]: depth === 0,\n [CssClasses.leafButton]: depth,\n 'text-indigo-500 dark:text-indigo-400': active,\n 'text-gray-900 dark:text-gray-100': hasActiveItem && !active,\n 'text-gray-800 dark:text-gray-200': !hasActiveItem && !active,\n },\n ]\"\n :style=\"{\n paddingLeft: depth >= 1 ? `${(depth - 1) * 12 + 48}px` : undefined,\n }\"\n :href=\"group.href\"\n @click=\"\n () => {\n if (collapsible) {\n open = !open\n } else {\n emit('updateActivePosition')\n }\n }\n \"\n >\n <IconChevronDownSmall\n v-if=\"props.collapsible\"\n stroke-color=\"current\"\n :size=\"depth ? '8' : '16'\"\n :class=\"[\n CssClasses.expandedIcon,\n {\n 'rotate-0': open,\n '-rotate-90': !open,\n },\n ]\"\n :style=\"{\n marginLeft: depth >= 1 ? `${(depth - 1) * 12 + 28}px` : undefined,\n }\"\n />\n {{ group.label }}\n </component>\n <div\n ref=\"$listWrapper\"\n class=\"grid transition-all relative\"\n :class=\"{\n 'grid-rows-[0fr]': !open && collapsible,\n 'grid-rows-[1fr]': open || !collapsible,\n }\"\n @transitionstart=\"\n () => {\n markerIsMoving = true\n }\n \"\n @transitionend=\"\n () => {\n markerIsMoving = false\n if (open || !hasActiveItem) {\n emit('updateMarkerPosition')\n }\n }\n \"\n >\n <div\n v-if=\"open && collapsible && depth === 0\"\n :class=\"CssClasses.openListBorderLeft\"\n />\n <DocGroupElements\n ref=\"$groupElements\"\n class=\"overflow-hidden\"\n :depth=\"depth\"\n :items=\"group.items\"\n :active-path=\"activePath\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n @hide-marker=\"emit('hideMarker')\"\n @update-marker-position=\"() => emit('updateMarkerPosition')\"\n @update-active-position=\"\n (opts) => (open ? emit('updateActivePosition', opts) : null)\n \"\n />\n </div>\n</template>\n","<script lang=\"ts\" setup>\nimport {\n watch,\n type DefineComponent,\n ref,\n onMounted,\n inject,\n nextTick,\n computed,\n} from 'vue'\nimport { type NavItemLink, CssLink } from '@cypress-design/constants-docmenu'\n\nconst props = withDefaults(\n defineProps<{\n item: NavItemLink\n active: boolean\n collapsible: boolean\n depth?: number\n linkComponent: DefineComponent | 'a'\n }>(),\n {\n depth: -1,\n },\n)\n\nconst emit = defineEmits<{\n (\n event: 'update:active',\n active: boolean,\n opts?: { top: number; height: number },\n ): void\n}>()\n\nconst $container = ref<HTMLLIElement>()\n\nconst markerIsMoving = inject('transition-is-moving', ref(false))\n\nfunction setActiveMarkerPosition() {\n if (props.active) {\n nextTick(() => {\n const { top = 0, height = 36 } =\n $container.value?.getBoundingClientRect() ?? {}\n\n emit('update:active', props.active, {\n top,\n height,\n })\n })\n }\n}\n\nonMounted(() => {\n watch(\n () => props.active,\n (active) => {\n if (active) {\n setActiveMarkerPosition()\n } else {\n emit('update:active', active)\n }\n },\n { immediate: true },\n )\n})\n\ndefineExpose({\n setActiveMarkerPosition,\n})\n\nwatch(\n () => props.active,\n (active) => {\n setTimeout(() => {\n if (active && $container.value) {\n // if active check if the item is visible in the\n // viewport and scrollIntoView if not\n const rect = $container.value.getBoundingClientRect()\n\n if (\n rect.top > 0 &&\n rect.bottom < window.innerHeight &&\n rect.left > 0 &&\n rect.right < window.innerWidth\n ) {\n return\n }\n\n $container.value.scrollIntoView({\n block: 'nearest',\n inline: 'nearest',\n })\n }\n }, 200)\n },\n)\n\nconst itemWithoutLabel = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { label, ...rest } = props.item\n return rest\n})\n</script>\n\n<template>\n <li ref=\"$container\" :class=\"CssLink.wrapper\">\n <component\n :is=\"linkComponent\"\n v-bind=\"itemWithoutLabel\"\n :class=\"[\n CssLink.static,\n {\n [CssLink.active]: active,\n [CssLink.inactive]: !active,\n [CssLink.negativeDepth]: depth < 0,\n [CssLink.positiveDepth]: depth >= 0,\n },\n ]\"\n :style=\"{\n paddingLeft: depth >= 0 ? `${depth * 12 + 48}px` : undefined,\n }\"\n >\n <div\n v-if=\"depth >= 0\"\n :class=\"[\n CssLink.markerStatic,\n {\n hidden: !markerIsMoving || !active,\n 'group-hover:block bg-gray-300': !active && collapsible,\n 'bg-indigo-500': active && markerIsMoving,\n },\n ]\"\n />\n {{ item.label }}\n </component>\n </li>\n</template>\n","<script lang=\"ts\">\nexport function hasActiveItemRecursively(\n items: (NavGroup | NavItemLink)[],\n activePath?: string,\n): boolean {\n return items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items, activePath)\n }\n return item.href === activePath\n })\n}\n\nexport interface DocGroupEventsEmitted {\n /**\n * If the group is not collapsed, this event will emit the\n * active marker position all the way to the menu component\n */\n (event: 'updateActivePosition', opts?: { top: number; height: number }): void\n /**\n * This event will trigger a re-render of the active marker\n * to update its position if not in the current subtree\n */\n (event: 'updateMarkerPosition'): void\n /**\n * This event will bubble-up and hide the active marker\n */\n (event: 'hideMarker'): void\n}\n</script>\n\n<script lang=\"ts\" setup>\nimport { DefineComponent, computed, ref } from 'vue'\nimport { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu'\nimport DocGroup from './_DocGroup.vue'\nimport DocLink from './_DocLink.vue'\n\nconst props = defineProps<{\n items: (NavGroup | NavItemLink)[]\n activePath?: string\n collapsible: boolean\n linkComponent: DefineComponent | 'a'\n depth: number\n}>()\n\nconst emit = defineEmits<DocGroupEventsEmitted>()\n\nconst $items = ref<(typeof DocLink)[]>([])\nconst $groups = ref<(typeof DocGroup)[]>([])\n\nconst hasActiveItem = computed(() =>\n props.items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items, props.activePath)\n }\n return item.href === props.activePath\n }),\n)\n\n/**\n * update the position of the marker when opening a group\n * @param index\n */\nfunction reTriggerSetActiveGroup(index = -1) {\n $items.value.forEach((item) => {\n item.setActiveMarkerPosition()\n })\n\n // calculate the index of the calling group in the list of groups\n const indexGroup =\n index -\n // remove all the items that are not groups from the array and count them\n props.items.slice(0, index).filter((item) => !('items' in item)).length\n\n // only update groups that come after the toggled one\n // others will not need to update the marker\n // since they are \"before\" in the rendering tree\n $groups.value.slice(indexGroup + 1).forEach((group) => {\n group.reTriggerSetActiveGroup()\n })\n}\n\ndefineExpose({\n reTriggerSetActiveGroup,\n})\n</script>\n\n<template>\n <ul class=\"list-none p-0\">\n <template v-for=\"(item, index) in items\">\n <li v-if=\"item && 'items' in item\" class=\"relative list-none p-0\">\n <DocGroup\n ref=\"$groups\"\n :active-path=\"activePath\"\n :group=\"item\"\n :depth=\"depth + 1\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n @update-active-position=\"\n (opts) => {\n emit('updateActivePosition', opts)\n }\n \"\n @update-marker-position=\"\n () => {\n if (hasActiveItem) {\n reTriggerSetActiveGroup(index)\n } else {\n emit('updateMarkerPosition')\n }\n }\n \"\n @hide-marker=\"emit('hideMarker')\"\n />\n </li>\n <DocLink\n v-else\n ref=\"$items\"\n :item=\"item\"\n :active=\"item.href === activePath\"\n :depth=\"depth\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n @update:active=\"\n (_, opts) => {\n if (!opts) {\n return\n } else if (depth < 0) {\n emit('hideMarker')\n } else {\n emit('updateActivePosition', opts)\n }\n }\n \"\n />\n </template>\n </ul>\n</template>\n","<script lang=\"ts\" setup>\nimport { ref, type DefineComponent, provide } from 'vue'\nimport { NavGroup, NavItemLink } from '@cypress-design/constants-docmenu'\nimport DocGroupElements from './_DocGroupElements.vue'\n\nwithDefaults(\n defineProps<{\n items: (NavItemLink | NavGroup)[]\n activePath?: string\n collapsible?: boolean\n linkComponent?: DefineComponent | 'a'\n }>(),\n {\n linkComponent: 'a',\n collapsible: true,\n activePath: undefined,\n },\n)\n\nconst $container = ref<HTMLDivElement>()\n\nconst activeTop = ref(0)\nconst activeHeight = ref(36)\nconst showMarker = ref(false)\n\nfunction updateActiveMarkerPosition({ top, height } = { height: 0, top: 0 }) {\n const containerTop = $container.value?.getBoundingClientRect().top || 0\n activeTop.value = top - containerTop\n activeHeight.value = height\n showMarker.value = true\n}\n\nconst markerIsMoving = ref(false)\n\nprovide('transition-is-moving', markerIsMoving)\n</script>\n\n<template>\n <div ref=\"$container\" class=\"relative\">\n <div\n v-if=\"showMarker && collapsible && !markerIsMoving\"\n data-cy=\"doc-menu-active-marker\"\n class=\"absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px]\"\n :style=\"{\n top: `${activeTop}px`,\n height: `${activeHeight - 8}px`,\n }\"\n />\n <DocGroupElements\n :items=\"items\"\n :active-path=\"activePath\"\n :collapsible=\"collapsible\"\n :link-component=\"linkComponent\"\n :depth=\"-1\"\n @update-active-position=\"updateActiveMarkerPosition\"\n @hide-marker=\"showMarker = false\"\n />\n </div>\n</template>\n"],"names":["CssClasses","CssLink","props","__props","open","ref","$groupElements","$listWrapper","Head","computed","emit","__emit","hasActiveItem","item","hasActiveItemRecursively","reTriggerSetActiveGroup","_a","active","markerIsMoving","inject","watch","__expose","$container","setActiveMarkerPosition","nextTick","top","height","onMounted","rect","itemWithoutLabel","label","rest","items","activePath","$items","$groups","index","indexGroup","group","activeTop","activeHeight","showMarker","updateActiveMarkerPosition","containerTop","provide"],"mappings":"8TAAA,MAAMA,EAAa,CACf,aAAc,kFACd,OAAQ,s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,UAC5B,CAAA,EAOM,SAAAa,EAAwBqB,EAAQ,GAAI,CACpCF,EAAA,MAAM,QAASrB,GAAS,CAC7BA,EAAK,wBAAwB,CAAA,CAC9B,EAGD,MAAMwB,EACJD,EAEAlC,EAAM,MAAM,MAAM,EAAGkC,CAAK,EAAE,OAAQvB,GAAS,EAAE,UAAWA,EAAK,EAAE,OAKnEsB,EAAQ,MAAM,MAAME,EAAa,CAAC,EAAE,QAASC,GAAU,CACrDA,EAAM,wBAAwB,CAAA,CAC/B,CACH,CAEa,OAAAjB,EAAA,CACX,wBAAAN,CAAA,CACD,gtCCjED,MAAMO,EAAajB,EAAAA,MAEbkC,EAAYlC,MAAI,CAAC,EACjBmC,EAAenC,MAAI,EAAE,EACrBoC,EAAapC,MAAI,EAAK,EAEnB,SAAAqC,EAA2B,CAAE,IAAAjB,EAAK,OAAAC,CAAO,EAAI,CAAE,OAAQ,EAAG,IAAK,GAAK,OAC3E,MAAMiB,IAAe3B,EAAAM,EAAW,QAAX,YAAAN,EAAkB,wBAAwB,MAAO,EACtEuB,EAAU,MAAQd,EAAMkB,EACxBH,EAAa,MAAQd,EACrBe,EAAW,MAAQ,EACrB,CAEM,MAAAvB,EAAiBb,MAAI,EAAK,EAEhCuC,OAAAA,UAAQ,uBAAwB1B,CAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress-design/vue-docmenu",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-next.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"*"
|
|
6
6
|
],
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"build:types": "yarn vue-tsc --project ./tsconfig.build.json"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@cypress-design/
|
|
24
|
-
"@cypress-design/vue-icon": "^1.0.0"
|
|
23
|
+
"@cypress-design/vue-icon": "^2.0.0-next.0"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
|
-
"@cypress-design/
|
|
26
|
+
"@cypress-design/constants-docmenu": "2.0.0-next.0",
|
|
27
|
+
"@cypress-design/rollup-plugin-tailwind-keep": "1.0.1-next.0"
|
|
28
28
|
},
|
|
29
29
|
"license": "MIT"
|
|
30
30
|
}
|
package/vite.config.ts
CHANGED