@aplus-frontend/ui
Version:
32 lines (31 loc) • 1.15 kB
JavaScript
import { defineComponent as c, useSlots as u, cloneVNode as p, onMounted as f, createElementBlock as d, openBlock as o, Fragment as V, renderList as _, createBlock as y, resolveDynamicComponent as C } from "vue";
import { useInjectForm as F } from "../context.mjs";
import { isFunction as k, cloneDeep as g } from "lodash-unified";
import { isPromise as h } from "../../utils/is.mjs";
const I = /* @__PURE__ */ c({
name: "ApFormSet",
__name: "index",
props: {
name: {},
as: { default: "array" },
initialValue: {},
transform: {}
},
setup(i) {
const { internalInstance: l } = F(), s = u(), e = i, m = () => (s.default?.() || []).map((r, t) => {
const a = e.as === "array" ? [e.name, t] : [e.name, r.props?.name || ""];
return p(r, { name: a });
});
return f(async () => {
let n = k(e.initialValue) ? e.initialValue() : e.initialValue;
h(n) && (n = await n), l?.registerField({
name: e.name,
initialValue: g(n),
transform: e.transform
});
}), (n, r) => (o(!0), d(V, null, _(m(), (t, a) => (o(), y(C(t), { key: a }))), 128));
}
});
export {
I as default
};