@cypress-design/vue-docmenu 0.4.2 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +3 -3
- package/CHANGELOG.md +17 -0
- package/DocMenu.vue +7 -3
- package/DocMenuVue.cy.tsx +27 -17
- package/_DocGroup.vue +68 -35
- package/_DocGroupElements.vue +66 -25
- package/_DocLink.vue +26 -18
- 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 +181 -150
- 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/dist/index.es.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as A, ref as u, computed as P, inject as I, watch as C, openBlock as p, createElementBlock as f, Fragment as B, createBlock as M, resolveDynamicComponent as S, normalizeClass as h, unref as k, withCtx as D, createCommentVNode as $, createTextVNode as E, toDisplayString as G, createElementVNode as z, createVNode as x, onMounted as H, normalizeStyle as L, nextTick as N, renderList as V, provide as j } from "vue";
|
|
2
2
|
import { IconChevronDownSmall as F } from "@cypress-design/vue-icon";
|
|
3
|
-
const
|
|
3
|
+
const b = {
|
|
4
|
+
expandedIcon: "absolute left-0 transform transition-transform text-gray-400 dark:text-gray-700",
|
|
4
5
|
button: "flex leading-[24px] py-[10px] items-center relative w-full text-start",
|
|
5
6
|
topButton: "leading-[24px] text-[16px] pl-[24px] font-medium",
|
|
6
|
-
leafButton: "leading-[20px] text-[14px] pl-[
|
|
7
|
-
|
|
7
|
+
leafButton: "leading-[20px] text-[14px] pl-[48px]",
|
|
8
|
+
openListBorderLeft: "absolute left-[8px] top-0 w-[1px] h-full bg-gray-100 dark:bg-gray-900"
|
|
9
|
+
}, R = /* @__PURE__ */ A({
|
|
8
10
|
__name: "_DocGroup",
|
|
9
11
|
props: {
|
|
10
12
|
group: {},
|
|
@@ -13,72 +15,94 @@ const P = {
|
|
|
13
15
|
linkComponent: {},
|
|
14
16
|
depth: { default: 0 }
|
|
15
17
|
},
|
|
16
|
-
emits: ["updateActivePosition", "
|
|
17
|
-
setup(
|
|
18
|
-
const
|
|
19
|
-
() =>
|
|
20
|
-
), e =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function o() {
|
|
18
|
+
emits: ["updateActivePosition", "updateMarkerPosition", "hideMarker"],
|
|
19
|
+
setup(g, { expose: c, emit: d }) {
|
|
20
|
+
const n = g, i = u(n.group.collapsed !== !0), v = u(), m = u(), s = P(
|
|
21
|
+
() => n.collapsible ? "button" : n.group.href ? "a" : "div"
|
|
22
|
+
), e = d, o = P(
|
|
23
|
+
() => n.group.items.some((t) => "items" in t ? w(t.items, n.activePath) : t.href === n.activePath)
|
|
24
|
+
);
|
|
25
|
+
function a() {
|
|
25
26
|
var t;
|
|
26
|
-
(t =
|
|
27
|
+
(t = v.value) == null || t.reTriggerSetActiveGroup();
|
|
27
28
|
}
|
|
28
|
-
const
|
|
29
|
-
return
|
|
29
|
+
const l = P(() => n.group.href === n.activePath), y = I("transition-is-moving", u(!1));
|
|
30
|
+
return C(l, (t) => {
|
|
30
31
|
t && e("hideMarker");
|
|
31
|
-
}),
|
|
32
|
-
|
|
33
|
-
}),
|
|
34
|
-
reTriggerSetActiveGroup:
|
|
35
|
-
}), (t,
|
|
36
|
-
(p(),
|
|
37
|
-
class:
|
|
38
|
-
|
|
32
|
+
}), C(i, (t) => {
|
|
33
|
+
o.value ? t ? a() : e("hideMarker") : e("updateMarkerPosition");
|
|
34
|
+
}), c({
|
|
35
|
+
reTriggerSetActiveGroup: a
|
|
36
|
+
}), (t, r) => (p(), f(B, null, [
|
|
37
|
+
(p(), M(S(s.value), {
|
|
38
|
+
class: h([
|
|
39
|
+
k(b).button,
|
|
39
40
|
{
|
|
40
|
-
[
|
|
41
|
-
[
|
|
42
|
-
"text-indigo-500":
|
|
41
|
+
[k(b).topButton]: t.depth === 0,
|
|
42
|
+
[k(b).leafButton]: t.depth,
|
|
43
|
+
"text-indigo-500 dark:text-indigo-400": l.value,
|
|
44
|
+
"text-gray-900 dark:text-gray-100": o.value && !l.value,
|
|
45
|
+
"text-gray-800 dark:text-gray-200": !o.value && !l.value
|
|
43
46
|
}
|
|
44
47
|
]),
|
|
45
48
|
href: t.group.href,
|
|
46
|
-
onClick:
|
|
47
|
-
t.collapsible ?
|
|
49
|
+
onClick: r[0] || (r[0] = () => {
|
|
50
|
+
t.collapsible ? i.value = !i.value : e("updateActivePosition");
|
|
48
51
|
})
|
|
49
52
|
}, {
|
|
50
|
-
default:
|
|
51
|
-
|
|
53
|
+
default: D(() => [
|
|
54
|
+
n.collapsible ? (p(), M(k(F), {
|
|
52
55
|
key: 0,
|
|
53
|
-
"stroke-color": "
|
|
56
|
+
"stroke-color": "current",
|
|
54
57
|
size: t.depth ? "8" : "16",
|
|
55
|
-
class:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
class: h([
|
|
59
|
+
k(b).expandedIcon,
|
|
60
|
+
{
|
|
61
|
+
"rotate-0": i.value,
|
|
62
|
+
"-rotate-90": !i.value,
|
|
63
|
+
"ml-[28px]": t.depth
|
|
64
|
+
}
|
|
65
|
+
])
|
|
66
|
+
}, null, 8, ["size", "class"])) : $("", !0),
|
|
67
|
+
E(" " + G(t.group.label), 1)
|
|
62
68
|
]),
|
|
63
69
|
_: 1
|
|
64
70
|
}, 8, ["class", "href"])),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
z("div", {
|
|
72
|
+
class: h(["grid transition-all relative", {
|
|
73
|
+
"grid-rows-[0fr]": !i.value && t.collapsible,
|
|
74
|
+
"grid-rows-[1fr]": i.value || !t.collapsible
|
|
75
|
+
}]),
|
|
76
|
+
ref_key: "$listWrapper",
|
|
77
|
+
ref: m,
|
|
78
|
+
onTransitionstart: r[4] || (r[4] = () => {
|
|
79
|
+
y.value = !0;
|
|
80
|
+
}),
|
|
81
|
+
onTransitionend: r[5] || (r[5] = () => {
|
|
82
|
+
y.value = !1, (i.value || !o.value) && e("updateMarkerPosition");
|
|
83
|
+
})
|
|
84
|
+
}, [
|
|
85
|
+
i.value && t.collapsible && t.depth === 0 ? (p(), f("div", {
|
|
86
|
+
key: 0,
|
|
87
|
+
class: h(k(b).openListBorderLeft)
|
|
88
|
+
}, null, 2)) : $("", !0),
|
|
89
|
+
x(U, {
|
|
90
|
+
ref_key: "$groupElements",
|
|
91
|
+
ref: v,
|
|
92
|
+
class: "overflow-hidden",
|
|
93
|
+
depth: t.depth,
|
|
94
|
+
items: t.group.items,
|
|
95
|
+
"active-path": t.activePath,
|
|
96
|
+
collapsible: t.collapsible,
|
|
97
|
+
"link-component": t.linkComponent,
|
|
98
|
+
onHideMarker: r[1] || (r[1] = (T) => e("hideMarker")),
|
|
99
|
+
onUpdateMarkerPosition: r[2] || (r[2] = () => e("updateMarkerPosition")),
|
|
100
|
+
onUpdateActivePosition: r[3] || (r[3] = (T) => i.value ? e("updateActivePosition", T) : null)
|
|
101
|
+
}, null, 8, ["depth", "items", "active-path", "collapsible", "link-component"])
|
|
102
|
+
], 34)
|
|
79
103
|
], 64));
|
|
80
104
|
}
|
|
81
|
-
}),
|
|
105
|
+
}), O = /* @__PURE__ */ A({
|
|
82
106
|
__name: "_DocLink",
|
|
83
107
|
props: {
|
|
84
108
|
item: {},
|
|
@@ -88,63 +112,68 @@ const P = {
|
|
|
88
112
|
linkComponent: {}
|
|
89
113
|
},
|
|
90
114
|
emits: ["update:active"],
|
|
91
|
-
setup(
|
|
92
|
-
const
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const { top:
|
|
97
|
-
|
|
98
|
-
top:
|
|
115
|
+
setup(g, { expose: c, emit: d }) {
|
|
116
|
+
const n = g, i = d, v = u(), m = I("transition-is-moving", u(!1));
|
|
117
|
+
function s() {
|
|
118
|
+
n.active && N(() => {
|
|
119
|
+
var a;
|
|
120
|
+
const { top: e = 0, height: o = 36 } = ((a = v.value) == null ? void 0 : a.getBoundingClientRect()) ?? {};
|
|
121
|
+
i("update:active", n.active, {
|
|
122
|
+
top: e,
|
|
99
123
|
height: o
|
|
100
124
|
});
|
|
101
|
-
}
|
|
125
|
+
});
|
|
102
126
|
}
|
|
103
127
|
return H(() => {
|
|
104
|
-
|
|
105
|
-
() =>
|
|
128
|
+
C(
|
|
129
|
+
() => n.active,
|
|
106
130
|
(e) => {
|
|
107
|
-
e ?
|
|
131
|
+
e ? s() : i("update:active", e);
|
|
108
132
|
},
|
|
109
133
|
{ immediate: !0 }
|
|
110
134
|
);
|
|
111
|
-
}),
|
|
112
|
-
setActiveMarkerPosition:
|
|
113
|
-
}), (e,
|
|
135
|
+
}), c({
|
|
136
|
+
setActiveMarkerPosition: s
|
|
137
|
+
}), (e, o) => (p(), f("li", {
|
|
114
138
|
ref_key: "$container",
|
|
115
|
-
ref:
|
|
116
|
-
class:
|
|
117
|
-
"pl-[16px]": e.depth >= 0
|
|
118
|
-
}])
|
|
139
|
+
ref: v,
|
|
140
|
+
class: "list-none p-0"
|
|
119
141
|
}, [
|
|
120
|
-
(p(),
|
|
121
|
-
class:
|
|
122
|
-
"text-indigo-500": e.active,
|
|
142
|
+
(p(), M(S(e.linkComponent), {
|
|
143
|
+
class: h(["group relative block w-full pl-[24px]", {
|
|
144
|
+
"text-indigo-500 dark:text-indigo-400": e.active,
|
|
145
|
+
"text-gray-700 dark:text-gray-500": !e.active,
|
|
123
146
|
"py-[8px] text-[16px] leading-[24px]": e.depth < 0,
|
|
124
147
|
"leading-[20px] text-[14px] py-[12px]": e.depth >= 0
|
|
125
148
|
}]),
|
|
149
|
+
style: L({
|
|
150
|
+
paddingLeft: e.depth >= 0 ? `${e.depth * 12 + 48}px` : void 0
|
|
151
|
+
}),
|
|
126
152
|
href: e.item.href
|
|
127
153
|
}, {
|
|
128
|
-
default:
|
|
129
|
-
e.depth >= 0 ? (p(),
|
|
154
|
+
default: D(() => [
|
|
155
|
+
e.depth >= 0 ? (p(), f("div", {
|
|
130
156
|
key: 0,
|
|
131
|
-
class:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
D(" " + T(e.item.label), 1)
|
|
157
|
+
class: h(["left-[6.5px] absolute top-[4px] bottom-[4px] w-[4px] z-10 rounded-full", {
|
|
158
|
+
hidden: !k(m) || !e.active,
|
|
159
|
+
"group-hover:block bg-gray-300": !e.active && e.collapsible,
|
|
160
|
+
"bg-indigo-500": e.active && k(m)
|
|
161
|
+
}])
|
|
162
|
+
}, null, 2)) : $("", !0),
|
|
163
|
+
E(" " + G(e.item.label), 1)
|
|
139
164
|
]),
|
|
140
165
|
_: 1
|
|
141
|
-
}, 8, ["class", "href"]))
|
|
142
|
-
],
|
|
166
|
+
}, 8, ["class", "style", "href"]))
|
|
167
|
+
], 512));
|
|
143
168
|
}
|
|
144
|
-
}),
|
|
169
|
+
}), W = { class: "list-none p-0" }, q = {
|
|
145
170
|
key: 0,
|
|
146
171
|
class: "relative list-none p-0"
|
|
147
|
-
}
|
|
172
|
+
};
|
|
173
|
+
function w(g, c) {
|
|
174
|
+
return g.some((d) => "items" in d ? w(d.items, c) : d.href === c);
|
|
175
|
+
}
|
|
176
|
+
const U = /* @__PURE__ */ A({
|
|
148
177
|
__name: "_DocGroupElements",
|
|
149
178
|
props: {
|
|
150
179
|
items: {},
|
|
@@ -153,63 +182,64 @@ const P = {
|
|
|
153
182
|
linkComponent: { type: [Object, Function, String] },
|
|
154
183
|
depth: {}
|
|
155
184
|
},
|
|
156
|
-
emits: ["updateActivePosition", "
|
|
157
|
-
setup(
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
185
|
+
emits: ["updateActivePosition", "updateMarkerPosition", "hideMarker"],
|
|
186
|
+
setup(g, { expose: c, emit: d }) {
|
|
187
|
+
const n = g, i = d, v = u([]), m = u([]), s = P(
|
|
188
|
+
() => n.items.some((o) => "items" in o ? w(o.items, n.activePath) : o.href === n.activePath)
|
|
189
|
+
);
|
|
190
|
+
function e(o = -1) {
|
|
191
|
+
v.value.forEach((l) => {
|
|
192
|
+
l.setActiveMarkerPosition();
|
|
193
|
+
});
|
|
194
|
+
const a = o - // remove all the items that are not groups from the array and count them
|
|
195
|
+
n.items.slice(0, o).filter((l) => !("items" in l)).length;
|
|
196
|
+
m.value.slice(a + 1).forEach((l) => {
|
|
197
|
+
l.reTriggerSetActiveGroup();
|
|
167
198
|
});
|
|
168
199
|
}
|
|
169
|
-
return
|
|
170
|
-
reTriggerSetActiveGroup:
|
|
171
|
-
}), (o,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}])
|
|
176
|
-
}, [
|
|
177
|
-
(p(!0), d($, null, R(o.items, (t) => (p(), d($, null, [
|
|
178
|
-
t && "items" in t ? (p(), d("li", V, [
|
|
179
|
-
C(I, {
|
|
200
|
+
return c({
|
|
201
|
+
reTriggerSetActiveGroup: e
|
|
202
|
+
}), (o, a) => (p(), f("ul", W, [
|
|
203
|
+
(p(!0), f(B, null, V(o.items, (l, y) => (p(), f(B, null, [
|
|
204
|
+
l && "items" in l ? (p(), f("li", q, [
|
|
205
|
+
x(R, {
|
|
180
206
|
ref_for: !0,
|
|
181
207
|
ref_key: "$groups",
|
|
182
|
-
ref:
|
|
208
|
+
ref: m,
|
|
183
209
|
"active-path": o.activePath,
|
|
184
|
-
group:
|
|
210
|
+
group: l,
|
|
185
211
|
depth: o.depth + 1,
|
|
186
212
|
collapsible: o.collapsible,
|
|
187
213
|
"link-component": o.linkComponent,
|
|
188
|
-
onUpdateActivePosition:
|
|
189
|
-
|
|
214
|
+
onUpdateActivePosition: a[0] || (a[0] = (t) => {
|
|
215
|
+
i("updateActivePosition", t);
|
|
190
216
|
}),
|
|
191
|
-
onUpdateMarkerPosition:
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
217
|
+
onUpdateMarkerPosition: () => {
|
|
218
|
+
s.value ? e(y) : i("updateMarkerPosition");
|
|
219
|
+
},
|
|
220
|
+
onHideMarker: a[1] || (a[1] = (t) => i("hideMarker"))
|
|
221
|
+
}, null, 8, ["active-path", "group", "depth", "collapsible", "link-component", "onUpdateMarkerPosition"])
|
|
222
|
+
])) : (p(), M(O, {
|
|
196
223
|
key: 1,
|
|
197
224
|
ref_for: !0,
|
|
198
225
|
ref_key: "$items",
|
|
199
|
-
ref:
|
|
200
|
-
item:
|
|
201
|
-
active:
|
|
226
|
+
ref: v,
|
|
227
|
+
item: l,
|
|
228
|
+
active: l.href === o.activePath,
|
|
202
229
|
depth: o.depth,
|
|
203
230
|
collapsible: o.collapsible,
|
|
204
231
|
"link-component": o.linkComponent,
|
|
205
|
-
"onUpdate:active":
|
|
206
|
-
|
|
232
|
+
"onUpdate:active": a[2] || (a[2] = (t, r) => {
|
|
233
|
+
if (r)
|
|
234
|
+
o.depth < 0 ? i("hideMarker") : i("updateActivePosition", r);
|
|
235
|
+
else
|
|
236
|
+
return;
|
|
207
237
|
})
|
|
208
238
|
}, null, 8, ["item", "active", "depth", "collapsible", "link-component"]))
|
|
209
239
|
], 64))), 256))
|
|
210
|
-
]
|
|
240
|
+
]));
|
|
211
241
|
}
|
|
212
|
-
}),
|
|
242
|
+
}), Q = /* @__PURE__ */ A({
|
|
213
243
|
__name: "DocMenu",
|
|
214
244
|
props: {
|
|
215
245
|
items: {},
|
|
@@ -217,42 +247,43 @@ const P = {
|
|
|
217
247
|
collapsible: { type: Boolean, default: !0 },
|
|
218
248
|
linkComponent: { type: [Object, Function, String], default: "a" }
|
|
219
249
|
},
|
|
220
|
-
setup(
|
|
221
|
-
const
|
|
222
|
-
function
|
|
223
|
-
var
|
|
224
|
-
const
|
|
225
|
-
|
|
250
|
+
setup(g) {
|
|
251
|
+
const c = u(), d = u(0), n = u(36), i = u(!1);
|
|
252
|
+
function v({ top: s, height: e } = { height: 0, top: 0 }) {
|
|
253
|
+
var a;
|
|
254
|
+
const o = ((a = c.value) == null ? void 0 : a.getBoundingClientRect().top) || 0;
|
|
255
|
+
d.value = s - o, n.value = e, i.value = !0;
|
|
226
256
|
}
|
|
227
|
-
|
|
257
|
+
const m = u(!1);
|
|
258
|
+
return j("transition-is-moving", m), (s, e) => (p(), f("div", {
|
|
228
259
|
ref_key: "$container",
|
|
229
|
-
ref:
|
|
260
|
+
ref: c,
|
|
230
261
|
class: "relative"
|
|
231
262
|
}, [
|
|
232
|
-
|
|
263
|
+
i.value && s.collapsible && !m.value ? (p(), f("div", {
|
|
233
264
|
key: 0,
|
|
234
265
|
"data-cy": "doc-menu-active-marker",
|
|
235
266
|
class: "absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px]",
|
|
236
|
-
style:
|
|
237
|
-
top: `${
|
|
238
|
-
height: `${
|
|
267
|
+
style: L({
|
|
268
|
+
top: `${d.value}px`,
|
|
269
|
+
height: `${n.value - 8}px`
|
|
239
270
|
})
|
|
240
|
-
}, null, 4)) :
|
|
241
|
-
|
|
242
|
-
items:
|
|
243
|
-
"active-path":
|
|
244
|
-
collapsible:
|
|
245
|
-
"link-component":
|
|
271
|
+
}, null, 4)) : $("", !0),
|
|
272
|
+
x(U, {
|
|
273
|
+
items: s.items,
|
|
274
|
+
"active-path": s.activePath,
|
|
275
|
+
collapsible: s.collapsible,
|
|
276
|
+
"link-component": s.linkComponent,
|
|
246
277
|
depth: -1,
|
|
247
|
-
onUpdateActivePosition:
|
|
248
|
-
onHideMarker: e[0] || (e[0] = (
|
|
278
|
+
onUpdateActivePosition: v,
|
|
279
|
+
onHideMarker: e[0] || (e[0] = (o) => i.value = !1)
|
|
249
280
|
}, null, 8, ["items", "active-path", "collapsible", "link-component"])
|
|
250
281
|
], 512));
|
|
251
282
|
}
|
|
252
283
|
});
|
|
253
284
|
export {
|
|
254
|
-
|
|
285
|
+
Q as default
|
|
255
286
|
};
|
|
256
287
|
//# sourceMappingURL=index.es.mjs.map
|
|
257
288
|
|
|
258
|
-
/* <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] list-none p-0
|
|
289
|
+
/* <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 ml-[28px] grid grid-rows-[0fr] grid-rows-[1fr] overflow-hidden text-indigo-400 text-gray-100 text-gray-200 icon-dark-current block w-full pl-[24px] text-gray-700 dark:text-gray-500 py-[8px] text-[16px] leading-[24px] leading-[20px] text-[14px] py-[12px] left-[6.5px] top-[4px] bottom-[4px] z-10 hidden group-hover:block bg-gray-300 text-gray-500 left-0 transform transition-transform text-gray-400 dark:text-gray-700 flex py-[10px] items-center text-start font-medium pl-[48px] left-[8px] top-0 w-[1px] h-full bg-gray-100 dark:bg-gray-900"> */
|
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 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-[40px]',\n};\n","<script lang=\"ts\" setup>\nimport { computed, type DefineComponent, ref, watch, nextTick } from 'vue'\nimport { IconChevronDownSmall } from '@cypress-design/vue-icon'\nimport { NavGroup, classes } from '@cypress-design/constants-docmenu'\nimport DocGroupElements 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>()\n\nconst Head = computed(() =>\n props.collapsible ? 'button' : props.group.href ? 'a' : 'div',\n)\n\nconst emit = defineEmits<{\n (event: 'updateActivePosition', opts?: { top: number; height: number }): void\n (event: 'hideMarker'): void\n (event: 'updateMarkerPosition'): void\n}>()\n\nfunction hasActiveItemRecursively(items = props.group.items): boolean {\n return items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items)\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\nwatch(active, (active) => {\n if (active) {\n emit('hideMarker')\n }\n})\n\nwatch(open, async (open) => {\n await nextTick()\n if (hasActiveItemRecursively()) {\n if (open) {\n reTriggerSetActiveGroup()\n } else {\n emit('hideMarker')\n }\n } else {\n emit('updateMarkerPosition')\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': active,\n },\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=\"gray-400\"\n :size=\"depth ? '8' : '16'\"\n class=\"absolute left-0 transform transition-transform\"\n :class=\"{\n 'rotate-0': open,\n '-rotate-90': !open,\n 'ml-[16px]': depth,\n }\"\n />\n {{ group.label }}\n </component>\n <DocGroupElements\n ref=\"$groupElements\"\n v-show=\"open\"\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=\"(opts) => emit('updateActivePosition', opts)\"\n />\n</template>\n","<script lang=\"ts\" setup>\nimport { watch, type DefineComponent, ref, onMounted } 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\nfunction setActiveMarkerPosition() {\n if (props.active) {\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\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</script>\n\n<template>\n <li\n ref=\"$container\"\n class=\"list-none p-0\"\n :class=\"{\n 'pl-[16px]': depth >= 0,\n }\"\n >\n <component\n :is=\"linkComponent\"\n class=\"group relative block w-full pl-[24px]\"\n :class=\"{\n 'text-indigo-500': active,\n 'py-[8px] text-[16px] leading-[24px]': depth < 0,\n 'leading-[20px] text-[14px] py-[12px]': depth >= 0,\n }\"\n :href=\"item.href\"\n >\n <div\n v-if=\"depth >= 0\"\n class=\"absolute h-[80%] top-[10%] w-[4px] z-10 rounded-full hidden\"\n :class=\"{\n 'group-hover:block bg-gray-300': !active && collapsible,\n }\"\n :style=\"{\n left: `-${18.5 + depth * 7.5}px`,\n }\"\n />\n {{ item.label }}\n </component>\n </li>\n</template>\n","<script lang=\"ts\" setup>\nimport { DefineComponent, 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<{\n (event: 'updateActivePosition', opts?: { top: number; height: number }): void\n (event: 'hideMarker'): void\n (event: 'updateMarkerPosition'): void\n}>()\n\nconst $items = ref<(typeof DocLink)[]>([])\nconst $groups = ref<(typeof DocGroup)[]>([])\n\nfunction hasActiveItemRecursively(items = props.items): boolean {\n return items.some((item) => {\n if ('items' in item) {\n return hasActiveItemRecursively(item.items)\n }\n return item.href === props.activePath\n })\n}\n\nfunction reTriggerSetActiveGroup() {\n $items.value.forEach((item) => {\n item.setActiveMarkerPosition()\n })\n $groups.value.forEach((group) => {\n group.reTriggerSetActiveGroup()\n })\n}\n\ndefineExpose({\n reTriggerSetActiveGroup,\n})\n</script>\n\n<template>\n <ul\n class=\"list-none p-0\"\n :class=\"{\n 'border-l border-gray-100': depth === 0 && collapsible,\n 'ml-[8px]': depth >= 0,\n }\"\n >\n <template v-for=\"item in items\">\n <li class=\"relative list-none p-0\" v-if=\"item && 'items' in item\">\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 (hasActiveItemRecursively()) {\n reTriggerSetActiveGroup()\n } else {\n emit('updateMarkerPosition')\n }\n }\n \"\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) return\n emit('updateActivePosition', opts)\n }\n \"\n />\n </template>\n </ul>\n</template>\n","<script lang=\"ts\" setup>\nimport { ref, type DefineComponent } 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</script>\n\n<template>\n <div ref=\"$container\" class=\"relative\">\n <div\n v-if=\"showMarker && collapsible\"\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 + 4}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","Head","computed","emit","__emit","hasActiveItemRecursively","items","item","reTriggerSetActiveGroup","_a","active","watch","nextTick","__expose","$container","setActiveMarkerPosition","top","height","onMounted","$items","$groups","group","activeTop","activeHeight","showMarker","updateActiveMarkerPosition","containerTop"],"mappings":";;AAAO,MAAMA,IAAU;AAAA,EACnB,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,YAAY;AAChB;;;;;;;;;;;ACEA,UAAMC,IAAQC,GAaRC,IAAOC,EAAIH,EAAM,MAAM,cAAc,EAAI,GACzCI,IAAiBD,KAEjBE,IAAOC;AAAA,MAAS,MACpBN,EAAM,cAAc,WAAWA,EAAM,MAAM,OAAO,MAAM;AAAA,IAAA,GAGpDO,IAAOC;AAMb,aAASC,EAAyBC,IAAQV,EAAM,MAAM,OAAgB;AAC7D,aAAAU,EAAM,KAAK,CAACC,MACb,WAAWA,IACNF,EAAyBE,EAAK,KAAK,IAErCA,EAAK,SAASX,EAAM,UAC5B;AAAA,IACH;AAEA,aAASY,IAA0B;;AACjC,OAAAC,IAAAT,EAAe,UAAf,QAAAS,EAAsB;AAAA,IACxB;AAEA,UAAMC,IAASR,EAAS,MAAMN,EAAM,MAAM,SAASA,EAAM,UAAU;AAE7D,WAAAe,EAAAD,GAAQ,CAACA,MAAW;AACxB,MAAIA,KACFP,EAAK,YAAY;AAAA,IACnB,CACD,GAEKQ,EAAAb,GAAM,OAAOA,MAAS;AAC1B,YAAMc,EAAS,GACXP,MACEP,IACsBU,MAExBL,EAAK,YAAY,IAGnBA,EAAK,sBAAsB;AAAA,IAC7B,CACD,GAEYU,EAAA;AAAA,MACX,yBAAAL;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChED,UAAMZ,IAAQC,GAaRM,IAAOC,GAQPU,IAAaf;AAEnB,aAASgB,IAA0B;;AACjC,UAAInB,EAAM,QAAQ;AACV,cAAA,EAAE,KAAAoB,IAAM,GAAG,QAAAC,IAAS,SACxBR,IA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Q,GAAG,KAAK,KAAK;;AAC3E,YAAMS,MAAejB,IAAAK,EAAW,UAAX,gBAAAL,EAAkB,wBAAwB,QAAO;AACtE,MAAAa,EAAU,QAAQN,IAAMU,GACxBH,EAAa,QAAQN,GACrBO,EAAW,QAAQ;AAAA,IACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
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\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 :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 'ml-[28px]': depth,\n },\n ]\"\n />\n {{ group.label }}\n </component>\n <div\n class=\"grid transition-all relative\"\n ref=\"$listWrapper\"\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} 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</script>\n\n<template>\n <li ref=\"$container\" class=\"list-none p-0\">\n <component\n :is=\"linkComponent\"\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 :href=\"item.href\"\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 class=\"relative list-none p-0\" v-if=\"item && 'items' in item\">\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","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,aAASa,IAA0B;;AACjC,OAAAC,IAAAV,EAAe,UAAf,QAAAU,EAAsB;AAAA,IACxB;AAEA,UAAMC,IAASR,EAAS,MAAMP,EAAM,MAAM,SAASA,EAAM,UAAU,GAE7D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;;;;"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,
|
|
1
|
+
(function(e,u){typeof exports=="object"&&typeof module<"u"?module.exports=u(require("vue"),require("@cypress-design/vue-icon")):typeof define=="function"&&define.amd?define(["vue","@cypress-design/vue-icon"],u):(e=typeof globalThis<"u"?globalThis:e||self,e.DocMenu=u(e.Vue,e.CyIcon))})(this,function(e,u){"use strict";const g={expandedIcon:"absolute left-0 transform transition-transform text-gray-400 dark:text-gray-700",button:"flex leading-[24px] py-[10px] items-center relative w-full text-start",topButton:"leading-[24px] text-[16px] pl-[24px] font-medium",leafButton:"leading-[20px] text-[14px] pl-[48px]",openListBorderLeft:"absolute left-[8px] top-0 w-[1px] h-full bg-gray-100 dark:bg-gray-900"},C=e.defineComponent({__name:"_DocGroup",props:{group:{},activePath:{},collapsible:{type:Boolean},linkComponent:{},depth:{default:0}},emits:["updateActivePosition","updateMarkerPosition","hideMarker"],setup(k,{expose:d,emit:c}){const r=k,i=e.ref(r.group.collapsed!==!0),m=e.ref(),f=e.ref(),p=e.computed(()=>r.collapsible?"button":r.group.href?"a":"div"),t=c,n=e.computed(()=>r.group.items.some(o=>"items"in o?y(o.items,r.activePath):o.href===r.activePath));function l(){var o;(o=m.value)==null||o.reTriggerSetActiveGroup()}const a=e.computed(()=>r.group.href===r.activePath),h=e.inject("transition-is-moving",e.ref(!1));return e.watch(a,o=>{o&&t("hideMarker")}),e.watch(i,o=>{n.value?o?l():t("hideMarker"):t("updateMarkerPosition")}),d({reTriggerSetActiveGroup:l}),(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":n.value&&!a.value,"text-gray-800 dark:text-gray-200":!n.value&&!a.value}]),href:o.group.href,onClick:s[0]||(s[0]=()=>{o.collapsible?i.value=!i.value:t("updateActivePosition")})},{default:e.withCtx(()=>[r.collapsible?(e.openBlock(),e.createBlock(e.unref(u.IconChevronDownSmall),{key:0,"stroke-color":"current",size:o.depth?"8":"16",class:e.normalizeClass([e.unref(g).expandedIcon,{"rotate-0":i.value,"-rotate-90":!i.value,"ml-[28px]":o.depth}])},null,8,["size","class"])):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(o.group.label),1)]),_:1},8,["class","href"])),e.createElementVNode("div",{class:e.normalizeClass(["grid transition-all relative",{"grid-rows-[0fr]":!i.value&&o.collapsible,"grid-rows-[1fr]":i.value||!o.collapsible}]),ref_key:"$listWrapper",ref:f,onTransitionstart:s[4]||(s[4]=()=>{h.value=!0}),onTransitionend:s[5]||(s[5]=()=>{h.value=!1,(i.value||!n.value)&&t("updateMarkerPosition")})},[i.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:m,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]=B=>t("hideMarker")),onUpdateMarkerPosition:s[2]||(s[2]=()=>t("updateMarkerPosition")),onUpdateActivePosition:s[3]||(s[3]=B=>i.value?t("updateActivePosition",B):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(k,{expose:d,emit:c}){const r=k,i=c,m=e.ref(),f=e.inject("transition-is-moving",e.ref(!1));function p(){r.active&&e.nextTick(()=>{var l;const{top:t=0,height:n=36}=((l=m.value)==null?void 0:l.getBoundingClientRect())??{};i("update:active",r.active,{top:t,height:n})})}return e.onMounted(()=>{e.watch(()=>r.active,t=>{t?p():i("update:active",t)},{immediate:!0})}),d({setActiveMarkerPosition:p}),(t,n)=>(e.openBlock(),e.createElementBlock("li",{ref_key:"$container",ref:m,class:"list-none p-0"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.linkComponent),{class:e.normalizeClass(["group relative block w-full pl-[24px]",{"text-indigo-500 dark:text-indigo-400":t.active,"text-gray-700 dark:text-gray-500":!t.active,"py-[8px] text-[16px] leading-[24px]":t.depth<0,"leading-[20px] text-[14px] py-[12px]":t.depth>=0}]),style:e.normalizeStyle({paddingLeft:t.depth>=0?`${t.depth*12+48}px`:void 0}),href:t.item.href},{default:e.withCtx(()=>[t.depth>=0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["left-[6.5px] absolute top-[4px] bottom-[4px] w-[4px] z-10 rounded-full",{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},8,["class","style","href"]))],512))}}),M={class:"list-none p-0"},v={key:0,class:"relative list-none p-0"};function y(k,d){return k.some(c=>"items"in c?y(c.items,d):c.href===d)}const b=e.defineComponent({__name:"_DocGroupElements",props:{items:{},activePath:{},collapsible:{type:Boolean},linkComponent:{type:[Object,Function,String]},depth:{}},emits:["updateActivePosition","updateMarkerPosition","hideMarker"],setup(k,{expose:d,emit:c}){const r=k,i=c,m=e.ref([]),f=e.ref([]),p=e.computed(()=>r.items.some(n=>"items"in n?y(n.items,r.activePath):n.href===r.activePath));function t(n=-1){m.value.forEach(a=>{a.setActiveMarkerPosition()});const l=n-r.items.slice(0,n).filter(a=>!("items"in a)).length;f.value.slice(l+1).forEach(a=>{a.reTriggerSetActiveGroup()})}return d({reTriggerSetActiveGroup:t}),(n,l)=>(e.openBlock(),e.createElementBlock("ul",M,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.items,(a,h)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[a&&"items"in a?(e.openBlock(),e.createElementBlock("li",v,[e.createVNode(C,{ref_for:!0,ref_key:"$groups",ref:f,"active-path":n.activePath,group:a,depth:n.depth+1,collapsible:n.collapsible,"link-component":n.linkComponent,onUpdateActivePosition:l[0]||(l[0]=o=>{i("updateActivePosition",o)}),onUpdateMarkerPosition:()=>{p.value?t(h):i("updateMarkerPosition")},onHideMarker:l[1]||(l[1]=o=>i("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:m,item:a,active:a.href===n.activePath,depth:n.depth,collapsible:n.collapsible,"link-component":n.linkComponent,"onUpdate:active":l[2]||(l[2]=(o,s)=>{if(s)n.depth<0?i("hideMarker"):i("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:{type:[Object,Function,String],default:"a"}},setup(k){const d=e.ref(),c=e.ref(0),r=e.ref(36),i=e.ref(!1);function m({top:p,height:t}={height:0,top:0}){var l;const n=((l=d.value)==null?void 0:l.getBoundingClientRect().top)||0;c.value=p-n,r.value=t,i.value=!0}const f=e.ref(!1);return e.provide("transition-is-moving",f),(p,t)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"$container",ref:d,class:"relative"},[i.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:`${c.value}px`,height:`${r.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:m,onHideMarker:t[0]||(t[0]=n=>i.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] list-none p-0
|
|
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 ml-[28px] grid grid-rows-[0fr] grid-rows-[1fr] overflow-hidden text-indigo-400 text-gray-100 text-gray-200 icon-dark-current block w-full pl-[24px] text-gray-700 dark:text-gray-500 py-[8px] text-[16px] leading-[24px] leading-[20px] text-[14px] py-[12px] left-[6.5px] top-[4px] bottom-[4px] z-10 hidden group-hover:block bg-gray-300 text-gray-500 left-0 transform transition-transform text-gray-400 dark:text-gray-700 flex py-[10px] items-center text-start font-medium pl-[48px] left-[8px] top-0 w-[1px] h-full bg-gray-100 dark:bg-gray-900"> */
|