dk-plus
Version:
192 lines (191 loc) • 8.02 kB
JavaScript
import P from "./index2.js";
import { resolveComponent as f, openBlock as l, createElementBlock as s, normalizeClass as t, createVNode as S, withCtx as g, createBlock as k, Teleport as z, withDirectives as C, createElementVNode as m, normalizeStyle as h, renderSlot as i, createCommentVNode as r, Fragment as u, renderList as b, withModifiers as y, toDisplayString as p, createTextVNode as v, vShow as T } from "vue";
import V from "../../_virtual/index.js";
const B = {
key: 0,
class: "dk-select_tags"
}, F = ["onClick"], O = {
key: 0,
class: "dk-select_tag dk-select_tag--more"
}, I = {
key: 0,
class: "dk-select_header"
}, M = ["disabled", "onClick"], R = {
key: 3,
class: "dk-select_empty"
}, N = {
key: 4,
class: "dk-select_footer"
}, E = {
key: 0,
class: "dk-select_header"
}, K = ["disabled", "onClick"], U = {
key: 3,
class: "dk-select_empty"
}, L = {
key: 4,
class: "dk-select_footer"
};
function j(e, n, q, A, G, H) {
const w = f("dk-input"), $ = f("dk-icon"), D = f("dk-trigger");
return l(), s("div", {
class: t(["dk-select", { "is-disabled": e.disabled, "is-open": e.open, "is-show-clear": e.showClear, "is-multiple": e.multiple }]),
onKeydown: n[7] || (n[7] = (...o) => e.onKeydown && e.onKeydown(...o))
}, [
S(D, {
ref: "triggerCompRef",
trigger: "click",
disabled: e.disabled,
"on-open": e.onOpen,
"on-close": e.onClose,
"on-change": e.onTriggerChange,
"content-ref": e.dropdownRef
}, {
content: g(() => [
e.teleported ? (l(), k(z, {
key: 0,
to: e.appendTo
}, [
C(m("div", {
ref: "dropdownRef",
class: t(["dk-select_dropdown", e.popperClass]),
style: h([e.dropdownStyle, e.popperStyle]),
onScrollPassive: n[5] || (n[5] = (...o) => e.onPopupScroll && e.onPopupScroll(...o))
}, [
e.$slots.header ? (l(), s("div", I, [
i(e.$slots, "header")
])) : r("", !0),
e.hasDefaultSlot ? i(e.$slots, "default", { key: 1 }) : (l(!0), s(u, { key: 2 }, b(e.filteredOptions, (o) => {
var a;
return l(), s("button", {
key: String(o.label) + String(o.value),
class: t(["dk-select_option", { "is-selected": e.isSelected(o), "is-hover": e.hoverIndex >= 0 && ((a = e.filteredOptions[e.hoverIndex]) == null ? void 0 : a.label) === o.label }]),
type: "button",
disabled: e.disabled || !!o.disabled,
onClick: y((d) => e.onPick(o), ["stop"])
}, p(o.label), 11, M);
}), 128)),
e.filteredOptions.length === 0 && !e.hasDefaultSlot || e.loading ? (l(), s("div", R, [
e.$slots.loading && e.loading ? i(e.$slots, "loading", { key: 0 }) : e.$slots.empty ? i(e.$slots, "empty", { key: 1 }) : (l(), s(u, { key: 2 }, [
v(p(e.emptyDisplayText), 1)
], 64))
])) : r("", !0),
e.$slots.footer ? (l(), s("div", N, [
i(e.$slots, "footer")
])) : r("", !0)
], 38), [
[T, e.open]
])
], 8, ["to"])) : C((l(), s("div", {
key: 1,
ref: "dropdownRef",
class: t(["dk-select_dropdown", e.popperClass]),
style: h([e.dropdownStyle, e.popperStyle]),
onScrollPassive: n[6] || (n[6] = (...o) => e.onPopupScroll && e.onPopupScroll(...o))
}, [
e.$slots.header ? (l(), s("div", E, [
i(e.$slots, "header")
])) : r("", !0),
e.hasDefaultSlot ? i(e.$slots, "default", { key: 1 }) : (l(!0), s(u, { key: 2 }, b(e.filteredOptions, (o) => {
var a;
return l(), s("button", {
key: String(o.label) + String(o.value),
class: t(["dk-select_option", { "is-selected": e.isSelected(o), "is-hover": e.hoverIndex >= 0 && ((a = e.filteredOptions[e.hoverIndex]) == null ? void 0 : a.label) === o.label }]),
type: "button",
disabled: e.disabled || !!o.disabled,
onClick: y((d) => e.onPick(o), ["stop"])
}, p(o.label), 11, K);
}), 128)),
e.filteredOptions.length === 0 && !e.hasDefaultSlot || e.loading ? (l(), s("div", U, [
e.$slots.loading && e.loading ? i(e.$slots, "loading", { key: 0 }) : e.$slots.empty ? i(e.$slots, "empty", { key: 1 }) : (l(), s(u, { key: 2 }, [
v(p(e.emptyDisplayText), 1)
], 64))
])) : r("", !0),
e.$slots.footer ? (l(), s("div", L, [
i(e.$slots, "footer")
])) : r("", !0)
], 38)), [
[T, e.open]
])
]),
default: g(() => {
var o, a;
return [
m("div", {
ref: "triggerElRef",
class: "dk-select_trigger",
style: h({ width: e.width }),
onMouseenter: n[2] || (n[2] = (d) => e.hovering = !0),
onMouseleave: n[3] || (n[3] = (d) => e.hovering = !1),
onClick: n[4] || (n[4] = (...d) => e.refreshDropdownPosition && e.refreshDropdownPosition(...d))
}, [
e.multiple ? (l(), k(w, {
key: 0,
id: e.id,
modelValue: e.inputText,
"onUpdate:modelValue": n[0] || (n[0] = (d) => e.inputText = d),
name: e.name,
disabled: e.disabled,
readonly: !e.filterable,
clearable: !1,
placeholder: e.multiplePlaceholder,
size: (o = e.size) != null ? o : void 0,
width: e.width,
onFocus: e.onFocus,
onBlur: e.onBlur
}, {
prefix: g(() => [
e.collapsedTags.length || e.collapseTags && e.collapsedMoreCount ? (l(), s("div", B, [
(l(!0), s(u, null, b(e.collapsedTags, (d) => (l(), s("span", {
key: String(d.value),
class: "dk-select_tag"
}, [
v(p(d.label) + " ", 1),
m("button", {
class: "dk-select_tag-close",
type: "button",
onClick: y((J) => e.onRemoveTag(d.value), ["stop"])
}, "\xD7", 8, F)
]))), 128)),
e.collapseTags && e.collapsedMoreCount ? (l(), s("span", O, "+" + p(e.collapsedMoreCount), 1)) : r("", !0)
])) : r("", !0)
]),
_: 1
}, 8, ["id", "modelValue", "name", "disabled", "readonly", "placeholder", "size", "width", "onFocus", "onBlur"])) : (l(), k(w, {
key: 1,
id: e.id,
modelValue: e.inputText,
"onUpdate:modelValue": n[1] || (n[1] = (d) => e.inputText = d),
name: e.name,
disabled: e.disabled,
readonly: !e.filterable,
clearable: !1,
placeholder: e.displayText || e.placeholder,
size: (a = e.size) != null ? a : void 0,
width: e.width,
onFocus: e.onFocus,
onBlur: e.onBlur
}, null, 8, ["id", "modelValue", "name", "disabled", "readonly", "placeholder", "size", "width", "onFocus", "onBlur"])),
e.showClear ? (l(), k($, {
key: 2,
class: "dk-select_clear",
icon: e.clearIcon,
size: "16px",
onClick: y(e.onClear, ["stop"])
}, null, 8, ["icon", "onClick"])) : r("", !0),
S($, {
class: t(["dk-select_arrow", { "is-open": e.open }]),
icon: e.suffixIcon,
size: "16px"
}, null, 8, ["class", "icon"])
], 36)
];
}),
_: 3
}, 8, ["disabled", "on-open", "on-close", "on-change", "content-ref"])
], 34);
}
const Y = /* @__PURE__ */ V(P, [["render", j]]);
export {
Y as default
};