ucc-ui
Version:
ucc-ui components library
135 lines (134 loc) • 4.11 kB
JavaScript
import { defineComponent as P, useSlots as S, computed as d, ref as p, provide as H, openBlock as l, createElementBlock as g, normalizeClass as I, createVNode as s, unref as o, mergeProps as c, withCtx as r, renderSlot as u, Fragment as O, renderList as A, createBlock as v } from "vue";
import { _ as G } from "./DropdownItem-BLZVFF_f.js";
import { _ as N } from "./DropdownMenu-BN1zKfi1.js";
import { C as V, a as _, U as F } from "./CodeEditor-CoBtVBCt.js";
import { U as K, a as C } from "./Dialog-B5dowvNE.js";
import { d as j } from "./hooks-Dj9Dthmd.js";
import "./utils-BzE2Aob-.js";
import "./ConfigProvider-C-6nRyrn.js";
import { k as q } from "./vendors-PY6Ic9FA.js";
const J = Symbol("CDropdownCtx"), te = /* @__PURE__ */ P({
name: "UDropdown",
inheritAttrs: !1,
__name: "Dropdown",
props: {
data: { default: (m) => [] },
type: {},
size: { default: "default" },
maxHeight: {},
splitButton: { type: Boolean },
disabled: { type: Boolean },
placement: {},
trigger: { default: V.CLICK },
hideOnClick: { type: Boolean, default: !0 },
showTimeout: {},
hideTimeout: {},
role: {},
tabindex: {},
tooltipProps: {},
teleported: { type: Boolean }
},
emits: ["command", "visible-change", "click"],
setup(m, { expose: h, emit: b }) {
const a = m, k = b;
S();
const w = d(() => a.size), y = p(!1);
H(J, {
size: w,
handleItemClick: z
});
const n = p(), f = p(), B = d(() => {
var e;
return (e = f.value) == null ? void 0 : e.ref;
}), T = d(() => ({
effect: _.LIGHT,
...a.tooltipProps
}));
function z(e) {
var t;
a.hideOnClick && ((t = n.value) == null || t.hide()), !q(e.command) && k("command", e.command);
}
function E() {
var e;
(e = n.value) == null || e.onOpen();
}
function $() {
var e;
(e = n.value) == null || e.onClose();
}
const { beforeEnter: U, enter: D, afterEnter: R, leave: L } = j();
return h({
doShow: E,
doHide: $
}), (e, t) => (l(), g("div", {
class: I(["u-dropdown", { "is-disabled": e.disabled }])
}, [
s(o(F), c({
ref_key: "tooltipRef",
ref: n,
transition: "",
"virtual-triggering": e.splitButton,
"virtual-ref": B.value,
trigger: e.trigger,
padding: 0,
width: 0,
"hide-timeout": e.hideTimeout,
"show-timeout": e.showTimeout,
placement: e.placement
}, T.value, {
"transition-props": {
onBeforeEnter: o(U),
onEnter: o(D),
onAfterEnter: o(R),
onLeave: o(L)
},
visible: y.value,
onVisibleChange: t[1] || (t[1] = (i) => e.$emit("visible-change", i))
}), {
content: r(() => [
s(N, null, {
default: r(() => [
u(e.$slots, "dropdown", {}, () => [
(l(!0), g(O, null, A(e.data, (i) => (l(), v(G, c({
key: i.command,
ref_for: !0
}, i), null, 16))), 128))
])
]),
_: 3
})
]),
default: r(() => [
e.splitButton ? (l(), v(o(K), {
key: 0,
type: e.type,
size: e.size,
disabled: e.disabled
}, {
default: r(() => [
s(o(C), {
onClick: t[0] || (t[0] = (i) => e.$emit("click", i))
}, {
default: r(() => [
u(e.$slots, "default")
]),
_: 3
}),
s(o(C), {
ref_key: "triggerRef",
ref: f,
icon: "angle-down"
}, null, 512)
]),
_: 3
}, 8, ["type", "size", "disabled"])) : u(e.$slots, "default", { key: 1 })
]),
_: 3
}, 16, ["virtual-triggering", "virtual-ref", "trigger", "hide-timeout", "show-timeout", "placement", "transition-props", "visible"])
], 2));
}
});
export {
J as C,
te as _
};