@scalar/sidebar 0.8.12 → 0.8.14
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/_virtual/_plugin-vue_export-helper.js +8 -0
- package/dist/components/HttpMethod.vue.js +7 -0
- package/dist/components/HttpMethod.vue.js.map +1 -0
- package/dist/components/HttpMethod.vue.script.js +33 -0
- package/dist/components/HttpMethod.vue.script.js.map +1 -0
- package/dist/components/ScalarSidebar.vue.d.ts +1 -1
- package/dist/components/ScalarSidebar.vue.js +7 -0
- package/dist/components/ScalarSidebar.vue.js.map +1 -0
- package/dist/components/ScalarSidebar.vue.script.js +92 -0
- package/dist/components/ScalarSidebar.vue.script.js.map +1 -0
- package/dist/components/SidebarHttpBadge.vue.js +9 -0
- package/dist/components/SidebarHttpBadge.vue.js.map +1 -0
- package/dist/components/SidebarHttpBadge.vue.script.js +38 -0
- package/dist/components/SidebarHttpBadge.vue.script.js.map +1 -0
- package/dist/components/SidebarItem.vue.d.ts +1 -1
- package/dist/components/SidebarItem.vue.js +7 -0
- package/dist/components/SidebarItem.vue.js.map +1 -0
- package/dist/components/SidebarItem.vue.script.js +266 -0
- package/dist/components/SidebarItem.vue.script.js.map +1 -0
- package/dist/components/SidebarItemDecorator.vue.js +13 -0
- package/dist/components/SidebarItemDecorator.vue.js.map +1 -0
- package/dist/components/SidebarItemLabel.vue.js +7 -0
- package/dist/components/SidebarItemLabel.vue.js.map +1 -0
- package/dist/components/SidebarItemLabel.vue.script.js +26 -0
- package/dist/components/SidebarItemLabel.vue.script.js.map +1 -0
- package/dist/helpers/create-sidebar-state.js +137 -0
- package/dist/helpers/create-sidebar-state.js.map +1 -0
- package/dist/helpers/filter-items.js +16 -0
- package/dist/helpers/filter-items.js.map +1 -0
- package/dist/helpers/generate-reverse-index.js +42 -0
- package/dist/helpers/generate-reverse-index.js.map +1 -0
- package/dist/helpers/get-child-entry.js +22 -0
- package/dist/helpers/get-child-entry.js.map +1 -0
- package/dist/helpers/has-children.js +12 -0
- package/dist/helpers/has-children.js.map +1 -0
- package/dist/helpers/is-sidebar-folder.js +25 -0
- package/dist/helpers/is-sidebar-folder.js.map +1 -0
- package/dist/helpers/scroll-sidebar-to-top.js +51 -0
- package/dist/helpers/scroll-sidebar-to-top.js.map +1 -0
- package/dist/hooks/use-draggable.js +112 -0
- package/dist/hooks/use-draggable.js.map +1 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.js +10 -832
- package/dist/style.css +2306 -2314
- package/package.json +5 -5
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region \0plugin-vue:export-helper
|
|
2
|
+
var _plugin_vue_export_helper_default = (sfc, props) => {
|
|
3
|
+
const target = sfc.__vccOpts || sfc;
|
|
4
|
+
for (const [key, val] of props) target[key] = val;
|
|
5
|
+
return target;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { _plugin_vue_export_helper_default as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import HttpMethod_vue_vue_type_script_setup_true_lang_default from "./HttpMethod.vue.script.js";
|
|
2
|
+
//#region src/components/HttpMethod.vue
|
|
3
|
+
var HttpMethod_default = HttpMethod_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { HttpMethod_default as default };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=HttpMethod.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpMethod.vue.js","names":[],"sources":["../../src/components/HttpMethod.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { normalizeHttpMethod } from '@scalar/helpers/http/normalize-http-method'\nimport { computed, type Component } from 'vue'\n\nconst props = defineProps<{\n /** The type of element to render as, defaults to `span` */\n as?: Component | string\n /** The css style property or variable that will be set to the request method color, defaults to `color` */\n property?: string\n /** Whether or not to abbreviated the slot content */\n short?: boolean\n /** The HTTP method to show */\n method: HttpMethod | string\n}>()\n\n/** Grabs the method info object which contains abbreviation, color, and background color etc */\nconst httpMethodInfo = computed(() =>\n getHttpMethodInfo(String(props.method || '')),\n)\n\n/** Full method name */\nconst normalized = computed(() => normalizeHttpMethod(props.method))\n</script>\n\n<template>\n <component\n :is=\"as ?? 'span'\"\n class=\"uppercase\"\n :style=\"{ [property || 'color']: httpMethodInfo.colorVar }\">\n <slot />\n {{ short ? httpMethodInfo.short : normalized }}\n </component>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { computed, createBlock, createTextVNode, defineComponent, normalizeStyle, openBlock, renderSlot, resolveDynamicComponent, toDisplayString, withCtx } from "vue";
|
|
2
|
+
import { getHttpMethodInfo } from "@scalar/helpers/http/http-info";
|
|
3
|
+
import { normalizeHttpMethod } from "@scalar/helpers/http/normalize-http-method";
|
|
4
|
+
//#region src/components/HttpMethod.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var HttpMethod_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
6
|
+
__name: "HttpMethod",
|
|
7
|
+
props: {
|
|
8
|
+
as: {},
|
|
9
|
+
property: {},
|
|
10
|
+
short: { type: Boolean },
|
|
11
|
+
method: {}
|
|
12
|
+
},
|
|
13
|
+
setup(__props) {
|
|
14
|
+
const props = __props;
|
|
15
|
+
/** Grabs the method info object which contains abbreviation, color, and background color etc */
|
|
16
|
+
const httpMethodInfo = computed(() => getHttpMethodInfo(String(props.method || "")));
|
|
17
|
+
/** Full method name */
|
|
18
|
+
const normalized = computed(() => normalizeHttpMethod(props.method));
|
|
19
|
+
return (_ctx, _cache) => {
|
|
20
|
+
return openBlock(), createBlock(resolveDynamicComponent(__props.as ?? "span"), {
|
|
21
|
+
class: "uppercase",
|
|
22
|
+
style: normalizeStyle({ [__props.property || "color"]: httpMethodInfo.value.colorVar })
|
|
23
|
+
}, {
|
|
24
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default"), createTextVNode(" " + toDisplayString(__props.short ? httpMethodInfo.value.short : normalized.value), 1)]),
|
|
25
|
+
_: 3
|
|
26
|
+
}, 8, ["style"]);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
//#endregion
|
|
31
|
+
export { HttpMethod_vue_vue_type_script_setup_true_lang_default as default };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=HttpMethod.vue.script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpMethod.vue.script.js","names":[],"sources":["../../src/components/HttpMethod.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { normalizeHttpMethod } from '@scalar/helpers/http/normalize-http-method'\nimport { computed, type Component } from 'vue'\n\nconst props = defineProps<{\n /** The type of element to render as, defaults to `span` */\n as?: Component | string\n /** The css style property or variable that will be set to the request method color, defaults to `color` */\n property?: string\n /** Whether or not to abbreviated the slot content */\n short?: boolean\n /** The HTTP method to show */\n method: HttpMethod | string\n}>()\n\n/** Grabs the method info object which contains abbreviation, color, and background color etc */\nconst httpMethodInfo = computed(() =>\n getHttpMethodInfo(String(props.method || '')),\n)\n\n/** Full method name */\nconst normalized = computed(() => normalizeHttpMethod(props.method))\n</script>\n\n<template>\n <component\n :is=\"as ?? 'span'\"\n class=\"uppercase\"\n :style=\"{ [property || 'color']: httpMethodInfo.colorVar }\">\n <slot />\n {{ short ? httpMethodInfo.short : normalized }}\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;EAMA,MAAM,QAAQ;;EAYd,MAAM,iBAAiB,eACrB,kBAAkB,OAAO,MAAM,UAAU,GAAG,CAAC,CAC/C;;EAGA,MAAM,aAAa,eAAe,oBAAoB,MAAM,OAAO,CAAA;;uBAIjE,YAMY,wBALL,QAAA,MAAE,OAAA,EAAA;IACP,OAAM;IACL,OAAK,eAAA,GAAK,QAAA,YAAQ,UAAc,eAAA,MAAe,UAAQ,CAAA;;2BAChD,CAAR,WAAQ,KAAA,QAAA,UAAA,EAAA,gBAAA,MACR,gBAAG,QAAA,QAAQ,eAAA,MAAe,QAAQ,WAAA,MAAU,EAAA,EAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import ScalarSidebar_vue_vue_type_script_setup_true_lang_default from "./ScalarSidebar.vue.script.js";
|
|
2
|
+
//#region src/components/ScalarSidebar.vue
|
|
3
|
+
var ScalarSidebar_default = ScalarSidebar_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { ScalarSidebar_default as default };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=ScalarSidebar.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScalarSidebar.vue.js","names":[],"sources":["../../src/components/ScalarSidebar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarSidebar, ScalarSidebarItems } from '@scalar/components'\n\nimport { filterItems } from '@/helpers/filter-items'\nimport type {\n DraggingItem,\n HoveredItem,\n UseDraggableOptions,\n} from '@/hooks/use-draggable'\nimport type { Item, Layout } from '@/types'\n\nimport SidebarItem from './SidebarItem.vue'\n\nconst {\n layout,\n items,\n indent = 20,\n} = defineProps<{\n /**\n * Layout type for the sidebar.\n * Determines whether the sidebar should behave in 'client' or 'reference' mode.\n */\n layout: Layout\n /**\n * List of items to render in the sidebar.\n */\n items: Item[]\n /**\n * Function to determine whether a given item (by id) is currently selected.\n */\n isSelected: (id: string) => boolean\n /**\n * Function to determine whether a given item (by id) is currently expanded (open to show children).\n */\n isExpanded: (id: string) => boolean\n /**\n * Sidebar configuration options.\n * - operationTitleSource: sets whether operations show their path or summary as the display title.\n */\n options?: {\n operationTitleSource: 'path' | 'summary' | undefined\n }\n /**\n * The indentation in pixels to apply to nested items/groups in the sidebar.\n */\n indent?: number\n /**\n * Prevents this item from being dragged.\n *\n * @default true\n */\n isDraggable?: UseDraggableOptions['isDraggable']\n /**\n * Prevents this item from being hovered and dropped into. Can be either a function or a boolean.\n *\n * @default true\n */\n isDroppable?: UseDraggableOptions['isDroppable']\n}>()\n\nconst emit = defineEmits<{\n /**\n * Emitted when the user reorders sidebar items via drag-and-drop.\n * @param draggingItem - The item being dragged.\n * @param hoveredItem - The item currently being hovered over.\n */\n (e: 'reorder', draggingItem: DraggingItem, hoveredItem: HoveredItem): void\n\n /**\n * Emitted when a sidebar item is selected.\n * @param id - The id of the selected item.\n */\n (e: 'selectItem', id: string): void\n\n /**\n * Emitted when the group is toggled.\n * @param id - The id of the group.\n */\n (e: 'toggleGroup', id: string): void\n}>()\n\nconst slots = defineSlots<{\n /** Overrides the main items list */\n default?(): unknown\n /** Adds an optional decorator for each item like an edit menu */\n decorator?(props: { item: Item }): unknown\n /** Places content at the top of the sidebar outside of the items list */\n header?(): unknown\n /** Places content between the header and the items list */\n spacer?(): unknown\n /** Places content at the bottom of the sidebar outside of the items list */\n footer?(): unknown\n /** Places content before the first item in the items list */\n before?(): unknown\n /** Places content when an item is empty */\n empty?(props: { item: Item }): unknown\n /** Places content when an item is empty */\n icon?(props: { item: Item; open: boolean }): unknown\n}>()\n\n/**\n * Handle drag and drop reordering of sidebar items.\n * Emit the reorder event to the parent component for handling.\n */\nconst handleDragEnd = (\n draggingItem: DraggingItem,\n hoveredItem: HoveredItem,\n) => {\n emit('reorder', draggingItem, hoveredItem)\n}\n</script>\n<template>\n <ScalarSidebar\n class=\"flex min-h-0 flex-col\"\n :style=\"{ '--scalar-sidebar-indent': indent + 'px' }\">\n <slot name=\"header\" />\n <slot>\n <ScalarSidebarItems class=\"custom-scroll\">\n <!-- First item -->\n <slot name=\"before\" />\n <SidebarItem\n v-for=\"item in filterItems(layout, items)\"\n :key=\"item.id\"\n :isDraggable=\"isDraggable ?? layout === 'client'\"\n :isDroppable=\"isDroppable\"\n :isExpanded=\"isExpanded\"\n :isSelected=\"isSelected\"\n :item=\"item\"\n :layout=\"layout\"\n :options=\"options\"\n @onDragEnd=\"handleDragEnd\"\n @selectItem=\"(id) => emit('selectItem', id)\"\n @toggleGroup=\"(id) => emit('toggleGroup', id)\">\n <template\n v-if=\"slots.decorator\"\n #decorator=\"props\">\n <slot\n name=\"decorator\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"slots.empty\"\n #empty=\"props\">\n <slot\n name=\"empty\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"slots.icon\"\n #icon=\"props\">\n <slot\n name=\"icon\"\n v-bind=\"props\" />\n </template>\n </SidebarItem>\n </ScalarSidebarItems>\n <!-- Spacer -->\n <slot name=\"spacer\">\n <div class=\"flex-1\"></div>\n </slot>\n </slot>\n <slot name=\"footer\" />\n </ScalarSidebar>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { filterItems } from "../helpers/filter-items.js";
|
|
2
|
+
import SidebarItem_default from "./SidebarItem.vue.js";
|
|
3
|
+
import { Fragment, createBlock, createElementBlock, createElementVNode, createSlots, createVNode, defineComponent, mergeProps, normalizeStyle, openBlock, renderList, renderSlot, unref, useSlots, withCtx } from "vue";
|
|
4
|
+
import { ScalarSidebar, ScalarSidebarItems } from "@scalar/components";
|
|
5
|
+
//#region src/components/ScalarSidebar.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var ScalarSidebar_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
7
|
+
__name: "ScalarSidebar",
|
|
8
|
+
props: {
|
|
9
|
+
layout: {},
|
|
10
|
+
items: {},
|
|
11
|
+
isSelected: { type: Function },
|
|
12
|
+
isExpanded: { type: Function },
|
|
13
|
+
options: {},
|
|
14
|
+
indent: { default: 20 },
|
|
15
|
+
isDraggable: {},
|
|
16
|
+
isDroppable: { type: Function }
|
|
17
|
+
},
|
|
18
|
+
emits: [
|
|
19
|
+
"reorder",
|
|
20
|
+
"selectItem",
|
|
21
|
+
"toggleGroup"
|
|
22
|
+
],
|
|
23
|
+
setup(__props, { emit: __emit }) {
|
|
24
|
+
const emit = __emit;
|
|
25
|
+
const slots = useSlots();
|
|
26
|
+
/**
|
|
27
|
+
* Handle drag and drop reordering of sidebar items.
|
|
28
|
+
* Emit the reorder event to the parent component for handling.
|
|
29
|
+
*/
|
|
30
|
+
const handleDragEnd = (draggingItem, hoveredItem) => {
|
|
31
|
+
emit("reorder", draggingItem, hoveredItem);
|
|
32
|
+
};
|
|
33
|
+
return (_ctx, _cache) => {
|
|
34
|
+
return openBlock(), createBlock(unref(ScalarSidebar), {
|
|
35
|
+
class: "flex min-h-0 flex-col",
|
|
36
|
+
style: normalizeStyle({ "--scalar-sidebar-indent": __props.indent + "px" })
|
|
37
|
+
}, {
|
|
38
|
+
default: withCtx(() => [
|
|
39
|
+
renderSlot(_ctx.$slots, "header"),
|
|
40
|
+
renderSlot(_ctx.$slots, "default", {}, () => [createVNode(unref(ScalarSidebarItems), { class: "custom-scroll" }, {
|
|
41
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "before"), (openBlock(true), createElementBlock(Fragment, null, renderList(unref(filterItems)(__props.layout, __props.items), (item) => {
|
|
42
|
+
return openBlock(), createBlock(SidebarItem_default, {
|
|
43
|
+
key: item.id,
|
|
44
|
+
isDraggable: __props.isDraggable ?? __props.layout === "client",
|
|
45
|
+
isDroppable: __props.isDroppable,
|
|
46
|
+
isExpanded: __props.isExpanded,
|
|
47
|
+
isSelected: __props.isSelected,
|
|
48
|
+
item,
|
|
49
|
+
layout: __props.layout,
|
|
50
|
+
options: __props.options,
|
|
51
|
+
onOnDragEnd: handleDragEnd,
|
|
52
|
+
onSelectItem: _cache[0] || (_cache[0] = (id) => emit("selectItem", id)),
|
|
53
|
+
onToggleGroup: _cache[1] || (_cache[1] = (id) => emit("toggleGroup", id))
|
|
54
|
+
}, createSlots({ _: 2 }, [
|
|
55
|
+
slots.decorator ? {
|
|
56
|
+
name: "decorator",
|
|
57
|
+
fn: withCtx((props) => [renderSlot(_ctx.$slots, "decorator", mergeProps({ ref_for: true }, props))]),
|
|
58
|
+
key: "0"
|
|
59
|
+
} : void 0,
|
|
60
|
+
slots.empty ? {
|
|
61
|
+
name: "empty",
|
|
62
|
+
fn: withCtx((props) => [renderSlot(_ctx.$slots, "empty", mergeProps({ ref_for: true }, props))]),
|
|
63
|
+
key: "1"
|
|
64
|
+
} : void 0,
|
|
65
|
+
slots.icon ? {
|
|
66
|
+
name: "icon",
|
|
67
|
+
fn: withCtx((props) => [renderSlot(_ctx.$slots, "icon", mergeProps({ ref_for: true }, props))]),
|
|
68
|
+
key: "2"
|
|
69
|
+
} : void 0
|
|
70
|
+
]), 1032, [
|
|
71
|
+
"isDraggable",
|
|
72
|
+
"isDroppable",
|
|
73
|
+
"isExpanded",
|
|
74
|
+
"isSelected",
|
|
75
|
+
"item",
|
|
76
|
+
"layout",
|
|
77
|
+
"options"
|
|
78
|
+
]);
|
|
79
|
+
}), 128))]),
|
|
80
|
+
_: 3
|
|
81
|
+
}), renderSlot(_ctx.$slots, "spacer", {}, () => [_cache[2] || (_cache[2] = createElementVNode("div", { class: "flex-1" }, null, -1))])]),
|
|
82
|
+
renderSlot(_ctx.$slots, "footer")
|
|
83
|
+
]),
|
|
84
|
+
_: 3
|
|
85
|
+
}, 8, ["style"]);
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
//#endregion
|
|
90
|
+
export { ScalarSidebar_vue_vue_type_script_setup_true_lang_default as default };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=ScalarSidebar.vue.script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScalarSidebar.vue.script.js","names":[],"sources":["../../src/components/ScalarSidebar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarSidebar, ScalarSidebarItems } from '@scalar/components'\n\nimport { filterItems } from '@/helpers/filter-items'\nimport type {\n DraggingItem,\n HoveredItem,\n UseDraggableOptions,\n} from '@/hooks/use-draggable'\nimport type { Item, Layout } from '@/types'\n\nimport SidebarItem from './SidebarItem.vue'\n\nconst {\n layout,\n items,\n indent = 20,\n} = defineProps<{\n /**\n * Layout type for the sidebar.\n * Determines whether the sidebar should behave in 'client' or 'reference' mode.\n */\n layout: Layout\n /**\n * List of items to render in the sidebar.\n */\n items: Item[]\n /**\n * Function to determine whether a given item (by id) is currently selected.\n */\n isSelected: (id: string) => boolean\n /**\n * Function to determine whether a given item (by id) is currently expanded (open to show children).\n */\n isExpanded: (id: string) => boolean\n /**\n * Sidebar configuration options.\n * - operationTitleSource: sets whether operations show their path or summary as the display title.\n */\n options?: {\n operationTitleSource: 'path' | 'summary' | undefined\n }\n /**\n * The indentation in pixels to apply to nested items/groups in the sidebar.\n */\n indent?: number\n /**\n * Prevents this item from being dragged.\n *\n * @default true\n */\n isDraggable?: UseDraggableOptions['isDraggable']\n /**\n * Prevents this item from being hovered and dropped into. Can be either a function or a boolean.\n *\n * @default true\n */\n isDroppable?: UseDraggableOptions['isDroppable']\n}>()\n\nconst emit = defineEmits<{\n /**\n * Emitted when the user reorders sidebar items via drag-and-drop.\n * @param draggingItem - The item being dragged.\n * @param hoveredItem - The item currently being hovered over.\n */\n (e: 'reorder', draggingItem: DraggingItem, hoveredItem: HoveredItem): void\n\n /**\n * Emitted when a sidebar item is selected.\n * @param id - The id of the selected item.\n */\n (e: 'selectItem', id: string): void\n\n /**\n * Emitted when the group is toggled.\n * @param id - The id of the group.\n */\n (e: 'toggleGroup', id: string): void\n}>()\n\nconst slots = defineSlots<{\n /** Overrides the main items list */\n default?(): unknown\n /** Adds an optional decorator for each item like an edit menu */\n decorator?(props: { item: Item }): unknown\n /** Places content at the top of the sidebar outside of the items list */\n header?(): unknown\n /** Places content between the header and the items list */\n spacer?(): unknown\n /** Places content at the bottom of the sidebar outside of the items list */\n footer?(): unknown\n /** Places content before the first item in the items list */\n before?(): unknown\n /** Places content when an item is empty */\n empty?(props: { item: Item }): unknown\n /** Places content when an item is empty */\n icon?(props: { item: Item; open: boolean }): unknown\n}>()\n\n/**\n * Handle drag and drop reordering of sidebar items.\n * Emit the reorder event to the parent component for handling.\n */\nconst handleDragEnd = (\n draggingItem: DraggingItem,\n hoveredItem: HoveredItem,\n) => {\n emit('reorder', draggingItem, hoveredItem)\n}\n</script>\n<template>\n <ScalarSidebar\n class=\"flex min-h-0 flex-col\"\n :style=\"{ '--scalar-sidebar-indent': indent + 'px' }\">\n <slot name=\"header\" />\n <slot>\n <ScalarSidebarItems class=\"custom-scroll\">\n <!-- First item -->\n <slot name=\"before\" />\n <SidebarItem\n v-for=\"item in filterItems(layout, items)\"\n :key=\"item.id\"\n :isDraggable=\"isDraggable ?? layout === 'client'\"\n :isDroppable=\"isDroppable\"\n :isExpanded=\"isExpanded\"\n :isSelected=\"isSelected\"\n :item=\"item\"\n :layout=\"layout\"\n :options=\"options\"\n @onDragEnd=\"handleDragEnd\"\n @selectItem=\"(id) => emit('selectItem', id)\"\n @toggleGroup=\"(id) => emit('toggleGroup', id)\">\n <template\n v-if=\"slots.decorator\"\n #decorator=\"props\">\n <slot\n name=\"decorator\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"slots.empty\"\n #empty=\"props\">\n <slot\n name=\"empty\"\n v-bind=\"props\" />\n </template>\n <template\n v-if=\"slots.icon\"\n #icon=\"props\">\n <slot\n name=\"icon\"\n v-bind=\"props\" />\n </template>\n </SidebarItem>\n </ScalarSidebarItems>\n <!-- Spacer -->\n <slot name=\"spacer\">\n <div class=\"flex-1\"></div>\n </slot>\n </slot>\n <slot name=\"footer\" />\n </ScalarSidebar>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EA4DA,MAAM,OAAO;EAqBb,MAAM,QAAQ,UAAA;;;;;EAuBd,MAAM,iBACJ,cACA,gBACG;AACH,QAAK,WAAW,cAAc,YAAW;;;uB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AA;KAGvB,WAAsB,KAAA,QAAA,SAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import _plugin_vue_export_helper_default from "../_virtual/_plugin-vue_export-helper.js";
|
|
2
|
+
import SidebarHttpBadge_vue_vue_type_script_setup_true_lang_default from "./SidebarHttpBadge.vue.script.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
//#region src/components/SidebarHttpBadge.vue
|
|
5
|
+
var SidebarHttpBadge_default = /* @__PURE__ */ _plugin_vue_export_helper_default(SidebarHttpBadge_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-1857170e"]]);
|
|
6
|
+
//#endregion
|
|
7
|
+
export { SidebarHttpBadge_default as default };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=SidebarHttpBadge.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarHttpBadge.vue.js","names":[],"sources":["../../src/components/SidebarHttpBadge.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport { ScalarIconWebhooksLogo } from '@scalar/icons'\n\nimport HttpMethod from './HttpMethod.vue'\n\ndefineProps<{\n method: string\n active?: boolean\n webhook?: boolean\n}>()\n</script>\n<template>\n <HttpMethod\n :class=\"[\n 'sidebar-heading-type',\n `sidebar-heading-type--${method.toLowerCase()}`,\n { 'sidebar-heading-type-active': active },\n ]\"\n :method=\"method\"\n property=\"--method-color\"\n short>\n <span class=\"sr-only\">HTTP Method: </span>\n <slot>\n <ScalarIconWebhooksLogo\n v-if=\"webhook\"\n :style=\"{\n color: getHttpMethodInfo(method).colorVar,\n }\"\n weight=\"bold\" />\n </slot>\n </HttpMethod>\n</template>\n\n<style scoped>\n.sidebar-heading-type {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n overflow: hidden;\n line-height: 14px;\n flex-shrink: 0;\n text-transform: uppercase;\n color: var(--method-color, var(--scalar-color-1));\n font-size: 10px;\n font-weight: var(--scalar-bold);\n font-family: var(--scalar-font-code);\n white-space: nowrap;\n}\n</style>\n"],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import HttpMethod_default from "./HttpMethod.vue.js";
|
|
2
|
+
import { createBlock, createCommentVNode, createElementVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, renderSlot, unref, withCtx } from "vue";
|
|
3
|
+
import { getHttpMethodInfo } from "@scalar/helpers/http/http-info";
|
|
4
|
+
import { ScalarIconWebhooksLogo } from "@scalar/icons";
|
|
5
|
+
//#region src/components/SidebarHttpBadge.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var SidebarHttpBadge_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
7
|
+
__name: "SidebarHttpBadge",
|
|
8
|
+
props: {
|
|
9
|
+
method: {},
|
|
10
|
+
active: { type: Boolean },
|
|
11
|
+
webhook: { type: Boolean }
|
|
12
|
+
},
|
|
13
|
+
setup(__props) {
|
|
14
|
+
return (_ctx, _cache) => {
|
|
15
|
+
return openBlock(), createBlock(HttpMethod_default, {
|
|
16
|
+
class: normalizeClass([
|
|
17
|
+
"sidebar-heading-type",
|
|
18
|
+
`sidebar-heading-type--${__props.method.toLowerCase()}`,
|
|
19
|
+
{ "sidebar-heading-type-active": __props.active }
|
|
20
|
+
]),
|
|
21
|
+
method: __props.method,
|
|
22
|
+
property: "--method-color",
|
|
23
|
+
short: ""
|
|
24
|
+
}, {
|
|
25
|
+
default: withCtx(() => [_cache[0] || (_cache[0] = createElementVNode("span", { class: "sr-only" }, "HTTP Method:\xA0", -1)), renderSlot(_ctx.$slots, "default", {}, () => [__props.webhook ? (openBlock(), createBlock(unref(ScalarIconWebhooksLogo), {
|
|
26
|
+
key: 0,
|
|
27
|
+
style: normalizeStyle({ color: unref(getHttpMethodInfo)(__props.method).colorVar }),
|
|
28
|
+
weight: "bold"
|
|
29
|
+
}, null, 8, ["style"])) : createCommentVNode("", true)], true)]),
|
|
30
|
+
_: 3
|
|
31
|
+
}, 8, ["class", "method"]);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
//#endregion
|
|
36
|
+
export { SidebarHttpBadge_vue_vue_type_script_setup_true_lang_default as default };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=SidebarHttpBadge.vue.script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarHttpBadge.vue.script.js","names":[],"sources":["../../src/components/SidebarHttpBadge.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport { ScalarIconWebhooksLogo } from '@scalar/icons'\n\nimport HttpMethod from './HttpMethod.vue'\n\ndefineProps<{\n method: string\n active?: boolean\n webhook?: boolean\n}>()\n</script>\n<template>\n <HttpMethod\n :class=\"[\n 'sidebar-heading-type',\n `sidebar-heading-type--${method.toLowerCase()}`,\n { 'sidebar-heading-type-active': active },\n ]\"\n :method=\"method\"\n property=\"--method-color\"\n short>\n <span class=\"sr-only\">HTTP Method: </span>\n <slot>\n <ScalarIconWebhooksLogo\n v-if=\"webhook\"\n :style=\"{\n color: getHttpMethodInfo(method).colorVar,\n }\"\n weight=\"bold\" />\n </slot>\n </HttpMethod>\n</template>\n\n<style scoped>\n.sidebar-heading-type {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n overflow: hidden;\n line-height: 14px;\n flex-shrink: 0;\n text-transform: uppercase;\n color: var(--method-color, var(--scalar-color-1));\n font-size: 10px;\n font-weight: var(--scalar-bold);\n font-family: var(--scalar-font-code);\n white-space: nowrap;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;uBAaE,YAkBa,oBAAA;IAjBV,OAAK,eAAA;;8BAAiE,QAAA,OAAO,aAAW;sCAA6C,QAAA,QAAM;;IAK3I,QAAQ,QAAA;IACT,UAAS;IACT,OAAA;;2BAC+C,CAAA,OAAA,OAAA,OAAA,KAA/C,mBAA+C,QAAA,EAAzC,OAAM,WAAS,EAAC,oBAAkB,GAAA,GACxC,WAOO,KAAA,QAAA,WAAA,EAAA,QAAA,CALG,QAAA,WAAA,WAAA,EADR,YAKkB,MAAA,uBAAA,EAAA;;KAHf,OAAK,eAAA,EAAA,OAAqB,MAAA,kBAAiB,CAAC,QAAA,OAAM,CAAE,UAAA,CAAA;KAGrD,QAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DraggingItem, type HoveredItem, type UseDraggableOptions } from '../hooks/use-draggable';
|
|
1
|
+
import { type DraggingItem, type HoveredItem, type UseDraggableOptions } from '../hooks/use-draggable.js';
|
|
2
2
|
import type { Item, Layout } from '../types';
|
|
3
3
|
type __VLS_Props = {
|
|
4
4
|
/**
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import SidebarItem_vue_vue_type_script_setup_true_lang_default from "./SidebarItem.vue.script.js";
|
|
2
|
+
//#region src/components/SidebarItem.vue
|
|
3
|
+
var SidebarItem_default = SidebarItem_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { SidebarItem_default as default };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=SidebarItem.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarItem.vue.js","names":[],"sources":["../../src/components/SidebarItem.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport {\n ScalarSidebarGroup,\n ScalarSidebarItem,\n ScalarSidebarSection,\n} from '@scalar/components'\nimport { LibraryIcon } from '@scalar/icons/library'\n\nimport SidebarItemDecorator from '@/components/SidebarItemDecorator.vue'\nimport { filterItems } from '@/helpers/filter-items'\nimport { hasChildren } from '@/helpers/has-children'\nimport { isSidebarFolder } from '@/helpers/is-sidebar-folder'\nimport {\n useDraggable,\n type DraggingItem,\n type HoveredItem,\n type UseDraggableOptions,\n} from '@/hooks/use-draggable'\nimport type { Item, Layout } from '@/types'\n\nimport SidebarHttpBadge from './SidebarHttpBadge.vue'\nimport SidebarItemLabel from './SidebarItemLabel.vue'\n\nconst { item, layout, isSelected, isExpanded, isDraggable, isDroppable } =\n defineProps<{\n /**\n * The sidebar item to render.\n */\n item: Item\n /**\n * The layout mode for the sidebar ('client' or 'reference').\n */\n layout: Layout\n /**\n * Function to determine if an item is currently selected by id.\n */\n isSelected: (id: string) => boolean\n /**\n * Function to determine if an item is currently expanded (showing its children) by id.\n */\n isExpanded: (id: string) => boolean\n /**\n * Sidebar configuration options.\n * - operationTitleSource: sets whether operations show their path or summary as the display title.\n */\n options:\n | {\n operationTitleSource: 'path' | 'summary' | undefined\n }\n | undefined\n\n /**\n * Prevents this item from being dragged.\n *\n * @default true\n */\n isDraggable?: UseDraggableOptions['isDraggable']\n /**\n * Prevents this item from being hovered and dropped into. Can be either a function or a boolean.\n *\n * @default true\n */\n isDroppable?: UseDraggableOptions['isDroppable']\n }>()\n\nconst emit = defineEmits<{\n /**\n * Emitted when the item is selected\n * @param id - The id of the selected item\n */\n (e: 'selectItem', id: string): void\n /**\n * Emitted when a drag operation ends for this item\n * @param draggingItem - The item being dragged\n * @param hoveredItem - The item currently being hovered over\n */\n (e: 'onDragEnd', draggingItem: DraggingItem, hoveredItem: HoveredItem): void\n\n /**\n * Emitted when the group is toggled\n * @param id - The id of the group\n */\n (e: 'toggleGroup', id: string): void\n}>()\n\nconst slots = defineSlots<{\n /**\n * Adds an optional decorator for each item, such as an edit menu.\n * The slot receives an object with the current item.\n */\n decorator?(props: { item: Item }): unknown\n /**\n * Adds an optional empty state for an item.\n * The slot receives an object with the current item.\n */\n empty?(props: { item: Item }): unknown\n /**\n * Adds an optional icon for each item.\n * The slot receives an object with the current item and the open state.\n */\n icon?(props: { item: Item; open: boolean }): unknown\n}>()\n\nconst isGroup = (\n currentItem: Item,\n): currentItem is Item & { isGroup: true } => {\n return 'isGroup' in currentItem && currentItem.isGroup\n}\n\nconst isDeprecated = (\n currentItem: Item,\n): currentItem is Item & { isDeprecated: true } => {\n return ('isDeprecated' in currentItem && currentItem.isDeprecated) ?? false\n}\n\n/**\n * Handle drag end event and bubble it up to parent.\n */\nconst onDragEnd = (draggingItem: DraggingItem, hoveredItem: HoveredItem) => {\n emit('onDragEnd', draggingItem, hoveredItem)\n}\nconst { draggableAttrs, draggableEvents } = useDraggable({\n id: item.id,\n isDraggable,\n isDroppable,\n onDragEnd,\n})\n</script>\n<template>\n <!-- Sidebar section -->\n <ScalarSidebarSection\n v-if=\"hasChildren(item) && isGroup(item)\"\n :data-sidebar-id=\"item.id\"\n v-bind=\"draggableAttrs\"\n v-on=\"draggableEvents\">\n {{ item.title }}\n <template #items>\n <SidebarItem\n v-for=\"child in filterItems(layout, item.children)\"\n :key=\"child.id\"\n :isDraggable=\"isDraggable\"\n :isDroppable=\"isDroppable\"\n :isExpanded=\"isExpanded\"\n :isSelected=\"isSelected\"\n :item=\"child\"\n :layout=\"layout\"\n :options=\"options\"\n @onDragEnd=\"onDragEnd\"\n @selectItem=\"(id) => emit('selectItem', id)\"\n @toggleGroup=\"(id) => emit('toggleGroup', id)\">\n <template\n v-if=\"slots.decorator\"\n #decorator=\"slotProps\">\n <slot\n v-bind=\"slotProps\"\n name=\"decorator\" />\n </template>\n <template\n v-if=\"slots.empty\"\n #empty=\"slotProps\">\n <slot\n v-bind=\"slotProps\"\n name=\"empty\" />\n </template>\n <template\n v-if=\"slots.icon\"\n #icon=\"slotProps\">\n <slot\n v-bind=\"slotProps\"\n name=\"icon\" />\n </template>\n </SidebarItem>\n </template>\n </ScalarSidebarSection>\n\n <!-- Sidebar group (folder) -->\n <ScalarSidebarGroup\n v-else-if=\"isSidebarFolder(layout, item, slots.empty !== undefined)\"\n :active=\"isSelected(item.id)\"\n class=\"relative\"\n controlled\n :data-sidebar-id=\"item.id\"\n v-bind=\"draggableAttrs\"\n :discrete=\"layout === 'reference' && item.type === 'text'\"\n :open=\"isExpanded(item.id)\"\n v-on=\"draggableEvents\"\n @click=\"() => emit('selectItem', item.id)\"\n @toggle=\"() => emit('toggleGroup', item.id)\">\n <template\n v-if=\"item.type === 'document'\"\n #icon=\"{ open }\">\n <slot\n :item=\"item\"\n name=\"icon\"\n :open=\"open\">\n <LibraryIcon\n class=\"block\"\n :src=\"('icon' in item && item.icon) || 'interface-content-folder'\" />\n </slot>\n </template>\n <span\n v-if=\"isDeprecated(item)\"\n class=\"line-through\">\n <SidebarItemLabel\n :item\n :operationTitleSource=\"options?.operationTitleSource\" />\n </span>\n <SidebarItemLabel\n v-else\n :item\n :operationTitleSource=\"options?.operationTitleSource\" />\n <template\n v-if=\"'method' in item\"\n #aside>\n <SidebarHttpBadge\n :active=\"isSelected(item.id)\"\n class=\"mr-1 ml-2 h-4 self-start\"\n :class=\"{\n // Hide the badge when we're showing the decorator\n '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':\n slots.decorator,\n }\"\n :method=\"item.method\"\n :webhook=\"item.type === 'webhook'\" />\n </template>\n <template\n v-if=\"slots.decorator\"\n #after>\n <SidebarItemDecorator>\n <slot\n :item\n name=\"decorator\" />\n </SidebarItemDecorator>\n </template>\n <template #items>\n <SidebarItem\n v-for=\"child in filterItems(layout, item.children ?? [])\"\n :key=\"child.id\"\n :isDraggable=\"isDraggable\"\n :isDroppable=\"isDroppable\"\n :isExpanded=\"isExpanded\"\n :isSelected=\"isSelected\"\n :item=\"child\"\n :layout=\"layout\"\n :options=\"options\"\n :parentIds=\"[]\"\n @onDragEnd=\"onDragEnd\"\n @selectItem=\"(id) => emit('selectItem', id)\"\n @toggleGroup=\"(id) => emit('toggleGroup', id)\">\n <template\n v-if=\"slots.decorator\"\n #decorator=\"slotProps\">\n <slot\n v-bind=\"slotProps\"\n name=\"decorator\" />\n </template>\n <template\n v-if=\"slots.empty\"\n #empty=\"slotProps\">\n <slot\n v-bind=\"slotProps\"\n name=\"empty\" />\n </template>\n <template\n v-if=\"slots.icon\"\n #icon=\"slotProps\">\n <slot\n v-bind=\"slotProps\"\n name=\"icon\" />\n </template>\n </SidebarItem>\n <template v-if=\"slots.empty && (item.children?.length ?? 0) === 0\">\n <slot\n :item\n name=\"empty\" />\n </template>\n </template>\n </ScalarSidebarGroup>\n\n <!-- Sidebar item (leaf node) -->\n <ScalarSidebarItem\n is=\"button\"\n v-else\n v-bind=\"draggableAttrs\"\n class=\"relative\"\n :data-sidebar-id=\"item.id\"\n :selected=\"isSelected(item.id)\"\n v-on=\"draggableEvents\"\n @click=\"() => emit('selectItem', item.id)\">\n <template\n v-if=\"slots.icon\"\n #icon>\n <slot\n :item=\"item\"\n name=\"icon\"\n :open=\"true\" />\n </template>\n <span\n v-if=\"isDeprecated(item)\"\n class=\"line-through\">\n <SidebarItemLabel\n :item\n :operationTitleSource=\"options?.operationTitleSource\" />\n </span>\n <SidebarItemLabel\n v-else\n :item\n :operationTitleSource=\"options?.operationTitleSource\" />\n <template\n v-if=\"'method' in item\"\n #aside>\n <SidebarHttpBadge\n v-if=\"'method' in item\"\n :active=\"isSelected(item.id)\"\n class=\"ml-2 h-4 self-start\"\n :class=\"{\n // Hide the badge when we're showing the decorator\n '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':\n slots.decorator,\n }\"\n :method=\"item.method\"\n :webhook=\"item.type === 'webhook'\" />\n </template>\n <template\n v-if=\"slots.decorator\"\n #after>\n <SidebarItemDecorator>\n <slot\n :item\n name=\"decorator\" />\n </SidebarItemDecorator>\n </template>\n </ScalarSidebarItem>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { filterItems } from "../helpers/filter-items.js";
|
|
2
|
+
import SidebarItemDecorator_default from "./SidebarItemDecorator.vue.js";
|
|
3
|
+
import { hasChildren } from "../helpers/has-children.js";
|
|
4
|
+
import { isSidebarFolder } from "../helpers/is-sidebar-folder.js";
|
|
5
|
+
import { useDraggable } from "../hooks/use-draggable.js";
|
|
6
|
+
import SidebarHttpBadge_default from "./SidebarHttpBadge.vue.js";
|
|
7
|
+
import SidebarItemLabel_default from "./SidebarItemLabel.vue.js";
|
|
8
|
+
import { Fragment, createBlock, createCommentVNode, createElementBlock, createSlots, createTextVNode, createVNode, defineComponent, mergeProps, normalizeClass, openBlock, renderList, renderSlot, resolveComponent, toDisplayString, toHandlers, unref, useSlots, withCtx } from "vue";
|
|
9
|
+
import { ScalarSidebarGroup, ScalarSidebarItem, ScalarSidebarSection } from "@scalar/components";
|
|
10
|
+
import { LibraryIcon } from "@scalar/icons/library";
|
|
11
|
+
//#region src/components/SidebarItem.vue?vue&type=script&setup=true&lang.ts
|
|
12
|
+
var _hoisted_1 = {
|
|
13
|
+
key: 0,
|
|
14
|
+
class: "line-through"
|
|
15
|
+
};
|
|
16
|
+
var _hoisted_2 = {
|
|
17
|
+
key: 0,
|
|
18
|
+
class: "line-through"
|
|
19
|
+
};
|
|
20
|
+
var SidebarItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
21
|
+
__name: "SidebarItem",
|
|
22
|
+
props: {
|
|
23
|
+
item: {},
|
|
24
|
+
layout: {},
|
|
25
|
+
isSelected: { type: Function },
|
|
26
|
+
isExpanded: { type: Function },
|
|
27
|
+
options: {},
|
|
28
|
+
isDraggable: {},
|
|
29
|
+
isDroppable: { type: Function }
|
|
30
|
+
},
|
|
31
|
+
emits: [
|
|
32
|
+
"selectItem",
|
|
33
|
+
"onDragEnd",
|
|
34
|
+
"toggleGroup"
|
|
35
|
+
],
|
|
36
|
+
setup(__props, { emit: __emit }) {
|
|
37
|
+
const emit = __emit;
|
|
38
|
+
const slots = useSlots();
|
|
39
|
+
const isGroup = (currentItem) => {
|
|
40
|
+
return "isGroup" in currentItem && currentItem.isGroup;
|
|
41
|
+
};
|
|
42
|
+
const isDeprecated = (currentItem) => {
|
|
43
|
+
return ("isDeprecated" in currentItem && currentItem.isDeprecated) ?? false;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Handle drag end event and bubble it up to parent.
|
|
47
|
+
*/
|
|
48
|
+
const onDragEnd = (draggingItem, hoveredItem) => {
|
|
49
|
+
emit("onDragEnd", draggingItem, hoveredItem);
|
|
50
|
+
};
|
|
51
|
+
const { draggableAttrs, draggableEvents } = useDraggable({
|
|
52
|
+
id: __props.item.id,
|
|
53
|
+
isDraggable: __props.isDraggable,
|
|
54
|
+
isDroppable: __props.isDroppable,
|
|
55
|
+
onDragEnd
|
|
56
|
+
});
|
|
57
|
+
return (_ctx, _cache) => {
|
|
58
|
+
const _component_SidebarItem = resolveComponent("SidebarItem", true);
|
|
59
|
+
return unref(hasChildren)(__props.item) && isGroup(__props.item) ? (openBlock(), createBlock(unref(ScalarSidebarSection), mergeProps({
|
|
60
|
+
key: 0,
|
|
61
|
+
"data-sidebar-id": __props.item.id
|
|
62
|
+
}, unref(draggableAttrs), toHandlers(unref(draggableEvents))), {
|
|
63
|
+
items: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(filterItems)(__props.layout, __props.item.children), (child) => {
|
|
64
|
+
return openBlock(), createBlock(_component_SidebarItem, {
|
|
65
|
+
key: child.id,
|
|
66
|
+
isDraggable: __props.isDraggable,
|
|
67
|
+
isDroppable: __props.isDroppable,
|
|
68
|
+
isExpanded: __props.isExpanded,
|
|
69
|
+
isSelected: __props.isSelected,
|
|
70
|
+
item: child,
|
|
71
|
+
layout: __props.layout,
|
|
72
|
+
options: __props.options,
|
|
73
|
+
onOnDragEnd: onDragEnd,
|
|
74
|
+
onSelectItem: _cache[0] || (_cache[0] = (id) => emit("selectItem", id)),
|
|
75
|
+
onToggleGroup: _cache[1] || (_cache[1] = (id) => emit("toggleGroup", id))
|
|
76
|
+
}, createSlots({ _: 2 }, [
|
|
77
|
+
slots.decorator ? {
|
|
78
|
+
name: "decorator",
|
|
79
|
+
fn: withCtx((slotProps) => [renderSlot(_ctx.$slots, "decorator", mergeProps({ ref_for: true }, slotProps))]),
|
|
80
|
+
key: "0"
|
|
81
|
+
} : void 0,
|
|
82
|
+
slots.empty ? {
|
|
83
|
+
name: "empty",
|
|
84
|
+
fn: withCtx((slotProps) => [renderSlot(_ctx.$slots, "empty", mergeProps({ ref_for: true }, slotProps))]),
|
|
85
|
+
key: "1"
|
|
86
|
+
} : void 0,
|
|
87
|
+
slots.icon ? {
|
|
88
|
+
name: "icon",
|
|
89
|
+
fn: withCtx((slotProps) => [renderSlot(_ctx.$slots, "icon", mergeProps({ ref_for: true }, slotProps))]),
|
|
90
|
+
key: "2"
|
|
91
|
+
} : void 0
|
|
92
|
+
]), 1032, [
|
|
93
|
+
"isDraggable",
|
|
94
|
+
"isDroppable",
|
|
95
|
+
"isExpanded",
|
|
96
|
+
"isSelected",
|
|
97
|
+
"item",
|
|
98
|
+
"layout",
|
|
99
|
+
"options"
|
|
100
|
+
]);
|
|
101
|
+
}), 128))]),
|
|
102
|
+
default: withCtx(() => [createTextVNode(toDisplayString(__props.item.title) + " ", 1)]),
|
|
103
|
+
_: 3
|
|
104
|
+
}, 16, ["data-sidebar-id"])) : unref(isSidebarFolder)(__props.layout, __props.item, slots.empty !== void 0) ? (openBlock(), createBlock(unref(ScalarSidebarGroup), mergeProps({
|
|
105
|
+
key: 1,
|
|
106
|
+
active: __props.isSelected(__props.item.id),
|
|
107
|
+
class: "relative",
|
|
108
|
+
controlled: "",
|
|
109
|
+
"data-sidebar-id": __props.item.id
|
|
110
|
+
}, unref(draggableAttrs), {
|
|
111
|
+
discrete: __props.layout === "reference" && __props.item.type === "text",
|
|
112
|
+
open: __props.isExpanded(__props.item.id)
|
|
113
|
+
}, toHandlers(unref(draggableEvents)), {
|
|
114
|
+
onClick: _cache[4] || (_cache[4] = () => emit("selectItem", __props.item.id)),
|
|
115
|
+
onToggle: _cache[5] || (_cache[5] = () => emit("toggleGroup", __props.item.id))
|
|
116
|
+
}), createSlots({
|
|
117
|
+
items: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(filterItems)(__props.layout, __props.item.children ?? []), (child) => {
|
|
118
|
+
return openBlock(), createBlock(_component_SidebarItem, {
|
|
119
|
+
key: child.id,
|
|
120
|
+
isDraggable: __props.isDraggable,
|
|
121
|
+
isDroppable: __props.isDroppable,
|
|
122
|
+
isExpanded: __props.isExpanded,
|
|
123
|
+
isSelected: __props.isSelected,
|
|
124
|
+
item: child,
|
|
125
|
+
layout: __props.layout,
|
|
126
|
+
options: __props.options,
|
|
127
|
+
parentIds: [],
|
|
128
|
+
onOnDragEnd: onDragEnd,
|
|
129
|
+
onSelectItem: _cache[2] || (_cache[2] = (id) => emit("selectItem", id)),
|
|
130
|
+
onToggleGroup: _cache[3] || (_cache[3] = (id) => emit("toggleGroup", id))
|
|
131
|
+
}, createSlots({ _: 2 }, [
|
|
132
|
+
slots.decorator ? {
|
|
133
|
+
name: "decorator",
|
|
134
|
+
fn: withCtx((slotProps) => [renderSlot(_ctx.$slots, "decorator", mergeProps({ ref_for: true }, slotProps))]),
|
|
135
|
+
key: "0"
|
|
136
|
+
} : void 0,
|
|
137
|
+
slots.empty ? {
|
|
138
|
+
name: "empty",
|
|
139
|
+
fn: withCtx((slotProps) => [renderSlot(_ctx.$slots, "empty", mergeProps({ ref_for: true }, slotProps))]),
|
|
140
|
+
key: "1"
|
|
141
|
+
} : void 0,
|
|
142
|
+
slots.icon ? {
|
|
143
|
+
name: "icon",
|
|
144
|
+
fn: withCtx((slotProps) => [renderSlot(_ctx.$slots, "icon", mergeProps({ ref_for: true }, slotProps))]),
|
|
145
|
+
key: "2"
|
|
146
|
+
} : void 0
|
|
147
|
+
]), 1032, [
|
|
148
|
+
"isDraggable",
|
|
149
|
+
"isDroppable",
|
|
150
|
+
"isExpanded",
|
|
151
|
+
"isSelected",
|
|
152
|
+
"item",
|
|
153
|
+
"layout",
|
|
154
|
+
"options"
|
|
155
|
+
]);
|
|
156
|
+
}), 128)), slots.empty && (__props.item.children?.length ?? 0) === 0 ? renderSlot(_ctx.$slots, "empty", {
|
|
157
|
+
key: 0,
|
|
158
|
+
item: __props.item
|
|
159
|
+
}) : createCommentVNode("", true)]),
|
|
160
|
+
default: withCtx(() => [isDeprecated(__props.item) ? (openBlock(), createElementBlock("span", _hoisted_1, [createVNode(SidebarItemLabel_default, {
|
|
161
|
+
item: __props.item,
|
|
162
|
+
operationTitleSource: __props.options?.operationTitleSource
|
|
163
|
+
}, null, 8, ["item", "operationTitleSource"])])) : (openBlock(), createBlock(SidebarItemLabel_default, {
|
|
164
|
+
key: 1,
|
|
165
|
+
item: __props.item,
|
|
166
|
+
operationTitleSource: __props.options?.operationTitleSource
|
|
167
|
+
}, null, 8, ["item", "operationTitleSource"]))]),
|
|
168
|
+
_: 2
|
|
169
|
+
}, [
|
|
170
|
+
__props.item.type === "document" ? {
|
|
171
|
+
name: "icon",
|
|
172
|
+
fn: withCtx(({ open }) => [renderSlot(_ctx.$slots, "icon", {
|
|
173
|
+
item: __props.item,
|
|
174
|
+
open
|
|
175
|
+
}, () => [createVNode(unref(LibraryIcon), {
|
|
176
|
+
class: "block",
|
|
177
|
+
src: "icon" in __props.item && __props.item.icon || "interface-content-folder"
|
|
178
|
+
}, null, 8, ["src"])])]),
|
|
179
|
+
key: "0"
|
|
180
|
+
} : void 0,
|
|
181
|
+
"method" in __props.item ? {
|
|
182
|
+
name: "aside",
|
|
183
|
+
fn: withCtx(() => [createVNode(SidebarHttpBadge_default, {
|
|
184
|
+
active: __props.isSelected(__props.item.id),
|
|
185
|
+
class: normalizeClass(["mr-1 ml-2 h-4 self-start", { "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": slots.decorator }]),
|
|
186
|
+
method: __props.item.method,
|
|
187
|
+
webhook: __props.item.type === "webhook"
|
|
188
|
+
}, null, 8, [
|
|
189
|
+
"active",
|
|
190
|
+
"class",
|
|
191
|
+
"method",
|
|
192
|
+
"webhook"
|
|
193
|
+
])]),
|
|
194
|
+
key: "1"
|
|
195
|
+
} : void 0,
|
|
196
|
+
slots.decorator ? {
|
|
197
|
+
name: "after",
|
|
198
|
+
fn: withCtx(() => [createVNode(SidebarItemDecorator_default, null, {
|
|
199
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "decorator", { item: __props.item })]),
|
|
200
|
+
_: 3
|
|
201
|
+
})]),
|
|
202
|
+
key: "2"
|
|
203
|
+
} : void 0
|
|
204
|
+
]), 1040, [
|
|
205
|
+
"active",
|
|
206
|
+
"data-sidebar-id",
|
|
207
|
+
"discrete",
|
|
208
|
+
"open"
|
|
209
|
+
])) : (openBlock(), createBlock(unref(ScalarSidebarItem), mergeProps({
|
|
210
|
+
key: 2,
|
|
211
|
+
is: "button"
|
|
212
|
+
}, unref(draggableAttrs), {
|
|
213
|
+
class: "relative",
|
|
214
|
+
"data-sidebar-id": __props.item.id,
|
|
215
|
+
selected: __props.isSelected(__props.item.id)
|
|
216
|
+
}, toHandlers(unref(draggableEvents)), { onClick: _cache[6] || (_cache[6] = () => emit("selectItem", __props.item.id)) }), createSlots({
|
|
217
|
+
default: withCtx(() => [isDeprecated(__props.item) ? (openBlock(), createElementBlock("span", _hoisted_2, [createVNode(SidebarItemLabel_default, {
|
|
218
|
+
item: __props.item,
|
|
219
|
+
operationTitleSource: __props.options?.operationTitleSource
|
|
220
|
+
}, null, 8, ["item", "operationTitleSource"])])) : (openBlock(), createBlock(SidebarItemLabel_default, {
|
|
221
|
+
key: 1,
|
|
222
|
+
item: __props.item,
|
|
223
|
+
operationTitleSource: __props.options?.operationTitleSource
|
|
224
|
+
}, null, 8, ["item", "operationTitleSource"]))]),
|
|
225
|
+
_: 2
|
|
226
|
+
}, [
|
|
227
|
+
slots.icon ? {
|
|
228
|
+
name: "icon",
|
|
229
|
+
fn: withCtx(() => [renderSlot(_ctx.$slots, "icon", {
|
|
230
|
+
item: __props.item,
|
|
231
|
+
open: true
|
|
232
|
+
})]),
|
|
233
|
+
key: "0"
|
|
234
|
+
} : void 0,
|
|
235
|
+
"method" in __props.item ? {
|
|
236
|
+
name: "aside",
|
|
237
|
+
fn: withCtx(() => ["method" in __props.item ? (openBlock(), createBlock(SidebarHttpBadge_default, {
|
|
238
|
+
key: 0,
|
|
239
|
+
active: __props.isSelected(__props.item.id),
|
|
240
|
+
class: normalizeClass(["ml-2 h-4 self-start", { "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": slots.decorator }]),
|
|
241
|
+
method: __props.item.method,
|
|
242
|
+
webhook: __props.item.type === "webhook"
|
|
243
|
+
}, null, 8, [
|
|
244
|
+
"active",
|
|
245
|
+
"class",
|
|
246
|
+
"method",
|
|
247
|
+
"webhook"
|
|
248
|
+
])) : createCommentVNode("", true)]),
|
|
249
|
+
key: "1"
|
|
250
|
+
} : void 0,
|
|
251
|
+
slots.decorator ? {
|
|
252
|
+
name: "after",
|
|
253
|
+
fn: withCtx(() => [createVNode(SidebarItemDecorator_default, null, {
|
|
254
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "decorator", { item: __props.item })]),
|
|
255
|
+
_: 3
|
|
256
|
+
})]),
|
|
257
|
+
key: "2"
|
|
258
|
+
} : void 0
|
|
259
|
+
]), 1040, ["data-sidebar-id", "selected"]));
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
//#endregion
|
|
264
|
+
export { SidebarItem_vue_vue_type_script_setup_true_lang_default as default };
|
|
265
|
+
|
|
266
|
+
//# sourceMappingURL=SidebarItem.vue.script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarItem.vue.script.js","names":[],"sources":["../../src/components/SidebarItem.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport {\n ScalarSidebarGroup,\n ScalarSidebarItem,\n ScalarSidebarSection,\n} from '@scalar/components'\nimport { LibraryIcon } from '@scalar/icons/library'\n\nimport SidebarItemDecorator from '@/components/SidebarItemDecorator.vue'\nimport { filterItems } from '@/helpers/filter-items'\nimport { hasChildren } from '@/helpers/has-children'\nimport { isSidebarFolder } from '@/helpers/is-sidebar-folder'\nimport {\n useDraggable,\n type DraggingItem,\n type HoveredItem,\n type UseDraggableOptions,\n} from '@/hooks/use-draggable'\nimport type { Item, Layout } from '@/types'\n\nimport SidebarHttpBadge from './SidebarHttpBadge.vue'\nimport SidebarItemLabel from './SidebarItemLabel.vue'\n\nconst { item, layout, isSelected, isExpanded, isDraggable, isDroppable } =\n defineProps<{\n /**\n * The sidebar item to render.\n */\n item: Item\n /**\n * The layout mode for the sidebar ('client' or 'reference').\n */\n layout: Layout\n /**\n * Function to determine if an item is currently selected by id.\n */\n isSelected: (id: string) => boolean\n /**\n * Function to determine if an item is currently expanded (showing its children) by id.\n */\n isExpanded: (id: string) => boolean\n /**\n * Sidebar configuration options.\n * - operationTitleSource: sets whether operations show their path or summary as the display title.\n */\n options:\n | {\n operationTitleSource: 'path' | 'summary' | undefined\n }\n | undefined\n\n /**\n * Prevents this item from being dragged.\n *\n * @default true\n */\n isDraggable?: UseDraggableOptions['isDraggable']\n /**\n * Prevents this item from being hovered and dropped into. Can be either a function or a boolean.\n *\n * @default true\n */\n isDroppable?: UseDraggableOptions['isDroppable']\n }>()\n\nconst emit = defineEmits<{\n /**\n * Emitted when the item is selected\n * @param id - The id of the selected item\n */\n (e: 'selectItem', id: string): void\n /**\n * Emitted when a drag operation ends for this item\n * @param draggingItem - The item being dragged\n * @param hoveredItem - The item currently being hovered over\n */\n (e: 'onDragEnd', draggingItem: DraggingItem, hoveredItem: HoveredItem): void\n\n /**\n * Emitted when the group is toggled\n * @param id - The id of the group\n */\n (e: 'toggleGroup', id: string): void\n}>()\n\nconst slots = defineSlots<{\n /**\n * Adds an optional decorator for each item, such as an edit menu.\n * The slot receives an object with the current item.\n */\n decorator?(props: { item: Item }): unknown\n /**\n * Adds an optional empty state for an item.\n * The slot receives an object with the current item.\n */\n empty?(props: { item: Item }): unknown\n /**\n * Adds an optional icon for each item.\n * The slot receives an object with the current item and the open state.\n */\n icon?(props: { item: Item; open: boolean }): unknown\n}>()\n\nconst isGroup = (\n currentItem: Item,\n): currentItem is Item & { isGroup: true } => {\n return 'isGroup' in currentItem && currentItem.isGroup\n}\n\nconst isDeprecated = (\n currentItem: Item,\n): currentItem is Item & { isDeprecated: true } => {\n return ('isDeprecated' in currentItem && currentItem.isDeprecated) ?? false\n}\n\n/**\n * Handle drag end event and bubble it up to parent.\n */\nconst onDragEnd = (draggingItem: DraggingItem, hoveredItem: HoveredItem) => {\n emit('onDragEnd', draggingItem, hoveredItem)\n}\nconst { draggableAttrs, draggableEvents } = useDraggable({\n id: item.id,\n isDraggable,\n isDroppable,\n onDragEnd,\n})\n</script>\n<template>\n <!-- Sidebar section -->\n <ScalarSidebarSection\n v-if=\"hasChildren(item) && isGroup(item)\"\n :data-sidebar-id=\"item.id\"\n v-bind=\"draggableAttrs\"\n v-on=\"draggableEvents\">\n {{ item.title }}\n <template #items>\n <SidebarItem\n v-for=\"child in filterItems(layout, item.children)\"\n :key=\"child.id\"\n :isDraggable=\"isDraggable\"\n :isDroppable=\"isDroppable\"\n :isExpanded=\"isExpanded\"\n :isSelected=\"isSelected\"\n :item=\"child\"\n :layout=\"layout\"\n :options=\"options\"\n @onDragEnd=\"onDragEnd\"\n @selectItem=\"(id) => emit('selectItem', id)\"\n @toggleGroup=\"(id) => emit('toggleGroup', id)\">\n <template\n v-if=\"slots.decorator\"\n #decorator=\"slotProps\">\n <slot\n v-bind=\"slotProps\"\n name=\"decorator\" />\n </template>\n <template\n v-if=\"slots.empty\"\n #empty=\"slotProps\">\n <slot\n v-bind=\"slotProps\"\n name=\"empty\" />\n </template>\n <template\n v-if=\"slots.icon\"\n #icon=\"slotProps\">\n <slot\n v-bind=\"slotProps\"\n name=\"icon\" />\n </template>\n </SidebarItem>\n </template>\n </ScalarSidebarSection>\n\n <!-- Sidebar group (folder) -->\n <ScalarSidebarGroup\n v-else-if=\"isSidebarFolder(layout, item, slots.empty !== undefined)\"\n :active=\"isSelected(item.id)\"\n class=\"relative\"\n controlled\n :data-sidebar-id=\"item.id\"\n v-bind=\"draggableAttrs\"\n :discrete=\"layout === 'reference' && item.type === 'text'\"\n :open=\"isExpanded(item.id)\"\n v-on=\"draggableEvents\"\n @click=\"() => emit('selectItem', item.id)\"\n @toggle=\"() => emit('toggleGroup', item.id)\">\n <template\n v-if=\"item.type === 'document'\"\n #icon=\"{ open }\">\n <slot\n :item=\"item\"\n name=\"icon\"\n :open=\"open\">\n <LibraryIcon\n class=\"block\"\n :src=\"('icon' in item && item.icon) || 'interface-content-folder'\" />\n </slot>\n </template>\n <span\n v-if=\"isDeprecated(item)\"\n class=\"line-through\">\n <SidebarItemLabel\n :item\n :operationTitleSource=\"options?.operationTitleSource\" />\n </span>\n <SidebarItemLabel\n v-else\n :item\n :operationTitleSource=\"options?.operationTitleSource\" />\n <template\n v-if=\"'method' in item\"\n #aside>\n <SidebarHttpBadge\n :active=\"isSelected(item.id)\"\n class=\"mr-1 ml-2 h-4 self-start\"\n :class=\"{\n // Hide the badge when we're showing the decorator\n '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':\n slots.decorator,\n }\"\n :method=\"item.method\"\n :webhook=\"item.type === 'webhook'\" />\n </template>\n <template\n v-if=\"slots.decorator\"\n #after>\n <SidebarItemDecorator>\n <slot\n :item\n name=\"decorator\" />\n </SidebarItemDecorator>\n </template>\n <template #items>\n <SidebarItem\n v-for=\"child in filterItems(layout, item.children ?? [])\"\n :key=\"child.id\"\n :isDraggable=\"isDraggable\"\n :isDroppable=\"isDroppable\"\n :isExpanded=\"isExpanded\"\n :isSelected=\"isSelected\"\n :item=\"child\"\n :layout=\"layout\"\n :options=\"options\"\n :parentIds=\"[]\"\n @onDragEnd=\"onDragEnd\"\n @selectItem=\"(id) => emit('selectItem', id)\"\n @toggleGroup=\"(id) => emit('toggleGroup', id)\">\n <template\n v-if=\"slots.decorator\"\n #decorator=\"slotProps\">\n <slot\n v-bind=\"slotProps\"\n name=\"decorator\" />\n </template>\n <template\n v-if=\"slots.empty\"\n #empty=\"slotProps\">\n <slot\n v-bind=\"slotProps\"\n name=\"empty\" />\n </template>\n <template\n v-if=\"slots.icon\"\n #icon=\"slotProps\">\n <slot\n v-bind=\"slotProps\"\n name=\"icon\" />\n </template>\n </SidebarItem>\n <template v-if=\"slots.empty && (item.children?.length ?? 0) === 0\">\n <slot\n :item\n name=\"empty\" />\n </template>\n </template>\n </ScalarSidebarGroup>\n\n <!-- Sidebar item (leaf node) -->\n <ScalarSidebarItem\n is=\"button\"\n v-else\n v-bind=\"draggableAttrs\"\n class=\"relative\"\n :data-sidebar-id=\"item.id\"\n :selected=\"isSelected(item.id)\"\n v-on=\"draggableEvents\"\n @click=\"() => emit('selectItem', item.id)\">\n <template\n v-if=\"slots.icon\"\n #icon>\n <slot\n :item=\"item\"\n name=\"icon\"\n :open=\"true\" />\n </template>\n <span\n v-if=\"isDeprecated(item)\"\n class=\"line-through\">\n <SidebarItemLabel\n :item\n :operationTitleSource=\"options?.operationTitleSource\" />\n </span>\n <SidebarItemLabel\n v-else\n :item\n :operationTitleSource=\"options?.operationTitleSource\" />\n <template\n v-if=\"'method' in item\"\n #aside>\n <SidebarHttpBadge\n v-if=\"'method' in item\"\n :active=\"isSelected(item.id)\"\n class=\"ml-2 h-4 self-start\"\n :class=\"{\n // Hide the badge when we're showing the decorator\n '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':\n slots.decorator,\n }\"\n :method=\"item.method\"\n :webhook=\"item.type === 'webhook'\" />\n </template>\n <template\n v-if=\"slots.decorator\"\n #after>\n <SidebarItemDecorator>\n <slot\n :item\n name=\"decorator\" />\n </SidebarItemDecorator>\n </template>\n </ScalarSidebarItem>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiEA,MAAM,OAAO;EAoBb,MAAM,QAAQ,UAAA;EAkBd,MAAM,WACJ,gBAC4C;AAC5C,UAAO,aAAa,eAAe,YAAY;;EAGjD,MAAM,gBACJ,gBACiD;AACjD,WAAQ,kBAAkB,eAAe,YAAY,iBAAiB;;;;;EAMxE,MAAM,aAAa,cAA4B,gBAA6B;AAC1E,QAAK,aAAa,cAAc,YAAW;;EAE7C,MAAM,EAAE,gBAAgB,oBAAoB,aAAa;GACvD,IAAI,QAAA,KAAK;GACT,aAAU,QAAA;GACV,aAAU,QAAA;GACV;GACD,CAAA;;;UAKS,MAAA,YAAW,CAAC,QAAA,KAAI,IAAK,QAAQ,QAAA,KAAI,IAAA,WAAA,EADzC,YA2CuB,MAAA,qBAAA,EA3CvB,WA2CuB;;IAzCpB,mBAAiB,QAAA,KAAK;MACf,MAAA,eAAc,EACtB,WAAM,MAAgB,gBAAD,CAAA,CAAA,EAAA;IAEV,OAAK,cAEuC,EAAA,UAAA,KAAA,EADrD,mBAkCc,UAAA,MAAA,WAjCI,MAAA,YAAW,CAAC,QAAA,QAAQ,QAAA,KAAK,SAAQ,GAA1C,UAAK;yBADd,YAkCc,wBAAA;MAhCX,KAAK,MAAM;MACX,aAAa,QAAA;MACb,aAAa,QAAA;MACb,YAAY,QAAA;MACZ,YAAY,QAAA;MACZ,MAAM;MACN,QAAQ,QAAA;MACR,SAAS,QAAA;MACT,aAAW;MACX,cAAU,OAAA,OAAA,OAAA,MAAG,OAAO,KAAI,cAAe,GAAE;MACzC,eAAW,OAAA,OAAA,OAAA,MAAG,OAAO,KAAI,eAAgB,GAAE;;MAEpC,MAAM,YAAA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CAAA,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _plugin_vue_export_helper_default from "../_virtual/_plugin-vue_export-helper.js";
|
|
2
|
+
import { createElementBlock, openBlock, renderSlot } from "vue";
|
|
3
|
+
//#region src/components/SidebarItemDecorator.vue
|
|
4
|
+
var _sfc_main = {};
|
|
5
|
+
var _hoisted_1 = { 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" };
|
|
6
|
+
function _sfc_render(_ctx, _cache) {
|
|
7
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [renderSlot(_ctx.$slots, "default")]);
|
|
8
|
+
}
|
|
9
|
+
var SidebarItemDecorator_default = /* @__PURE__ */ _plugin_vue_export_helper_default(_sfc_main, [["render", _sfc_render]]);
|
|
10
|
+
//#endregion
|
|
11
|
+
export { SidebarItemDecorator_default as default };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=SidebarItemDecorator.vue.js.map
|