Files
appco_dist/.output/server/chunks/build/BasicSelect-DMW6tJJc.mjs
T
2025-08-24 13:00:31 +03:30

191 lines
7.7 KiB
JavaScript

import { defineComponent, computed, mergeProps, unref, withCtx, createVNode, toDisplayString, createBlock, openBlock, Fragment, renderList, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrInterpolate, ssrRenderComponent, ssrRenderList } from 'vue/server-renderer';
import { get } from 'lodash-es';
import { u as usePrefix } from './BasicIconOld-93vAWohq.mjs';
import { ax as Select, ay as SelectOption, az as __nuxt_component_2$4 } from './server.mjs';
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "BasicSelect",
__ssrInlineRender: true,
props: {
title: {},
value: { type: [String, Number, Boolean, Array] },
valueText: { type: [String, Number, Boolean, Array] },
style: {},
size: {},
keyName: {},
disabled: { type: Boolean },
mode: {},
valueName: {},
multiple: { type: Boolean },
items: {},
placeholder: {},
allowClear: { type: Boolean, default: true },
hasTooltip: { type: Boolean, default: true }
},
emits: ["update:value", "change", "update:valueText"],
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const localValue = computed({
get() {
return props.value;
},
set(value) {
emit("update:value", value);
}
});
function setValueText(val) {
localTextValue.value = get(val, props.valueName);
}
const localTextValue = computed({
get() {
return props.valueText;
},
set(value) {
emit("update:valueText", value);
}
});
const filterOption = (input, option) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
};
const handleChange = (e) => {
setValueText(props.items.find((x) => get(x, props.keyName) === e));
emit(
"change",
props.items.find((x) => get(x, props.keyName) === e)
);
};
const { prefixCls } = usePrefix("select");
return (_ctx, _push, _parent, _attrs) => {
const _component_a_select = Select;
const _component_a_select_option = SelectOption;
const _component_a_tooltip = __nuxt_component_2$4;
_push(`<div${ssrRenderAttrs(mergeProps({
class: [unref(prefixCls)]
}, _attrs))}><div>${ssrInterpolate(props.title)}</div>`);
_push(ssrRenderComponent(_component_a_select, {
class: "w-full",
size: props.size,
value: localValue.value,
"onUpdate:value": ($event) => localValue.value = $event,
disabled: props.disabled,
"show-search": "",
mode: props.mode,
style: props.style,
multiple: props.multiple,
onChange: handleChange,
placeholder: props.placeholder,
allowClear: props.allowClear,
"filter-option": filterOption,
autofocus: false,
"get-popup-container": (triggerNode) => triggerNode.parentElement,
onFocus: (e) => e.preventDefault()
}, {
default: withCtx((_, _push2, _parent2, _scopeId) => {
if (_push2) {
_push2(`<!--[-->`);
ssrRenderList(props.items, (val, i) => {
_push2(ssrRenderComponent(_component_a_select_option, {
key: i,
label: unref(get)(val, props.valueName),
value: unref(get)(val, props.keyName)
}, {
default: withCtx((_2, _push3, _parent3, _scopeId2) => {
if (_push3) {
if (props.hasTooltip) {
_push3(ssrRenderComponent(_component_a_tooltip, {
placement: "left",
class: "cursor-pointer"
}, {
title: withCtx((_3, _push4, _parent4, _scopeId3) => {
if (_push4) {
_push4(`<span${_scopeId3}>${ssrInterpolate(unref(get)(val, props.valueName))}</span>`);
} else {
return [
createVNode("span", null, toDisplayString(unref(get)(val, props.valueName)), 1)
];
}
}),
default: withCtx((_3, _push4, _parent4, _scopeId3) => {
if (_push4) {
_push4(`<div class="truncate max-w-40"${_scopeId3}>${ssrInterpolate(unref(get)(val, props.valueName))}</div>`);
} else {
return [
createVNode("div", { class: "truncate max-w-40" }, toDisplayString(unref(get)(val, props.valueName)), 1)
];
}
}),
_: 2
}, _parent3, _scopeId2));
} else {
_push3(`<div${_scopeId2}>${ssrInterpolate(unref(get)(val, props.valueName))}</div>`);
}
} else {
return [
props.hasTooltip ? (openBlock(), createBlock(_component_a_tooltip, {
key: 0,
placement: "left",
class: "cursor-pointer"
}, {
title: withCtx(() => [
createVNode("span", null, toDisplayString(unref(get)(val, props.valueName)), 1)
]),
default: withCtx(() => [
createVNode("div", { class: "truncate max-w-40" }, toDisplayString(unref(get)(val, props.valueName)), 1)
]),
_: 2
}, 1024)) : (openBlock(), createBlock("div", { key: 1 }, toDisplayString(unref(get)(val, props.valueName)), 1))
];
}
}),
_: 2
}, _parent2, _scopeId));
});
_push2(`<!--]-->`);
} else {
return [
(openBlock(true), createBlock(Fragment, null, renderList(props.items, (val, i) => {
return openBlock(), createBlock(_component_a_select_option, {
key: i,
label: unref(get)(val, props.valueName),
value: unref(get)(val, props.keyName)
}, {
default: withCtx(() => [
props.hasTooltip ? (openBlock(), createBlock(_component_a_tooltip, {
key: 0,
placement: "left",
class: "cursor-pointer"
}, {
title: withCtx(() => [
createVNode("span", null, toDisplayString(unref(get)(val, props.valueName)), 1)
]),
default: withCtx(() => [
createVNode("div", { class: "truncate max-w-40" }, toDisplayString(unref(get)(val, props.valueName)), 1)
]),
_: 2
}, 1024)) : (openBlock(), createBlock("div", { key: 1 }, toDisplayString(unref(get)(val, props.valueName)), 1))
]),
_: 2
}, 1032, ["label", "value"]);
}), 128))
];
}
}),
_: 1
}, _parent));
_push(`</div>`);
};
}
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/BasicPacks/BasicSelect.vue");
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const BasicSelect = Object.assign(_sfc_main, { __name: "BasicPacksBasicSelect" });
export { BasicSelect as B };
//# sourceMappingURL=BasicSelect-DMW6tJJc.mjs.map