@scalar/sidebar 0.8.8 → 0.8.10

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.
Files changed (31) hide show
  1. package/dist/components/ScalarSidebar.vue.d.ts +2 -2
  2. package/dist/components/SidebarItem.vue.d.ts +2 -2
  3. package/dist/components/SidebarItemLabel.vue.d.ts +1 -1
  4. package/dist/helpers/filter-items.d.ts +1 -1
  5. package/dist/helpers/has-children.d.ts +1 -1
  6. package/dist/helpers/is-sidebar-folder.d.ts +1 -1
  7. package/dist/index.d.ts +9 -9
  8. package/dist/index.js +832 -20
  9. package/dist/index.js.map +1 -0
  10. package/dist/style.css +4535 -1
  11. package/package.json +12 -18
  12. package/dist/_virtual/_plugin-vue_export-helper.js +0 -9
  13. package/dist/components/HttpMethod.vue.js +0 -30
  14. package/dist/components/HttpMethod.vue2.js +0 -4
  15. package/dist/components/ScalarSidebar.vue.js +0 -82
  16. package/dist/components/ScalarSidebar.vue2.js +0 -4
  17. package/dist/components/SidebarHttpBadge.vue.js +0 -7
  18. package/dist/components/SidebarHttpBadge.vue2.js +0 -41
  19. package/dist/components/SidebarItem.vue.js +0 -264
  20. package/dist/components/SidebarItem.vue2.js +0 -4
  21. package/dist/components/SidebarItemDecorator.vue.js +0 -12
  22. package/dist/components/SidebarItemLabel.vue.js +0 -22
  23. package/dist/components/SidebarItemLabel.vue2.js +0 -4
  24. package/dist/helpers/create-sidebar-state.js +0 -38
  25. package/dist/helpers/filter-items.js +0 -4
  26. package/dist/helpers/generate-reverse-index.js +0 -14
  27. package/dist/helpers/get-child-entry.js +0 -14
  28. package/dist/helpers/has-children.js +0 -4
  29. package/dist/helpers/is-sidebar-folder.js +0 -5
  30. package/dist/helpers/scroll-sidebar-to-top.js +0 -27
  31. package/dist/hooks/use-draggable.js +0 -82
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "git+https://github.com/scalar/scalar.git",
11
11
  "directory": "packages/sidebar"
12
12
  },
13
- "version": "0.8.8",
13
+ "version": "0.8.10",
14
14
  "engines": {
15
15
  "node": ">=22"
16
16
  },
@@ -31,34 +31,28 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "vue": "^3.5.26",
34
- "@scalar/components": "0.20.8",
35
- "@scalar/helpers": "0.4.1",
36
- "@scalar/icons": "0.6.0",
37
- "@scalar/use-hooks": "0.4.0",
38
- "@scalar/themes": "0.15.0",
39
- "@scalar/workspace-store": "0.40.1"
34
+ "@scalar/helpers": "0.4.2",
35
+ "@scalar/components": "0.20.10",
36
+ "@scalar/themes": "0.15.1",
37
+ "@scalar/icons": "0.6.1",
38
+ "@scalar/use-hooks": "0.4.1",
39
+ "@scalar/workspace-store": "0.40.3"
40
40
  },
41
41
  "devDependencies": {
42
- "@tailwindcss/vite": "^4.1.18",
42
+ "@tailwindcss/vite": "^4.2.0",
43
43
  "@types/jsdom": "27.0.0",
44
44
  "@types/node": "^24.1.0",
45
45
  "@vitejs/plugin-vue": "^6.0.3",
46
46
  "@vue/test-utils": "2.4.6",
47
47
  "jsdom": "27.4.0",
48
48
  "tailwindcss": "^4.1.18",
49
- "vite": "^7.3.1",
50
- "vitest": "4.0.16",
51
- "@scalar/build-tooling": "0.5.0"
49
+ "vite": "8.0.0",
50
+ "vitest": "4.1.0"
52
51
  },
53
52
  "scripts": {
54
- "build": "scalar-build-vite",
53
+ "build": "vite build && vue-tsc -p tsconfig.build.json",
55
54
  "dev": "vite ./playground -c ./vite.config.ts",
56
- "format": "scalar-format",
57
- "format:check": "scalar-format-check",
58
- "lint:check": "scalar-lint-check",
59
- "lint:fix": "scalar-lint-fix",
60
55
  "test": "vitest",
61
- "types:build": "scalar-types-build-vue",
62
- "types:check": "scalar-types-check-vue"
56
+ "types:check": "vue-tsc --noEmit"
63
57
  }
64
58
  }
@@ -1,9 +0,0 @@
1
- const s = (t, e) => {
2
- const o = t.__vccOpts || t;
3
- for (const [r, c] of e)
4
- o[r] = c;
5
- return o;
6
- };
7
- export {
8
- s as default
9
- };
@@ -1,30 +0,0 @@
1
- import { defineComponent as l, computed as r, createBlock as s, openBlock as p, resolveDynamicComponent as m, normalizeStyle as c, withCtx as d, renderSlot as h, createTextVNode as i, toDisplayString as u } from "vue";
2
- import { getHttpMethodInfo as f } from "@scalar/helpers/http/http-info";
3
- import { normalizeHttpMethod as y } from "@scalar/helpers/http/normalize-http-method";
4
- const x = /* @__PURE__ */ l({
5
- __name: "HttpMethod",
6
- props: {
7
- as: {},
8
- property: {},
9
- short: { type: Boolean },
10
- method: {}
11
- },
12
- setup(t) {
13
- const e = t, o = r(
14
- () => f(String(e.method || ""))
15
- ), n = r(() => y(e.method));
16
- return (a, v) => (p(), s(m(t.as ?? "span"), {
17
- class: "uppercase",
18
- style: c({ [t.property || "color"]: o.value.colorVar })
19
- }, {
20
- default: d(() => [
21
- h(a.$slots, "default"),
22
- i(" " + u(t.short ? o.value.short : n.value), 1)
23
- ]),
24
- _: 3
25
- }, 8, ["style"]));
26
- }
27
- });
28
- export {
29
- x as default
30
- };
@@ -1,4 +0,0 @@
1
- import f from "./HttpMethod.vue.js";
2
- export {
3
- f as default
4
- };
@@ -1,82 +0,0 @@
1
- import { defineComponent as y, useSlots as g, createBlock as f, openBlock as i, unref as d, normalizeStyle as S, withCtx as s, renderSlot as r, createVNode as b, createElementBlock as D, Fragment as $, renderList as E, createSlots as k, mergeProps as m, createElementVNode as I } from "vue";
2
- import { ScalarSidebar as v, ScalarSidebarItems as F } from "@scalar/components";
3
- import { filterItems as x } from "../helpers/filter-items.js";
4
- import B from "./SidebarItem.vue.js";
5
- const w = /* @__PURE__ */ y({
6
- __name: "ScalarSidebar",
7
- props: {
8
- layout: {},
9
- items: {},
10
- isSelected: { type: Function },
11
- isExpanded: { type: Function },
12
- options: {},
13
- indent: { default: 20 },
14
- isDraggable: {},
15
- isDroppable: { type: Function }
16
- },
17
- emits: ["reorder", "selectItem", "toggleGroup"],
18
- setup(e, { emit: c }) {
19
- const n = c, a = g(), p = (t, l) => {
20
- n("reorder", t, l);
21
- };
22
- return (t, l) => (i(), f(d(v), {
23
- class: "flex min-h-0 flex-col",
24
- style: S({ "--scalar-sidebar-indent": e.indent + "px" })
25
- }, {
26
- default: s(() => [
27
- r(t.$slots, "header"),
28
- r(t.$slots, "default", {}, () => [
29
- b(d(F), { class: "custom-scroll" }, {
30
- default: s(() => [
31
- r(t.$slots, "before"),
32
- (i(!0), D($, null, E(d(x)(e.layout, e.items), (u) => (i(), f(B, {
33
- key: u.id,
34
- isDraggable: e.isDraggable ?? e.layout === "client",
35
- isDroppable: e.isDroppable,
36
- isExpanded: e.isExpanded,
37
- isSelected: e.isSelected,
38
- item: u,
39
- layout: e.layout,
40
- options: e.options,
41
- onOnDragEnd: p,
42
- onSelectItem: l[0] || (l[0] = (o) => n("selectItem", o)),
43
- onToggleGroup: l[1] || (l[1] = (o) => n("toggleGroup", o))
44
- }, k({ _: 2 }, [
45
- a.decorator ? {
46
- name: "decorator",
47
- fn: s((o) => [
48
- r(t.$slots, "decorator", m({ ref_for: !0 }, o))
49
- ]),
50
- key: "0"
51
- } : void 0,
52
- a.empty ? {
53
- name: "empty",
54
- fn: s((o) => [
55
- r(t.$slots, "empty", m({ ref_for: !0 }, o))
56
- ]),
57
- key: "1"
58
- } : void 0,
59
- a.icon ? {
60
- name: "icon",
61
- fn: s((o) => [
62
- r(t.$slots, "icon", m({ ref_for: !0 }, o))
63
- ]),
64
- key: "2"
65
- } : void 0
66
- ]), 1032, ["isDraggable", "isDroppable", "isExpanded", "isSelected", "item", "layout", "options"]))), 128))
67
- ]),
68
- _: 3
69
- }),
70
- r(t.$slots, "spacer", {}, () => [
71
- l[2] || (l[2] = I("div", { class: "flex-1" }, null, -1))
72
- ])
73
- ]),
74
- r(t.$slots, "footer")
75
- ]),
76
- _: 3
77
- }, 8, ["style"]));
78
- }
79
- });
80
- export {
81
- w as default
82
- };
@@ -1,4 +0,0 @@
1
- import f from "./ScalarSidebar.vue.js";
2
- export {
3
- f as default
4
- };
@@ -1,7 +0,0 @@
1
- import t from "./SidebarHttpBadge.vue2.js";
2
- /* empty css */
3
- import o from "../_virtual/_plugin-vue_export-helper.js";
4
- const p = /* @__PURE__ */ o(t, [["__scopeId", "data-v-1857170e"]]);
5
- export {
6
- p as default
7
- };
@@ -1,41 +0,0 @@
1
- import { defineComponent as n, createBlock as t, openBlock as r, normalizeClass as d, withCtx as m, createElementVNode as s, renderSlot as i, createCommentVNode as c, unref as a, normalizeStyle as h } from "vue";
2
- import { getHttpMethodInfo as f } from "@scalar/helpers/http/http-info";
3
- import { ScalarIconWebhooksLogo as p } from "@scalar/icons";
4
- import y from "./HttpMethod.vue.js";
5
- const w = /* @__PURE__ */ n({
6
- __name: "SidebarHttpBadge",
7
- props: {
8
- method: {},
9
- active: { type: Boolean },
10
- webhook: { type: Boolean }
11
- },
12
- setup(e) {
13
- return (l, o) => (r(), t(y, {
14
- class: d([
15
- "sidebar-heading-type",
16
- `sidebar-heading-type--${e.method.toLowerCase()}`,
17
- { "sidebar-heading-type-active": e.active }
18
- ]),
19
- method: e.method,
20
- property: "--method-color",
21
- short: ""
22
- }, {
23
- default: m(() => [
24
- o[0] || (o[0] = s("span", { class: "sr-only" }, "HTTP Method: ", -1)),
25
- i(l.$slots, "default", {}, () => [
26
- e.webhook ? (r(), t(a(p), {
27
- key: 0,
28
- style: h({
29
- color: a(f)(e.method).colorVar
30
- }),
31
- weight: "bold"
32
- }, null, 8, ["style"])) : c("", !0)
33
- ], !0)
34
- ]),
35
- _: 3
36
- }, 8, ["class", "method"]));
37
- }
38
- });
39
- export {
40
- w as default
41
- };
@@ -1,264 +0,0 @@
1
- import { defineComponent as N, useSlots as V, resolveComponent as H, createBlock as u, unref as n, openBlock as r, mergeProps as m, toHandlers as D, withCtx as o, createTextVNode as L, toDisplayString as O, createElementBlock as g, Fragment as E, renderList as I, createSlots as b, renderSlot as d, createVNode as y, createCommentVNode as $, normalizeClass as G } from "vue";
2
- import { ScalarSidebarSection as z, ScalarSidebarGroup as A, ScalarSidebarItem as P } from "@scalar/components";
3
- import { LibraryIcon as j } from "@scalar/icons/library";
4
- import w from "./SidebarItemDecorator.vue.js";
5
- import { filterItems as C } from "../helpers/filter-items.js";
6
- import { hasChildren as q } from "../helpers/has-children.js";
7
- import { isSidebarFolder as J } from "../helpers/is-sidebar-folder.js";
8
- import { useDraggable as K } from "../hooks/use-draggable.js";
9
- import F from "./SidebarHttpBadge.vue.js";
10
- import f from "./SidebarItemLabel.vue.js";
11
- const M = {
12
- key: 0,
13
- class: "line-through"
14
- }, Q = {
15
- key: 0,
16
- class: "line-through"
17
- }, ie = /* @__PURE__ */ N({
18
- __name: "SidebarItem",
19
- props: {
20
- item: {},
21
- layout: {},
22
- isSelected: { type: Function },
23
- isExpanded: { type: Function },
24
- options: {},
25
- isDraggable: {},
26
- isDroppable: { type: Function }
27
- },
28
- emits: ["selectItem", "onDragEnd", "toggleGroup"],
29
- setup(e, { emit: x }) {
30
- const s = x, l = V(), B = (t) => "isGroup" in t && t.isGroup, h = (t) => ("isDeprecated" in t && t.isDeprecated) ?? !1, S = (t, a) => {
31
- s("onDragEnd", t, a);
32
- }, { draggableAttrs: k, draggableEvents: v } = K({
33
- id: e.item.id,
34
- isDraggable: e.isDraggable,
35
- isDroppable: e.isDroppable,
36
- onDragEnd: S
37
- });
38
- return (t, a) => {
39
- const T = H("SidebarItem", !0);
40
- return n(q)(e.item) && B(e.item) ? (r(), u(n(z), m({
41
- key: 0,
42
- "data-sidebar-id": e.item.id
43
- }, n(k), D(n(v))), {
44
- items: o(() => [
45
- (r(!0), g(E, null, I(n(C)(e.layout, e.item.children), (c) => (r(), u(T, {
46
- key: c.id,
47
- isDraggable: e.isDraggable,
48
- isDroppable: e.isDroppable,
49
- isExpanded: e.isExpanded,
50
- isSelected: e.isSelected,
51
- item: c,
52
- layout: e.layout,
53
- options: e.options,
54
- onOnDragEnd: S,
55
- onSelectItem: a[0] || (a[0] = (i) => s("selectItem", i)),
56
- onToggleGroup: a[1] || (a[1] = (i) => s("toggleGroup", i))
57
- }, b({ _: 2 }, [
58
- l.decorator ? {
59
- name: "decorator",
60
- fn: o((i) => [
61
- d(t.$slots, "decorator", m({ ref_for: !0 }, i))
62
- ]),
63
- key: "0"
64
- } : void 0,
65
- l.empty ? {
66
- name: "empty",
67
- fn: o((i) => [
68
- d(t.$slots, "empty", m({ ref_for: !0 }, i))
69
- ]),
70
- key: "1"
71
- } : void 0,
72
- l.icon ? {
73
- name: "icon",
74
- fn: o((i) => [
75
- d(t.$slots, "icon", m({ ref_for: !0 }, i))
76
- ]),
77
- key: "2"
78
- } : void 0
79
- ]), 1032, ["isDraggable", "isDroppable", "isExpanded", "isSelected", "item", "layout", "options"]))), 128))
80
- ]),
81
- default: o(() => [
82
- L(O(e.item.title) + " ", 1)
83
- ]),
84
- _: 3
85
- }, 16, ["data-sidebar-id"])) : n(J)(e.layout, e.item, l.empty !== void 0) ? (r(), u(n(A), m({
86
- key: 1,
87
- active: e.isSelected(e.item.id),
88
- class: "relative",
89
- controlled: "",
90
- "data-sidebar-id": e.item.id
91
- }, n(k), {
92
- discrete: e.layout === "reference" && e.item.type === "text",
93
- open: e.isExpanded(e.item.id)
94
- }, D(n(v)), {
95
- onClick: a[4] || (a[4] = () => s("selectItem", e.item.id)),
96
- onToggle: a[5] || (a[5] = () => s("toggleGroup", e.item.id))
97
- }), b({
98
- items: o(() => [
99
- (r(!0), g(E, null, I(n(C)(e.layout, e.item.children ?? []), (c) => (r(), u(T, {
100
- key: c.id,
101
- isDraggable: e.isDraggable,
102
- isDroppable: e.isDroppable,
103
- isExpanded: e.isExpanded,
104
- isSelected: e.isSelected,
105
- item: c,
106
- layout: e.layout,
107
- options: e.options,
108
- parentIds: [],
109
- onOnDragEnd: S,
110
- onSelectItem: a[2] || (a[2] = (i) => s("selectItem", i)),
111
- onToggleGroup: a[3] || (a[3] = (i) => s("toggleGroup", i))
112
- }, b({ _: 2 }, [
113
- l.decorator ? {
114
- name: "decorator",
115
- fn: o((i) => [
116
- d(t.$slots, "decorator", m({ ref_for: !0 }, i))
117
- ]),
118
- key: "0"
119
- } : void 0,
120
- l.empty ? {
121
- name: "empty",
122
- fn: o((i) => [
123
- d(t.$slots, "empty", m({ ref_for: !0 }, i))
124
- ]),
125
- key: "1"
126
- } : void 0,
127
- l.icon ? {
128
- name: "icon",
129
- fn: o((i) => [
130
- d(t.$slots, "icon", m({ ref_for: !0 }, i))
131
- ]),
132
- key: "2"
133
- } : void 0
134
- ]), 1032, ["isDraggable", "isDroppable", "isExpanded", "isSelected", "item", "layout", "options"]))), 128)),
135
- l.empty && (e.item.children?.length ?? 0) === 0 ? d(t.$slots, "empty", {
136
- key: 0,
137
- item: e.item
138
- }) : $("", !0)
139
- ]),
140
- default: o(() => [
141
- h(e.item) ? (r(), g("span", M, [
142
- y(f, {
143
- item: e.item,
144
- operationTitleSource: e.options?.operationTitleSource
145
- }, null, 8, ["item", "operationTitleSource"])
146
- ])) : (r(), u(f, {
147
- key: 1,
148
- item: e.item,
149
- operationTitleSource: e.options?.operationTitleSource
150
- }, null, 8, ["item", "operationTitleSource"]))
151
- ]),
152
- _: 2
153
- }, [
154
- e.item.type === "document" ? {
155
- name: "icon",
156
- fn: o(({ open: c }) => [
157
- d(t.$slots, "icon", {
158
- item: e.item,
159
- open: c
160
- }, () => [
161
- y(n(j), {
162
- class: "block",
163
- src: "icon" in e.item && e.item.icon || "interface-content-folder"
164
- }, null, 8, ["src"])
165
- ])
166
- ]),
167
- key: "0"
168
- } : void 0,
169
- "method" in e.item ? {
170
- name: "aside",
171
- fn: o(() => [
172
- y(F, {
173
- active: e.isSelected(e.item.id),
174
- class: G(["mr-1 ml-2 h-4 self-start", {
175
- // Hide the badge when we're showing the decorator
176
- "group-hover/button:opacity-0 group-focus-visible/button:opacity-0 group-has-[~*_[aria-expanded=true]]/button:opacity-0 group-has-[~*:focus-within]/button:opacity-0 group-has-[~*:hover]/button:opacity-0": l.decorator
177
- }]),
178
- method: e.item.method,
179
- webhook: e.item.type === "webhook"
180
- }, null, 8, ["active", "class", "method", "webhook"])
181
- ]),
182
- key: "1"
183
- } : void 0,
184
- l.decorator ? {
185
- name: "after",
186
- fn: o(() => [
187
- y(w, null, {
188
- default: o(() => [
189
- d(t.$slots, "decorator", { item: e.item })
190
- ]),
191
- _: 3
192
- })
193
- ]),
194
- key: "2"
195
- } : void 0
196
- ]), 1040, ["active", "data-sidebar-id", "discrete", "open"])) : (r(), u(n(P), m({
197
- key: 2,
198
- is: "button"
199
- }, n(k), {
200
- class: "relative",
201
- "data-sidebar-id": e.item.id,
202
- selected: e.isSelected(e.item.id)
203
- }, D(n(v)), {
204
- onClick: a[6] || (a[6] = () => s("selectItem", e.item.id))
205
- }), b({
206
- default: o(() => [
207
- h(e.item) ? (r(), g("span", Q, [
208
- y(f, {
209
- item: e.item,
210
- operationTitleSource: e.options?.operationTitleSource
211
- }, null, 8, ["item", "operationTitleSource"])
212
- ])) : (r(), u(f, {
213
- key: 1,
214
- item: e.item,
215
- operationTitleSource: e.options?.operationTitleSource
216
- }, null, 8, ["item", "operationTitleSource"]))
217
- ]),
218
- _: 2
219
- }, [
220
- l.icon ? {
221
- name: "icon",
222
- fn: o(() => [
223
- d(t.$slots, "icon", {
224
- item: e.item,
225
- open: !0
226
- })
227
- ]),
228
- key: "0"
229
- } : void 0,
230
- "method" in e.item ? {
231
- name: "aside",
232
- fn: o(() => [
233
- "method" in e.item ? (r(), u(F, {
234
- key: 0,
235
- active: e.isSelected(e.item.id),
236
- class: G(["ml-2 h-4 self-start", {
237
- // Hide the badge when we're showing the decorator
238
- "group-hover/button:opacity-0 group-focus-visible/button:opacity-0 group-has-[~*_[aria-expanded=true]]/button:opacity-0 group-has-[~*:focus-within]/button:opacity-0 group-has-[~*:hover]/button:opacity-0": l.decorator
239
- }]),
240
- method: e.item.method,
241
- webhook: e.item.type === "webhook"
242
- }, null, 8, ["active", "class", "method", "webhook"])) : $("", !0)
243
- ]),
244
- key: "1"
245
- } : void 0,
246
- l.decorator ? {
247
- name: "after",
248
- fn: o(() => [
249
- y(w, null, {
250
- default: o(() => [
251
- d(t.$slots, "decorator", { item: e.item })
252
- ]),
253
- _: 3
254
- })
255
- ]),
256
- key: "2"
257
- } : void 0
258
- ]), 1040, ["data-sidebar-id", "selected"]));
259
- };
260
- }
261
- });
262
- export {
263
- ie as default
264
- };
@@ -1,4 +0,0 @@
1
- import f from "./SidebarItem.vue.js";
2
- export {
3
- f as default
4
- };
@@ -1,12 +0,0 @@
1
- import { createElementBlock as t, openBlock as o, renderSlot as r } from "vue";
2
- import a from "../_virtual/_plugin-vue_export-helper.js";
3
- const c = {}, i = { class: "bg-b-2 absolute top-[1lh] right-0.75 flex -translate-y-1/2 rounded border p-0.25 opacity-0 peer-hover/button:opacity-100 peer-focus-visible/button:opacity-100 focus-within:opacity-100 hover:opacity-100 has-[&[aria-expanded=true]]:opacity-100" };
4
- function n(e, s) {
5
- return o(), t("div", i, [
6
- r(e.$slots, "default")
7
- ]);
8
- }
9
- const l = /* @__PURE__ */ a(c, [["render", n]]);
10
- export {
11
- l as default
12
- };
@@ -1,22 +0,0 @@
1
- import { defineComponent as n, createBlock as t, openBlock as i, unref as r } from "vue";
2
- import { ScalarWrappingText as a } from "@scalar/components";
3
- const p = /* @__PURE__ */ n({
4
- __name: "SidebarItemLabel",
5
- props: {
6
- item: {},
7
- operationTitleSource: {}
8
- },
9
- setup(e) {
10
- return (m, o) => e.item.type === "model" ? (i(), t(r(a), {
11
- key: 0,
12
- preset: "property",
13
- text: e.item.title
14
- }, null, 8, ["text"])) : (i(), t(r(a), {
15
- key: 1,
16
- text: e.operationTitleSource === "path" && "path" in e.item ? e.item.path : e.item.title
17
- }, null, 8, ["text"]));
18
- }
19
- });
20
- export {
21
- p as default
22
- };
@@ -1,4 +0,0 @@
1
- import f from "./SidebarItemLabel.vue.js";
2
- export {
3
- f as default
4
- };
@@ -1,38 +0,0 @@
1
- import { computed as v, toValue as k, ref as c } from "vue";
2
- import { generateReverseIndex as S } from "./generate-reverse-index.js";
3
- const g = (o, t) => {
4
- const s = v(
5
- () => S({
6
- items: k(o),
7
- nestedKey: t?.key ?? "children"
8
- })
9
- ), a = c({}), n = c({}), u = c(null), m = (e) => {
10
- const f = (r) => {
11
- r && (a.value[r.id] = !0, "parent" in r && r.parent && f(r.parent));
12
- };
13
- t?.hooks?.onBeforeSelect && t.hooks.onBeforeSelect(e), a.value = {}, u.value = e, e !== null && f(s.value.get(e)), t?.hooks?.onAfterSelect && t.hooks.onAfterSelect(e);
14
- }, p = (e, f) => {
15
- const r = (l) => {
16
- l && (n.value[l.id] = !0, "parent" in l && l.parent && r(l.parent));
17
- };
18
- t?.hooks?.onBeforeExpand && t.hooks.onBeforeExpand(e), f === !1 ? n.value[e] = !1 : r(s.value.get(e)), t?.hooks?.onAfterExpand && t.hooks.onAfterExpand(e);
19
- }, x = (e) => n.value[e] ?? !1, d = (e) => a.value[e] ?? !1, h = (e) => s.value.get(e);
20
- return {
21
- items: v(() => k(o)),
22
- index: s,
23
- selectedItems: a,
24
- expandedItems: n,
25
- selectedItem: u,
26
- setSelected: m,
27
- setExpanded: p,
28
- isExpanded: x,
29
- isSelected: d,
30
- getEntryById: h,
31
- reset: () => {
32
- a.value = {}, n.value = {};
33
- }
34
- };
35
- };
36
- export {
37
- g as createSidebarState
38
- };
@@ -1,4 +0,0 @@
1
- const n = /* @__PURE__ */ new Set(["document", "operation", "example", "tag"]), o = (t, e) => t === "reference" ? e : e.filter((r) => n.has(r.type));
2
- export {
3
- o as filterItems
4
- };
@@ -1,14 +0,0 @@
1
- const h = ({
2
- items: c,
3
- nestedKey: i = "children",
4
- filter: f = () => !0,
5
- getId: p = (a) => a.id
6
- }) => {
7
- const a = /* @__PURE__ */ new Map(), t = (r) => {
8
- f(r) && a.set(p(r), r), i in r && Array.isArray(r[i]) && r[i]?.forEach((s) => t({ ...s, parent: r }));
9
- };
10
- return c.forEach(t), a;
11
- };
12
- export {
13
- h as generateReverseIndex
14
- };
@@ -1,14 +0,0 @@
1
- const l = (t, r) => {
2
- if (r.type === t)
3
- return r;
4
- if ("children" in r)
5
- for (const n of r.children ?? []) {
6
- const i = l(t, n);
7
- if (i)
8
- return i;
9
- }
10
- return null;
11
- };
12
- export {
13
- l as getChildEntry
14
- };
@@ -1,4 +0,0 @@
1
- const h = (r) => "children" in r && Array.isArray(r.children) && r.children.length > 0;
2
- export {
3
- h as hasChildren
4
- };
@@ -1,5 +0,0 @@
1
- import { hasChildren as t } from "./has-children.js";
2
- const o = (r, e, n) => t(e) ? r === "client" ? !0 : r === "reference" ? e.type !== "operation" && e.type !== "webhook" : !1 : r === "client" && n ? e.type === "document" || e.type === "tag" : !1;
3
- export {
4
- o as isSidebarFolder
5
- };
@@ -1,27 +0,0 @@
1
- const l = (t) => {
2
- if (window.getComputedStyle(t).display !== "contents")
3
- return t;
4
- for (const o of t.children)
5
- if (o instanceof HTMLElement && o.offsetParent !== null)
6
- return o;
7
- return t;
8
- }, i = (t) => t.dataset.sidebarType !== "heading" ? 0 : t.querySelector(".sidebar-heading")?.offsetHeight ?? 0, a = (t, o) => {
9
- let r = t.offsetTop, e = t.offsetParent;
10
- for (; e && e !== o; )
11
- r += e.offsetTop, e = e.offsetParent;
12
- return r;
13
- }, u = (t, o = 100) => {
14
- if (typeof window > "u")
15
- return;
16
- const r = document.querySelector(`[data-sidebar-id="${t}"]`), e = r?.closest(".custom-scroll, .custom-scrollbar") ?? null;
17
- if (!r || !e)
18
- return;
19
- const n = l(r), c = a(n, e), f = i(r), s = c + f - o;
20
- e.scrollTo({
21
- top: s > 0 ? s : 0,
22
- behavior: "smooth"
23
- });
24
- };
25
- export {
26
- u as scrollSidebarToTop
27
- };