yanzhen-design-vue
Version:
97 lines (96 loc) • 3.97 kB
JavaScript
import { defineComponent, openBlock, createBlock, unref, mergeProps, createSlots, withCtx, resolveDynamicComponent, createElementBlock, createVNode, createElementVNode, toDisplayString, createCommentVNode, createTextVNode } from "vue";
import { Select, Divider, Tooltip, Tag, Spin } from "ant-design-vue";
import { selectName, selectProps, selectEmits, selectOptions } from "./select.mjs";
import { useSelect } from "./use-select.mjs";
const _hoisted_1 = { key: 0 };
const _hoisted_2 = ["title"];
const _sfc_main = /* @__PURE__ */ defineComponent({
...{ name: selectName },
__name: "select",
props: selectProps,
emits: selectEmits,
setup(__props, { expose: __expose, emit: __emit }) {
const { ns } = selectOptions;
const props = __props;
const emit = __emit;
const [
{
selectCtx,
proxyProps,
showCreateOptionButton,
addOptionHandler,
dropdownVisibleChangeHandler,
createItem,
searchMatchOption
}
] = useSelect(props, emit);
__expose({
ref: selectCtx
});
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(Select), mergeProps({
ref_key: "selectCtx",
ref: selectCtx,
class: [unref(ns).b()]
}, unref(proxyProps), { onDropdownVisibleChange: unref(dropdownVisibleChangeHandler) }), createSlots({
dropdownRender: withCtx(({ menuNode: menu }) => [
(openBlock(), createBlock(resolveDynamicComponent(menu))),
unref(showCreateOptionButton) && unref(searchMatchOption) ? (openBlock(), createElementBlock("div", _hoisted_1, [
createVNode(unref(Divider), { style: { "margin": "4px 0" } }),
createElementVNode("div", {
style: { "color": "black", "padding": "5px 12px", "cursor": "pointer", "word-break": "break-all" },
onClick: _cache[2] || (_cache[2] = //@ts-ignore
(...args) => unref(addOptionHandler) && unref(addOptionHandler)(...args)),
onMousedown: _cache[3] || (_cache[3] = (e) => e.preventDefault())
}, ' 创建选项"' + toDisplayString(unref(createItem)) + '" ', 33)
])) : createCommentVNode("", true)
]),
option: withCtx((item) => [
createVNode(unref(Tooltip), { placement: "right" }, {
title: withCtx(() => [
createTextVNode(toDisplayString(item[props.labelKey]), 1)
]),
default: withCtx(() => [
_ctx.showTag ? (openBlock(), createBlock(unref(Tag), {
key: 0,
color: item.color
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(item[props.labelKey]), 1)
]),
_: 2
}, 1032, ["color"])) : (openBlock(), createElementBlock("span", {
key: 1,
title: item[props.labelKey]
}, toDisplayString(item[props.labelKey]), 9, _hoisted_2))
]),
_: 2
}, 1024)
]),
_: 2
}, [
unref(showCreateOptionButton) ? {
name: "notFoundContent",
fn: withCtx(() => [
createElementVNode("div", {
style: { "color": "black", "cursor": "pointer", "word-break": "break-all" },
onClick: _cache[0] || (_cache[0] = //@ts-ignore
(...args) => unref(addOptionHandler) && unref(addOptionHandler)(...args)),
onMousedown: _cache[1] || (_cache[1] = (e) => e.preventDefault())
}, ' 创建选项"' + toDisplayString(unref(createItem)) + '" ', 33)
]),
key: "0"
} : props.fetching ? {
name: "notFoundContent",
fn: withCtx(() => [
createVNode(unref(Spin), { size: "small" })
]),
key: "1"
} : void 0
]), 1040, ["class", "onDropdownVisibleChange"]);
};
}
});
export {
_sfc_main as default
};