@coderlt/form-designer
Version:
基于vue3的设计器,可视化开发页面表单
37 lines (36 loc) • 1.07 kB
JavaScript
import { inject as c, ref as s, computed as a, onMounted as t, watch as f, toRef as I, onUnmounted as h } from "vue";
import { b1 as m, b2 as w, bj as y } from "./index-74b7090f.js";
const K = () => {
const o = c(m, void 0), u = c(w, void 0);
return {
form: o,
formItem: u
};
}, U = (o, {
formItemContext: u,
disableIdGeneration: n,
disableIdManagement: d
}) => {
n || (n = s(!1)), d || (d = s(!1));
const v = s();
let e;
const p = a(() => {
var l;
return !!(!o.label && u && u.inputIds && ((l = u.inputIds) == null ? void 0 : l.length) <= 1);
});
return t(() => {
e = f([I(o, "id"), n], ([l, r]) => {
const i = l ?? (r ? void 0 : y().value);
i !== v.value && (u != null && u.removeInputId && (v.value && u.removeInputId(v.value), !(d != null && d.value) && !r && i && u.addInputId(i)), v.value = i);
}, { immediate: !0 });
}), h(() => {
e && e(), u != null && u.removeInputId && v.value && u.removeInputId(v.value);
}), {
isLabeledByFormItem: p,
inputId: v
};
};
export {
U as a,
K as u
};