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