vue-admin-core
Version:
A Component Library for Vue 3
91 lines (86 loc) • 2.98 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var vue$1 = require('@formily/vue');
require('../../preview-text/index.js');
var elementPlus = require('element-plus');
require('../../../components/config-provider/index.js');
var iconsVue = require('@element-plus/icons-vue');
var useArrToStr = require('../../__builtins__/hooks/useArrToStr.js');
var lodashEs = require('lodash-es');
var useGlobalConfig = require('../../../components/config-provider/src/hooks/use-global-config.js');
var index = require('../../preview-text/src/index.js');
const SelectOption = vue.defineComponent({
name: "FSelect",
props: {
...elementPlus.ElSelect.props,
options: Array,
props: {
type: Object,
default: () => ({
children: "children",
label: "label",
value: "value",
disabled: "disabled"
})
}
},
emits: [elementPlus.UPDATE_MODEL_EVENT, elementPlus.CHANGE_EVENT],
setup(props, ctx) {
const config = useGlobalConfig.useGlobalConfig();
const select = vue.ref();
const _props = useArrToStr.useArrToStr(props, ctx, {
vm: select
});
return () => {
const options = props.options || [];
const slots = {
...ctx.slots
};
if (options.length !== 0 && !ctx.slots.default) {
slots.default = () => options.map((option) => {
if (typeof option === "string") {
return vue$1.h(elementPlus.ElOption, {
key: option,
value: option,
label: option
}, {});
} else {
return vue$1.h(elementPlus.ElOption, {
key: option[props.props.value] || option[config.value.dictValueKey],
label: option[props.props.label] || option[config.value.dictLabelKey],
value: option[props.props.value] || option[config.value.dictValueKey],
disabled: lodashEs.isFunction(props.props.disabled) ? props.props.disabled(option) : option[props.props.disabled]
}, {});
}
});
}
return vue$1.h(elementPlus.ElSelect, vue.reactive({
...lodashEs.omit(vue.toRefs(props), ["options", "props"]),
..._props,
ref: (ref2) => select.value = ref2
}), slots);
};
}
});
const Select = vue$1.connect(SelectOption, vue$1.mapProps({
dataSource: "options",
loading: true,
value: "modelValue",
readOnly: "readonly"
}, (props, field) => {
return {
...props,
suffixIcon: (
// @ts-ignore
(field == null ? void 0 : field["loading"]) || (field == null ? void 0 : field["validating"]) ? vue.createVNode(elementPlus.ElIcon, {
"class": "is-loading"
}, {
default: () => [vue.createVNode(iconsVue.Loading, null, null)]
}) : props.suffixIcon
)
};
}), vue$1.mapReadPretty(index.PreviewText.Select));
exports.Select = Select;
exports.default = Select;
//# sourceMappingURL=index.js.map