@extclp/vexip-ui
Version:
A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good
150 lines (149 loc) • 4.72 kB
JavaScript
import { defineComponent as L, inject as R, ref as m, computed as s, reactive as j, watch as T, onBeforeUnmount as D, createElementBlock as f, openBlock as v, normalizeClass as i, createElementVNode as y, createVNode as p, unref as l, renderSlot as g, withCtx as C, normalizeProps as G, guardReactiveProps as H, createCommentVNode as $, createTextVNode as O, toDisplayString as U, normalizeStyle as q } from "vue";
import "../collapse-transition/index.mjs";
import "../icon/index.mjs";
import "../renderer/index.mjs";
import { useProps as F, createIconProp as J, useNameHelper as K, useIcons as M, emitEvent as Q } from "@vexip-ui/config";
import { collapsePanelProps as W } from "./props.mjs";
import { COLLAPSE_STATE as X, getIndexId as Y } from "./symbol.mjs";
import Z from "../renderer/renderer.mjs";
import S from "../icon/icon.mjs";
import ee from "./collapse-transition.mjs";
const ae = ["id", "aria-expanded", "aria-controls", "aria-describedby"], te = ["id", "aria-labelledby"], me = /* @__PURE__ */ L({
name: "CollapsePanel",
__name: "collapse-panel",
props: W,
emits: ["update:expanded"],
setup(E, { expose: I, emit: k }) {
const a = F("collapsePanel", E, {
label: {
default: null,
static: !0
},
title: "",
disabled: !1,
contentStyle: null,
expanded: !1,
card: !1,
arrowType: {
default: "right",
validator: (e) => ["right", "left", "none"].includes(e)
},
icon: J(),
ghost: !1,
slots: () => ({})
}), N = k, n = R(X, null), t = K("collapse"), V = M(), r = m(a.expanded), d = m(a.label), u = m(), h = Y(), b = s(() => `${t.be("tab")}-${h}`), c = s(() => `${t.be("body")}-${h}`), x = s(() => n ? !1 : a.card), z = s(() => n ? !1 : a.ghost), A = s(() => n ? n.arrowType : a.arrowType), B = s(() => [
t.be("panel"),
t.bs("vars"),
t.bem("panel", `arrow-${A.value}`),
{
[t.bem("panel", "inherit")]: n || a.inherit,
[t.bem("panel", "card")]: x.value,
[t.bem("panel", "ghost")]: !x.value && z.value,
[t.bem("panel", "expanded")]: r.value,
[t.bem("panel", "disabled")]: a.disabled
}
]);
if (n) {
const e = j({
tab: u,
label: d,
expanded: r,
setExpanded: P
});
T(
() => a.label,
(o) => {
const w = d.value;
d.value = o || o === 0 ? o : w;
}
), n.registerPanel(e), D(() => {
n.unregisterPanel(e);
});
} else
T(
() => a.expanded,
(e) => {
r.value = e;
}
);
function P(e) {
r.value = e, N("update:expanded", e), Q(a.onToggle, e);
}
function _(e = !r.value) {
a.disabled || (n ? n.expandPanel(d.value, e) : P(e));
}
return I({
currentExpanded: r,
tab: u,
tabId: b,
bodyId: c,
handleToggle: _
}), (e, o) => (v(), f("section", {
class: i(B.value)
}, [
y("button", {
id: b.value,
ref_key: "tab",
ref: u,
class: i(l(t).be("header")),
type: "button",
role: "tab",
"aria-expanded": r.value,
"aria-controls": c.value,
"aria-describedby": c.value,
onClick: o[0] || (o[0] = (w) => _())
}, [
y("div", {
class: i(l(t).be("arrow"))
}, [
g(e.$slots, "arrow", { expanded: r.value }, () => [
p(l(Z), {
renderer: l(a).slots.arrow,
data: { expanded: r.value }
}, {
default: C(() => [
p(l(S), G(H(l(V).angleRight)), null, 16)
]),
_: 1
}, 8, ["renderer", "data"])
])
], 2),
g(e.$slots, "title", {}, () => [
l(a).icon ? (v(), f("div", {
key: 0,
class: i(l(t).be("icon"))
}, [
p(l(S), {
icon: l(a).icon
}, null, 8, ["icon"])
], 2)) : $("", !0),
O(" " + U(l(a).title), 1)
])
], 10, ae),
p(l(ee), null, {
default: C(() => [
r.value ? (v(), f("div", {
key: 0,
id: c.value,
class: i(l(t).be("body")),
role: "tabpanel",
tabindex: "0",
"aria-labelledby": b.value
}, [
y("div", {
class: i(l(t).be("content")),
style: q(l(a).contentStyle)
}, [
g(e.$slots, "default")
], 6)
], 10, te)) : $("", !0)
]),
_: 3
})
], 2));
}
});
export {
me as default
};
//# sourceMappingURL=collapse-panel.vue2.mjs.map