@aplus-frontend/ui
Version:
42 lines (41 loc) • 1.06 kB
JavaScript
import { defineComponent as p, ref as i, watchEffect as d, unref as v, renderSlot as _ } from "vue";
import { useInjectForm as g } from "../context.mjs";
import { isNumber as h, cloneDeep as y } from "lodash-unified";
import { getModelValue as V } from "../utils/get.mjs";
const D = /* @__PURE__ */ p({
name: "ApFormDependency",
__name: "index",
props: {
nameList: {}
},
setup(a) {
const c = a, {
model: f
} = g(), r = i({});
function u(e, s, l) {
let t = s;
for (let o = 0; o < e.length; o++) {
const n = e[o];
if (o === e.length - 1)
t[n] = l;
else {
const m = e[o + 1];
(typeof t[n] != "object" || t[n] === null) && (t[n] = h(m) ? [] : {}), t = t[n];
}
}
}
return d(() => {
const e = y(r.value);
for (const s of c.nameList) {
const l = [s].flat(1), t = V(v(f), l);
u(l, e, t);
}
r.value = e;
}), (e, s) => _(e.$slots, "default", {
values: r.value
});
}
});
export {
D as default
};