vue-admin-core
Version:
A Component Library for Vue 3
123 lines (118 loc) • 3.53 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../__builtins__/index.js');
var vue$1 = require('@formily/vue');
require('../../preview-text/index.js');
var elementPlus = require('element-plus');
var lodashEs = require('lodash-es');
var iconsVue = require('@element-plus/icons-vue');
var transformComponent = require('../../__builtins__/shared/transform-component.js');
var index = require('../../preview-text/src/index.js');
var index$1 = require('../../__builtins__/configs/index.js');
var utils = require('../../__builtins__/shared/utils.js');
const RefElInput = vue.defineComponent({
name: "RefElInput",
props: elementPlus.ElInput.props,
setup(props, {
attrs,
slots
}) {
const field = vue$1.useField();
return () => vue.h(elementPlus.ElInput, {
...attrs,
...props,
ref: (inst) => {
field.value.inject({
getRef: () => inst
});
}
}, slots);
}
});
const TransformElInput = transformComponent.transformComponent(RefElInput, {
change: "update:modelValue"
});
const InnerInput = vue$1.connect(TransformElInput, vue$1.mapProps({
value: "modelValue",
readOnly: "readonly"
}, (props, field) => {
return {
...props,
ref: (inst) => {
field.inject({
getInstance: () => inst
});
},
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.Input));
const TextArea = vue$1.connect(InnerInput, vue$1.mapProps((props) => {
return {
...props,
type: "textarea"
};
}), vue$1.mapReadPretty(index.PreviewText.Input));
const Password = vue$1.connect(InnerInput, vue$1.mapProps((props) => ({
...props,
showPassword: true
})));
const Item = vue.defineComponent({
name: "FInputItem",
inheritAttrs: false,
setup(_, {
attrs
}) {
const field = vue$1.useField();
const schema = vue$1.useFieldSchema();
const schemas = schema.value.schema;
lodashEs.map(schemas, (value, key) => {
value["name"] = key;
});
const prepend = lodashEs.find(schemas, ["x-slot", "prepend"]);
const append = lodashEs.find(schemas, ["x-slot", "append"]);
const input = lodashEs.find(schemas, (item) => !item["x-slot"] || item["x-slot"] === "default");
const slots = {};
if (prepend) {
slots["prepend"] = () => {
return vue.h(vue$1.RecursionField, {
name: prepend.name,
schema: prepend,
basePath: field.value.address
});
};
}
if (append) {
slots["append"] = () => vue.h(vue$1.RecursionField, {
name: append.name,
schema: append,
basePath: field.value.address
});
}
return () => {
return vue.h(vue$1.Field, {
...new vue$1.Schema(input).toFieldProps(),
class: [`${index$1.stylePrefix}-select-input`, attrs == null ? void 0 : attrs.class],
style: attrs == null ? void 0 : attrs.style,
basePath: field.value.address
}, slots);
};
}
});
const Input = utils.composeExport(InnerInput, {
TextArea,
Password,
Item
});
exports.Input = Input;
exports.Item = Item;
exports.Password = Password;
exports.default = Input;
//# sourceMappingURL=index.js.map