ai-form-designer
Version:
vue3+adv的设计器,可视化开发页面表单
128 lines (127 loc) • 4.41 kB
JavaScript
import { defineComponent as C, inject as E, resolveComponent as I, createBlock as f, openBlock as s, unref as l, isRef as U, withCtx as b, createElementVNode as x, createElementBlock as k, createCommentVNode as g, normalizeClass as w, createVNode as u, provide as N, withDirectives as O, vShow as A, createTextVNode as M, reactive as R } from "vue";
import { d as j } from "./vuedraggable.umd-R2PMz9bE.js";
import { p as y, n as $ } from "./index-DwcJO-0a.js";
import { _ as h } from "./icon.vue_vue_type_script_setup_true_lang-DW206h_7.js";
const z = {
key: 0,
class: "pl-4"
}, D = /* @__PURE__ */ C({
name: "EOptionItem",
__name: "optionItem",
props: {
modelValue: {}
},
emits: ["update:modelValue"],
setup(c, { emit: p }) {
const v = c, i = y.getComponent("input"), V = E("tree", !1), d = $(v, "modelValue", p);
function m(a) {
const n = {
label: "",
value: ""
};
a.children ? a.children.push(n) : a.children = [n];
}
function r(a) {
d.value = d.value.filter((n, _) => _ !== a);
}
return (a, n) => {
const _ = I("EOptionItem");
return s(), f(l(j), {
modelValue: l(d),
"onUpdate:modelValue": n[0] || (n[0] = (e) => U(d) ? d.value = e : null),
"item-key": "id",
"component-data": {
type: "transition-group"
},
group: "option-list",
handle: ".handle",
animation: 200
}, {
item: b(({ element: e, index: B }) => [
x("div", null, [
x("div", {
class: w([l(V) ? "grid-cols-[16px_auto_auto_16px_16px]" : "grid-cols-[16px_auto_auto_16px]", "option-item text-16px grid text-$epic-text-secondary gap-2 items-center mb-2"])
}, [
u(l(h), {
class: "mr-2 cursor-move handle",
name: "icon--epic--drag"
}),
u(l(i), {
modelValue: e.label,
"onUpdate:modelValue": (t) => e.label = t,
value: e.label,
"onUpdate:value": (t) => e.label = t,
placeholder: "label"
}, null, 8, ["modelValue", "onUpdate:modelValue", "value", "onUpdate:value"]),
u(l(i), {
modelValue: e.value,
"onUpdate:modelValue": (t) => e.value = t,
value: e.value,
"onUpdate:value": (t) => e.value = t,
placeholder: "value"
}, null, 8, ["modelValue", "onUpdate:modelValue", "value", "onUpdate:value"]),
l(V) ? (s(), f(l(h), {
key: 0,
class: "cursor-pointer text-lg!",
name: "icon--epic--add-rounded",
onClick: (t) => m(e)
}, null, 8, ["onClick"])) : g("", !0),
u(l(h), {
class: "hover:text-red cursor-pointer",
name: "icon--epic--delete-outline-rounded",
onClick: (t) => r(B)
}, null, 8, ["onClick"])
], 2),
e.children ? (s(), k("div", z, [
u(_, {
modelValue: e.children,
"onUpdate:modelValue": (t) => e.children = t
}, null, 8, ["modelValue", "onUpdate:modelValue"])
])) : g("", !0)
])
]),
_: 1
}, 8, ["modelValue"]);
};
}
}), S = { class: "" }, T = { class: "py-4 my-2 text-center text-gray-400 bg-white" }, J = /* @__PURE__ */ C({
__name: "index",
props: {
tree: { type: Boolean },
modelValue: {}
},
emits: ["update:modelValue"],
setup(c, { emit: p }) {
const v = y.getComponent("button"), i = c, o = $(i, "modelValue", p);
N("tree", i.tree);
function d() {
const m = R({
label: "",
value: ""
});
o.value = [...o.value, m];
}
return (m, r) => {
var a;
return s(), k("div", S, [
O(x("div", T, "暂无选项", 512), [
[A, !((a = l(o)) != null && a.length)]
]),
u(D, {
modelValue: l(o),
"onUpdate:modelValue": r[0] || (r[0] = (n) => U(o) ? o.value = n : null)
}, null, 8, ["modelValue"]),
u(l(v), { onClick: d }, {
default: b(() => r[1] || (r[1] = [
M("添加选项")
])),
_: 1,
__: [1]
})
]);
};
}
});
export {
J as default
};