@scalar/api-client
Version:
the open source API testing client
90 lines (89 loc) • 3.63 kB
JavaScript
import { defineComponent as x, useId as y, createBlock as f, openBlock as o, unref as s, normalizeClass as i, withCtx as n, createVNode as r, createElementVNode as l, createElementBlock as d, createCommentVNode as a, renderSlot as c, createTextVNode as C, toDisplayString as m, mergeProps as _ } from "vue";
import { Disclosure as S, DisclosureButton as v, DisclosurePanel as k } from "@headlessui/vue";
import { ScalarIcon as B } from "@scalar/components";
import V from "./ValueEmitter.vue.js";
const $ = ["aria-labelledby"], w = { class: "text-c-1 m-0 flex flex-1 items-center gap-1.5 leading-[20px]" }, D = ["id"], I = {
key: 0,
class: "sr-only"
}, N = {
key: 0,
class: "bg-b-2 text-c-2 inline-flex h-5 w-5 items-center justify-center rounded-full border text-xs font-semibold"
}, O = { class: "sr-only" }, z = {
key: 0,
class: "ui-not-open:hidden flex items-center gap-2 pr-0.75"
}, E = {
name: "CollapsibleSection"
}, A = /* @__PURE__ */ x({
...E,
props: {
defaultOpen: { type: Boolean, default: !0 },
itemCount: { default: 0 },
isStatic: { type: Boolean }
},
emits: ["update:modelValue"],
setup(P, { emit: b }) {
const h = b, u = y();
return (e, p) => (o(), f(s(S), {
as: "div",
class: i(["group/collapse text-c-2 focus-within:text-c-1 last:ui-open:border-b-0 border-b", e.isStatic && "last-of-type:first-of-type:border-b-0"]),
defaultOpen: e.defaultOpen,
static: e.isStatic
}, {
default: n(({ open: t }) => [
r(V, {
value: t,
onChange: p[0] || (p[0] = (g) => h("update:modelValue", g))
}, null, 8, ["value"]),
l("section", {
"aria-labelledby": s(u),
class: "contents"
}, [
l("div", {
class: i(["bg-b-2 flex items-center", e.isStatic && "rounded-t-lg border border-b-0"])
}, [
r(s(v), {
class: i(["hover:text-c-1 group box-content flex max-h-8 flex-1 items-center gap-2.5 overflow-hidden px-1 py-1.5 text-base font-medium outline-none md:px-1.5 xl:pr-0.5 xl:pl-2", e.isStatic && "!pl-3"]),
disabled: e.isStatic
}, {
default: n(() => [
e.isStatic ? a("", !0) : (o(), f(s(B), {
key: 0,
class: "text-c-3 group-hover:text-c-1 rounded-px ui-open:rotate-90 ui-not-open:rotate-0 outline-offset-2 group-focus-visible:outline",
icon: "ChevronRight",
size: "md"
})),
l("h2", w, [
l("span", {
id: s(u),
class: "contents"
}, [
c(e.$slots, "title", { open: t }),
t ? a("", !0) : (o(), d("span", I, " (Collapsed) "))
], 8, D),
!t && e.itemCount ? (o(), d("span", N, [
C(m(e.itemCount) + " ", 1),
l("span", O, "Item" + m(e.itemCount === 1 ? "" : "s"), 1)
])) : a("", !0)
])
]),
_: 2
}, 1032, ["class", "disabled"]),
e.$slots.actions ? (o(), d("div", z, [
c(e.$slots, "actions", { open: t })
])) : a("", !0)
], 2),
r(s(k), _(e.$attrs, { class: "diclosure-panel h-full max-h-fit rounded-b" }), {
default: n(() => [
c(e.$slots, "default", { open: t })
]),
_: 2
}, 1040)
], 8, $)
]),
_: 3
}, 8, ["class", "defaultOpen", "static"]));
}
});
export {
A as default
};