@cypress-design/vue-docmenu 0.5.0 → 0.5.2

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.
@@ -2,13 +2,13 @@ $ yarn build:module && yarn build:types
2
2
  $ yarn vite build
3
3
  $ /home/runner/work/cypress-design/cypress-design/node_modules/.bin/vite build
4
4
  The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
5
- vite v5.0.4 building for production...
5
+ vite v5.0.11 building for production...
6
6
  transforming...
7
7
  ✓ 10 modules transformed.
8
8
  rendering chunks...
9
9
  computing gzip size...
10
- dist/index.es.mjs 11.16 kB │ gzip: 3.23 kB │ map: 15.79 kB
11
- dist/index.umd.js 8.74 kB │ gzip: 2.80 kB │ map: 15.34 kB
12
- ✓ built in 3.61s
10
+ dist/index.es.mjs 11.32 kB │ gzip: 3.30 kB │ map: 15.91 kB
11
+ dist/index.umd.js 8.87 kB │ gzip: 2.85 kB │ map: 15.51 kB
12
+ ✓ built in 2.92s
13
13
  $ yarn vue-tsc --project ./tsconfig.build.json
14
14
  $ /home/runner/work/cypress-design/cypress-design/node_modules/.bin/vue-tsc --project ./tsconfig.build.json
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @cypress-design/vue-docmenu
2
2
 
3
+ ## 0.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`fe2f9f0`](https://github.com/cypress-io/cypress-design/commit/fe2f9f0435117454b3d81ce22ec3e9258330a725) Thanks [@elevatebart](https://github.com/elevatebart)! - make margin of button on depth button
8
+
9
+ ## 0.5.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`9f750c5`](https://github.com/cypress-io/cypress-design/commit/9f750c57722351c43d8dda136796a1ea98c203c8) Thanks [@elevatebart](https://github.com/elevatebart)! - adjust colors according to designs and refactor react side to use context
14
+
3
15
  ## 0.5.0
4
16
 
5
17
  ### Minor Changes
package/DocMenuVue.cy.tsx CHANGED
@@ -53,7 +53,11 @@ describe('<DocMenu/>', () => {
53
53
 
54
54
  function mountStory(items: (NavItemLink | NavGroup)[] = [], activePath = '') {
55
55
  mount(() => {
56
- return <DocMenu items={items} activePath={activePath} />
56
+ return (
57
+ <div class="p-4">
58
+ <DocMenu items={items} activePath={activePath} />
59
+ </div>
60
+ )
57
61
  })
58
62
  }
59
63
  assertions(mountStory)
package/_DocGroup.vue CHANGED
@@ -47,27 +47,6 @@ const active = computed(() => props.group.href === props.activePath)
47
47
 
48
48
  const markerIsMoving = inject('transition-is-moving', ref(false))
49
49
 
50
- watch(open, () => {
51
- $listWrapper.value?.addEventListener(
52
- 'transitionstart',
53
- () => {
54
- markerIsMoving.value = true
55
- },
56
- { once: true },
57
- )
58
-
59
- $listWrapper.value?.addEventListener(
60
- 'transitionend',
61
- () => {
62
- markerIsMoving.value = false
63
- if (open.value || !hasActiveItem.value) {
64
- emit('updateMarkerPosition')
65
- }
66
- },
67
- { once: true },
68
- )
69
- })
70
-
71
50
  watch(active, (active) => {
72
51
  if (active) {
73
52
  emit('hideMarker')
@@ -99,13 +78,14 @@ defineExpose({
99
78
  {
100
79
  [classes.topButton]: depth === 0,
101
80
  [classes.leafButton]: depth,
102
- 'text-indigo-500': active,
103
- 'text-gray-900 dark:text-gray-200':
104
- !hasActiveItem && !active && depth === 0,
105
- 'text-gray-700 dark:text-gray-500':
106
- !hasActiveItem && !active && depth >= 0,
81
+ 'text-indigo-500 dark:text-indigo-400': active,
82
+ 'text-gray-900 dark:text-gray-100': hasActiveItem && !active,
83
+ 'text-gray-800 dark:text-gray-200': !hasActiveItem && !active,
107
84
  },
108
85
  ]"
86
+ :style="{
87
+ paddingLeft: depth >= 1 ? `${(depth - 1) * 12 + 48}px` : undefined,
88
+ }"
109
89
  :href="group.href"
110
90
  @click="
111
91
  () => {
@@ -126,9 +106,11 @@ defineExpose({
126
106
  {
127
107
  'rotate-0': open,
128
108
  '-rotate-90': !open,
129
- 'ml-[28px]': depth,
130
109
  },
131
110
  ]"
111
+ :style="{
112
+ marginLeft: depth >= 1 ? `${(depth - 1) * 12 + 28}px` : undefined,
113
+ }"
132
114
  />
133
115
  {{ group.label }}
134
116
  </component>
@@ -139,6 +121,19 @@ defineExpose({
139
121
  'grid-rows-[0fr]': !open && collapsible,
140
122
  'grid-rows-[1fr]': open || !collapsible,
141
123
  }"
124
+ @transitionstart="
125
+ () => {
126
+ markerIsMoving = true
127
+ }
128
+ "
129
+ @transitionend="
130
+ () => {
131
+ markerIsMoving = false
132
+ if (open || !hasActiveItem) {
133
+ emit('updateMarkerPosition')
134
+ }
135
+ }
136
+ "
142
137
  >
143
138
  <div
144
139
  v-if="open && collapsible && depth === 0"
package/_DocLink.vue CHANGED
@@ -1,5 +1,13 @@
1
1
  <script lang="ts" setup>
2
- import { watch, type DefineComponent, ref, onMounted, inject } from 'vue'
2
+ import {
3
+ watch,
4
+ type DefineComponent,
5
+ ref,
6
+ onMounted,
7
+ inject,
8
+ nextTick,
9
+ computed,
10
+ } from 'vue'
3
11
  import type { NavItemLink } from '@cypress-design/constants-docmenu'
4
12
 
5
13
  const props = withDefaults(
@@ -29,12 +37,14 @@ const markerIsMoving = inject('transition-is-moving', ref(false))
29
37
 
30
38
  function setActiveMarkerPosition() {
31
39
  if (props.active) {
32
- const { top = 0, height = 36 } =
33
- $container.value?.getBoundingClientRect() ?? {}
40
+ nextTick(() => {
41
+ const { top = 0, height = 36 } =
42
+ $container.value?.getBoundingClientRect() ?? {}
34
43
 
35
- emit('update:active', props.active, {
36
- top,
37
- height,
44
+ emit('update:active', props.active, {
45
+ top,
46
+ height,
47
+ })
38
48
  })
39
49
  }
40
50
  }
@@ -56,15 +66,22 @@ onMounted(() => {
56
66
  defineExpose({
57
67
  setActiveMarkerPosition,
58
68
  })
69
+
70
+ const itemWithoutLabel = computed(() => {
71
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
72
+ const { label, ...rest } = props.item
73
+ return rest
74
+ })
59
75
  </script>
60
76
 
61
77
  <template>
62
78
  <li ref="$container" class="list-none p-0">
63
79
  <component
64
80
  :is="linkComponent"
81
+ v-bind="itemWithoutLabel"
65
82
  class="group relative block w-full pl-[24px]"
66
83
  :class="{
67
- 'text-indigo-500': active,
84
+ 'text-indigo-500 dark:text-indigo-400': active,
68
85
  'text-gray-700 dark:text-gray-500': !active,
69
86
  'py-[8px] text-[16px] leading-[24px]': depth < 0,
70
87
  'leading-[20px] text-[14px] py-[12px]': depth >= 0,
@@ -72,7 +89,6 @@ defineExpose({
72
89
  :style="{
73
90
  paddingLeft: depth >= 0 ? `${depth * 12 + 48}px` : undefined,
74
91
  }"
75
- :href="item.href"
76
92
  >
77
93
  <div
78
94
  v-if="depth >= 0"
@@ -9,7 +9,7 @@ declare const _default: DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRunt
9
9
  linkComponent: string;
10
10
  collapsible: boolean;
11
11
  activePath: undefined;
12
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
12
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
13
13
  items: (NavItemLink | NavGroup)[];
14
14
  activePath?: string | undefined;
15
15
  collapsible?: boolean | undefined;
@@ -18,7 +18,7 @@ declare const _default: DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRunt
18
18
  } | undefined) => void;
19
19
  updateMarkerPosition: () => void;
20
20
  hideMarker: () => void;
21
- }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
21
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
22
22
  group: NavGroup;
23
23
  activePath?: string | undefined;
24
24
  collapsible: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"_DocGroup.vue.d.ts","sourceRoot":"","sources":["../_DocGroup.vue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,eAAe,EAAsB,MAAM,KAAK,CAAA;AAExE,OAAO,EAAE,QAAQ,EAAW,MAAM,mCAAmC,CAAA;AAwCrE,iBAAS,uBAAuB,SAE/B;;WAmQU,QAAQ;;iBAEF,OAAO;mBACL,eAAe,GAAG,GAAG;;;;;;;;;;;;;;WAH7B,QAAQ;;iBAEF,OAAO;mBACL,eAAe,GAAG,GAAG;;;;;;;;;;;;WAC5B,MAAM;;AAXlB,wBAcG;AACH,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC;AAC9M,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAE1B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QACxE,OAAO,EAAE,C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,CAAC,CAAC,CAAC,CAAC,GAAG;QACxE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KACb,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AACN,KAAK,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -35,7 +35,7 @@ declare const _default: DefineComponent<__VLS_TypePropsToRuntimeProps<{
35
35
  } | undefined) => void;
36
36
  updateMarkerPosition: () => void;
37
37
  hideMarker: () => void;
38
- }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
38
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
39
39
  items: (NavGroup | NavItemLink)[];
40
40
  activePath?: string | undefined;
41
41
  collapsible: boolean;
@@ -16,7 +16,7 @@ declare const _default: DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRunt
16
16
  top: number;
17
17
  height: number;
18
18
  } | undefined) => void;
19
- }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
19
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
20
20
  item: NavItemLink;
21
21
  active: boolean;
22
22
  collapsible: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"_DocLink.vue.d.ts","sourceRoot":"","sources":["../_DocLink.vue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,eAAe,EAA0B,MAAM,KAAK,CAAA;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AA6BpE,iBAAS,uBAAuB,SAU/B;;UA+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ock as f, Fragment as B, createBlock as $, resolveDynamicComponent as L, normalizeClass as k, unref as g, withCtx as S, createCommentVNode as A, createTextVNode as D, toDisplayString as G, createElementVNode as z, createVNode as w, onMounted as H, normalizeStyle as T, renderList as N, provide as V } from "vue";
1
+ import { defineComponent as A, ref as u, computed as y, inject as I, watch as C, openBlock as p, createElementBlock as f, Fragment as B, createBlock as M, resolveDynamicComponent as D, normalizeClass as b, unref as k, normalizeStyle as x, withCtx as E, createCommentVNode as $, createTextVNode as G, toDisplayString as S, createElementVNode as z, createVNode as w, onMounted as H, mergeProps as N, nextTick as V, renderList as R, provide as W } from "vue";
2
2
  import { IconChevronDownSmall as j } from "@cypress-design/vue-icon";
3
- const b = {
3
+ const h = {
4
4
  expandedIcon: "absolute left-0 transform transition-transform text-gray-400 dark:text-gray-700",
5
5
  button: "flex leading-[24px] py-[10px] items-center relative w-full text-start",
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__ */ C({
9
+ }, F = /* @__PURE__ */ A({
10
10
  __name: "_DocGroup",
11
11
  props: {
12
12
  group: {},
@@ -16,102 +16,98 @@ const b = {
16
16
  depth: { default: 0 }
17
17
  },
18
18
  emits: ["updateActivePosition", "updateMarkerPosition", "hideMarker"],
19
- setup(h, { expose: v, emit: d }) {
20
- const n = h, i = u(n.group.collapsed !== !0), m = u(), c = u(), r = P(
21
- () => n.collapsible ? "button" : n.group.href ? "a" : "div"
22
- ), e = d, o = P(
23
- () => n.group.items.some((t) => "items" in t ? x(t.items, n.activePath) : t.href === n.activePath)
19
+ setup(g, { expose: v, emit: d }) {
20
+ const i = g, o = u(i.group.collapsed !== !0), c = u(), m = u(), s = y(
21
+ () => i.collapsible ? "button" : i.group.href ? "a" : "div"
22
+ ), l = d, e = y(
23
+ () => i.group.items.some((t) => "items" in t ? L(t.items, i.activePath) : t.href === i.activePath)
24
24
  );
25
- function a() {
25
+ function n() {
26
26
  var t;
27
- (t = m.value) == null || t.reTriggerSetActiveGroup();
27
+ (t = c.value) == null || t.reTriggerSetActiveGroup();
28
28
  }
29
- const l = P(() => n.group.href === n.activePath), y = I("transition-is-moving", u(!1));
30
- return M(i, () => {
31
- var t, s;
32
- (t = c.value) == null || t.addEventListener(
33
- "transitionstart",
34
- () => {
35
- y.value = !0;
36
- },
37
- { once: !0 }
38
- ), (s = c.value) == null || s.addEventListener(
39
- "transitionend",
40
- () => {
41
- y.value = !1, (i.value || !o.value) && e("updateMarkerPosition");
42
- },
43
- { once: !0 }
44
- );
45
- }), M(l, (t) => {
46
- t && e("hideMarker");
47
- }), M(i, (t) => {
48
- o.value ? t ? a() : e("hideMarker") : e("updateMarkerPosition");
29
+ const a = y(() => i.group.href === i.activePath), P = I("transition-is-moving", u(!1));
30
+ return C(a, (t) => {
31
+ t && l("hideMarker");
32
+ }), C(o, (t) => {
33
+ e.value ? t ? n() : l("hideMarker") : l("updateMarkerPosition");
49
34
  }), v({
50
- reTriggerSetActiveGroup: a
51
- }), (t, s) => (p(), f(B, null, [
52
- (p(), $(L(r.value), {
53
- class: k([
54
- g(b).button,
35
+ reTriggerSetActiveGroup: n
36
+ }), (t, r) => (p(), f(B, null, [
37
+ (p(), M(D(s.value), {
38
+ class: b([
39
+ k(h).button,
55
40
  {
56
- [g(b).topButton]: t.depth === 0,
57
- [g(b).leafButton]: t.depth,
58
- "text-indigo-500": l.value,
59
- "text-gray-900 dark:text-gray-200": !o.value && !l.value && t.depth === 0,
60
- "text-gray-700 dark:text-gray-500": !o.value && !l.value && t.depth >= 0
41
+ [k(h).topButton]: t.depth === 0,
42
+ [k(h).leafButton]: t.depth,
43
+ "text-indigo-500 dark:text-indigo-400": a.value,
44
+ "text-gray-900 dark:text-gray-100": e.value && !a.value,
45
+ "text-gray-800 dark:text-gray-200": !e.value && !a.value
61
46
  }
62
47
  ]),
48
+ style: x({
49
+ paddingLeft: t.depth >= 1 ? `${(t.depth - 1) * 12 + 48}px` : void 0
50
+ }),
63
51
  href: t.group.href,
64
- onClick: s[0] || (s[0] = () => {
65
- t.collapsible ? i.value = !i.value : e("updateActivePosition");
52
+ onClick: r[0] || (r[0] = () => {
53
+ t.collapsible ? o.value = !o.value : l("updateActivePosition");
66
54
  })
67
55
  }, {
68
- default: S(() => [
69
- n.collapsible ? (p(), $(g(j), {
56
+ default: E(() => [
57
+ i.collapsible ? (p(), M(k(j), {
70
58
  key: 0,
71
59
  "stroke-color": "current",
72
60
  size: t.depth ? "8" : "16",
73
- class: k([
74
- g(b).expandedIcon,
61
+ class: b([
62
+ k(h).expandedIcon,
75
63
  {
76
- "rotate-0": i.value,
77
- "-rotate-90": !i.value,
78
- "ml-[28px]": t.depth
64
+ "rotate-0": o.value,
65
+ "-rotate-90": !o.value
79
66
  }
80
- ])
81
- }, null, 8, ["size", "class"])) : A("", !0),
82
- D(" " + G(t.group.label), 1)
67
+ ]),
68
+ style: x({
69
+ marginLeft: t.depth >= 1 ? `${(t.depth - 1) * 12 + 28}px` : void 0
70
+ })
71
+ }, null, 8, ["size", "class", "style"])) : $("", !0),
72
+ G(" " + S(t.group.label), 1)
83
73
  ]),
84
74
  _: 1
85
- }, 8, ["class", "href"])),
75
+ }, 8, ["class", "style", "href"])),
86
76
  z("div", {
87
- class: k(["grid transition-all relative", {
88
- "grid-rows-[0fr]": !i.value && t.collapsible,
89
- "grid-rows-[1fr]": i.value || !t.collapsible
77
+ class: b(["grid transition-all relative", {
78
+ "grid-rows-[0fr]": !o.value && t.collapsible,
79
+ "grid-rows-[1fr]": o.value || !t.collapsible
90
80
  }]),
91
81
  ref_key: "$listWrapper",
92
- ref: c
82
+ ref: m,
83
+ onTransitionstart: r[4] || (r[4] = () => {
84
+ P.value = !0;
85
+ }),
86
+ onTransitionend: r[5] || (r[5] = () => {
87
+ P.value = !1, (o.value || !e.value) && l("updateMarkerPosition");
88
+ })
93
89
  }, [
94
- i.value && t.collapsible && t.depth === 0 ? (p(), f("div", {
90
+ o.value && t.collapsible && t.depth === 0 ? (p(), f("div", {
95
91
  key: 0,
96
- class: k(g(b).openListBorderLeft)
97
- }, null, 2)) : A("", !0),
92
+ class: b(k(h).openListBorderLeft)
93
+ }, null, 2)) : $("", !0),
98
94
  w(U, {
99
95
  ref_key: "$groupElements",
100
- ref: m,
96
+ ref: c,
101
97
  class: "overflow-hidden",
102
98
  depth: t.depth,
103
99
  items: t.group.items,
104
100
  "active-path": t.activePath,
105
101
  collapsible: t.collapsible,
106
102
  "link-component": t.linkComponent,
107
- onHideMarker: s[1] || (s[1] = (E) => e("hideMarker")),
108
- onUpdateMarkerPosition: s[2] || (s[2] = () => e("updateMarkerPosition")),
109
- onUpdateActivePosition: s[3] || (s[3] = (E) => i.value ? e("updateActivePosition", E) : null)
103
+ onHideMarker: r[1] || (r[1] = (T) => l("hideMarker")),
104
+ onUpdateMarkerPosition: r[2] || (r[2] = () => l("updateMarkerPosition")),
105
+ onUpdateActivePosition: r[3] || (r[3] = (T) => o.value ? l("updateActivePosition", T) : null)
110
106
  }, null, 8, ["depth", "items", "active-path", "collapsible", "link-component"])
111
- ], 2)
107
+ ], 34)
112
108
  ], 64));
113
109
  }
114
- }), R = /* @__PURE__ */ C({
110
+ }), q = /* @__PURE__ */ A({
115
111
  __name: "_DocLink",
116
112
  props: {
117
113
  item: {},
@@ -121,126 +117,130 @@ const b = {
121
117
  linkComponent: {}
122
118
  },
123
119
  emits: ["update:active"],
124
- setup(h, { expose: v, emit: d }) {
125
- const n = h, i = d, m = u(), c = I("transition-is-moving", u(!1));
126
- function r() {
127
- var e;
128
- if (n.active) {
129
- const { top: o = 0, height: a = 36 } = ((e = m.value) == null ? void 0 : e.getBoundingClientRect()) ?? {};
130
- i("update:active", n.active, {
131
- top: o,
132
- height: a
120
+ setup(g, { expose: v, emit: d }) {
121
+ const i = g, o = d, c = u(), m = I("transition-is-moving", u(!1));
122
+ function s() {
123
+ i.active && V(() => {
124
+ var a;
125
+ const { top: e = 0, height: n = 36 } = ((a = c.value) == null ? void 0 : a.getBoundingClientRect()) ?? {};
126
+ o("update:active", i.active, {
127
+ top: e,
128
+ height: n
133
129
  });
134
- }
130
+ });
135
131
  }
136
- return H(() => {
137
- M(
138
- () => n.active,
132
+ H(() => {
133
+ C(
134
+ () => i.active,
139
135
  (e) => {
140
- e ? r() : i("update:active", e);
136
+ e ? s() : o("update:active", e);
141
137
  },
142
138
  { immediate: !0 }
143
139
  );
144
140
  }), v({
145
- setActiveMarkerPosition: r
146
- }), (e, o) => (p(), f("li", {
141
+ setActiveMarkerPosition: s
142
+ });
143
+ const l = y(() => {
144
+ const { label: e, ...n } = i.item;
145
+ return n;
146
+ });
147
+ return (e, n) => (p(), f("li", {
147
148
  ref_key: "$container",
148
- ref: m,
149
+ ref: c,
149
150
  class: "list-none p-0"
150
151
  }, [
151
- (p(), $(L(e.linkComponent), {
152
- class: k(["group relative block w-full pl-[24px]", {
153
- "text-indigo-500": e.active,
152
+ (p(), M(D(e.linkComponent), N(l.value, {
153
+ class: ["group relative block w-full pl-[24px]", {
154
+ "text-indigo-500 dark:text-indigo-400": e.active,
154
155
  "text-gray-700 dark:text-gray-500": !e.active,
155
156
  "py-[8px] text-[16px] leading-[24px]": e.depth < 0,
156
157
  "leading-[20px] text-[14px] py-[12px]": e.depth >= 0
157
- }]),
158
- style: T({
158
+ }],
159
+ style: {
159
160
  paddingLeft: e.depth >= 0 ? `${e.depth * 12 + 48}px` : void 0
160
- }),
161
- href: e.item.href
162
- }, {
163
- default: S(() => [
161
+ }
162
+ }), {
163
+ default: E(() => [
164
164
  e.depth >= 0 ? (p(), f("div", {
165
165
  key: 0,
166
- class: k(["left-[6.5px] absolute top-[4px] bottom-[4px] w-[4px] z-10 rounded-full", {
167
- hidden: !g(c) || !e.active,
166
+ class: b(["left-[6.5px] absolute top-[4px] bottom-[4px] w-[4px] z-10 rounded-full", {
167
+ hidden: !k(m) || !e.active,
168
168
  "group-hover:block bg-gray-300": !e.active && e.collapsible,
169
- "bg-indigo-500": e.active && g(c)
169
+ "bg-indigo-500": e.active && k(m)
170
170
  }])
171
- }, null, 2)) : A("", !0),
172
- D(" " + G(e.item.label), 1)
171
+ }, null, 2)) : $("", !0),
172
+ G(" " + S(e.item.label), 1)
173
173
  ]),
174
174
  _: 1
175
- }, 8, ["class", "style", "href"]))
175
+ }, 16, ["class", "style"]))
176
176
  ], 512));
177
177
  }
178
- }), O = { class: "list-none p-0" }, W = {
178
+ }), J = { class: "list-none p-0" }, K = {
179
179
  key: 0,
180
180
  class: "relative list-none p-0"
181
181
  };
182
- function x(h, v) {
183
- return h.some((d) => "items" in d ? x(d.items, v) : d.href === v);
182
+ function L(g, v) {
183
+ return g.some((d) => "items" in d ? L(d.items, v) : d.href === v);
184
184
  }
185
- const U = /* @__PURE__ */ C({
185
+ const U = /* @__PURE__ */ A({
186
186
  __name: "_DocGroupElements",
187
187
  props: {
188
188
  items: {},
189
189
  activePath: {},
190
190
  collapsible: { type: Boolean },
191
- linkComponent: { type: [Object, Function, String] },
191
+ linkComponent: {},
192
192
  depth: {}
193
193
  },
194
194
  emits: ["updateActivePosition", "updateMarkerPosition", "hideMarker"],
195
- setup(h, { expose: v, emit: d }) {
196
- const n = h, i = d, m = u([]), c = u([]), r = P(
197
- () => n.items.some((o) => "items" in o ? x(o.items, n.activePath) : o.href === n.activePath)
195
+ setup(g, { expose: v, emit: d }) {
196
+ const i = g, o = d, c = u([]), m = u([]), s = y(
197
+ () => i.items.some((e) => "items" in e ? L(e.items, i.activePath) : e.href === i.activePath)
198
198
  );
199
- function e(o = -1) {
200
- m.value.forEach((l) => {
201
- l.setActiveMarkerPosition();
199
+ function l(e = -1) {
200
+ c.value.forEach((a) => {
201
+ a.setActiveMarkerPosition();
202
202
  });
203
- const a = o - // remove all the items that are not groups from the array and count them
204
- n.items.slice(0, o).filter((l) => !("items" in l)).length;
205
- c.value.slice(a + 1).forEach((l) => {
206
- l.reTriggerSetActiveGroup();
203
+ const n = e - // remove all the items that are not groups from the array and count them
204
+ i.items.slice(0, e).filter((a) => !("items" in a)).length;
205
+ m.value.slice(n + 1).forEach((a) => {
206
+ a.reTriggerSetActiveGroup();
207
207
  });
208
208
  }
209
209
  return v({
210
- reTriggerSetActiveGroup: e
211
- }), (o, a) => (p(), f("ul", O, [
212
- (p(!0), f(B, null, N(o.items, (l, y) => (p(), f(B, null, [
213
- l && "items" in l ? (p(), f("li", W, [
210
+ reTriggerSetActiveGroup: l
211
+ }), (e, n) => (p(), f("ul", J, [
212
+ (p(!0), f(B, null, R(e.items, (a, P) => (p(), f(B, null, [
213
+ a && "items" in a ? (p(), f("li", K, [
214
214
  w(F, {
215
215
  ref_for: !0,
216
216
  ref_key: "$groups",
217
- ref: c,
218
- "active-path": o.activePath,
219
- group: l,
220
- depth: o.depth + 1,
221
- collapsible: o.collapsible,
222
- "link-component": o.linkComponent,
223
- onUpdateActivePosition: a[0] || (a[0] = (t) => {
224
- i("updateActivePosition", t);
217
+ ref: m,
218
+ "active-path": e.activePath,
219
+ group: a,
220
+ depth: e.depth + 1,
221
+ collapsible: e.collapsible,
222
+ "link-component": e.linkComponent,
223
+ onUpdateActivePosition: n[0] || (n[0] = (t) => {
224
+ o("updateActivePosition", t);
225
225
  }),
226
226
  onUpdateMarkerPosition: () => {
227
- r.value ? e(y) : i("updateMarkerPosition");
227
+ s.value ? l(P) : o("updateMarkerPosition");
228
228
  },
229
- onHideMarker: a[1] || (a[1] = (t) => i("hideMarker"))
229
+ onHideMarker: n[1] || (n[1] = (t) => o("hideMarker"))
230
230
  }, null, 8, ["active-path", "group", "depth", "collapsible", "link-component", "onUpdateMarkerPosition"])
231
- ])) : (p(), $(R, {
231
+ ])) : (p(), M(q, {
232
232
  key: 1,
233
233
  ref_for: !0,
234
234
  ref_key: "$items",
235
- ref: m,
236
- item: l,
237
- active: l.href === o.activePath,
238
- depth: o.depth,
239
- collapsible: o.collapsible,
240
- "link-component": o.linkComponent,
241
- "onUpdate:active": a[2] || (a[2] = (t, s) => {
242
- if (s)
243
- o.depth < 0 ? i("hideMarker") : i("updateActivePosition", s);
235
+ ref: c,
236
+ item: a,
237
+ active: a.href === e.activePath,
238
+ depth: e.depth,
239
+ collapsible: e.collapsible,
240
+ "link-component": e.linkComponent,
241
+ "onUpdate:active": n[2] || (n[2] = (t, r) => {
242
+ if (r)
243
+ e.depth < 0 ? o("hideMarker") : o("updateActivePosition", r);
244
244
  else
245
245
  return;
246
246
  })
@@ -248,51 +248,51 @@ const U = /* @__PURE__ */ C({
248
248
  ], 64))), 256))
249
249
  ]));
250
250
  }
251
- }), K = /* @__PURE__ */ C({
251
+ }), X = /* @__PURE__ */ A({
252
252
  __name: "DocMenu",
253
253
  props: {
254
254
  items: {},
255
255
  activePath: { default: void 0 },
256
256
  collapsible: { type: Boolean, default: !0 },
257
- linkComponent: { type: [Object, Function, String], default: "a" }
257
+ linkComponent: { default: "a" }
258
258
  },
259
- setup(h) {
260
- const v = u(), d = u(0), n = u(36), i = u(!1);
261
- function m({ top: r, height: e } = { height: 0, top: 0 }) {
262
- var a;
263
- const o = ((a = v.value) == null ? void 0 : a.getBoundingClientRect().top) || 0;
264
- d.value = r - o, n.value = e, i.value = !0;
259
+ setup(g) {
260
+ const v = u(), d = u(0), i = u(36), o = u(!1);
261
+ function c({ top: s, height: l } = { height: 0, top: 0 }) {
262
+ var n;
263
+ const e = ((n = v.value) == null ? void 0 : n.getBoundingClientRect().top) || 0;
264
+ d.value = s - e, i.value = l, o.value = !0;
265
265
  }
266
- const c = u(!1);
267
- return V("transition-is-moving", c), (r, e) => (p(), f("div", {
266
+ const m = u(!1);
267
+ return W("transition-is-moving", m), (s, l) => (p(), f("div", {
268
268
  ref_key: "$container",
269
269
  ref: v,
270
270
  class: "relative"
271
271
  }, [
272
- i.value && r.collapsible && !c.value ? (p(), f("div", {
272
+ o.value && s.collapsible && !m.value ? (p(), f("div", {
273
273
  key: 0,
274
274
  "data-cy": "doc-menu-active-marker",
275
275
  class: "absolute h-[36px] w-[4px] z-50 rounded-full bg-indigo-500 transition-all duration-300 ml-[6.5px] mt-[4px]",
276
- style: T({
276
+ style: x({
277
277
  top: `${d.value}px`,
278
- height: `${n.value - 8}px`
278
+ height: `${i.value - 8}px`
279
279
  })
280
- }, null, 4)) : A("", !0),
280
+ }, null, 4)) : $("", !0),
281
281
  w(U, {
282
- items: r.items,
283
- "active-path": r.activePath,
284
- collapsible: r.collapsible,
285
- "link-component": r.linkComponent,
282
+ items: s.items,
283
+ "active-path": s.activePath,
284
+ collapsible: s.collapsible,
285
+ "link-component": s.linkComponent,
286
286
  depth: -1,
287
- onUpdateActivePosition: m,
288
- onHideMarker: e[0] || (e[0] = (o) => i.value = !1)
287
+ onUpdateActivePosition: c,
288
+ onHideMarker: l[0] || (l[0] = (e) => o.value = !1)
289
289
  }, null, 8, ["items", "active-path", "collapsible", "link-component"])
290
290
  ], 512));
291
291
  }
292
292
  });
293
293
  export {
294
- K as default
294
+ X as default
295
295
  };
296
296
  //# sourceMappingURL=index.es.mjs.map
297
297
 
298
- /* <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 text-gray-900 dark:text-gray-200 text-gray-700 dark:text-gray-500 rotate-0 -rotate-90 ml-[28px] grid grid-rows-[0fr] grid-rows-[1fr] overflow-hidden text-gray-200 text-gray-500 icon-dark-current block w-full pl-[24px] 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 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"> */
298
+ /* <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 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"> */
@@ -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(open, () => {\n $listWrapper.value?.addEventListener(\n 'transitionstart',\n () => {\n markerIsMoving.value = true\n },\n { once: true },\n )\n\n $listWrapper.value?.addEventListener(\n 'transitionend',\n () => {\n markerIsMoving.value = false\n if (open.value || !hasActiveItem.value) {\n emit('updateMarkerPosition')\n }\n },\n { once: true },\n )\n})\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': active,\n 'text-gray-900 dark:text-gray-200':\n !hasActiveItem && !active && depth === 0,\n 'text-gray-700 dark:text-gray-500':\n !hasActiveItem && !active && depth >= 0,\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 >\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 { watch, type DefineComponent, ref, onMounted, inject } 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 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 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': 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","_b","__expose","$container","setActiveMarkerPosition","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,M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M,wBAAwB;AAAA,MAAA,CAC/B;AAAA,IACH;AAEa,WAAAZ,EAAA;AAAA,MACX,yBAAAP;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjED,UAAMQ,IAAalB,KAEb8B,IAAY9B,EAAI,CAAC,GACjB+B,IAAe/B,EAAI,EAAE,GACrBgC,IAAahC,EAAI,EAAK;AAEnB,aAAAiC,EAA2B,EAAE,KAAAb,GAAK,QAAAC,EAAO,IAAI,EAAE,QAAQ,GAAG,KAAK,KAAK;;AAC3E,YAAMa,MAAevB,IAAAO,EAAW,UAAX,gBAAAP,EAAkB,wBAAwB,QAAO;AACtE,MAAAmB,EAAU,QAAQV,IAAMc,GACxBH,EAAa,QAAQV,GACrBW,EAAW,QAAQ;AAAA,IACrB;AAEM,UAAAnB,IAAiBb,EAAI,EAAK;AAEhC,WAAAmC,EAAQ,wBAAwBtB,CAAc;;;;;;;;;;;;;;;;;;;;;;;;;;"}
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 :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 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 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\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\">\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 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","itemWithoutLabel","label","rest","items","activePath","$items","$groups","index","indexGroup","group","activeTop","activeHeight","showMarker","updateActiveMarkerPosition","containerTop","provide"],"mappings":";;AAAO,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AM,MAAM,GAAGiC,CAAK,EAAE,OAAO,CAACtB,MAAS,EAAE,WAAWA,EAAK,EAAE;AAKnE,MAAAqB,EAAQ,MAAM,MAAME,IAAa,CAAC,EAAE,QAAQ,CAACC,MAAU;AACrD,QAAAA,EAAM,wBAAwB;AAAA,MAAA,CAC/B;AAAA,IACH;AAEa,WAAAhB,EAAA;AAAA,MACX,yBAAAN;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjED,UAAMO,IAAajB,KAEbiC,IAAYjC,EAAI,CAAC,GACjBkC,IAAelC,EAAI,EAAE,GACrBmC,IAAanC,EAAI,EAAK;AAEnB,aAAAoC,EAA2B,EAAE,KAAAhB,GAAK,QAAAC,EAAO,IAAI,EAAE,QAAQ,GAAG,KAAK,KAAK;;AAC3E,YAAMgB,MAAe1B,IAAAM,EAAW,UAAX,gBAAAN,EAAkB,wBAAwB,QAAO;AACtE,MAAAsB,EAAU,QAAQb,IAAMiB,GACxBH,EAAa,QAAQb,GACrBc,EAAW,QAAQ;AAAA,IACrB;AAEM,UAAAtB,IAAiBb,EAAI,EAAK;AAEhC,WAAAsC,EAAQ,wBAAwBzB,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.CyIcon))})(this,function(e,k){"use strict";const h={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:c}){const r=u,i=e.ref(r.group.collapsed!==!0),f=e.ref(),d=e.ref(),s=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=f.value)==null||o.reTriggerSetActiveGroup()}const a=e.computed(()=>r.group.href===r.activePath),g=e.inject("transition-is-moving",e.ref(!1));return e.watch(i,()=>{var o,p;(o=d.value)==null||o.addEventListener("transitionstart",()=>{g.value=!0},{once:!0}),(p=d.value)==null||p.addEventListener("transitionend",()=>{g.value=!1,(i.value||!n.value)&&t("updateMarkerPosition")},{once:!0})}),e.watch(a,o=>{o&&t("hideMarker")}),e.watch(i,o=>{n.value?o?l():t("hideMarker"):t("updateMarkerPosition")}),m({reTriggerSetActiveGroup:l}),(o,p)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.value),{class:e.normalizeClass([e.unref(h).button,{[e.unref(h).topButton]:o.depth===0,[e.unref(h).leafButton]:o.depth,"text-indigo-500":a.value,"text-gray-900 dark:text-gray-200":!n.value&&!a.value&&o.depth===0,"text-gray-700 dark:text-gray-500":!n.value&&!a.value&&o.depth>=0}]),href:o.group.href,onClick:p[0]||(p[0]=()=>{o.collapsible?i.value=!i.value:t("updateActivePosition")})},{default:e.withCtx(()=>[r.collapsible?(e.openBlock(),e.createBlock(e.unref(k.IconChevronDownSmall),{key:0,"stroke-color":"current",size:o.depth?"8":"16",class:e.normalizeClass([e.unref(h).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:d},[i.value&&o.collapsible&&o.depth===0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(h).openListBorderLeft)},null,2)):e.createCommentVNode("",!0),e.createVNode(b,{ref_key:"$groupElements",ref:f,class:"overflow-hidden",depth:o.depth,items:o.group.items,"active-path":o.activePath,collapsible:o.collapsible,"link-component":o.linkComponent,onHideMarker:p[1]||(p[1]=B=>t("hideMarker")),onUpdateMarkerPosition:p[2]||(p[2]=()=>t("updateMarkerPosition")),onUpdateActivePosition:p[3]||(p[3]=B=>i.value?t("updateActivePosition",B):null)},null,8,["depth","items","active-path","collapsible","link-component"])],2)],64))}}),C=e.defineComponent({__name:"_DocLink",props:{item:{},active:{type:Boolean},collapsible:{type:Boolean},depth:{default:-1},linkComponent:{}},emits:["update:active"],setup(u,{expose:m,emit:c}){const r=u,i=c,f=e.ref(),d=e.inject("transition-is-moving",e.ref(!1));function s(){var t;if(r.active){const{top:n=0,height:l=36}=((t=f.value)==null?void 0:t.getBoundingClientRect())??{};i("update:active",r.active,{top:n,height:l})}}return e.onMounted(()=>{e.watch(()=>r.active,t=>{t?s():i("update:active",t)},{immediate:!0})}),m({setActiveMarkerPosition:s}),(t,n)=>(e.openBlock(),e.createElementBlock("li",{ref_key:"$container",ref:f,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":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(d)||!t.active,"group-hover:block bg-gray-300":!t.active&&t.collapsible,"bg-indigo-500":t.active&&e.unref(d)}])},null,2)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(t.item.label),1)]),_:1},8,["class","style","href"]))],512))}}),P={class:"list-none p-0"},M={key:0,class:"relative list-none p-0"};function y(u,m){return u.some(c=>"items"in c?y(c.items,m):c.href===m)}const b=e.defineComponent({__name:"_DocGroupElements",props:{items:{},activePath:{},collapsible:{type:Boolean},linkComponent:{type:[Object,Function,String]},depth:{}},emits:["updateActivePosition","updateMarkerPosition","hideMarker"],setup(u,{expose:m,emit:c}){const r=u,i=c,f=e.ref([]),d=e.ref([]),s=e.computed(()=>r.items.some(n=>"items"in n?y(n.items,r.activePath):n.href===r.activePath));function t(n=-1){f.value.forEach(a=>{a.setActiveMarkerPosition()});const l=n-r.items.slice(0,n).filter(a=>!("items"in a)).length;d.value.slice(l+1).forEach(a=>{a.reTriggerSetActiveGroup()})}return m({reTriggerSetActiveGroup:t}),(n,l)=>(e.openBlock(),e.createElementBlock("ul",P,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.items,(a,g)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[a&&"items"in a?(e.openBlock(),e.createElementBlock("li",M,[e.createVNode(v,{ref_for:!0,ref_key:"$groups",ref:d,"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:()=>{s.value?t(g):i("updateMarkerPosition")},onHideMarker:l[1]||(l[1]=o=>i("hideMarker"))},null,8,["active-path","group","depth","collapsible","link-component","onUpdateMarkerPosition"])])):(e.openBlock(),e.createBlock(C,{key:1,ref_for:!0,ref_key:"$items",ref:f,item:a,active:a.href===n.activePath,depth:n.depth,collapsible:n.collapsible,"link-component":n.linkComponent,"onUpdate:active":l[2]||(l[2]=(o,p)=>{if(p)n.depth<0?i("hideMarker"):i("updateActivePosition",p);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(u){const m=e.ref(),c=e.ref(0),r=e.ref(36),i=e.ref(!1);function f({top:s,height:t}={height:0,top:0}){var l;const n=((l=m.value)==null?void 0:l.getBoundingClientRect().top)||0;c.value=s-n,r.value=t,i.value=!0}const d=e.ref(!1);return e.provide("transition-is-moving",d),(s,t)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"$container",ref:m,class:"relative"},[i.value&&s.collapsible&&!d.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:s.items,"active-path":s.activePath,collapsible:s.collapsible,"link-component":s.linkComponent,depth:-1,onUpdateActivePosition:f,onHideMarker:t[0]||(t[0]=n=>i.value=!1)},null,8,["items","active-path","collapsible","link-component"])],512))}})});
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"},P=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 i=k,n=e.ref(i.group.collapsed!==!0),m=e.ref(),f=e.ref(),p=e.computed(()=>i.collapsible?"button":i.group.href?"a":"div"),a=c,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=m.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")}),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":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(u.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",{class:e.normalizeClass(["grid transition-all relative",{"grid-rows-[0fr]":!n.value&&o.collapsible,"grid-rows-[1fr]":n.value||!o.collapsible}]),ref_key:"$listWrapper",ref:f,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: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=>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))}}),C=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 i=k,n=c,m=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=m.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})}),d({setActiveMarkerPosition:p});const a=e.computed(()=>{const{label:t,...l}=i.item;return l});return(t,l)=>(e.openBlock(),e.createElementBlock("li",{ref_key:"$container",ref:m,class:"list-none p-0"},[(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))}}),v={class:"list-none p-0"},M={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:{},depth:{}},emits:["updateActivePosition","updateMarkerPosition","hideMarker"],setup(k,{expose:d,emit:c}){const i=k,n=c,m=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){m.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 d({reTriggerSetActiveGroup:a}),(t,l)=>(e.openBlock(),e.createElementBlock("ul",v,[(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(P,{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(C,{key:1,ref_for:!0,ref_key:"$items",ref:m,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(k){const d=e.ref(),c=e.ref(0),i=e.ref(36),n=e.ref(!1);function m({top:p,height:a}={height:0,top:0}){var l;const t=((l=d.value)==null?void 0:l.getBoundingClientRect().top)||0;c.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:d,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:`${c.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:m,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 text-gray-900 dark:text-gray-200 text-gray-700 dark:text-gray-500 rotate-0 -rotate-90 ml-[28px] grid grid-rows-[0fr] grid-rows-[1fr] overflow-hidden text-gray-200 text-gray-500 icon-dark-current block w-full pl-[24px] 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 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"> */
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 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"> */
@@ -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(open, () => {\n $listWrapper.value?.addEventListener(\n 'transitionstart',\n () => {\n markerIsMoving.value = true\n },\n { once: true },\n )\n\n $listWrapper.value?.addEventListener(\n 'transitionend',\n () => {\n markerIsMoving.value = false\n if (open.value || !hasActiveItem.value) {\n emit('updateMarkerPosition')\n }\n },\n { once: true },\n )\n})\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': active,\n 'text-gray-900 dark:text-gray-200':\n !hasActiveItem && !active && depth === 0,\n 'text-gray-700 dark:text-gray-500':\n !hasActiveItem && !active && depth >= 0,\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 >\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 { watch, type DefineComponent, ref, onMounted, inject } 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 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 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': 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","_b","__expose","$container","setActiveMarkerPosition","top","height","onMounted","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,qO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MAAI,CAAC,EACjB+B,EAAe/B,MAAI,EAAE,EACrBgC,EAAahC,MAAI,EAAK,EAEnB,SAAAiC,EAA2B,CAAE,IAAAb,EAAK,OAAAC,CAAO,EAAI,CAAE,OAAQ,EAAG,IAAK,GAAK,OAC3E,MAAMa,IAAevB,EAAAO,EAAW,QAAX,YAAAP,EAAkB,wBAAwB,MAAO,EACtEmB,EAAU,MAAQV,EAAMc,EACxBH,EAAa,MAAQV,EACrBW,EAAW,MAAQ,EACrB,CAEM,MAAAnB,EAAiBb,MAAI,EAAK,EAEhCmC,OAAAA,UAAQ,uBAAwBtB,CAAc"}
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\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 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 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\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\">\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 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","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,E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