"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),_=require("lodash-unified"),F=require("../context.js"),g=require("../hooks/use-regist-form.js"),k=t.defineComponent({name:"ApFormList",__name:"index",props:{name:{},initialValue:{},transform:{type:[Function,Object]}},setup(f){let o=1;const s=[],r=f,{model:c,updateModel:l}=F.useInjectForm();g.default(r);const a=t.computed(()=>r.name?_.isArray(r.name)?r.name.reduce((e,n)=>e?.[n],t.unref(c)):c?.value[r.name]:null);function d(e=void 0){const n=t.unref(a)?[...t.unref(a),e]:[e],u=o;return s.push(u),o+=1,l?.(r.name,n),u}function p(e){let n=t.unref(a)||[];n=[...n.slice(0,e),...n.slice(e+1)],s.splice(e,1),l?.(r.name,n)}function v(){return m.value.map(e=>e.key)}const y={add:d,remove:p,getFieldKeys:v},m=t.computed(()=>(t.unref(a)||[]).map((n,u)=>{let i=s[u];return typeof i>"u"&&(s[u]=o,i=o,o+=1),{key:i,fieldName:u,name:[r.name,u].flat(),value:n}}));return(e,n)=>t.renderSlot(e.$slots,"default",{fields:m.value,actions:y})}});exports.default=k;
