1 "use strict";const s=require("vue"),b=require("./CdxLabel.cjs"),y=require("./CdxMessage.cjs"),t=require("./constants.js"),a=require("./useGeneratedId.cjs"),$=require("./useComputedDisabled.cjs"),C=require("./_plugin-vue_export-helper.js"),h=t.makeStringTypeValidator(t.ValidationStatusTypes),I=s.defineComponent({name:"CdxField",components:{CdxLabel:b,CdxMessage:y},props:{labelIcon:{type:[String,Object],default:""},optional:{type:Boolean,default:!1},optionalFlag:{type:String,default:""},hideLabel:{type:Boolean,default:!1},isFieldset:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},status:{type:String,default:"default",validator:h},messages:{type:Object,default:()=>({})}},setup(e,{slots:n}){const{disabled:r,status:u,isFieldset:o}=s.toRefs(e),d=$(r),i=s.computed(()=>({"cdx-field--disabled":d.value,"cdx-field--is-fieldset":o.value})),l=a("label"),c=a("description"),p=a("input"),m=s.computed(()=>o.value?void 0:p);s.provide(t.FieldInputIdKey,m);const f=s.computed(()=>!o.value&&n.description?c:void 0);s.provide(t.FieldDescriptionIdKey,f),s.provide(t.DisabledKey,d),s.provide(t.FieldStatusKey,u);const v=s.computed(()=>e.status!=="default"&&e.status in e.messages?e.messages[e.status]:""),g=s.computed(()=>e.status==="default"?"notice":e.status);return{rootClasses:i,computedDisabled:d,labelId:l,descriptionId:c,inputId:p,validationMessage:v,validationMessageType:g}}}),S={class:"cdx-field__control"},F={class:"cdx-field__help-text"},k={key:0,class:"cdx-field__validation-message"};function D(e,n,r,u,o,d){const i=s.resolveComponent("cdx-label"),l=s.resolveComponent("cdx-message");return s.openBlock(),s.createBlock(s.resolveDynamicComponent(e.isFieldset?"fieldset":"div"),{class:s.normalizeClass(["cdx-field",e.rootClasses]),"aria-disabled":!e.isFieldset&&e.computedDisabled?!0:void 0,disabled:e.isFieldset&&e.computedDisabled?!0:void 0},{default:s.withCtx(()=>[s.createVNode(i,{id:e.labelId,icon:e.labelIcon,"visually-hidden":e.hideLabel,optional:e.optional,"optional-flag":e.optionalFlag,"input-id":e.inputId,"description-id":e.descriptionId,disabled:e.computedDisabled,"is-legend":e.isFieldset},s.createSlots({default:s.withCtx(()=>[s.renderSlot(e.$slots,"label")]),_:2},[e.$slots.description&&e.$slots.description().length>0?{name:"description",fn:s.withCtx(()=>[s.renderSlot(e.$slots,"description")]),key:"0"}:void 0]),1032,["id","icon","visually-hidden","optional","optional-flag","input-id","description-id","disabled","is-legend"]),s.createElementVNode("div",S,[s.renderSlot(e.$slots,"default")]),s.createElementVNode("div",F,[s.renderSlot(e.$slots,"help-text")]),!e.computedDisabled&&e.validationMessage||e.$slots[e.validationMessageType]?(s.openBlock(),s.createElementBlock("div",k,[s.createVNode(l,{type:e.validationMessageType,inline:!0},{default:s.withCtx(()=>[e.status==="warning"&&e.$slots.warning?s.renderSlot(e.$slots,"warning",{key:0}):e.status==="error"&&e.$slots.error?s.renderSlot(e.$slots,"error",{key:1}):e.status==="success"&&e.$slots.success?s.renderSlot(e.$slots,"success",{key:2}):(s.openBlock(),s.createElementBlock(s.Fragment,{key:3},[s.createTextVNode(s.toDisplayString(e.validationMessage),1)],64))]),_:3},8,["type"])])):s.createCommentVNode("v-if",!0)]),_:3},8,["class","aria-disabled","disabled"])}const B=C._export_sfc(I,[["render",D]]);module.exports=B;