@cypress-design/vue-docmenu 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.mjs CHANGED
@@ -1,209 +1,179 @@
1
- import { h as E, defineComponent as C, openBlock as r, createElementBlock as s, normalizeClass as m, createElementVNode as z, normalizeStyle as B, createCommentVNode as x, createTextVNode as O, toDisplayString as _, ref as $, computed as k, Fragment as f, createBlock as b, resolveDynamicComponent as G, unref as g, withCtx as I, withDirectives as L, renderList as D, createVNode as N, vShow as M } from "vue";
2
- import * as V from "@cypress-design/icon-registry";
3
- import { ICON_COLOR_PROP_NAMES as H } from "@cypress-design/icon-registry";
4
- const T = ({
5
- body: p,
6
- compiledClasses: e,
7
- size: l,
8
- ...o
9
- }) => {
10
- const n = Object.keys(o).reduce(
11
- (a, h) => (!H.includes(
12
- h
13
- ) && h !== "name" && (a[h] = o[h]), a),
14
- {}
15
- ), c = {
16
- width: l,
17
- height: l,
18
- viewBox: `0 0 ${l} ${l}`,
19
- fill: "none",
20
- innerHTML: p,
21
- class: void 0,
22
- ...n
23
- // add all standard attributes back to the svg tag
24
- };
25
- return e.length && (c.class = e.join(" ")), c;
26
- }, A = (p) => {
27
- const { interactiveColorsOnGroup: e, name: l, ...o } = p, { sizeWithDefault: n, compiledClasses: c } = V.getComponentAttributes({
28
- ...o,
29
- availableSizes: ["8", "16"],
30
- interactiveColorsOnGroup: e
31
- }), a = {
32
- 8: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 2.5 3 3 3-3" class="icon-dark"/>',
33
- 16: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m4 6 4 4 4-4" class="icon-dark"/>'
34
- }[n];
35
- if (!a)
36
- throw Error(`Icon "chevron-down-small" is not available in size ${n}`);
37
- return E("svg", T({
38
- ...o,
39
- size: n,
40
- body: a,
41
- compiledClasses: c
42
- }));
43
- }, y = {
1
+ import { defineComponent as v, openBlock as t, createElementBlock as p, normalizeClass as a, createBlock as u, resolveDynamicComponent as x, withCtx as B, normalizeStyle as w, createCommentVNode as k, createTextVNode as $, toDisplayString as D, ref as C, computed as g, Fragment as d, unref as m, withDirectives as G, createElementVNode as H, renderList as z, createVNode as S, vShow as L } from "vue";
2
+ import { IconChevronDownSmall as M } from "@cypress-design/vue-icon";
3
+ const b = {
44
4
  button: "flex leading-[24px] py-[10px] items-center relative w-full",
45
5
  topButton: "leading-[24px] text-[16px] pl-[24px] font-medium",
46
6
  leafButton: "leading-[20px] text-[14px] pl-[40px]"
47
- }, P = ["href"], S = /* @__PURE__ */ C({
7
+ }, N = /* @__PURE__ */ v({
48
8
  __name: "_DocLink",
49
9
  props: {
50
10
  item: {},
11
+ collapsible: { type: Boolean },
51
12
  depth: { default: -1 },
52
- collapsible: { type: Boolean }
13
+ linkComponent: {}
53
14
  },
54
- setup(p) {
55
- return (e, l) => (r(), s("li", {
56
- class: m(["list-none p-0", {
57
- "pl-[16px]": e.depth >= 0
15
+ setup(h) {
16
+ return (l, o) => (t(), p("li", {
17
+ class: a(["list-none p-0", {
18
+ "pl-[16px]": l.depth >= 0
58
19
  }])
59
20
  }, [
60
- z("a", {
61
- class: m(["group relative block w-full pl-[24px]", {
62
- "text-indigo-500 dark:text-indigo-200": e.item.active,
63
- "py-[8px] text-[16px] leading-[24px]": e.depth < 0,
64
- "leading-[20px] text-[14px] py-[12px]": e.depth >= 0
21
+ (t(), u(x(l.linkComponent), {
22
+ class: a(["group relative block w-full pl-[24px]", {
23
+ "text-indigo-500": l.item.active,
24
+ "py-[8px] text-[16px] leading-[24px]": l.depth < 0,
25
+ "leading-[20px] text-[14px] py-[12px]": l.depth >= 0
65
26
  }]),
66
- href: e.item.href
67
- }, [
68
- e.depth >= 0 ? (r(), s("div", {
69
- key: 0,
70
- class: m(["absolute h-[80%] top-[10%] w-[4px] z-10 rounded-full hidden", {
71
- "group-hover:block bg-gray-300": !e.item.active && e.collapsible
72
- }]),
73
- style: B({
74
- left: `-${18.5 + e.depth * 7.5}px`
75
- })
76
- }, null, 6)) : x("", !0),
77
- O(" " + _(e.item.text), 1)
78
- ], 10, P)
27
+ href: l.item.href
28
+ }, {
29
+ default: B(() => [
30
+ l.depth >= 0 ? (t(), p("div", {
31
+ key: 0,
32
+ class: a(["absolute h-[80%] top-[10%] w-[4px] z-10 rounded-full hidden", {
33
+ "group-hover:block bg-gray-300": !l.item.active && l.collapsible
34
+ }]),
35
+ style: w({
36
+ left: `-${18.5 + l.depth * 7.5}px`
37
+ })
38
+ }, null, 6)) : k("", !0),
39
+ $(" " + D(l.item.label), 1)
40
+ ]),
41
+ _: 1
42
+ }, 8, ["class", "href"]))
79
43
  ], 2));
80
44
  }
81
- }), R = {
45
+ }), O = {
82
46
  key: 0,
83
47
  class: "relative list-none p-0"
84
- }, j = /* @__PURE__ */ C({
48
+ }, V = /* @__PURE__ */ v({
85
49
  __name: "_DocGroup",
86
50
  props: {
87
51
  group: {},
88
52
  collapsible: { type: Boolean },
53
+ linkComponent: {},
89
54
  depth: { default: 0 }
90
55
  },
91
- setup(p, { expose: e }) {
92
- const l = p, o = $(l.depth === 0), n = $([]), c = k(() => n.value && o.value ? n.value.reduce(
93
- (t, { height: u }) => t + u,
94
- l.group.items.length
56
+ setup(h, { expose: l }) {
57
+ const o = h, n = C(o.depth === 0), c = C([]), I = g(() => c.value && n.value ? c.value.reduce(
58
+ (e, { height: i }) => e + i,
59
+ o.group.items.length
95
60
  ) : 0);
96
- e({
97
- height: c
61
+ l({
62
+ height: I
98
63
  });
99
- const a = k(() => {
100
- var w;
101
- const t = l.group.items.findIndex(
102
- (d) => "href" in d && d.active
64
+ const E = g(() => {
65
+ var y;
66
+ const e = o.group.items.findIndex(
67
+ (s) => "href" in s && s.active
103
68
  );
104
- let u = l.group.items.filter(
105
- (d, v) => !("href" in d) && v < t
69
+ let i = o.group.items.filter(
70
+ (s, f) => !("href" in s) && f < e
106
71
  ).length;
107
- const i = (w = n.value) == null ? void 0 : w.reduce((d, v) => u < -1 ? d : (u--, d + v.height), 0);
108
- return (t + i) * 44;
109
- }), h = k(
110
- () => l.collapsible ? "button" : l.group.href ? "a" : "div"
72
+ const r = (y = c.value) == null ? void 0 : y.reduce((s, f) => i < -1 ? s : (i--, s + f.height), 0);
73
+ return (e + r) * 44;
74
+ }), F = g(
75
+ () => o.collapsible ? "button" : o.group.href ? "a" : "div"
111
76
  );
112
- return (t, u) => (r(), s(f, null, [
113
- (r(), b(G(h.value), {
114
- class: m([
115
- g(y).button,
77
+ return (e, i) => (t(), p(d, null, [
78
+ (t(), u(x(F.value), {
79
+ class: a([
80
+ m(b).button,
116
81
  {
117
- [g(y).topButton]: t.depth === 0,
118
- [g(y).leafButton]: t.depth,
119
- "text-indigo-500 dark:text-indigo-200": l.group.active
82
+ [m(b).topButton]: e.depth === 0,
83
+ [m(b).leafButton]: e.depth,
84
+ "text-indigo-500": o.group.active
120
85
  }
121
86
  ]),
122
- href: l.group.href,
123
- onClick: u[0] || (u[0] = () => {
124
- t.collapsible && (o.value = !o.value);
87
+ href: o.group.href,
88
+ onClick: i[0] || (i[0] = () => {
89
+ e.collapsible && (n.value = !n.value);
125
90
  })
126
91
  }, {
127
- default: I(() => [
128
- l.collapsible ? (r(), b(g(A), {
92
+ default: B(() => [
93
+ o.collapsible ? (t(), u(m(M), {
129
94
  key: 0,
130
95
  "stroke-color": "gray-400",
131
- size: t.depth ? "8" : "16",
132
- class: m(["absolute left-0 transform transition-transform", {
133
- "rotate-0": o.value,
134
- "-rotate-90": !o.value,
135
- "ml-[16px]": t.depth
96
+ size: e.depth ? "8" : "16",
97
+ class: a(["absolute left-0 transform transition-transform", {
98
+ "rotate-0": n.value,
99
+ "-rotate-90": !n.value,
100
+ "ml-[16px]": e.depth
136
101
  }])
137
- }, null, 8, ["size", "class"])) : x("", !0),
138
- O(" " + _(t.group.text), 1)
102
+ }, null, 8, ["size", "class"])) : k("", !0),
103
+ $(" " + D(e.group.label), 1)
139
104
  ]),
140
105
  _: 1
141
106
  }, 8, ["class", "href"])),
142
- l.collapsible && t.depth >= 0 && o.value && t.group.items.some((i) => "href" in i && i.active) ? (r(), s("div", {
107
+ o.collapsible && e.depth >= 0 && n.value && e.group.items.some((r) => "href" in r && r.active) ? (t(), p("div", {
143
108
  key: 0,
144
109
  class: "absolute h-[36px] w-[4px] z-10 rounded-full bg-indigo-500 transition-all duration-300 ml-[6px] mt-[48px]",
145
- style: B({
146
- top: `${a.value}px`,
147
- left: `-${t.depth === 0 ? 0 : t.depth * 7.5 + 1}px`
110
+ style: w({
111
+ top: `${E.value}px`,
112
+ left: `-${e.depth === 0 ? 0 : e.depth * 7.5 + 1}px`
148
113
  })
149
- }, null, 4)) : x("", !0),
150
- L(z("ul", {
151
- class: m(["list-none p-0 ml-[7.5px]", {
152
- "border-l border-gray-100": t.depth === 0 && l.collapsible
114
+ }, null, 4)) : k("", !0),
115
+ G(H("ul", {
116
+ class: a(["list-none p-0 ml-[7.5px]", {
117
+ "border-l border-gray-100": e.depth === 0 && o.collapsible
153
118
  }])
154
119
  }, [
155
- (r(!0), s(f, null, D(t.group.items, (i) => (r(), s(f, null, [
156
- i && "items" in i ? (r(), s("li", R, [
157
- N(j, {
120
+ (t(!0), p(d, null, z(e.group.items, (r) => (t(), p(d, null, [
121
+ r && "items" in r ? (t(), p("li", O, [
122
+ S(V, {
158
123
  ref_for: !0,
159
124
  ref_key: "$groups",
160
- ref: n,
161
- group: i,
162
- depth: t.depth + 1,
163
- collapsible: l.collapsible
164
- }, null, 8, ["group", "depth", "collapsible"])
165
- ])) : (r(), b(S, {
125
+ ref: c,
126
+ group: r,
127
+ depth: e.depth + 1,
128
+ collapsible: o.collapsible,
129
+ "link-component": o.linkComponent
130
+ }, null, 8, ["group", "depth", "collapsible", "link-component"])
131
+ ])) : (t(), u(N, {
166
132
  key: 1,
167
- item: i,
168
- depth: t.depth,
169
- collapsible: t.collapsible
170
- }, null, 8, ["item", "depth", "collapsible"]))
133
+ item: r,
134
+ depth: e.depth,
135
+ collapsible: e.collapsible,
136
+ "link-component": o.linkComponent
137
+ }, null, 8, ["item", "depth", "collapsible", "link-component"]))
171
138
  ], 64))), 256))
172
139
  ], 2), [
173
- [M, o.value]
140
+ [L, n.value]
174
141
  ])
175
142
  ], 64));
176
143
  }
177
- }), F = { class: "overflow-y-hidden list-none p-0" }, W = {
144
+ }), T = { class: "overflow-y-hidden list-none p-0" }, j = {
178
145
  key: 0,
179
146
  class: "relative list-none p-0"
180
- }, K = /* @__PURE__ */ C({
147
+ }, A = /* @__PURE__ */ v({
181
148
  __name: "DocMenu",
182
149
  props: {
183
150
  items: {},
184
- collapsible: { type: Boolean, default: !0 }
151
+ collapsible: { type: Boolean, default: !0 },
152
+ linkComponent: { type: [Object, Function, String], default: "a" }
185
153
  },
186
- setup(p) {
187
- return (e, l) => (r(), s("ul", F, [
188
- (r(!0), s(f, null, D(e.items, (o) => (r(), s(f, null, [
189
- "items" in o ? (r(), s("li", W, [
190
- N(j, {
191
- group: o,
154
+ setup(h) {
155
+ return (l, o) => (t(), p("ul", T, [
156
+ (t(!0), p(d, null, z(l.items, (n) => (t(), p(d, null, [
157
+ "items" in n ? (t(), p("li", j, [
158
+ S(V, {
159
+ group: n,
192
160
  depth: 0,
193
- collapsible: e.collapsible
194
- }, null, 8, ["group", "collapsible"])
195
- ])) : (r(), b(S, {
161
+ collapsible: l.collapsible,
162
+ "link-component": l.linkComponent
163
+ }, null, 8, ["group", "collapsible", "link-component"])
164
+ ])) : (t(), u(N, {
196
165
  key: 1,
197
- item: o,
198
- collapsible: e.collapsible
199
- }, null, 8, ["item", "collapsible"]))
166
+ item: n,
167
+ collapsible: l.collapsible,
168
+ "link-component": l.linkComponent
169
+ }, null, 8, ["item", "collapsible", "link-component"]))
200
170
  ], 64))), 256))
201
171
  ]));
202
172
  }
203
173
  });
204
174
  export {
205
- K as default
175
+ A as default
206
176
  };
207
177
  //# sourceMappingURL=index.es.mjs.map
208
178
 
209
- /* <wind-keep class="overflow-y-hidden list-none p-0 relative filter text-indigo-500 dark:text-indigo-200 absolute left-0 transform transition-transform rotate-0 -rotate-90 ml-[16px] h-[36px] w-[4px] z-10 rounded-full bg-indigo-500 transition-all duration-300 ml-[6px] mt-[48px] ml-[7.5px] border-l border-gray-100 text-indigo-200 pl-[16px] block w-full pl-[24px] py-[8px] text-[16px] leading-[24px] leading-[20px] text-[14px] py-[12px] h-[80%] top-[10%] hidden group-hover:block bg-gray-300 flex py-[10px] items-center font-medium pl-[40px]"> */
179
+ /* <wind-keep class="overflow-y-hidden list-none p-0 relative filter text-indigo-500 absolute left-0 transform transition-transform rotate-0 -rotate-90 ml-[16px] h-[36px] w-[4px] z-10 rounded-full bg-indigo-500 transition-all duration-300 ml-[6px] mt-[48px] ml-[7.5px] border-l border-gray-100 icon-dark-gray-400 pl-[16px] block w-full pl-[24px] py-[8px] text-[16px] leading-[24px] leading-[20px] text-[14px] py-[12px] h-[80%] top-[10%] hidden group-hover:block bg-gray-300 flex py-[10px] items-center font-medium pl-[40px]"> */