"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),T=require("@ant-design/icons-vue"),f=require("@aplus-frontend/antdv"),R=require("@aplus-frontend/antdv/es/theme/internal"),i=require("lodash-unified");require("../../render/index.js");require("../../config-provider/index.js");const z=require("../../utils/slot.js"),j=require("../constant.js"),A=require("../context.js"),L=require("../hooks/use-regist-form.js"),M=require("../style/item.js"),O=require("../../config-provider/hooks/use-namespace.js"),$=require("../../render/render.js"),E=e.defineComponent({name:"ApFormItem",__name:"index",props:{htmlFor:{},prefixCls:{},label:{},help:{},extra:{},labelCol:{},wrapperCol:{},hasFeedback:{type:Boolean,default:!1},colon:{type:Boolean,default:void 0},labelAlign:{},prop:{},name:{},rules:{},autoLink:{type:Boolean,default:!0},required:{type:Boolean,default:void 0},validateFirst:{type:Boolean,default:void 0},validateStatus:{},validateTrigger:{},messageVariables:{},hidden:{type:Boolean},noStyle:{type:Boolean},tooltip:{},span:{},order:{},offset:{},push:{},pull:{},xs:{},sm:{},md:{},lg:{},xl:{},xxl:{},flex:{},bordered:{type:Boolean,default:!1},valuePropName:{default:"value"},initialValue:{},_signal:{},transform:{},description:{},customFilled:{},disabled:{type:Boolean},autoFocus:{type:Boolean,default:void 0}},setup(n,{expose:b}){const t=n,v=e.computed(()=>i.omit(t,[...j.apFormItemColPropKeys,"tooltip","label","description","autoFocus"])),y=e.useSlots(),{model:m,updateModel:h}=A.useInjectForm(),{m:d,b:F}=O.useNamespace("ap-form-item"),x=M.default("ap-form-item"),c=e.ref(!1),u=e.shallowRef(),[,g]=R.useToken();L.default(t);const p=e.computed(()=>t.name?i.isArray(t.name)?t.name.reduce((r,o)=>r?.[o],e.unref(m)):m?.value[t.name]:null);function V(r,o){const l=Object.keys(o),a={...o};return l.forEach(s=>{s in r||delete a[s]}),a}function B(r){if(!t.name)return r[0];const o=z.getValidVNodeList(r)[0];if(!o)return null;const l=o?.type?.props??{},a={autofocus:t.autoFocus??o?.props?.autofocus,variant:t.bordered?"borderless":o?.props?.variant,bordered:t.bordered?!1:o?.props?.bordered,onFocus:C,onBlur:N};return e.cloneVNode(o,{...V(l,a),[t.valuePropName]:e.unref(p),[`onUpdate:${t.valuePropName}`]:q})}function q(r){h?.(t.name,r)}function C(){c.value=!0}function N(){c.value=!1}function P(){u.value?.onFieldBlur()}function k(){u.value?.onFieldChange()}function w(){u.value?.clearValidate()}function S(){u.value?.resetField()}function I(r=!1){const o=e.unref(p);if(!r||!t.transform)return o;const l=i.isFunction(t.transform)?t.transform:t.transform.transformer;return t.transform?l(o):o}return b({onFieldBlur:P,onFieldChange:k,clearValidate:w,resetField:S,getFieldValue:I}),(r,o)=>(e.openBlock(),e.createBlock(e.unref(f.Form).Item,e.mergeProps({ref_key:"formItemRef",ref:u},v.value,{class:{[e.unref(d)("bordered")]:n.bordered,[e.unref(d)("focused")]:n.bordered&&c.value,[e.unref(d)("disabled")]:n.bordered&&n.disabled,[e.unref(F)()]:!0,[e.unref(x)]:!0},colon:n.bordered?!1:t.colon}),e.createSlots({default:e.withCtx(()=>[e.createVNode(e.unref($.default),{renderer:B},{default:e.withCtx(()=>[e.renderSlot(r.$slots,"default")]),_:3})]),_:2},[t.tooltip?{name:"tooltip",fn:e.withCtx(({class:l})=>[e.createElementVNode("span",{class:e.normalizeClass(l)},[e.createVNode(e.unref(f.Tooltip),{title:t.tooltip},{default:e.withCtx(()=>[e.createVNode(e.unref(T.QuestionCircleOutlined),{style:e.normalizeStyle({color:e.unref(g).colorTextTertiary,fontSize:"14px",transform:"translateY(1px)"})},null,8,["style"])]),_:1},8,["title"])],2)]),key:"0"}:void 0,n.label?{name:"label",fn:e.withCtx(()=>[e.createVNode(e.unref(f.TypographyText),{content:n.label,ellipsis:{tooltip:n.label},style:{"min-width":"0px",flex:"1"}},null,8,["content","ellipsis"])]),key:"1"}:void 0,e.renderList(e.unref(i.omit)(y,"default"),(l,a)=>({name:a,fn:e.withCtx(s=>[e.renderSlot(r.$slots,a,e.normalizeProps(e.guardReactiveProps(s||{})))])}))]),1040,["class","colon"]))}});exports.default=E;
