@cypress-design/vue-docmenu 1.0.0 → 1.1.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 -10
- package/CHANGELOG.md +6 -0
- package/_DocGroup.vue +6 -6
- package/dist/_DocGroup.vue.d.ts.map +1 -1
- package/dist/index.es.mjs +11 -12
- 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 +5 -5
- package/vite.config.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
$ /home/runner/work/cypress-design/cypress-design/node_modules/.bin/vite build
|
|
4
|
-
[33mThe CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.[39m
|
|
5
|
-
[36mvite v5.2.12 [32mbuilding for production...[36m[39m
|
|
1
|
+
[33mThe CJS build of Vite's Node API is deprecated. See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.[39m
|
|
2
|
+
[36mvite v5.4.19 [32mbuilding for production...[36m[39m
|
|
6
3
|
transforming...
|
|
7
4
|
[32m✓[39m 10 modules transformed.
|
|
8
5
|
rendering chunks...
|
|
9
6
|
computing gzip size...
|
|
10
|
-
[2mdist/[22m[36mindex.es.mjs [39m[1m[2m11.
|
|
11
|
-
[2mdist/[22m[36mindex.umd.js [39m[1m[2m9.
|
|
12
|
-
[32m✓ built in
|
|
13
|
-
$ yarn vue-tsc --project ./tsconfig.build.json
|
|
14
|
-
$ /home/runner/work/cypress-design/cypress-design/node_modules/.bin/vue-tsc --project ./tsconfig.build.json
|
|
7
|
+
[2mdist/[22m[36mindex.es.mjs [39m[1m[2m11.69 kB[22m[1m[22m[2m │ gzip: 3.45 kB[22m[2m │ map: 17.25 kB[22m
|
|
8
|
+
[2mdist/[22m[36mindex.umd.js [39m[1m[2m9.03 kB[22m[1m[22m[2m │ gzip: 2.96 kB[22m[2m │ map: 16.83 kB[22m
|
|
9
|
+
[32m✓ built in 3.02s[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @cypress-design/vue-docmenu
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#733](https://github.com/cypress-io/cypress-design/pull/733) [`5e916fb`](https://github.com/cypress-io/cypress-design/commit/5e916fbe2b83d1503ed80820a85a8705bdcaeef1) Thanks [@jennifer-shehane](https://github.com/jennifer-shehane)! - Depend on `@cypress-design/vue-icon` and `@cypress-design/react-icon` 3.x. These packages were last published against icon 1.x, so installs stayed on 1.x and missed the 3.x fixes, including tree-shakable named icon imports. None of the icons these components use were renamed or removed in 2.0 or 3.0, so there are no API changes. `@cypress-design/vue-modal` now also lists `@cypress-design/vue-icon` as a dependency instead of a devDependency, since its build imports it at runtime.
|
|
8
|
+
|
|
3
9
|
## 1.0.0
|
|
4
10
|
|
|
5
11
|
### 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"
|
|
@@ -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/index.es.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as A, ref as d, computed as y, inject as L, watch as P, createElementBlock as f, openBlock as p, Fragment as w, createBlock as $, createElementVNode as z, resolveDynamicComponent as D, normalizeStyle as B, normalizeClass as b, unref as h, withCtx as E, createCommentVNode as C, createTextVNode as G, toDisplayString as S, createVNode as x, onMounted as H, mergeProps as V, nextTick as N, renderList as R, provide as W } from "vue";
|
|
2
2
|
import { IconChevronDownSmall as j } from "@cypress-design/vue-icon";
|
|
3
3
|
const k = {
|
|
4
4
|
expandedIcon: "absolute left-0 transform transition-transform text-gray-400 dark:text-gray-700",
|
|
@@ -6,7 +6,7 @@ const k = {
|
|
|
6
6
|
topButton: "leading-[24px] text-[16px] pl-[24px] font-medium",
|
|
7
7
|
leafButton: "leading-[20px] text-[14px] pl-[48px]",
|
|
8
8
|
openListBorderLeft: "absolute left-[8px] top-0 w-[1px] h-full bg-gray-100 dark:bg-gray-900"
|
|
9
|
-
}, F = /* @__PURE__ */
|
|
9
|
+
}, F = /* @__PURE__ */ A({
|
|
10
10
|
__name: "_DocGroup",
|
|
11
11
|
props: {
|
|
12
12
|
group: {},
|
|
@@ -73,7 +73,7 @@ const k = {
|
|
|
73
73
|
style: B({
|
|
74
74
|
marginLeft: t.depth >= 1 ? `${(t.depth - 1) * 12 + 28}px` : void 0
|
|
75
75
|
})
|
|
76
|
-
}, null, 8, ["size", "class", "style"])) :
|
|
76
|
+
}, null, 8, ["size", "class", "style"])) : C("", !0),
|
|
77
77
|
G(" " + S(t.group.label), 1)
|
|
78
78
|
]),
|
|
79
79
|
_: 1
|
|
@@ -95,7 +95,7 @@ const k = {
|
|
|
95
95
|
i.value && t.collapsible && t.depth === 0 ? (p(), f("div", {
|
|
96
96
|
key: 0,
|
|
97
97
|
class: b(h(k).openListBorderLeft)
|
|
98
|
-
}, null, 2)) :
|
|
98
|
+
}, null, 2)) : C("", !0),
|
|
99
99
|
x(U, {
|
|
100
100
|
ref_key: "$groupElements",
|
|
101
101
|
ref: u,
|
|
@@ -112,7 +112,7 @@ const k = {
|
|
|
112
112
|
], 34)
|
|
113
113
|
], 64));
|
|
114
114
|
}
|
|
115
|
-
}), q = /* @__PURE__ */
|
|
115
|
+
}), q = /* @__PURE__ */ A({
|
|
116
116
|
__name: "_DocLink",
|
|
117
117
|
props: {
|
|
118
118
|
item: {},
|
|
@@ -188,7 +188,7 @@ const k = {
|
|
|
188
188
|
"group-hover:block bg-gray-300": !e.active && e.collapsible,
|
|
189
189
|
"bg-indigo-500": e.active && h(m)
|
|
190
190
|
}])
|
|
191
|
-
}, null, 2)) :
|
|
191
|
+
}, null, 2)) : C("", !0),
|
|
192
192
|
G(" " + S(e.item.label), 1)
|
|
193
193
|
]),
|
|
194
194
|
_: 1
|
|
@@ -202,7 +202,7 @@ const k = {
|
|
|
202
202
|
function T(g, c) {
|
|
203
203
|
return g.some((v) => "items" in v ? T(v.items, c) : v.href === c);
|
|
204
204
|
}
|
|
205
|
-
const U = /* @__PURE__ */
|
|
205
|
+
const U = /* @__PURE__ */ A({
|
|
206
206
|
__name: "_DocGroupElements",
|
|
207
207
|
props: {
|
|
208
208
|
items: {},
|
|
@@ -261,14 +261,13 @@ const U = /* @__PURE__ */ C({
|
|
|
261
261
|
"onUpdate:active": n[2] || (n[2] = (t, r) => {
|
|
262
262
|
if (r)
|
|
263
263
|
e.depth < 0 ? i("hideMarker") : i("updateActivePosition", r);
|
|
264
|
-
else
|
|
265
|
-
return;
|
|
264
|
+
else return;
|
|
266
265
|
})
|
|
267
266
|
}, null, 8, ["item", "active", "depth", "collapsible", "link-component"]))
|
|
268
267
|
], 64))), 256))
|
|
269
268
|
]));
|
|
270
269
|
}
|
|
271
|
-
}), X = /* @__PURE__ */
|
|
270
|
+
}), X = /* @__PURE__ */ A({
|
|
272
271
|
__name: "DocMenu",
|
|
273
272
|
props: {
|
|
274
273
|
items: {},
|
|
@@ -297,7 +296,7 @@ const U = /* @__PURE__ */ C({
|
|
|
297
296
|
top: `${v.value}px`,
|
|
298
297
|
height: `${o.value - 8}px`
|
|
299
298
|
})
|
|
300
|
-
}, null, 4)) :
|
|
299
|
+
}, null, 4)) : C("", !0),
|
|
301
300
|
x(U, {
|
|
302
301
|
items: s.items,
|
|
303
302
|
"active-path": s.activePath,
|
|
@@ -315,4 +314,4 @@ export {
|
|
|
315
314
|
};
|
|
316
315
|
//# sourceMappingURL=index.es.mjs.map
|
|
317
316
|
|
|
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 scroll-my-10 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
|
|
317
|
+
/* <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 scroll-my-10 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"> */
|
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,aAASa,IAA0B;;AACjC,OAAAC,IAAAV,EAAe,UAAf,QAAAU,EAAsB;AAAA,IACxB;AAEA,UAAMC,IAASR,EAAS,MAAMP,EAAM,MAAM,SAASA,EAAM,UAAU,GAE7DgB,IAAiBC,EAAO,wBAAwBd,EAAI,EAAK,CAAC;AAE1D,WAAAe,EAAAH,GAAQ,CAACA,MAAW;AACxB,MAAIA,KACFP,EAAK,YAAY;AAAA,IACnB,CACD,GAEKU,EAAAhB,GA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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: '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\nexport { CssClasses };\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 } 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":["CssClasses","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;;;;;;;;;;;ACGA,UAAMC,IAAQC,GAaRC,IAAOC,EAAIH,EAAM,MAAM,cAAc,EAAI,GACzCI,IAAiBD,EAAA,GACjBE,IAAeF,EAAA,GAEfG,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,GAE7DgB,IAAiBC,EAAO,wBAAwBd,EAAI,EAAK,CAAC;AAEhE,WAAAe,EAAMH,GAAQ,CAACA,MAAW;AACxB,MAAIA,KACFP,EAAK,YAAY;AAAA,IAErB,CAAC,GAEDU,EAAMhB,GAAM,CAACA,MAAS;AACpB,MAAIQ,EAAc,QACZR,IACFW,EAAA,IAEAL,EAAK,YAAY,IAGnBA,EAAK,sBAAsB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C,IAAYlC,EAAI,CAAC,GACjBmC,IAAenC,EAAI,EAAE,GACrBoC,IAAapC,EAAI,EAAK;AAE5B,aAASqC,EAA2B,EAAE,KAAAjB,GAAK,QAAAC,EAAA,IAAW,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;AAEA,UAAMvB,IAAiBb,EAAI,EAAK;AAEhC,WAAAuC,EAAQ,wBAAwB1B,CAAc;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,k){typeof exports=="object"&&typeof module<"u"?module.exports=k(require("vue"),require("@cypress-design/vue-icon")):typeof define=="function"&&define.amd?define(["vue","@cypress-design/vue-icon"],k):(e=typeof globalThis<"u"?globalThis:e||self,e.DocMenu=k(e.Vue,e.
|
|
1
|
+
(function(e,k){typeof exports=="object"&&typeof module<"u"?module.exports=k(require("vue"),require("@cypress-design/vue-icon")):typeof define=="function"&&define.amd?define(["vue","@cypress-design/vue-icon"],k):(e=typeof globalThis<"u"?globalThis:e||self,e.DocMenu=k(e.Vue,e.Icon))})(this,function(e,k){"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"},v=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"),a=d,t=e.computed(()=>i.group.items.some(o=>"items"in o?y(o.items,i.activePath):o.href===i.activePath));function l(){var o;(o=c.value)==null||o.reTriggerSetActiveGroup()}const r=e.computed(()=>i.group.href===i.activePath),h=e.inject("transition-is-moving",e.ref(!1));return e.watch(r,o=>{o&&a("hideMarker")}),e.watch(n,o=>{t.value?o?l():a("hideMarker"):a("updateMarkerPosition")}),e.watch(()=>i.activePath,()=>{t.value&&!n.value&&(n.value=!0)}),m({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":r.value,"text-gray-900 dark:text-gray-100":t.value&&!r.value,"text-gray-800 dark:text-gray-200":!t.value&&!r.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:a("updateActivePosition")})},{default:e.withCtx(()=>[i.collapsible?(e.openBlock(),e.createBlock(e.unref(k.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]=()=>{h.value=!0}),onTransitionend:s[5]||(s[5]=()=>{h.value=!1,(n.value||!t.value)&&a("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]=B=>a("hideMarker")),onUpdateMarkerPosition:s[2]||(s[2]=()=>a("updateMarkerPosition")),onUpdateActivePosition:s[3]||(s[3]=B=>n.value?a("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(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 r;const{top:t=0,height:l=36}=((r=c.value)==null?void 0:r.getBoundingClientRect())??{};n("update:active",i.active,{top:t,height:l})})}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 l=c.value.getBoundingClientRect();if(l.top>0&&l.bottom<window.innerHeight&&l.left>0&&l.right<window.innerWidth)return;c.value.scrollIntoView({block:"nearest",inline:"nearest"})}},200)});const a=e.computed(()=>{const{label:t,...l}=i.item;return l});return(t,l)=>(e.openBlock(),e.createElementBlock("li",{ref_key:"$container",ref:c,class:"list-none p-0 scroll-my-10"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.linkComponent),e.mergeProps(a.value,{class:["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:{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(["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},16,["class","style"]))],512))}}),C={class:"list-none p-0"},M={key:0,class:"relative list-none p-0"};function y(u,m){return u.some(d=>"items"in d?y(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?y(t.items,i.activePath):t.href===i.activePath));function a(t=-1){c.value.forEach(r=>{r.setActiveMarkerPosition()});const l=t-i.items.slice(0,t).filter(r=>!("items"in r)).length;f.value.slice(l+1).forEach(r=>{r.reTriggerSetActiveGroup()})}return m({reTriggerSetActiveGroup:a}),(t,l)=>(e.openBlock(),e.createElementBlock("ul",C,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.items,(r,h)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[r&&"items"in r?(e.openBlock(),e.createElementBlock("li",M,[e.createVNode(v,{ref_for:!0,ref_key:"$groups",ref:f,"active-path":t.activePath,group:r,depth:t.depth+1,collapsible:t.collapsible,"link-component":t.linkComponent,onUpdateActivePosition:l[0]||(l[0]=o=>{n("updateActivePosition",o)}),onUpdateMarkerPosition:()=>{p.value?a(h):n("updateMarkerPosition")},onHideMarker:l[1]||(l[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:r,active:r.href===t.activePath,depth:t.depth,collapsible:t.collapsible,"link-component":t.linkComponent,"onUpdate:active":l[2]||(l[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:a}={height:0,top:0}){var l;const t=((l=m.value)==null?void 0:l.getBoundingClientRect().top)||0;d.value=p-t,i.value=a,n.value=!0}const f=e.ref(!1);return e.provide("transition-is-moving",f),(p,a)=>(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:a[0]||(a[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 scroll-my-10 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
|
|
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 scroll-my-10 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"> */
|
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,GAAW,CACpBA,GACFP,EAAK,YAAY,CACnB,CACD,EAEKU,QAAAhB,EAAOA,GAAS,CAChBQ,EAAc,MACZR,EACsBW,IAExBL,EAAK,YAAY,EAGnBA,EAAK,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../_DocGroupElements.vue","../DocMenu.vue"],"sourcesContent":["const CssClasses = {\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\nexport { CssClasses };\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 } 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":["CssClasses","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":"4TAAA,MAAMA,EAAa,CACf,aAAc,kFACd,OAAQ,wEACR,UAAW,mDACX,WAAY,uCACZ,mBAAoB,uEACxB,qOCGA,MAAMC,EAAQC,EAaRC,EAAOC,EAAAA,IAAIH,EAAM,MAAM,YAAc,EAAI,EACzCI,EAAiBD,EAAAA,IAAA,EACjBE,EAAeF,EAAAA,IAAA,EAEfG,EAAOC,EAAAA,SAAS,IACpBP,EAAM,YAAc,SAAW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GAAU,CACrDA,EAAM,wBAAA,CACR,CAAC,CACH,CAEA,OAAAjB,EAAa,CACX,wBAAAN,CAAA,CACD,gtCCjED,MAAMO,EAAajB,EAAAA,IAAA,EAEbkC,EAAYlC,EAAAA,IAAI,CAAC,EACjBmC,EAAenC,EAAAA,IAAI,EAAE,EACrBoC,EAAapC,EAAAA,IAAI,EAAK,EAE5B,SAASqC,EAA2B,CAAE,IAAAjB,EAAK,OAAAC,CAAA,EAAW,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,CAEA,MAAMvB,EAAiBb,EAAAA,IAAI,EAAK,EAEhCuC,OAAAA,EAAAA,QAAQ,uBAAwB1B,CAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress-design/vue-docmenu",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"*"
|
|
6
6
|
],
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "yarn build:module && yarn build:types",
|
|
19
|
-
"build:module": "yarn vite build",
|
|
20
|
-
"build:types": "yarn vue-tsc --project ./tsconfig.build.json"
|
|
19
|
+
"build:module": "yarn exec vite build",
|
|
20
|
+
"build:types": "yarn exec 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": "^3.3.2"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
26
|
+
"@cypress-design/constants-docmenu": "*",
|
|
27
27
|
"@cypress-design/rollup-plugin-tailwind-keep": "*"
|
|
28
28
|
},
|
|
29
29
|
"license": "MIT"
|
package/vite.config.ts
CHANGED