@scalar/sidebar 0.3.0 → 0.5.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/components/ScalarSidebar.vue.d.ts +28 -3
- package/dist/components/ScalarSidebar.vue.d.ts.map +1 -1
- package/dist/components/ScalarSidebar.vue.js +31 -22
- package/dist/components/SidebarItem.vue.d.ts +35 -3
- package/dist/components/SidebarItem.vue.d.ts.map +1 -1
- package/dist/components/SidebarItem.vue.js +141 -135
- package/dist/helpers/create-sidebar-state.d.ts +2 -0
- package/dist/helpers/create-sidebar-state.d.ts.map +1 -1
- package/dist/helpers/create-sidebar-state.js +26 -22
- package/dist/helpers/get-child-entry.d.ts +14 -0
- package/dist/helpers/get-child-entry.d.ts.map +1 -0
- package/dist/helpers/get-child-entry.js +14 -0
- package/dist/hooks/use-draggable.d.ts +89 -0
- package/dist/hooks/use-draggable.d.ts.map +1 -0
- package/dist/hooks/use-draggable.js +82 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/style.css +1 -1
- package/package.json +9 -9
|
@@ -1,15 +1,40 @@
|
|
|
1
|
-
import type { DraggingItem, HoveredItem } from '
|
|
1
|
+
import type { DraggingItem, HoveredItem, UseDraggableOptions } from '../hooks/use-draggable.js';
|
|
2
2
|
import type { Item } from '../types';
|
|
3
3
|
type __VLS_Props = {
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Layout type for the sidebar.
|
|
6
|
+
* Determines whether the sidebar should behave in 'client' or 'reference' mode.
|
|
7
|
+
*/
|
|
5
8
|
layout: 'client' | 'reference';
|
|
6
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* List of items to render in the sidebar.
|
|
11
|
+
*/
|
|
7
12
|
items: Item[];
|
|
13
|
+
/**
|
|
14
|
+
* Function to determine whether a given item (by id) is currently selected.
|
|
15
|
+
*/
|
|
8
16
|
isSelected: (id: string) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Function to determine whether a given item (by id) is currently expanded (open to show children).
|
|
19
|
+
*/
|
|
9
20
|
isExpanded: (id: string) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Sidebar configuration options.
|
|
23
|
+
* - operationTitleSource: sets whether operations show their path or summary as the display title.
|
|
24
|
+
*/
|
|
10
25
|
options?: {
|
|
11
26
|
operationTitleSource: 'path' | 'summary' | undefined;
|
|
12
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* The indentation in pixels to apply to nested items/groups in the sidebar.
|
|
30
|
+
*/
|
|
31
|
+
indent?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Prevents sidebar items from being hovered and dropped into. Can be either a function or a boolean
|
|
34
|
+
*
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
isDroppable?: UseDraggableOptions['isDroppable'];
|
|
13
38
|
};
|
|
14
39
|
type __VLS_Slots = {
|
|
15
40
|
/** Overrides the main items list */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarSidebar.vue.d.ts","sourceRoot":"","sources":["../../src/components/ScalarSidebar.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarSidebar.vue.d.ts","sourceRoot":"","sources":["../../src/components/ScalarSidebar.vue"],"names":[],"mappings":"AAqIA,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,mBAAmB,EACpB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAInC,KAAK,WAAW,GAAG;IACjB;;;OAGG;IACH,MAAM,EAAE,QAAQ,GAAG,WAAW,CAAA;IAC9B;;OAEG;IACH,KAAK,EAAE,IAAI,EAAE,CAAA;IACb;;OAEG;IACH,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAA;IACnC;;OAEG;IACH,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAA;IACnC;;;OAGG;IACH,OAAO,CAAC,EAAE;QACR,oBAAoB,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;KACrD,CAAA;IACD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,WAAW,CAAC,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAA;CACjD,CAAC;AAuBF,KAAK,WAAW,GAAG;IACjB,oCAAoC;IACpC,OAAO,CAAC,IAAI,OAAO,CAAA;IACnB,iEAAiE;IACjE,SAAS,CAAC,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAA;IAC1C,yEAAyE;IACzE,MAAM,CAAC,IAAI,OAAO,CAAA;IAClB,4EAA4E;IAC5E,MAAM,CAAC,IAAI,OAAO,CAAA;IAClB,6DAA6D;IAC7D,MAAM,CAAC,IAAI,OAAO,CAAA;CACnB,CAAC;AAwIF,QAAA,MAAM,eAAe;;;;;;kFAOnB,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAQ1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,53 +1,62 @@
|
|
|
1
|
-
import { defineComponent as u, createBlock as
|
|
2
|
-
import { ScalarSidebar as
|
|
1
|
+
import { defineComponent as u, createBlock as i, openBlock as l, unref as d, normalizeStyle as f, withCtx as s, renderSlot as o, createVNode as c, createElementVNode as S, createElementBlock as y, Fragment as b, renderList as g, mergeProps as D } from "vue";
|
|
2
|
+
import { ScalarSidebar as E, ScalarSidebarItems as $ } from "@scalar/components";
|
|
3
3
|
import k from "./SidebarItem.vue.js";
|
|
4
|
-
const
|
|
4
|
+
const N = /* @__PURE__ */ u({
|
|
5
5
|
__name: "ScalarSidebar",
|
|
6
6
|
props: {
|
|
7
7
|
layout: {},
|
|
8
8
|
items: {},
|
|
9
9
|
isSelected: { type: Function },
|
|
10
10
|
isExpanded: { type: Function },
|
|
11
|
-
options: {}
|
|
11
|
+
options: {},
|
|
12
|
+
indent: { default: 20 },
|
|
13
|
+
isDroppable: { type: Function }
|
|
12
14
|
},
|
|
13
15
|
emits: ["reorder", "selectItem"],
|
|
14
|
-
setup(
|
|
15
|
-
const
|
|
16
|
-
|
|
16
|
+
setup(F, { emit: p }) {
|
|
17
|
+
const a = p, m = (e, t) => {
|
|
18
|
+
a("reorder", e, t);
|
|
17
19
|
};
|
|
18
|
-
return (e, t) => (
|
|
19
|
-
|
|
20
|
+
return (e, t) => (l(), i(d(E), {
|
|
21
|
+
class: "flex min-h-0 flex-col",
|
|
22
|
+
style: f({
|
|
23
|
+
"--scalar-sidebar-indent": e.indent + "px"
|
|
24
|
+
})
|
|
25
|
+
}, {
|
|
26
|
+
default: s(() => [
|
|
20
27
|
o(e.$slots, "header"),
|
|
21
28
|
o(e.$slots, "default", {}, () => [
|
|
22
|
-
|
|
23
|
-
default:
|
|
29
|
+
c(d($), { class: "custom-scroll pt-0" }, {
|
|
30
|
+
default: s(() => [
|
|
24
31
|
o(e.$slots, "before"),
|
|
25
|
-
(
|
|
26
|
-
key:
|
|
32
|
+
(l(!0), y(b, null, g(e.items, (n) => (l(), i(k, {
|
|
33
|
+
key: n.id,
|
|
34
|
+
isDraggable: e.layout === "client",
|
|
35
|
+
isDroppable: e.isDroppable,
|
|
27
36
|
isExpanded: e.isExpanded,
|
|
28
37
|
isSelected: e.isSelected,
|
|
29
|
-
item:
|
|
38
|
+
item: n,
|
|
30
39
|
layout: e.layout,
|
|
31
40
|
options: e.options,
|
|
32
|
-
onOnDragEnd:
|
|
33
|
-
onSelectItem: t[0] || (t[0] = (r) =>
|
|
41
|
+
onOnDragEnd: m,
|
|
42
|
+
onSelectItem: t[0] || (t[0] = (r) => a("selectItem", r))
|
|
34
43
|
}, {
|
|
35
|
-
decorator:
|
|
36
|
-
o(e.$slots, "decorator",
|
|
44
|
+
decorator: s((r) => [
|
|
45
|
+
o(e.$slots, "decorator", D({ ref_for: !0 }, r))
|
|
37
46
|
]),
|
|
38
47
|
_: 3
|
|
39
|
-
}, 8, ["isExpanded", "isSelected", "item", "layout", "options"]))), 128))
|
|
48
|
+
}, 8, ["isDraggable", "isDroppable", "isExpanded", "isSelected", "item", "layout", "options"]))), 128))
|
|
40
49
|
]),
|
|
41
50
|
_: 3
|
|
42
51
|
}),
|
|
43
|
-
t[1] || (t[1] =
|
|
52
|
+
t[1] || (t[1] = S("div", { class: "flex-1" }, null, -1))
|
|
44
53
|
]),
|
|
45
54
|
o(e.$slots, "footer")
|
|
46
55
|
]),
|
|
47
56
|
_: 3
|
|
48
|
-
}));
|
|
57
|
+
}, 8, ["style"]));
|
|
49
58
|
}
|
|
50
59
|
});
|
|
51
60
|
export {
|
|
52
|
-
|
|
61
|
+
N as default
|
|
53
62
|
};
|
|
@@ -1,25 +1,57 @@
|
|
|
1
|
-
import { type DraggingItem, type HoveredItem } from '
|
|
1
|
+
import { type DraggingItem, type HoveredItem, type UseDraggableOptions } from '../hooks/use-draggable.js';
|
|
2
2
|
import type { Item } from '../types';
|
|
3
3
|
type __VLS_Props = {
|
|
4
|
+
/**
|
|
5
|
+
* The sidebar item to render.
|
|
6
|
+
*/
|
|
4
7
|
item: Item;
|
|
8
|
+
/**
|
|
9
|
+
* The layout mode for the sidebar ('client' or 'reference').
|
|
10
|
+
*/
|
|
5
11
|
layout: 'client' | 'reference';
|
|
12
|
+
/**
|
|
13
|
+
* Function to determine if an item is currently selected by id.
|
|
14
|
+
*/
|
|
6
15
|
isSelected: (id: string) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Function to determine if an item is currently expanded (showing its children) by id.
|
|
18
|
+
*/
|
|
7
19
|
isExpanded: (id: string) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Sidebar configuration options.
|
|
22
|
+
* - operationTitleSource: sets whether operations show their path or summary as the display title.
|
|
23
|
+
*/
|
|
8
24
|
options: {
|
|
9
25
|
operationTitleSource: 'path' | 'summary' | undefined;
|
|
10
26
|
} | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Prevents this item from being dragged.
|
|
29
|
+
*
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
isDraggable?: UseDraggableOptions['isDraggable'];
|
|
33
|
+
/**
|
|
34
|
+
* Prevents this item from being hovered and dropped into. Can be either a function or a boolean.
|
|
35
|
+
*
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
isDroppable?: UseDraggableOptions['isDroppable'];
|
|
11
39
|
};
|
|
12
40
|
type __VLS_Slots = {
|
|
41
|
+
/**
|
|
42
|
+
* Adds an optional decorator for each item, such as an edit menu.
|
|
43
|
+
* The slot receives an object with the current item.
|
|
44
|
+
*/
|
|
13
45
|
decorator?(props: {
|
|
14
46
|
item: Item;
|
|
15
47
|
}): unknown;
|
|
16
48
|
};
|
|
17
49
|
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
18
|
-
selectItem: (id: string) => any;
|
|
19
50
|
onDragEnd: (draggingItem: DraggingItem, hoveredItem: HoveredItem) => any;
|
|
51
|
+
selectItem: (id: string) => any;
|
|
20
52
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
21
|
-
onSelectItem?: ((id: string) => any) | undefined;
|
|
22
53
|
onOnDragEnd?: ((draggingItem: DraggingItem, hoveredItem: HoveredItem) => any) | undefined;
|
|
54
|
+
onSelectItem?: ((id: string) => any) | undefined;
|
|
23
55
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
56
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
25
57
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidebarItem.vue.d.ts","sourceRoot":"","sources":["../../src/components/SidebarItem.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SidebarItem.vue.d.ts","sourceRoot":"","sources":["../../src/components/SidebarItem.vue"],"names":[],"mappings":"AAkQA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACzB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAInC,KAAK,WAAW,GAAG;IACf;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IACV;;OAEG;IACH,MAAM,EAAE,QAAQ,GAAG,WAAW,CAAA;IAC9B;;OAEG;IACH,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAA;IACnC;;OAEG;IACH,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAA;IACnC;;;OAGG;IACH,OAAO,EACH;QACE,oBAAoB,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;KACrD,GACD,SAAS,CAAA;IAEb;;;;OAIG;IACH,WAAW,CAAC,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAA;IAChD;;;;OAIG;IACH,WAAW,CAAC,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAA;CACjD,CAAC;AAmBJ,KAAK,WAAW,GAAG;IACjB;;;OAGG;IACH,SAAS,CAAC,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAA;CAC3C,CAAC;AAgYF,QAAA,MAAM,eAAe;;;;;;kFAOnB,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAQ1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,155 +1,161 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { ScalarSidebarSection as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
const z = /* @__PURE__ */ B({
|
|
1
|
+
import { defineComponent as T, resolveComponent as A, createBlock as a, openBlock as i, unref as o, mergeProps as d, toHandlers as S, withCtx as r, createTextVNode as D, toDisplayString as E, createElementBlock as v, Fragment as c, renderList as I, renderSlot as p, createSlots as w, createVNode as $, createCommentVNode as u } from "vue";
|
|
2
|
+
import { ScalarSidebarSection as N, ScalarSidebarGroup as V, ScalarSidebarGroupToggle as H, ScalarSidebarItem as L, ScalarWrappingText as C } from "@scalar/components";
|
|
3
|
+
import { LibraryIcon as O } from "@scalar/icons/library";
|
|
4
|
+
import { useDraggable as P } from "../hooks/use-draggable.js";
|
|
5
|
+
import G from "./SidebarHttpBadge.vue.js";
|
|
6
|
+
const K = /* @__PURE__ */ T({
|
|
8
7
|
__name: "SidebarItem",
|
|
9
8
|
props: {
|
|
10
9
|
item: {},
|
|
11
10
|
layout: {},
|
|
12
11
|
isSelected: { type: Function },
|
|
13
12
|
isExpanded: { type: Function },
|
|
14
|
-
options: {}
|
|
13
|
+
options: {},
|
|
14
|
+
isDraggable: {},
|
|
15
|
+
isDroppable: { type: Function }
|
|
15
16
|
},
|
|
16
17
|
emits: ["selectItem", "onDragEnd"],
|
|
17
|
-
setup(
|
|
18
|
-
const
|
|
18
|
+
setup(m, { emit: B }) {
|
|
19
|
+
const s = B, f = (e) => "children" in e && Array.isArray(e.children) && e.children.length > 0, F = (e) => "isGroup" in e && e.isGroup, k = (e) => m.layout === "reference" ? e : e.filter(
|
|
19
20
|
(t) => t.type === "operation" || t.type === "example" || t.type === "tag"
|
|
20
|
-
),
|
|
21
|
-
|
|
22
|
-
}
|
|
21
|
+
), b = (e, t) => {
|
|
22
|
+
s("onDragEnd", e, t);
|
|
23
|
+
}, { draggableAttrs: g, draggableEvents: y } = P({
|
|
24
|
+
id: m.item.id,
|
|
25
|
+
isDraggable: m.isDraggable,
|
|
26
|
+
isDroppable: m.isDroppable,
|
|
27
|
+
onDragEnd: b
|
|
28
|
+
});
|
|
23
29
|
return (e, t) => {
|
|
24
|
-
const
|
|
25
|
-
return o(),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
options: e.options,
|
|
42
|
-
onOnDragEnd: S,
|
|
43
|
-
onSelectItem: t[0] || (t[0] = (l) => a("selectItem", l))
|
|
44
|
-
}, {
|
|
45
|
-
decorator: i((l) => [
|
|
46
|
-
y(e.$slots, "decorator", v({ ref_for: !0 }, l))
|
|
47
|
-
]),
|
|
48
|
-
_: 3
|
|
49
|
-
}, 8, ["isExpanded", "isSelected", "item", "layout", "options"]))), 128))
|
|
30
|
+
const h = A("SidebarItem", !0);
|
|
31
|
+
return f(e.item) && F(e.item) ? (i(), a(o(N), d({ key: 0 }, o(g), S(o(y))), {
|
|
32
|
+
items: r(() => [
|
|
33
|
+
(i(!0), v(c, null, I(k(e.item.children), (l) => (i(), a(h, {
|
|
34
|
+
key: l.id,
|
|
35
|
+
isDraggable: e.isDraggable,
|
|
36
|
+
isDroppable: e.isDroppable,
|
|
37
|
+
isExpanded: e.isExpanded,
|
|
38
|
+
isSelected: e.isSelected,
|
|
39
|
+
item: l,
|
|
40
|
+
layout: e.layout,
|
|
41
|
+
options: e.options,
|
|
42
|
+
onOnDragEnd: b,
|
|
43
|
+
onSelectItem: t[0] || (t[0] = (n) => s("selectItem", n))
|
|
44
|
+
}, {
|
|
45
|
+
decorator: r((n) => [
|
|
46
|
+
p(e.$slots, "decorator", d({ ref_for: !0 }, n))
|
|
50
47
|
]),
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
_: 3
|
|
49
|
+
}, 8, ["isDraggable", "isDroppable", "isExpanded", "isSelected", "item", "layout", "options"]))), 128))
|
|
50
|
+
]),
|
|
51
|
+
default: r(() => [
|
|
52
|
+
D(E(e.item.title) + " ", 1)
|
|
53
|
+
]),
|
|
54
|
+
_: 3
|
|
55
|
+
}, 16)) : f(e.item) && (e.layout === "reference" && !(e.item.type === "operation" || e.item.type === "webhook") || e.layout === "client") ? (i(), a(o(V), d({
|
|
56
|
+
key: 1,
|
|
57
|
+
active: e.isSelected(e.item.id),
|
|
58
|
+
controlled: "",
|
|
59
|
+
open: e.isExpanded(e.item.id)
|
|
60
|
+
}, o(g), S(o(y)), {
|
|
61
|
+
onClick: t[2] || (t[2] = () => s("selectItem", e.item.id))
|
|
62
|
+
}), w({
|
|
63
|
+
items: r(() => [
|
|
64
|
+
(i(!0), v(c, null, I(k(e.item.children), (l) => (i(), a(h, {
|
|
65
|
+
key: l.id,
|
|
66
|
+
isDraggable: e.isDraggable,
|
|
67
|
+
isDroppable: e.isDroppable,
|
|
68
|
+
isExpanded: e.isExpanded,
|
|
69
|
+
isSelected: e.isSelected,
|
|
70
|
+
item: l,
|
|
71
|
+
layout: e.layout,
|
|
72
|
+
options: e.options,
|
|
73
|
+
parentIds: [],
|
|
74
|
+
onOnDragEnd: b,
|
|
75
|
+
onSelectItem: t[1] || (t[1] = (n) => s("selectItem", n))
|
|
76
|
+
}, {
|
|
77
|
+
decorator: r((n) => [
|
|
78
|
+
p(e.$slots, "decorator", d({ ref_for: !0 }, n))
|
|
53
79
|
]),
|
|
54
80
|
_: 3
|
|
55
|
-
}
|
|
81
|
+
}, 8, ["isDraggable", "isDroppable", "isExpanded", "isSelected", "item", "layout", "options"]))), 128))
|
|
82
|
+
]),
|
|
83
|
+
default: r(() => [
|
|
84
|
+
D(" " + E(e.item.title) + " ", 1)
|
|
85
|
+
]),
|
|
86
|
+
_: 2
|
|
87
|
+
}, [
|
|
88
|
+
e.item.type === "document" ? {
|
|
89
|
+
name: "icon",
|
|
90
|
+
fn: r(({ open: l }) => [
|
|
91
|
+
$(o(O), {
|
|
92
|
+
class: "text-c-3 block group-hover/group-button:hidden",
|
|
93
|
+
src: e.item.icon ?? "interface-content-folder"
|
|
94
|
+
}, null, 8, ["src"]),
|
|
95
|
+
$(o(H), {
|
|
96
|
+
class: "text-c-3 hidden group-hover/group-button:block",
|
|
97
|
+
open: l
|
|
98
|
+
}, null, 8, ["open"])
|
|
99
|
+
]),
|
|
100
|
+
key: "0"
|
|
101
|
+
} : void 0,
|
|
102
|
+
"method" in e.item || e.$slots.decorator ? {
|
|
103
|
+
name: "aside",
|
|
104
|
+
fn: r(() => [
|
|
105
|
+
e.$slots.decorator ? p(e.$slots, "decorator", {
|
|
106
|
+
key: 0,
|
|
107
|
+
item: e.item
|
|
108
|
+
}) : u("", !0),
|
|
109
|
+
"method" in e.item ? (i(), a(G, {
|
|
110
|
+
key: 1,
|
|
111
|
+
active: e.isSelected(e.item.id),
|
|
112
|
+
class: "ml-2 h-4 self-start",
|
|
113
|
+
method: e.item.method,
|
|
114
|
+
webhook: e.item.type === "webhook"
|
|
115
|
+
}, null, 8, ["active", "method", "webhook"])) : u("", !0)
|
|
116
|
+
]),
|
|
117
|
+
key: "1"
|
|
118
|
+
} : void 0
|
|
119
|
+
]), 1040, ["active", "open"])) : (i(), a(o(L), d({
|
|
120
|
+
key: 2,
|
|
121
|
+
is: "button"
|
|
122
|
+
}, o(g), S(o(y)), {
|
|
123
|
+
selected: e.isSelected(e.item.id),
|
|
124
|
+
onClick: t[3] || (t[3] = () => s("selectItem", e.item.id))
|
|
125
|
+
}), w({
|
|
126
|
+
default: r(() => [
|
|
127
|
+
e.item.type === "model" ? (i(), a(o(C), {
|
|
128
|
+
key: 0,
|
|
129
|
+
preset: "property",
|
|
130
|
+
text: e.item.title
|
|
131
|
+
}, null, 8, ["text"])) : (i(), a(o(C), {
|
|
56
132
|
key: 1,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
open: e.isExpanded(e.item.id),
|
|
60
|
-
onClick: t[2] || (t[2] = () => a("selectItem", e.item.id))
|
|
61
|
-
}, I({
|
|
62
|
-
items: i(() => [
|
|
63
|
-
(o(!0), p(u, null, E(g(e.item.children), (d) => (o(), n(b, {
|
|
64
|
-
key: d.id,
|
|
65
|
-
isExpanded: e.isExpanded,
|
|
66
|
-
isSelected: e.isSelected,
|
|
67
|
-
item: d,
|
|
68
|
-
layout: e.layout,
|
|
69
|
-
options: e.options,
|
|
70
|
-
parentIds: [],
|
|
71
|
-
onOnDragEnd: S,
|
|
72
|
-
onSelectItem: t[1] || (t[1] = (l) => a("selectItem", l))
|
|
73
|
-
}, {
|
|
74
|
-
decorator: i((l) => [
|
|
75
|
-
y(e.$slots, "decorator", v({ ref_for: !0 }, l))
|
|
76
|
-
]),
|
|
77
|
-
_: 3
|
|
78
|
-
}, 8, ["isExpanded", "isSelected", "item", "layout", "options"]))), 128))
|
|
79
|
-
]),
|
|
80
|
-
default: i(() => [
|
|
81
|
-
s(" " + m(e.item.title) + " ", 1)
|
|
82
|
-
]),
|
|
83
|
-
_: 2
|
|
84
|
-
}, [
|
|
85
|
-
e.item.type === "document" ? {
|
|
86
|
-
name: "icon",
|
|
87
|
-
fn: i(({ open: d }) => [
|
|
88
|
-
c(r(A), { class: "text-c-3 block group-hover/group-button:hidden" }),
|
|
89
|
-
c(r(O), {
|
|
90
|
-
class: "text-c-3 hidden group-hover/group-button:block",
|
|
91
|
-
open: d
|
|
92
|
-
}, null, 8, ["open"])
|
|
93
|
-
]),
|
|
94
|
-
key: "0"
|
|
95
|
-
} : void 0,
|
|
96
|
-
"method" in e.item || e.$slots.decorator ? {
|
|
97
|
-
name: "aside",
|
|
98
|
-
fn: i(() => [
|
|
99
|
-
e.$slots.decorator ? y(e.$slots, "decorator", {
|
|
100
|
-
key: 0,
|
|
101
|
-
item: e.item
|
|
102
|
-
}) : f("", !0),
|
|
103
|
-
"method" in e.item ? (o(), n(D, {
|
|
104
|
-
key: 1,
|
|
105
|
-
active: e.isSelected(e.item.id),
|
|
106
|
-
class: "ml-2 h-4 self-start",
|
|
107
|
-
method: e.item.method,
|
|
108
|
-
webhook: e.item.type === "webhook"
|
|
109
|
-
}, null, 8, ["active", "method", "webhook"])) : f("", !0)
|
|
110
|
-
]),
|
|
111
|
-
key: "1"
|
|
112
|
-
} : void 0
|
|
113
|
-
]), 1032, ["active", "open"])) : (o(), n(r(T), {
|
|
114
|
-
key: 2,
|
|
115
|
-
is: "button",
|
|
116
|
-
class: "text-left",
|
|
117
|
-
selected: e.isSelected(e.item.id),
|
|
118
|
-
onClick: t[3] || (t[3] = () => a("selectItem", e.item.id))
|
|
119
|
-
}, I({
|
|
120
|
-
default: i(() => [
|
|
121
|
-
e.item.type === "model" ? (o(), p(u, { key: 0 }, [
|
|
122
|
-
s(m(r(k)(e.item.title, { preset: "property" })), 1)
|
|
123
|
-
], 64)) : (o(), p(u, { key: 1 }, [
|
|
124
|
-
s(m(e.options?.operationTitleSource === "path" && "path" in e.item ? r(k)(e.item.path) : r(k)(e.item.title)), 1)
|
|
125
|
-
], 64))
|
|
126
|
-
]),
|
|
127
|
-
_: 2
|
|
128
|
-
}, [
|
|
129
|
-
"method" in e.item || e.$slots.decorator ? {
|
|
130
|
-
name: "aside",
|
|
131
|
-
fn: i(() => [
|
|
132
|
-
e.$slots.decorator ? y(e.$slots, "decorator", {
|
|
133
|
-
key: 0,
|
|
134
|
-
item: e.item
|
|
135
|
-
}) : f("", !0),
|
|
136
|
-
"method" in e.item ? (o(), n(D, {
|
|
137
|
-
key: 1,
|
|
138
|
-
active: e.isSelected(e.item.id),
|
|
139
|
-
class: "ml-2 h-4 self-start",
|
|
140
|
-
method: e.item.method,
|
|
141
|
-
webhook: e.item.type === "webhook"
|
|
142
|
-
}, null, 8, ["active", "method", "webhook"])) : f("", !0)
|
|
143
|
-
]),
|
|
144
|
-
key: "0"
|
|
145
|
-
} : void 0
|
|
146
|
-
]), 1032, ["selected"]))
|
|
133
|
+
text: e.options?.operationTitleSource === "path" && "path" in e.item ? e.item.path : e.item.title
|
|
134
|
+
}, null, 8, ["text"]))
|
|
147
135
|
]),
|
|
148
|
-
_:
|
|
149
|
-
},
|
|
136
|
+
_: 2
|
|
137
|
+
}, [
|
|
138
|
+
"method" in e.item || e.$slots.decorator ? {
|
|
139
|
+
name: "aside",
|
|
140
|
+
fn: r(() => [
|
|
141
|
+
e.$slots.decorator ? p(e.$slots, "decorator", {
|
|
142
|
+
key: 0,
|
|
143
|
+
item: e.item
|
|
144
|
+
}) : u("", !0),
|
|
145
|
+
"method" in e.item ? (i(), a(G, {
|
|
146
|
+
key: 1,
|
|
147
|
+
active: e.isSelected(e.item.id),
|
|
148
|
+
class: "ml-2 h-4 self-start",
|
|
149
|
+
method: e.item.method,
|
|
150
|
+
webhook: e.item.type === "webhook"
|
|
151
|
+
}, null, 8, ["active", "method", "webhook"])) : u("", !0)
|
|
152
|
+
]),
|
|
153
|
+
key: "0"
|
|
154
|
+
} : void 0
|
|
155
|
+
]), 1040, ["selected"]));
|
|
150
156
|
};
|
|
151
157
|
}
|
|
152
158
|
});
|
|
153
159
|
export {
|
|
154
|
-
|
|
160
|
+
K as default
|
|
155
161
|
};
|
|
@@ -73,6 +73,7 @@ export declare const createSidebarState: <T extends {
|
|
|
73
73
|
}>>;
|
|
74
74
|
selectedItems: import("vue").Ref<Record<string, boolean>, Record<string, boolean>>;
|
|
75
75
|
expandedItems: import("vue").Ref<Record<string, boolean>, Record<string, boolean>>;
|
|
76
|
+
selectedItem: import("vue").Ref<string | null, string | null>;
|
|
76
77
|
setSelected: (id: string | null) => void;
|
|
77
78
|
setExpanded: (id: string, value: boolean) => void;
|
|
78
79
|
isExpanded: (id: string) => boolean;
|
|
@@ -80,6 +81,7 @@ export declare const createSidebarState: <T extends {
|
|
|
80
81
|
getEntryById: (id: string) => (T & {
|
|
81
82
|
parent?: T | undefined;
|
|
82
83
|
}) | undefined;
|
|
84
|
+
reset: () => void;
|
|
83
85
|
};
|
|
84
86
|
export type SidebarState<Item extends {
|
|
85
87
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-sidebar-state.d.ts","sourceRoot":"","sources":["../../src/helpers/create-sidebar-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,KAAK,CAAA;AAInE,KAAK,mBAAmB,GAAG,OAAO,CAAC;IACjC,sFAAsF;IACtF,GAAG,EAAE,MAAM,CAAA;IACX,sDAAsD;IACtD,KAAK,EAAE,OAAO,CAAC;QACb;;;WAGG;QACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;QACpC;;;WAGG;QACH,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;QACnC;;;WAGG;QACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;QAC3C;;;WAGG;QACH,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;KAC3C,CAAC,CAAA;CACH,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACzD,OAAO,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAC5B,UAAU,mBAAmB
|
|
1
|
+
{"version":3,"file":"create-sidebar-state.d.ts","sourceRoot":"","sources":["../../src/helpers/create-sidebar-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,KAAK,CAAA;AAInE,KAAK,mBAAmB,GAAG,OAAO,CAAC;IACjC,sFAAsF;IACtF,GAAG,EAAE,MAAM,CAAA;IACX,sDAAsD;IACtD,KAAK,EAAE,OAAO,CAAC;QACb;;;WAGG;QACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;QACpC;;;WAGG;QACH,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;QACnC;;;WAGG;QACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;QAC3C;;;WAGG;QACH,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;KAC3C,CAAC,CAAA;CACH,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACzD,OAAO,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAC5B,UAAU,mBAAmB;;;;;;;;sBA6BJ,MAAM,GAAG,IAAI;sBAsDb,MAAM,SAAS,OAAO;qBAkCvB,MAAM;qBAIN,MAAM;uBAIJ,MAAM;;;;CAkBjC,CAAA;AAED,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,IAAI,UAAU,CAAC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAA"}
|
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import { generateReverseIndex as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
() =>
|
|
6
|
-
items:
|
|
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
7
|
nestedKey: t?.key ?? "children"
|
|
8
8
|
})
|
|
9
|
-
),
|
|
9
|
+
), a = c({}), n = c({}), u = c(null), m = (e) => {
|
|
10
10
|
const f = (r) => {
|
|
11
|
-
r && (
|
|
11
|
+
r && (a.value[r.id] = !0, "parent" in r && r.parent && f(r.parent));
|
|
12
12
|
};
|
|
13
|
-
t?.hooks?.onBeforeSelect && t.hooks.onBeforeSelect(e),
|
|
14
|
-
},
|
|
15
|
-
const r = (
|
|
16
|
-
|
|
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
17
|
};
|
|
18
|
-
t?.hooks?.onBeforeExpand && t.hooks.onBeforeExpand(e), f === !1 ?
|
|
19
|
-
}, x = (e) =>
|
|
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
20
|
return {
|
|
21
|
-
items:
|
|
22
|
-
index:
|
|
23
|
-
selectedItems:
|
|
24
|
-
expandedItems:
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
items: v(() => k(o)),
|
|
22
|
+
index: s,
|
|
23
|
+
selectedItems: a,
|
|
24
|
+
expandedItems: n,
|
|
25
|
+
selectedItem: u,
|
|
26
|
+
setSelected: m,
|
|
27
|
+
setExpanded: p,
|
|
27
28
|
isExpanded: x,
|
|
28
29
|
isSelected: d,
|
|
29
|
-
getEntryById: h
|
|
30
|
+
getEntryById: h,
|
|
31
|
+
reset: () => {
|
|
32
|
+
a.value = {}, n.value = {};
|
|
33
|
+
}
|
|
30
34
|
};
|
|
31
35
|
};
|
|
32
36
|
export {
|
|
33
|
-
|
|
37
|
+
g as createSidebarState
|
|
34
38
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively searches for and returns the first child node (including the given node itself)
|
|
4
|
+
* of a specific type within the provided node's subtree.
|
|
5
|
+
*
|
|
6
|
+
* @template Type - The type of node to search for.
|
|
7
|
+
* @param type - The node type to match.
|
|
8
|
+
* @param node - The root node to begin searching from.
|
|
9
|
+
* @returns The first child node of the specified type, or null if not found.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getChildEntry: <Type extends TraversedEntry["type"]>(type: Type, node: TraversedEntry) => (TraversedEntry & {
|
|
12
|
+
type: Type;
|
|
13
|
+
}) | null;
|
|
14
|
+
//# sourceMappingURL=get-child-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-child-entry.d.ts","sourceRoot":"","sources":["../../src/helpers/get-child-entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAEhF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,IAAI,SAAS,cAAc,CAAC,MAAM,CAAC,EAC/D,MAAM,IAAI,EACV,MAAM,cAAc,KACnB,CAAC,cAAc,GAAG;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,GAAG,IAgBtC,CAAA"}
|