@macrulez/vue-form-schema 0.1.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +461 -180
- package/dist/MaskEngine-BEXwX4BK.js +144 -0
- package/dist/MaskEngine-CPr-fSPy.cjs +1 -0
- package/dist/ValidationEngine-BC4U1ef1.js +135 -0
- package/dist/ValidationEngine-Diz-qTFs.cjs +1 -0
- package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
- package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
- package/dist/core/ConditionEvaluator.d.ts.map +1 -1
- package/dist/core/MaskEngine.d.ts.map +1 -1
- package/dist/core/ValidationEngine.d.ts +13 -0
- package/dist/core/ValidationEngine.d.ts.map +1 -1
- package/dist/core/formRegistry.d.ts +33 -0
- package/dist/core/formRegistry.d.ts.map +1 -0
- package/dist/core/inferTypes.d.ts.map +1 -1
- package/dist/core/schemaUtils.d.ts +38 -0
- package/dist/core/schemaUtils.d.ts.map +1 -1
- package/dist/core/serverErrors.d.ts +69 -0
- package/dist/core/serverErrors.d.ts.map +1 -0
- package/dist/core/types.d.ts +22 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/useForm.d.ts +4 -1
- package/dist/core/useForm.d.ts.map +1 -1
- package/dist/core/useMultiStepForm.d.ts.map +1 -1
- package/dist/devtools/index.d.ts +26 -0
- package/dist/devtools/index.d.ts.map +1 -0
- package/dist/devtools.cjs +1 -0
- package/dist/devtools.d.ts +6 -0
- package/dist/devtools.js +93 -0
- package/dist/formRegistry-Bv1eaWQ-.js +31 -0
- package/dist/formRegistry-DaDmXyYY.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +392 -359
- package/dist/openapi.cjs +1 -0
- package/dist/openapi.d.ts +202 -0
- package/dist/openapi.js +118 -0
- package/dist/parsers/json.d.ts.map +1 -1
- package/dist/parsers/openapi.d.ts +139 -0
- package/dist/parsers/openapi.d.ts.map +1 -0
- package/dist/parsers/valibot.d.ts +13 -4
- package/dist/parsers/valibot.d.ts.map +1 -1
- package/dist/parsers/yup.d.ts +10 -4
- package/dist/parsers/yup.d.ts.map +1 -1
- package/dist/parsers/zod.d.ts +18 -4
- package/dist/parsers/zod.d.ts.map +1 -1
- package/dist/schemaUtils-Cc7CwGXB.cjs +1 -0
- package/dist/schemaUtils-Cvlsk24U.js +337 -0
- package/dist/style.css +1 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/naive/index.d.ts +11 -0
- package/dist/ui/naive/index.d.ts.map +1 -0
- package/dist/ui/primevue/index.d.ts +11 -0
- package/dist/ui/primevue/index.d.ts.map +1 -0
- package/dist/ui/shadcn/index.d.ts +11 -0
- package/dist/ui/shadcn/index.d.ts.map +1 -0
- package/dist/ui/tailwind/index.d.ts +11 -0
- package/dist/ui/tailwind/index.d.ts.map +1 -0
- package/dist/ui-naive.cjs +1 -0
- package/dist/ui-naive.d.ts +411 -0
- package/dist/ui-naive.js +667 -0
- package/dist/ui-primevue.cjs +1 -0
- package/dist/ui-primevue.d.ts +411 -0
- package/dist/ui-primevue.js +651 -0
- package/dist/ui-shadcn.cjs +1 -0
- package/dist/ui-shadcn.d.ts +411 -0
- package/dist/ui-shadcn.js +650 -0
- package/dist/ui-tailwind.cjs +1 -0
- package/dist/ui-tailwind.d.ts +411 -0
- package/dist/ui-tailwind.js +669 -0
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +61 -10
- package/dist/ui.js +434 -299
- package/dist/valibot.cjs +1 -1
- package/dist/valibot.d.ts +35 -4
- package/dist/valibot.js +47 -20
- package/dist/yup.cjs +1 -1
- package/dist/yup.d.ts +33 -5
- package/dist/yup.js +16 -15
- package/dist/zod.cjs +1 -1
- package/dist/zod.d.ts +41 -5
- package/dist/zod.js +58 -28
- package/package.json +99 -25
- package/dist/MaskEngine-BqJQYybS.js +0 -233
- package/dist/MaskEngine-BwAs2Zb0.cjs +0 -1
- package/dist/__tests__/ConditionEvaluator.test.d.ts +0 -2
- package/dist/__tests__/ConditionEvaluator.test.d.ts.map +0 -1
- package/dist/__tests__/MaskEngine.test.d.ts +0 -2
- package/dist/__tests__/MaskEngine.test.d.ts.map +0 -1
- package/dist/__tests__/ValidationEngine.test.d.ts +0 -2
- package/dist/__tests__/ValidationEngine.test.d.ts.map +0 -1
- package/dist/__tests__/parsers.test.d.ts +0 -2
- package/dist/__tests__/parsers.test.d.ts.map +0 -1
- package/dist/__tests__/phase3.test.d.ts +0 -2
- package/dist/__tests__/phase3.test.d.ts.map +0 -1
- package/dist/__tests__/phase4.test.d.ts +0 -2
- package/dist/__tests__/phase4.test.d.ts.map +0 -1
- package/dist/__tests__/useFieldArray.test.d.ts +0 -2
- package/dist/__tests__/useFieldArray.test.d.ts.map +0 -1
- package/dist/__tests__/useForm.test.d.ts +0 -2
- package/dist/__tests__/useForm.test.d.ts.map +0 -1
- package/dist/__tests__/useMultiStepForm.test.d.ts +0 -2
- package/dist/__tests__/useMultiStepForm.test.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),x=require("./MaskEngine-CPr-fSPy.cjs"),F=require("./ValidationEngine-Diz-qTFs.cjs"),D={class:"mb-4 space-y-1.5"},R=["for"],A={key:0,class:"text-destructive ml-0.5","aria-hidden":"true"},P=["id"],g=e.defineComponent({__name:"BaseField",props:{field:{},error:{},touched:{type:Boolean}},setup(t){const s=t,o=e.computed(()=>{var d;return!!(s.touched&&((d=s.error)!=null&&d.length))}),c=e.computed(()=>`${s.field.name}-error`),n=e.computed(()=>({"aria-required":s.field.required?"true":void 0,"aria-invalid":o.value?"true":"false","aria-describedby":o.value?c.value:void 0}));return(d,i)=>(e.openBlock(),e.createElementBlock("div",D,[t.field.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:t.field.name,class:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"},[e.createTextVNode(e.toDisplayString(t.field.label)+" ",1),t.field.required?(e.openBlock(),e.createElementBlock("span",A,"*")):e.createCommentVNode("",!0)],8,R)):e.createCommentVNode("",!0),e.renderSlot(d.$slots,"default",e.normalizeProps(e.guardReactiveProps(n.value))),o.value?(e.openBlock(),e.createElementBlock("ul",{key:1,id:c.value,class:"space-y-0.5",role:"alert","aria-live":"polite"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.error,(a,m)=>(e.openBlock(),e.createElementBlock("li",{key:m,class:"text-destructive text-sm font-medium"},e.toDisplayString(a),1))),128))],8,P)):e.createCommentVNode("",!0)]))}}),L=["id","type","name","value","placeholder","disabled","required"],B=e.defineComponent({__name:"TextField",props:{field:{},modelValue:{},error:{},touched:{type:Boolean}},emits:["update:modelValue","blur"],setup(t,{emit:s}){const o=t,c=s,n=e.ref(null);let d=null;const i=e.computed(()=>{var a;return!!(o.touched&&((a=o.error)!=null&&a.length))});return e.onMounted(()=>{n.value&&o.field.mask&&(d=x.bindMask(n.value,o.field.mask))}),e.onUnmounted(()=>d==null?void 0:d()),(a,m)=>(e.openBlock(),e.createBlock(g,{field:t.field,error:t.error,touched:t.touched},{default:e.withCtx(f=>[e.createElementVNode("input",e.mergeProps({id:t.field.name,ref_key:"inputRef",ref:n,type:t.field.type==="email"?"email":"text",name:t.field.name,value:t.modelValue??"",placeholder:t.field.placeholder,disabled:t.field.disabled===!0,required:t.field.required},f,{class:["border-input placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",i.value?"border-destructive focus-visible:ring-destructive":""],onInput:m[0]||(m[0]=b=>c("update:modelValue",b.target.value)),onBlur:m[1]||(m[1]=b=>c("blur"))}),null,16,L)]),_:1},8,["field","error","touched"]))}}),T=["id","name","value","placeholder","disabled","required"],V=e.defineComponent({__name:"NumberField",props:{field:{},modelValue:{},error:{},touched:{type:Boolean}},emits:["update:modelValue","blur"],setup(t,{emit:s}){const o=t,c=s,n=e.computed(()=>{var i;return!!(o.touched&&((i=o.error)!=null&&i.length))});function d(i){const a=i.target.value;c("update:modelValue",a===""?null:Number(a))}return(i,a)=>(e.openBlock(),e.createBlock(g,{field:t.field,error:t.error,touched:t.touched},{default:e.withCtx(m=>[e.createElementVNode("input",e.mergeProps({id:t.field.name,type:"number",name:t.field.name,value:t.modelValue??"",placeholder:t.field.placeholder,disabled:t.field.disabled===!0,required:t.field.required},m,{class:["border-input placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",n.value?"border-destructive focus-visible:ring-destructive":""],onInput:d,onBlur:a[0]||(a[0]=f=>c("blur"))}),null,16,T)]),_:1},8,["field","error","touched"]))}}),I=["id","name","value","placeholder","disabled","required"],$=e.defineComponent({__name:"TextareaField",props:{field:{},modelValue:{},error:{},touched:{type:Boolean}},emits:["update:modelValue","blur"],setup(t,{emit:s}){const o=t,c=s,n=e.computed(()=>{var d;return!!(o.touched&&((d=o.error)!=null&&d.length))});return(d,i)=>(e.openBlock(),e.createBlock(g,{field:t.field,error:t.error,touched:t.touched},{default:e.withCtx(a=>[e.createElementVNode("textarea",e.mergeProps({id:t.field.name,name:t.field.name,value:t.modelValue??"",placeholder:t.field.placeholder,disabled:t.field.disabled===!0,required:t.field.required},a,{class:["border-input placeholder:text-muted-foreground focus-visible:ring-ring flex min-h-[70px] w-full resize-y rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",n.value?"border-destructive focus-visible:ring-destructive":""],onInput:i[0]||(i[0]=m=>c("update:modelValue",m.target.value)),onBlur:i[1]||(i[1]=m=>c("blur"))}),null,16,I)]),_:1},8,["field","error","touched"]))}}),M={key:0,class:"text-muted-foreground py-2 text-sm"},z=["id","name","disabled","required"],U=["selected"],j=["value","selected"],E=e.defineComponent({__name:"SelectField",props:{field:{},modelValue:{},error:{},touched:{type:Boolean}},emits:["update:modelValue","blur"],setup(t,{emit:s}){const o=t,c=s,n=e.computed(()=>Array.isArray(o.field.options)?o.field.options:[]),d=e.computed(()=>{var a;return!!(o.touched&&((a=o.error)!=null&&a.length))});function i(a){const m=a.target,f=n.value.find(b=>String(b.value)===m.value);c("update:modelValue",(f==null?void 0:f.value)??m.value)}return(a,m)=>(e.openBlock(),e.createBlock(g,{field:t.field,error:t.error,touched:t.touched},{default:e.withCtx(f=>[t.field.optionsLoading?(e.openBlock(),e.createElementBlock("div",M,"Loading…")):(e.openBlock(),e.createElementBlock("select",e.mergeProps({key:1,id:t.field.name,name:t.field.name,disabled:t.field.disabled===!0||t.field.optionsLoading,required:t.field.required},f,{class:["border-input focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",d.value?"border-destructive focus-visible:ring-destructive":""],onChange:i,onBlur:m[0]||(m[0]=b=>c("blur"))}),[e.createElementVNode("option",{value:"",disabled:"",selected:t.modelValue===null||t.modelValue===void 0||t.modelValue===""},e.toDisplayString(t.field.placeholder??"Select an option"),9,U),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,b=>(e.openBlock(),e.createElementBlock("option",{key:String(b.value),value:String(b.value),selected:t.modelValue===b.value},e.toDisplayString(b.label),9,j))),128))],16,z))]),_:1},8,["field","error","touched"]))}}),K={class:"flex cursor-pointer items-center gap-2.5"},O=["id","name","checked","disabled","required","aria-checked"],G={key:0,class:"text-sm leading-none"},C=e.defineComponent({__name:"CheckboxField",props:{field:{},modelValue:{type:[Boolean,null]},error:{},touched:{type:Boolean}},emits:["update:modelValue","blur"],setup(t,{emit:s}){const o=s;return(c,n)=>(e.openBlock(),e.createBlock(g,{field:{...t.field,label:void 0},error:t.error,touched:t.touched},{default:e.withCtx(d=>[e.createElementVNode("label",K,[e.createElementVNode("input",e.mergeProps({id:t.field.name,type:"checkbox",name:t.field.name,checked:!!t.modelValue,disabled:t.field.disabled===!0,required:t.field.required,"aria-checked":t.modelValue?"true":"false"},d,{class:"border-primary text-primary focus-visible:ring-ring peer h-4 w-4 shrink-0 cursor-pointer rounded-sm border shadow focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",onChange:n[0]||(n[0]=i=>o("update:modelValue",i.target.checked)),onBlur:n[1]||(n[1]=i=>o("blur"))}),null,16,O),t.field.label?(e.openBlock(),e.createElementBlock("span",G,e.toDisplayString(t.field.label),1)):e.createCommentVNode("",!0)])]),_:1},8,["field","error","touched"]))}}),H=["aria-required","aria-invalid","aria-describedby"],J={key:0,class:"text-sm font-medium leading-none"},Q={key:0,class:"text-destructive ml-0.5","aria-hidden":"true"},W={class:"space-y-2"},X=["name","value","checked","disabled","onChange"],Y={class:"text-sm leading-none"},Z=["id"],S=e.defineComponent({__name:"RadioField",props:{field:{},modelValue:{},error:{},touched:{type:Boolean}},emits:["update:modelValue","blur"],setup(t,{emit:s}){const o=t,c=s,n=e.computed(()=>{var a;return!!(o.touched&&((a=o.error)!=null&&a.length))}),d=e.computed(()=>`${o.field.name}-error`),i=e.computed(()=>Array.isArray(o.field.options)?o.field.options:[]);return(a,m)=>(e.openBlock(),e.createElementBlock("fieldset",{class:"mb-4 space-y-2","aria-required":t.field.required?"true":void 0,"aria-invalid":n.value?"true":"false","aria-describedby":n.value?d.value:void 0},[t.field.label?(e.openBlock(),e.createElementBlock("legend",J,[e.createTextVNode(e.toDisplayString(t.field.label)+" ",1),t.field.required?(e.openBlock(),e.createElementBlock("span",Q,"*")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",W,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,f=>(e.openBlock(),e.createElementBlock("label",{key:String(f.value),class:"flex cursor-pointer items-center gap-2.5"},[e.createElementVNode("input",{type:"radio",name:t.field.name,value:String(f.value),checked:t.modelValue===f.value,disabled:t.field.disabled===!0,class:"border-primary text-primary focus-visible:ring-ring h-4 w-4 cursor-pointer focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",onChange:b=>c("update:modelValue",f.value),onBlur:m[0]||(m[0]=b=>c("blur"))},null,40,X),e.createElementVNode("span",Y,e.toDisplayString(f.label),1)]))),128))]),n.value?(e.openBlock(),e.createElementBlock("ul",{key:1,id:d.value,class:"space-y-0.5",role:"alert","aria-live":"polite"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.error,(f,b)=>(e.openBlock(),e.createElementBlock("li",{key:b,class:"text-destructive text-sm font-medium"},e.toDisplayString(f),1))),128))],8,Z)):e.createCommentVNode("",!0)],8,H))}}),_=["id","name","value","disabled","required"],N=e.defineComponent({__name:"DateField",props:{field:{},modelValue:{},error:{},touched:{type:Boolean}},emits:["update:modelValue","blur"],setup(t,{emit:s}){const o=t,c=s,n=e.computed(()=>{var d;return!!(o.touched&&((d=o.error)!=null&&d.length))});return(d,i)=>(e.openBlock(),e.createBlock(g,{field:t.field,error:t.error,touched:t.touched},{default:e.withCtx(a=>[e.createElementVNode("input",e.mergeProps({id:t.field.name,type:"date",name:t.field.name,value:t.modelValue??"",disabled:t.field.disabled===!0,required:t.field.required},a,{class:["border-input focus-visible:ring-ring flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",n.value?"border-destructive focus-visible:ring-destructive":""],onInput:i[0]||(i[0]=m=>c("update:modelValue",m.target.value)),onBlur:i[1]||(i[1]=m=>c("blur"))}),null,16,_)]),_:1},8,["field","error","touched"]))}}),ee=["id","name","accept","multiple","disabled","required"],te={class:"text-muted-foreground pointer-events-none space-y-1 text-sm"},oe={key:0,class:"text-xs"},le={key:0,class:"mt-2 space-y-1"},re={class:"truncate"},ne={class:"text-muted-foreground ml-2 shrink-0 text-xs"},de=["aria-label","onClick"],w=e.defineComponent({__name:"FileField",props:{field:{},modelValue:{},error:{},touched:{type:Boolean}},emits:["update:modelValue","blur"],setup(t,{emit:s}){const o=t,c=s,n=e.ref(!1),d=e.ref(null),i=e.computed(()=>o.modelValue?Array.isArray(o.modelValue)?o.modelValue:[o.modelValue]:[]),a=e.computed(()=>o.field.multiple??!1);function m(r){if(!r||r.length===0){c("update:modelValue",null);return}c("update:modelValue",a.value?Array.from(r):r[0])}function f(r){m(r.target.files),c("blur")}function b(r){var l;n.value=!1,r.preventDefault(),m(((l=r.dataTransfer)==null?void 0:l.files)??null),c("blur")}function k(r){const l=i.value.filter((v,p)=>p!==r);l.length===0?(c("update:modelValue",null),d.value&&(d.value.value="")):c("update:modelValue",a.value?l:l[0])}function y(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}return(r,l)=>(e.openBlock(),e.createBlock(g,{field:t.field,error:t.error,touched:t.touched},{default:e.withCtx(v=>{var p;return[e.createElementVNode("div",{class:e.normalizeClass(["border-input relative rounded-md border border-dashed p-6 text-center transition-colors",n.value?"border-ring bg-accent":t.touched&&((p=t.error)!=null&&p.length)?"border-destructive":"hover:border-ring/60"]),onDragover:l[0]||(l[0]=e.withModifiers(u=>n.value=!0,["prevent"])),onDragleave:l[1]||(l[1]=u=>n.value=!1),onDrop:b},[e.createElementVNode("input",e.mergeProps({id:t.field.name,ref_key:"inputRef",ref:d,type:"file",name:t.field.name,accept:t.field.accept,multiple:a.value,disabled:t.field.disabled===!0,required:t.field.required},v,{class:"absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed",onChange:f}),null,16,ee),e.createElementVNode("div",te,[e.createElementVNode("p",null,e.toDisplayString(n.value?"Drop files here":"Click to upload or drag & drop"),1),t.field.accept?(e.openBlock(),e.createElementBlock("p",oe,e.toDisplayString(t.field.accept),1)):e.createCommentVNode("",!0)])],34),i.value.length?(e.openBlock(),e.createElementBlock("ul",le,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(u,h)=>(e.openBlock(),e.createElementBlock("li",{key:`${u.name}-${h}`,class:"border-input flex items-center justify-between rounded-md border px-3 py-2 text-sm"},[e.createElementVNode("span",re,e.toDisplayString(u.name),1),e.createElementVNode("span",ne,e.toDisplayString(y(u.size)),1),e.createElementVNode("button",{type:"button","aria-label":`Remove ${u.name}`,class:"text-muted-foreground hover:text-destructive ml-2 shrink-0 transition-colors",onClick:ve=>k(h)}," × ",8,de)]))),128))])):e.createCommentVNode("",!0)]}),_:1},8,["field","error","touched"]))}}),ie={class:"mb-4"},ae={key:0,class:"mb-2 text-sm font-medium leading-none"},ue={class:"flex-1 space-y-0"},ce=["onClick"],q=e.defineComponent({__name:"ArrayField",props:{field:{},form:{},components:{}},setup(t){const s=t,o=x.useRegistry(),c={text:B,email:B,number:V,textarea:$,select:E,checkbox:C,radio:S,date:N};function n(r){var l;return r.component?r.component:((l=s.components)==null?void 0:l[r.type])??o[r.type]??c[r.type]??null}const{rows:d,append:i,remove:a}=x.useFieldArray(s.form,s.field.name);function m(r){return F.getByPath(s.form.values.value,r.name)}function f(r,l){s.form.setField(r.name,l)}function b(r){var v;const l=s.form;(v=l.touchField)==null||v.call(l,r.name)}function k(r){return s.form.errors.value[r.name]??[]}function y(r){return s.form.touched.value[r.name]??!1}return(r,l)=>(e.openBlock(),e.createElementBlock("div",ie,[t.field.label?(e.openBlock(),e.createElementBlock("div",ae,e.toDisplayString(t.field.label),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(d),v=>(e.openBlock(),e.createElementBlock("div",{key:v.key,class:"border-input bg-card mb-2 flex items-start gap-2 rounded-md border p-3"},[e.createElementVNode("div",ue,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.fields,p=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:p.name},[n(p)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n(p)),{key:0,field:p,"model-value":m(p),error:k(p),touched:y(p),"onUpdate:modelValue":u=>f(p,u),onBlur:u=>b(p)},null,40,["field","model-value","error","touched","onUpdate:modelValue","onBlur"])):e.createCommentVNode("",!0)],64))),128))]),e.createElementVNode("button",{type:"button",class:"text-muted-foreground hover:text-destructive mt-7 shrink-0 rounded px-2 py-1 text-xs transition-colors",onClick:p=>e.unref(a)(v.index)}," Remove ",8,ce)]))),128)),e.createElementVNode("button",{type:"button",class:"border-input hover:border-ring hover:text-foreground text-muted-foreground mt-1 rounded-md border border-dashed px-4 py-2 text-sm transition-colors",onClick:l[0]||(l[0]=v=>e.unref(i)())}," + Add row ")]))}}),se={key:1,class:"border-input mb-4 rounded-md border p-4"},me={key:0,class:"px-1 text-sm font-medium leading-none"},fe=["disabled"],be=e.defineComponent({__name:"ShadcnFormRenderer",props:{form:{},components:{},submitLabel:{},fields:{}},emits:["submit"],setup(t,{emit:s}){const o=t,c=x.useRegistry(),n=s,d={text:B,email:B,number:V,textarea:$,select:E,checkbox:C,radio:S,date:N,file:w};function i(l){var v;return l.component?l.component:((v=o.components)==null?void 0:v[l.type])??c[l.type]??d[l.type]??null}function a(l){return F.getByPath(o.form.values.value,l.name)}function m(l,v){o.form.setField(l.name,v)}function f(l){var p;const v=o.form;(p=v.touchField)==null||p.call(v,l.name)}function b(l){return o.form.errors.value[l.name]??[]}function k(l){return o.form.touched.value[l.name]??!1}const y=e.computed(()=>(o.fields??o.form.fields.value).filter(l=>l.visible!==!1));async function r(l){l.preventDefault(),await o.form.submit(),n("submit")}return(l,v)=>{const p=e.resolveComponent("ShadcnFormRenderer",!0);return e.openBlock(),e.createElementBlock("form",{novalidate:"",onSubmit:r},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,u=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:u.name},[l.$slots[`field-${u.name}`]?e.renderSlot(l.$slots,`field-${u.name}`,{key:0,field:u,value:a(u),error:b(u),touched:k(u),setValue:h=>m(u,h),touch:()=>f(u)}):u.type==="group"?(e.openBlock(),e.createElementBlock("fieldset",se,[u.label?(e.openBlock(),e.createElementBlock("legend",me,e.toDisplayString(u.label),1)):e.createCommentVNode("",!0),u.fields?(e.openBlock(),e.createBlock(p,{key:1,form:t.form,fields:u.fields,components:t.components},null,8,["form","fields","components"])):e.createCommentVNode("",!0)])):u.type==="array"?(e.openBlock(),e.createBlock(q,{key:2,field:u,form:t.form,components:t.components},null,8,["field","form","components"])):i(u)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i(u)),{key:3,field:u,"model-value":a(u),error:b(u),touched:k(u),"onUpdate:modelValue":h=>m(u,h),onBlur:h=>f(u)},null,40,["field","model-value","error","touched","onUpdate:modelValue","onBlur"])):e.createCommentVNode("",!0)],64))),128)),e.renderSlot(l.$slots,"submit",{isSubmitting:t.form.isSubmitting.value,isValid:t.form.isValid.value},()=>[e.createElementVNode("button",{type:"submit",disabled:t.form.isSubmitting.value,class:"bg-primary text-primary-foreground hover:bg-primary/90 mt-2 inline-flex h-9 items-center justify-center rounded-md px-4 py-2 text-sm font-medium shadow transition-colors disabled:pointer-events-none disabled:opacity-50"},e.toDisplayString(t.submitLabel??"Submit"),9,fe)])],32)}}});exports.ShArrayField=q;exports.ShCheckboxField=C;exports.ShDateField=N;exports.ShFileField=w;exports.ShNumberField=V;exports.ShRadioField=S;exports.ShSelectField=E;exports.ShTextField=B;exports.ShTextareaField=$;exports.ShadcnFormRenderer=be;
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
3
|
+
import { ComponentProvideOptions } from 'vue';
|
|
4
|
+
import { ComputedRef } from 'vue';
|
|
5
|
+
import { DefineComponent } from 'vue';
|
|
6
|
+
import { ExtractPropTypes } from 'vue';
|
|
7
|
+
import { PropType } from 'vue';
|
|
8
|
+
import { PublicProps } from 'vue';
|
|
9
|
+
import { Ref } from 'vue';
|
|
10
|
+
|
|
11
|
+
declare const __VLS_component: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
12
|
+
form: UseFormReturn;
|
|
13
|
+
components?: Partial<Record<FieldDefinition["type"], Component | string>>;
|
|
14
|
+
submitLabel?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Internal: the field list to render. Used by the `group` case to recurse
|
|
17
|
+
* into `field.fields` instead of re-rendering the whole top-level schema
|
|
18
|
+
* (which would recurse into the same group forever). Defaults to the
|
|
19
|
+
* form's top-level fields — not meant to be passed by consumers.
|
|
20
|
+
*/
|
|
21
|
+
fields?: FieldDefinition[];
|
|
22
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
23
|
+
submit: () => void;
|
|
24
|
+
}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
25
|
+
form: UseFormReturn;
|
|
26
|
+
components?: Partial<Record<FieldDefinition["type"], Component | string>>;
|
|
27
|
+
submitLabel?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Internal: the field list to render. Used by the `group` case to recurse
|
|
30
|
+
* into `field.fields` instead of re-rendering the whole top-level schema
|
|
31
|
+
* (which would recurse into the same group forever). Defaults to the
|
|
32
|
+
* form's top-level fields — not meant to be passed by consumers.
|
|
33
|
+
*/
|
|
34
|
+
fields?: FieldDefinition[];
|
|
35
|
+
}>>> & Readonly<{
|
|
36
|
+
onSubmit?: (() => any) | undefined;
|
|
37
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
38
|
+
|
|
39
|
+
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
40
|
+
|
|
41
|
+
declare type __VLS_NonUndefinedable_10<T> = T extends undefined ? never : T;
|
|
42
|
+
|
|
43
|
+
declare type __VLS_NonUndefinedable_2<T> = T extends undefined ? never : T;
|
|
44
|
+
|
|
45
|
+
declare type __VLS_NonUndefinedable_3<T> = T extends undefined ? never : T;
|
|
46
|
+
|
|
47
|
+
declare type __VLS_NonUndefinedable_4<T> = T extends undefined ? never : T;
|
|
48
|
+
|
|
49
|
+
declare type __VLS_NonUndefinedable_5<T> = T extends undefined ? never : T;
|
|
50
|
+
|
|
51
|
+
declare type __VLS_NonUndefinedable_6<T> = T extends undefined ? never : T;
|
|
52
|
+
|
|
53
|
+
declare type __VLS_NonUndefinedable_7<T> = T extends undefined ? never : T;
|
|
54
|
+
|
|
55
|
+
declare type __VLS_NonUndefinedable_8<T> = T extends undefined ? never : T;
|
|
56
|
+
|
|
57
|
+
declare type __VLS_NonUndefinedable_9<T> = T extends undefined ? never : T;
|
|
58
|
+
|
|
59
|
+
declare function __VLS_template(): Partial<Record<`field-${string}`, (_: {
|
|
60
|
+
field: FieldDefinition;
|
|
61
|
+
value: unknown;
|
|
62
|
+
error: string[];
|
|
63
|
+
touched: boolean;
|
|
64
|
+
setValue: (v: unknown) => void;
|
|
65
|
+
touch: () => void;
|
|
66
|
+
}) => any>> & {
|
|
67
|
+
submit?(_: {
|
|
68
|
+
isSubmitting: boolean;
|
|
69
|
+
isValid: boolean;
|
|
70
|
+
}): any;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
74
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
75
|
+
type: PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
76
|
+
} : {
|
|
77
|
+
type: PropType<T[K]>;
|
|
78
|
+
required: true;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
declare type __VLS_TypePropsToRuntimeProps_10<T> = {
|
|
83
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
84
|
+
type: PropType<__VLS_NonUndefinedable_10<T[K]>>;
|
|
85
|
+
} : {
|
|
86
|
+
type: PropType<T[K]>;
|
|
87
|
+
required: true;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
declare type __VLS_TypePropsToRuntimeProps_2<T> = {
|
|
92
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
93
|
+
type: PropType<__VLS_NonUndefinedable_2<T[K]>>;
|
|
94
|
+
} : {
|
|
95
|
+
type: PropType<T[K]>;
|
|
96
|
+
required: true;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
declare type __VLS_TypePropsToRuntimeProps_3<T> = {
|
|
101
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
102
|
+
type: PropType<__VLS_NonUndefinedable_3<T[K]>>;
|
|
103
|
+
} : {
|
|
104
|
+
type: PropType<T[K]>;
|
|
105
|
+
required: true;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
declare type __VLS_TypePropsToRuntimeProps_4<T> = {
|
|
110
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
111
|
+
type: PropType<__VLS_NonUndefinedable_4<T[K]>>;
|
|
112
|
+
} : {
|
|
113
|
+
type: PropType<T[K]>;
|
|
114
|
+
required: true;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
declare type __VLS_TypePropsToRuntimeProps_5<T> = {
|
|
119
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
120
|
+
type: PropType<__VLS_NonUndefinedable_5<T[K]>>;
|
|
121
|
+
} : {
|
|
122
|
+
type: PropType<T[K]>;
|
|
123
|
+
required: true;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
declare type __VLS_TypePropsToRuntimeProps_6<T> = {
|
|
128
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
129
|
+
type: PropType<__VLS_NonUndefinedable_6<T[K]>>;
|
|
130
|
+
} : {
|
|
131
|
+
type: PropType<T[K]>;
|
|
132
|
+
required: true;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
declare type __VLS_TypePropsToRuntimeProps_7<T> = {
|
|
137
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
138
|
+
type: PropType<__VLS_NonUndefinedable_7<T[K]>>;
|
|
139
|
+
} : {
|
|
140
|
+
type: PropType<T[K]>;
|
|
141
|
+
required: true;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
declare type __VLS_TypePropsToRuntimeProps_8<T> = {
|
|
146
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
147
|
+
type: PropType<__VLS_NonUndefinedable_8<T[K]>>;
|
|
148
|
+
} : {
|
|
149
|
+
type: PropType<T[K]>;
|
|
150
|
+
required: true;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
declare type __VLS_TypePropsToRuntimeProps_9<T> = {
|
|
155
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
156
|
+
type: PropType<__VLS_NonUndefinedable_9<T[K]>>;
|
|
157
|
+
} : {
|
|
158
|
+
type: PropType<T[K]>;
|
|
159
|
+
required: true;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
164
|
+
new (): {
|
|
165
|
+
$slots: S;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
declare type AsyncValidatorFn = (value: unknown, values: Record<string, unknown>) => Promise<string | null>;
|
|
170
|
+
|
|
171
|
+
declare interface FieldDefinition {
|
|
172
|
+
type: FieldType;
|
|
173
|
+
/** Dot-path for nested fields, e.g. "address.city" */
|
|
174
|
+
name: string;
|
|
175
|
+
label?: string;
|
|
176
|
+
placeholder?: string;
|
|
177
|
+
defaultValue?: unknown | ((values: Record<string, unknown>) => unknown);
|
|
178
|
+
required?: boolean;
|
|
179
|
+
/** Static or dynamic disabled state */
|
|
180
|
+
disabled?: boolean | ((values: Record<string, unknown>) => boolean);
|
|
181
|
+
/** Static or dynamic visibility; string is evaluated as expression */
|
|
182
|
+
visible?: boolean | string | ((values: Record<string, unknown>) => boolean);
|
|
183
|
+
validators?: ValidatorFn[];
|
|
184
|
+
asyncValidators?: AsyncValidatorFn[];
|
|
185
|
+
mask?: string | MaskConfig;
|
|
186
|
+
/** For select / radio — static list, sync function, or async function */
|
|
187
|
+
options?: FieldOption[] | ((values: Record<string, unknown>) => FieldOption[] | Promise<FieldOption[]>);
|
|
188
|
+
/**
|
|
189
|
+
* Field names whose values trigger re-fetching of async options.
|
|
190
|
+
* Only relevant when `options` is an async function.
|
|
191
|
+
*/
|
|
192
|
+
optionsDeps?: string[];
|
|
193
|
+
/** Internal: set by useForm when async options are loading. Read-only for consumers. */
|
|
194
|
+
optionsLoading?: boolean;
|
|
195
|
+
/** For group and array */
|
|
196
|
+
fields?: FieldDefinition[];
|
|
197
|
+
/**
|
|
198
|
+
* Applied on every setField call before the value is stored.
|
|
199
|
+
* Use for trimming, type coercion, formatting, etc.
|
|
200
|
+
*/
|
|
201
|
+
transform?: (value: unknown, values: Record<string, unknown>) => unknown;
|
|
202
|
+
/**
|
|
203
|
+
* Applied at submit time to produce the final payload value.
|
|
204
|
+
* Runs after all validation passes.
|
|
205
|
+
*/
|
|
206
|
+
parse?: (raw: unknown) => unknown;
|
|
207
|
+
/**
|
|
208
|
+
* Custom Vue component to render this field.
|
|
209
|
+
* Receives FormFieldProps and must emit 'update:modelValue' and 'blur'.
|
|
210
|
+
*/
|
|
211
|
+
component?: Component | string;
|
|
212
|
+
/** Accepted file types, e.g. "image/*,.pdf" — passed to <input accept> */
|
|
213
|
+
accept?: string;
|
|
214
|
+
/** Allow selecting multiple files */
|
|
215
|
+
multiple?: boolean;
|
|
216
|
+
/** Maximum file size in bytes */
|
|
217
|
+
maxSize?: number;
|
|
218
|
+
/** Maximum number of files (only relevant when multiple=true) */
|
|
219
|
+
maxFiles?: number;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
declare interface FieldOption {
|
|
223
|
+
label: string;
|
|
224
|
+
value: unknown;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
declare type FieldType = 'text' | 'number' | 'email' | 'select' | 'checkbox' | 'radio' | 'textarea' | 'date' | 'array' | 'group' | 'file';
|
|
228
|
+
|
|
229
|
+
declare interface MaskConfig {
|
|
230
|
+
preset?: MaskPreset;
|
|
231
|
+
/** Custom mask pattern: '#' = digit, 'A' = letter, other chars are literals */
|
|
232
|
+
pattern?: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
declare type MaskPreset = 'phone-ru' | 'phone-eu' | 'date' | 'inn' | 'iban';
|
|
236
|
+
|
|
237
|
+
export declare const ShadcnFormRenderer: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
238
|
+
|
|
239
|
+
export declare const ShArrayField: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_10<{
|
|
240
|
+
field: FieldDefinition;
|
|
241
|
+
form: UseFormReturn;
|
|
242
|
+
components?: Partial<Record<FieldDefinition["type"], Component | string>>;
|
|
243
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_10<{
|
|
244
|
+
field: FieldDefinition;
|
|
245
|
+
form: UseFormReturn;
|
|
246
|
+
components?: Partial<Record<FieldDefinition["type"], Component | string>>;
|
|
247
|
+
}>>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
248
|
+
|
|
249
|
+
export declare const ShCheckboxField: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_6<{
|
|
250
|
+
field: FieldDefinition;
|
|
251
|
+
modelValue: boolean | null;
|
|
252
|
+
error?: string[];
|
|
253
|
+
touched?: boolean;
|
|
254
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
255
|
+
blur: () => void;
|
|
256
|
+
"update:modelValue": (value: boolean) => void;
|
|
257
|
+
}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_6<{
|
|
258
|
+
field: FieldDefinition;
|
|
259
|
+
modelValue: boolean | null;
|
|
260
|
+
error?: string[];
|
|
261
|
+
touched?: boolean;
|
|
262
|
+
}>>> & Readonly<{
|
|
263
|
+
onBlur?: (() => any) | undefined;
|
|
264
|
+
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
265
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
266
|
+
|
|
267
|
+
export declare const ShDateField: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_8<{
|
|
268
|
+
field: FieldDefinition;
|
|
269
|
+
modelValue: string | null;
|
|
270
|
+
error?: string[];
|
|
271
|
+
touched?: boolean;
|
|
272
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
273
|
+
blur: () => void;
|
|
274
|
+
"update:modelValue": (value: string) => void;
|
|
275
|
+
}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_8<{
|
|
276
|
+
field: FieldDefinition;
|
|
277
|
+
modelValue: string | null;
|
|
278
|
+
error?: string[];
|
|
279
|
+
touched?: boolean;
|
|
280
|
+
}>>> & Readonly<{
|
|
281
|
+
onBlur?: (() => any) | undefined;
|
|
282
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
283
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
284
|
+
|
|
285
|
+
export declare const ShFileField: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_9<{
|
|
286
|
+
field: FieldDefinition;
|
|
287
|
+
modelValue: File | File[] | null;
|
|
288
|
+
error?: string[];
|
|
289
|
+
touched?: boolean;
|
|
290
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
291
|
+
blur: () => void;
|
|
292
|
+
"update:modelValue": (value: File | File[] | null) => void;
|
|
293
|
+
}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_9<{
|
|
294
|
+
field: FieldDefinition;
|
|
295
|
+
modelValue: File | File[] | null;
|
|
296
|
+
error?: string[];
|
|
297
|
+
touched?: boolean;
|
|
298
|
+
}>>> & Readonly<{
|
|
299
|
+
onBlur?: (() => any) | undefined;
|
|
300
|
+
"onUpdate:modelValue"?: ((value: File | File[] | null) => any) | undefined;
|
|
301
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
302
|
+
|
|
303
|
+
export declare const ShNumberField: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_3<{
|
|
304
|
+
field: FieldDefinition;
|
|
305
|
+
modelValue: number | null;
|
|
306
|
+
error?: string[];
|
|
307
|
+
touched?: boolean;
|
|
308
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
309
|
+
blur: () => void;
|
|
310
|
+
"update:modelValue": (value: number | null) => void;
|
|
311
|
+
}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_3<{
|
|
312
|
+
field: FieldDefinition;
|
|
313
|
+
modelValue: number | null;
|
|
314
|
+
error?: string[];
|
|
315
|
+
touched?: boolean;
|
|
316
|
+
}>>> & Readonly<{
|
|
317
|
+
onBlur?: (() => any) | undefined;
|
|
318
|
+
"onUpdate:modelValue"?: ((value: number | null) => any) | undefined;
|
|
319
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
320
|
+
|
|
321
|
+
export declare const ShRadioField: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_7<{
|
|
322
|
+
field: FieldDefinition;
|
|
323
|
+
modelValue: unknown;
|
|
324
|
+
error?: string[];
|
|
325
|
+
touched?: boolean;
|
|
326
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
327
|
+
blur: () => void;
|
|
328
|
+
"update:modelValue": (value: unknown) => void;
|
|
329
|
+
}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_7<{
|
|
330
|
+
field: FieldDefinition;
|
|
331
|
+
modelValue: unknown;
|
|
332
|
+
error?: string[];
|
|
333
|
+
touched?: boolean;
|
|
334
|
+
}>>> & Readonly<{
|
|
335
|
+
onBlur?: (() => any) | undefined;
|
|
336
|
+
"onUpdate:modelValue"?: ((value: unknown) => any) | undefined;
|
|
337
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
338
|
+
|
|
339
|
+
export declare const ShSelectField: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_5<{
|
|
340
|
+
field: FieldDefinition;
|
|
341
|
+
modelValue: unknown;
|
|
342
|
+
error?: string[];
|
|
343
|
+
touched?: boolean;
|
|
344
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
345
|
+
blur: () => void;
|
|
346
|
+
"update:modelValue": (value: unknown) => void;
|
|
347
|
+
}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_5<{
|
|
348
|
+
field: FieldDefinition;
|
|
349
|
+
modelValue: unknown;
|
|
350
|
+
error?: string[];
|
|
351
|
+
touched?: boolean;
|
|
352
|
+
}>>> & Readonly<{
|
|
353
|
+
onBlur?: (() => any) | undefined;
|
|
354
|
+
"onUpdate:modelValue"?: ((value: unknown) => any) | undefined;
|
|
355
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
356
|
+
|
|
357
|
+
export declare const ShTextareaField: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_4<{
|
|
358
|
+
field: FieldDefinition;
|
|
359
|
+
modelValue: string | null;
|
|
360
|
+
error?: string[];
|
|
361
|
+
touched?: boolean;
|
|
362
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
363
|
+
blur: () => void;
|
|
364
|
+
"update:modelValue": (value: string) => void;
|
|
365
|
+
}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_4<{
|
|
366
|
+
field: FieldDefinition;
|
|
367
|
+
modelValue: string | null;
|
|
368
|
+
error?: string[];
|
|
369
|
+
touched?: boolean;
|
|
370
|
+
}>>> & Readonly<{
|
|
371
|
+
onBlur?: (() => any) | undefined;
|
|
372
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
373
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
374
|
+
|
|
375
|
+
export declare const ShTextField: DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_2<{
|
|
376
|
+
field: FieldDefinition;
|
|
377
|
+
modelValue: string | null;
|
|
378
|
+
error?: string[];
|
|
379
|
+
touched?: boolean;
|
|
380
|
+
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
381
|
+
blur: () => void;
|
|
382
|
+
"update:modelValue": (value: string) => void;
|
|
383
|
+
}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_2<{
|
|
384
|
+
field: FieldDefinition;
|
|
385
|
+
modelValue: string | null;
|
|
386
|
+
error?: string[];
|
|
387
|
+
touched?: boolean;
|
|
388
|
+
}>>> & Readonly<{
|
|
389
|
+
onBlur?: (() => any) | undefined;
|
|
390
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
391
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
392
|
+
|
|
393
|
+
declare interface UseFormReturn<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
394
|
+
fields: ComputedRef<FieldDefinition[]>;
|
|
395
|
+
values: Ref<T>;
|
|
396
|
+
errors: Ref<Record<string, string[]>>;
|
|
397
|
+
touched: Ref<Record<string, boolean>>;
|
|
398
|
+
/** Per-field async options loading state */
|
|
399
|
+
optionsLoading: Ref<Record<string, boolean>>;
|
|
400
|
+
isDirty: ComputedRef<boolean>;
|
|
401
|
+
isValid: ComputedRef<boolean>;
|
|
402
|
+
isSubmitting: Ref<boolean>;
|
|
403
|
+
submit(): Promise<void>;
|
|
404
|
+
reset(values?: Partial<T>): void;
|
|
405
|
+
setField(path: string, value: unknown): void;
|
|
406
|
+
getField(path: string): unknown;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
declare type ValidatorFn = (value: unknown, values: Record<string, unknown>) => string | null;
|
|
410
|
+
|
|
411
|
+
export { }
|