@josercl/form-maker 1.3.2 → 1.3.4
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/README.md +11 -17
- package/dist/index.iife.js +1 -1
- package/dist/index.js +162 -144
- package/dist/index.umd.cjs +1 -1
- package/lib/components/FormMaker.vue +4 -7
- package/lib/components/FormMakerInput.vue +1 -1
- package/lib/components/inputs/CheckboxInput.vue +10 -1
- package/lib/components/inputs/RadioInput.vue +9 -1
- package/lib/model.d.ts +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Form-Maker
|
|
2
2
|
|
|
3
3
|
<img src="https://badgen.net/gitlab/license/josercl/form-maker">
|
|
4
|
-
<a href="https://vuejs.org/" target="_blank"><img src="https://badgen.net/badge/vue/v3
|
|
4
|
+
<a href="https://vuejs.org/" target="_blank"><img src="https://badgen.net/badge/vue/v3?color=green"></a>
|
|
5
5
|
<a href="https://www.npmjs.com/package/@josercl/form-maker" target="_blank"><img src="https://badgen.net/npm/v/@josercl/form-maker/?color=red&icon=npm&label"></a>
|
|
6
6
|
<a href="https://www.npmjs.com/package/@josercl/form-maker" target="_blank"><img src="https://badgen.net/npm/dt/@josercl/form-maker"></a>
|
|
7
7
|
|
|
@@ -28,23 +28,17 @@ createApp(App)
|
|
|
28
28
|
|
|
29
29
|
### App.vue
|
|
30
30
|
```vuejs
|
|
31
|
+
<script setup>
|
|
32
|
+
import { reactive } from 'vue'
|
|
33
|
+
|
|
34
|
+
const person = reactive({
|
|
35
|
+
name: 'John Doe',
|
|
36
|
+
age: 20,
|
|
37
|
+
email: 'email@example.com',
|
|
38
|
+
})
|
|
39
|
+
</script>
|
|
40
|
+
|
|
31
41
|
<template>
|
|
32
42
|
<form-maker v-model="person" />
|
|
33
43
|
</template>
|
|
34
|
-
|
|
35
|
-
<script>
|
|
36
|
-
export default {
|
|
37
|
-
setup() {
|
|
38
|
-
const person = reactive({
|
|
39
|
-
name: 'John Doe',
|
|
40
|
-
age: 20,
|
|
41
|
-
email: 'email@example.com',
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
person,
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
</script>
|
|
50
44
|
```
|
package/dist/index.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var FormMaker=function(e){"use strict";const E=["onSubmit"],S={key:0},T=["disabled"],j=e.defineComponent({__name:"FormMaker",props:{loading:{type:Boolean,default:!1},hasActions:{type:Boolean,default:!0},modelValue:{default:()=>({})},fields:{default:()=>[]},hideDivider:{type:Boolean,default:!1},rowClass:{default:null},columnClass:{default:null},labelClass:{default:null},inputGroupClass:{default:null},inputWrapperClass:{default:null},inputErrorClass:{default:null},inputClass:{default:null},errorClass:{default:null},helpTextClass:{default:null},submitButtonClass:{default:null},submitButtonText:{default:"Submit"}},emits:["submit","update:modelValue"],setup(n,{emit:r}){const t=n,i=r,l=()=>i("submit"),a=e.computed(()=>t.fields.length>0?t.fields.map(o=>{let u=o;return Array.isArray(o)||(u=[o]),u.map(k=>k.id?k:{...k,id:`formMaker_${new Date().getTime()}_${k.name}`})}):Object.keys(t.modelValue).map(o=>[{name:o,label:o,id:`formMaker_${o}`}]));e.provide("labelClass",t.labelClass||e.inject("form-label")),e.provide("inputGroupClass",t.inputGroupClass||e.inject("input-group")),e.provide("inputWrapperClass",t.inputWrapperClass||e.inject("input-wrapper")),e.provide("inputErrorClass",t.inputErrorClass||e.inject("input-error")),e.provide("inputClass",t.inputClass||e.inject("input")),e.provide("errorClass",t.errorClass||e.inject("error")),e.provide("helpTextClass",t.helpTextClass||e.inject("help-text"));const s=t.rowClass||e.inject("form-row"),m=t.columnClass||e.inject("form-column"),C=t.submitButtonClass||e.inject("submit-button"),p=o=>{const u=o.split(".");let k=t.modelValue;for(let B=0;B<u.length-1;B+=1){const h=k[u[B]];if(!h)break;k=h}return k},d=o=>{const u=o.split(".");return u[u.length-1]};return(o,u)=>{const k=e.resolveComponent("form-maker-input");return e.openBlock(),e.createElementBlock("form",{class:"form-maker",onSubmit:e.withModifiers(l,["prevent"])},[o.loading?e.renderSlot(o.$slots,"loading",{key:0},()=>[e.createTextVNode(" Loading... ")]):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"default",{},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(B,h)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(s)),key:`fieldRow_${h}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B,(b,c)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([e.unref(m),b.columnClass]),key:`field_${h}_${c}`},[e.renderSlot(o.$slots,`${b.name}`,{field:b},()=>[e.createVNode(k,e.mergeProps({modelValue:p(b.name)[d(b.name)],"onUpdate:modelValue":V=>p(b.name)[d(b.name)]=V},b),null,16,["modelValue","onUpdate:modelValue"])])],2))),128))],2))),128))]),e.renderSlot(o.$slots,"extra"),e.renderSlot(o.$slots,"divider",{},()=>[o.hasActions&&!o.hideDivider?(e.openBlock(),e.createElementBlock("hr",S)):e.createCommentVNode("",!0)]),o.hasActions?e.renderSlot(o.$slots,"actions",{key:1},()=>[e.renderSlot(o.$slots,"submit-button",{},()=>[e.createElementVNode("button",{class:e.normalizeClass(e.unref(C)),disabled:o.loading,type:"submit"},e.toDisplayString(o.submitButtonText),11,T)]),e.renderSlot(o.$slots,"extra-buttons")]):e.createCommentVNode("",!0)],40,E)}}}),w=()=>{const n=e.inject("labelClass",null),r=e.inject("inputClass",null),t=e.inject("inputWrapperClass",null),i=e.inject("inputGroupClass",null),l=e.inject("inputErrorClass",null),a=e.inject("errorClass",null),s=e.inject("helpTextClass",null);return{labelClass:n,inputClass:r,inputWrapperClass:t,inputGroupClass:i,inputErrorClass:l,errorClass:a,helpTextClass:s}},N=(n,r=[])=>{const t=e.toRaw(r),i=e.ref(null);return e.watch(n,(l,a)=>{if(i.value=null,l!==a)for(let s=0;s<t.length;s+=1){const m=t[s];if(!m.validator(l)){i.value=m.message;break}}},{immediate:!0}),i};function y(n,r,t){const i=t??"modelValue";return e.computed({get:()=>n(),set:l=>r(`update:${i}`,l)})}const F=e.defineComponent({inheritAttrs:!1,__name:"FormMakerInput",props:{loading:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{default:"text"},rules:{default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,l=y(()=>t.modelValue,r),{labelClass:a,inputClass:s,inputWrapperClass:m,inputGroupClass:C,inputErrorClass:p,errorClass:d,helpTextClass:o}=w(),u=e.computed(()=>!!t.label),k=e.computed(()=>!!t.helpText),B=N(l,t.rules),h=e.computed(()=>!!t.error||!!B.value),b=e.computed(()=>t.error?t.error:B.value);return(c,V)=>{const H=e.resolveComponent("form-maker-label"),J=e.resolveComponent("form-maker-help"),K=e.resolveComponent("form-maker-error");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([h.value&&e.unref(p),e.unref(m)])},[c.type!=="checkbox"?e.renderSlot(c.$slots,"label",{key:0},()=>[u.value?(e.openBlock(),e.createBlock(H,{key:0,id:c.id,class:e.normalizeClass(e.unref(a))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.label),1)]),_:1},8,["id","class"])):e.createCommentVNode("",!0)]):e.createCommentVNode("",!0),e.renderSlot(c.$slots,"default",{},()=>[e.createElementVNode("div",{class:e.normalizeClass([e.unref(C),h.value&&e.unref(p)])},[e.renderSlot(c.$slots,"before"),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(`form-maker-input-${c.type}`),e.mergeProps({...c.$props,...c.$attrs},{class:[c.type!=="checkbox"&&e.unref(s),h.value&&e.unref(p)],label:c.label,modelValue:e.unref(l),"onUpdate:modelValue":V[0]||(V[0]=Q=>e.isRef(l)?l.value=Q:null)}),null,16,["class","label","modelValue"])),e.renderSlot(c.$slots,"after")],2)]),e.renderSlot(c.$slots,"help",{},()=>[k.value?(e.openBlock(),e.createBlock(J,{key:0,class:e.normalizeClass(e.unref(o))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.helpText),1)]),_:1},8,["class"])):e.createCommentVNode("",!0)]),e.renderSlot(c.$slots,"errors",{},()=>[h.value?(e.openBlock(),e.createBlock(K,{key:0,class:e.normalizeClass(e.unref(d))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(b.value),1)]),_:1},8,["class"])):e.createCommentVNode("",!0)])],2)}}}),D=["checked","value","onClick"],M=e.defineComponent({__name:"CheckboxInput",props:{options:{type:[Boolean,Array],default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,i=r,l=e.computed(()=>Array.isArray(t.options)&&t.options.length===0),a=e.computed(()=>t.modelValue),s=e.computed(()=>(Array.isArray(a.value)?a.value:[a.value]).filter(d=>!!d)),m=e.computed(()=>l.value?[{label:t.label,value:!0}]:t.options),C=p=>{let d=[...s.value];d.indexOf(p)===-1?d.push(p):d=d.filter(o=>o!==p),l.value?i("update:modelValue",d.length>0):i("update:modelValue",d)};return(p,d)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(o,u)=>(e.openBlock(),e.createElementBlock("div",{key:`option_${u}`},[e.createElementVNode("label",null,[e.createElementVNode("input",e.mergeProps(p.$props,{checked:s.value.indexOf(o.value)!==-1,value:o.value,type:"checkbox",onClick:()=>C(o.value)}),null,16,D),e.createTextVNode(" "+e.toDisplayString(o.label),1)])]))),128))}}),A=e.defineComponent({__name:"FileInput",props:{loading:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{},rules:{default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=r,i=l=>{const a=l.currentTarget;if(a.files&&a.files.length){const s=a.files[0];t("update:modelValue",s)}};return(l,a)=>(e.openBlock(),e.createElementBlock("input",e.mergeProps(l.$props,{type:"file",onChange:i}),null,16))}});function g(n,r){return e.h(`${n.as??"div"}`,r.attrs,r.slots)}g.props={as:{type:String,required:!1,default:"div"}};function $(n,{slots:r,attrs:t}){return e.h("label",{...t,for:n.id},r.default())}$.props={id:{type:String,default:null}};const G=$,O=["checked","value","onChange"],L=e.defineComponent({__name:"RadioInput",props:{options:{default:()=>[]},loading:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{},rules:{}},emits:["update:modelValue"],setup(n,{emit:r}){const t=r,i=l=>{t("update:modelValue",l)};return(l,a)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,(s,m)=>(e.openBlock(),e.createElementBlock("div",{key:`option_${m}`},[e.createElementVNode("label",null,[e.createElementVNode("input",e.mergeProps(l.$props,{checked:s.value===l.modelValue,value:s.value,type:"radio",onChange:C=>i(s.value)}),null,16,O),e.createTextVNode(" "+e.toDisplayString(s.label),1)])]))),128))}}),I=["id","disabled","name","placeholder"],P=["label"],R=["value"],z=["value"],x=e.defineComponent({__name:"SelectInput",props:{options:{default:()=>[]},optionGroups:{default:()=>({})},loading:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{},rules:{default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,l=y(()=>t.modelValue,r),a=Object.keys(t.optionGroups).length>0,s=e.computed(()=>t.options.map(m=>typeof m=="object"?m:{label:m,value:m}));return(m,C)=>e.withDirectives((e.openBlock(),e.createElementBlock("select",{id:m.id,"onUpdate:modelValue":C[0]||(C[0]=p=>e.isRef(l)?l.value=p:null),disabled:m.disabled,name:m.name,placeholder:m.placeholder},[a?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(m.optionGroups,(p,d)=>(e.openBlock(),e.createElementBlock("optgroup",{key:`optGroup_${d}`,label:d},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p,(o,u)=>(e.openBlock(),e.createElementBlock("option",{key:`option_${o}`,value:u},e.toDisplayString(o),9,R))),128))],8,P))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(s.value,(p,d)=>(e.openBlock(),e.createElementBlock("option",{key:`option_${d}`,value:p.value},e.toDisplayString(p.label),9,z))),128))],8,I)),[[e.vModelSelect,e.unref(l)]])}}),U=["id"],W=e.defineComponent({__name:"TextAreaInput",props:{modelValue:{}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,l=y(()=>t.modelValue,r);return(a,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("textarea",e.mergeProps({id:a.id,"onUpdate:modelValue":s[0]||(s[0]=m=>e.isRef(l)?l.value=m:null)},{...a.$props,...a.$attrs}),null,16,U)),[[e.vModelText,e.unref(l)]])}}),q=["type"],f=e.defineComponent({__name:"BasicInput",props:{loading:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{default:"text"},rules:{default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,l=y(()=>t.modelValue,r);return(a,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps({"onUpdate:modelValue":s[0]||(s[0]=m=>e.isRef(l)?l.value=m:null),type:a.type},{...a.$props,...a.$attrs}),null,16,q)),[[e.vModelDynamic,e.unref(l)]])}}),_={classes:{"form-row":"form-maker-row","form-column":"form-maker-column","form-label":"form-maker-label","input-group":"form-maker-input-group","input-wrapper":"form-maker-input-wrapper","input-error":"form-maker-input-error",input:"form-maker-input",error:"form-maker-error","help-text":"form-maker-help-text","submit-button":"form-maker-submit"},components:{"form-maker-input-color":f,"form-maker-input-date":f,"form-maker-input-email":f,"form-maker-input-month":f,"form-maker-input-number":f,"form-maker-input-password":f,"form-maker-input-search":f,"form-maker-input-tel":f,"form-maker-input-time":f,"form-maker-input-text":f,"form-maker-input-url":f,"form-maker-input-week":f,"form-maker-input-range":f,"form-maker-input-file":A,"form-maker-input-textarea":W,"form-maker-input-select":x,"form-maker-input-checkbox":M,"form-maker-input-radio":L,"form-maker-label":G,"form-maker-help":g,"form-maker-error":g}};return{install:(n,r={})=>{const t={classes:{..._.classes,...r.classes},components:{..._.components,...r.components}};n.component("FormMaker",j),n.component("FormMakerInput",F),Object.keys(t.classes).forEach(i=>{n.provide(i,t.classes[i])}),Object.keys(t.components).forEach(i=>{n.component(i,t.components[i])})}}}(Vue);
|
|
1
|
+
var FormMaker=function(e){"use strict";const E=["onSubmit"],S={key:0},T=["disabled"],j=e.defineComponent({__name:"FormMaker",props:{loading:{type:Boolean,default:!1},hasActions:{type:Boolean,default:!0},modelValue:{default:()=>({})},fields:{default:()=>[]},hideDivider:{type:Boolean,default:!1},rowClass:{default:null},columnClass:{default:null},labelClass:{default:null},inputGroupClass:{default:null},inputWrapperClass:{default:null},inputErrorClass:{default:null},inputClass:{default:null},errorClass:{default:null},helpTextClass:{default:null},submitButtonClass:{default:null},submitButtonText:{default:"Submit"}},emits:["submit","update:modelValue"],setup(a,{emit:r}){const t=a,i=r,l=()=>i("submit"),n=e.computed(()=>t.fields.length>0?t.fields.map(o=>{let u=o;return Array.isArray(o)||(u=[o]),u.map(k=>({...k,id:k.id||`formMaker_${new Date().getTime()}_${k.name}`}))}):Object.keys(t.modelValue).map(o=>[{name:o,label:o,id:`formMaker_${o}`}]));e.provide("labelClass",t.labelClass||e.inject("form-label")),e.provide("inputGroupClass",t.inputGroupClass||e.inject("input-group")),e.provide("inputWrapperClass",t.inputWrapperClass||e.inject("input-wrapper")),e.provide("inputErrorClass",t.inputErrorClass||e.inject("input-error")),e.provide("inputClass",t.inputClass||e.inject("input")),e.provide("errorClass",t.errorClass||e.inject("error")),e.provide("helpTextClass",t.helpTextClass||e.inject("help-text"));const s=t.rowClass||e.inject("form-row"),p=t.columnClass||e.inject("form-column"),C=t.submitButtonClass||e.inject("submit-button"),m=o=>{const u=o.split(".");let k=t.modelValue;for(let B=0;B<u.length-1;B+=1){const b=k[u[B]];if(!b)break;k=b}return k},d=o=>{const u=o.split(".");return u[u.length-1]};return(o,u)=>{const k=e.resolveComponent("form-maker-input");return e.openBlock(),e.createElementBlock("form",{class:"form-maker",onSubmit:e.withModifiers(l,["prevent"])},[o.loading?e.renderSlot(o.$slots,"loading",{key:0},()=>[e.createTextVNode(" Loading... ")]):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"default",{},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(B,b)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(s)),key:`fieldRow_${b}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B,(h,c)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([e.unref(p),h.columnClass]),key:`field_${b}_${c}`},[e.renderSlot(o.$slots,`${h.name}`,{field:h},()=>[e.createVNode(k,e.mergeProps({modelValue:m(h.name)[d(h.name)],"onUpdate:modelValue":V=>m(h.name)[d(h.name)]=V},h),null,16,["modelValue","onUpdate:modelValue"])])],2))),128))],2))),128))]),e.renderSlot(o.$slots,"extra"),e.renderSlot(o.$slots,"divider",{},()=>[o.hasActions&&!o.hideDivider?(e.openBlock(),e.createElementBlock("hr",S)):e.createCommentVNode("",!0)]),o.hasActions?e.renderSlot(o.$slots,"actions",{key:1},()=>[e.renderSlot(o.$slots,"submit-button",{},()=>[e.createElementVNode("button",{class:e.normalizeClass(e.unref(C)),disabled:o.loading,type:"submit"},e.toDisplayString(o.submitButtonText),11,T)]),e.renderSlot(o.$slots,"extra-buttons")]):e.createCommentVNode("",!0)],40,E)}}}),w=()=>{const a=e.inject("labelClass",null),r=e.inject("inputClass",null),t=e.inject("inputWrapperClass",null),i=e.inject("inputGroupClass",null),l=e.inject("inputErrorClass",null),n=e.inject("errorClass",null),s=e.inject("helpTextClass",null);return{labelClass:a,inputClass:r,inputWrapperClass:t,inputGroupClass:i,inputErrorClass:l,errorClass:n,helpTextClass:s}},N=(a,r=[])=>{const t=e.toRaw(r),i=e.ref(null);return e.watch(a,(l,n)=>{if(i.value=null,l!==n)for(let s=0;s<t.length;s+=1){const p=t[s];if(!p.validator(l)){i.value=p.message;break}}},{immediate:!0}),i};function y(a,r,t){const i=t??"modelValue";return e.computed({get:()=>a(),set:l=>r(`update:${i}`,l)})}const F=e.defineComponent({inheritAttrs:!1,__name:"FormMakerInput",props:{loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},id:{default:void 0},type:{default:"text"},rules:{default:()=>[]}},emits:["update:modelValue"],setup(a,{emit:r}){const t=a,l=y(()=>t.modelValue,r),{labelClass:n,inputClass:s,inputWrapperClass:p,inputGroupClass:C,inputErrorClass:m,errorClass:d,helpTextClass:o}=w(),u=e.computed(()=>!!t.label),k=e.computed(()=>!!t.helpText),B=N(l,t.rules),b=e.computed(()=>!!t.error||!!B.value),h=e.computed(()=>t.error?t.error:B.value);return(c,V)=>{const H=e.resolveComponent("form-maker-label"),J=e.resolveComponent("form-maker-help"),K=e.resolveComponent("form-maker-error");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([b.value&&e.unref(m),e.unref(p)])},[c.type!=="checkbox"?e.renderSlot(c.$slots,"label",{key:0},()=>[u.value?(e.openBlock(),e.createBlock(H,{key:0,id:c.id,class:e.normalizeClass(e.unref(n)),label:c.label},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.label),1)]),_:1},8,["id","class","label"])):e.createCommentVNode("",!0)]):e.createCommentVNode("",!0),e.renderSlot(c.$slots,"default",{},()=>[e.createElementVNode("div",{class:e.normalizeClass([e.unref(C),b.value&&e.unref(m)])},[e.renderSlot(c.$slots,"before"),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(`form-maker-input-${c.type}`),e.mergeProps({...c.$props,...c.$attrs},{class:[c.type!=="checkbox"&&e.unref(s),b.value&&e.unref(m)],modelValue:e.unref(l),"onUpdate:modelValue":V[0]||(V[0]=Q=>e.isRef(l)?l.value=Q:null)}),null,16,["class","modelValue"])),e.renderSlot(c.$slots,"after")],2)]),e.renderSlot(c.$slots,"help",{},()=>[k.value?(e.openBlock(),e.createBlock(J,{key:0,class:e.normalizeClass(e.unref(o))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.helpText),1)]),_:1},8,["class"])):e.createCommentVNode("",!0)]),e.renderSlot(c.$slots,"errors",{},()=>[b.value?(e.openBlock(),e.createBlock(K,{key:0,class:e.normalizeClass(e.unref(d))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.value),1)]),_:1},8,["class"])):e.createCommentVNode("",!0)])],2)}}}),D=["checked","value","onClick"],M=e.defineComponent({__name:"CheckboxInput",props:{options:{type:[Boolean,Array],default:()=>[]},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{},rules:{default:()=>[]}},emits:["update:modelValue"],setup(a,{emit:r}){const t=a,i=r,l=e.computed(()=>Array.isArray(t.options)&&t.options.length===0),n=e.computed(()=>t.modelValue),s=e.computed(()=>(Array.isArray(n.value)?n.value:[n.value]).filter(d=>!!d)),p=e.computed(()=>l.value?[{label:t.label,value:!0}]:t.options),C=m=>{let d=[...s.value];d.indexOf(m)===-1?d.push(m):d=d.filter(o=>o!==m),l.value?i("update:modelValue",d.length>0):i("update:modelValue",d)};return(m,d)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(o,u)=>(e.openBlock(),e.createElementBlock("div",{key:`option_${u}`},[e.createElementVNode("label",null,[e.createElementVNode("input",e.mergeProps(m.$props,{checked:s.value.indexOf(o.value)!==-1,value:o.value,type:"checkbox",onClick:()=>C(o.value)}),null,16,D),e.createTextVNode(" "+e.toDisplayString(o.label),1)])]))),128))}}),A=e.defineComponent({__name:"FileInput",props:{loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},id:{default:void 0},type:{},rules:{default:()=>[]}},emits:["update:modelValue"],setup(a,{emit:r}){const t=r,i=l=>{const n=l.currentTarget;if(n.files&&n.files.length){const s=n.files[0];t("update:modelValue",s)}};return(l,n)=>(e.openBlock(),e.createElementBlock("input",e.mergeProps(l.$props,{type:"file",onChange:i}),null,16))}});function g(a,r){return e.h(`${a.as??"div"}`,r.attrs,r.slots)}g.props={as:{type:String,required:!1,default:"div"}};function $(a,{slots:r,attrs:t}){return e.h("label",{...t,for:a.id},r.default())}$.props={id:{type:String,default:null}};const G=$,O=["checked","value","onChange"],L=e.defineComponent({__name:"RadioInput",props:{options:{default:()=>[]},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{},rules:{},id:{default:void 0}},emits:["update:modelValue"],setup(a,{emit:r}){const t=r,i=l=>{t("update:modelValue",l)};return(l,n)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,(s,p)=>(e.openBlock(),e.createElementBlock("div",{key:`option_${p}`},[e.createElementVNode("label",null,[e.createElementVNode("input",e.mergeProps(l.$props,{checked:s.value===l.modelValue,value:s.value,type:"radio",onChange:C=>i(s.value)}),null,16,O),e.createTextVNode(" "+e.toDisplayString(s.label),1)])]))),128))}}),I=["id","disabled","name","placeholder"],P=["label"],R=["value"],x=["value"],z=e.defineComponent({__name:"SelectInput",props:{options:{default:()=>[]},optionGroups:{default:()=>({})},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},id:{default:void 0},type:{},rules:{default:()=>[]}},emits:["update:modelValue"],setup(a,{emit:r}){const t=a,l=y(()=>t.modelValue,r),n=Object.keys(t.optionGroups).length>0,s=e.computed(()=>t.options.map(p=>typeof p=="object"?p:{label:p,value:p}));return(p,C)=>e.withDirectives((e.openBlock(),e.createElementBlock("select",{id:p.id,"onUpdate:modelValue":C[0]||(C[0]=m=>e.isRef(l)?l.value=m:null),disabled:p.disabled,name:p.name,placeholder:p.placeholder},[n?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(p.optionGroups,(m,d)=>(e.openBlock(),e.createElementBlock("optgroup",{key:`optGroup_${d}`,label:d},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m,(o,u)=>(e.openBlock(),e.createElementBlock("option",{key:`option_${o}`,value:u},e.toDisplayString(o),9,R))),128))],8,P))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(s.value,(m,d)=>(e.openBlock(),e.createElementBlock("option",{key:`option_${d}`,value:m.value},e.toDisplayString(m.label),9,x))),128))],8,I)),[[e.vModelSelect,e.unref(l)]])}}),U=["id"],W=e.defineComponent({__name:"TextAreaInput",props:{modelValue:{}},emits:["update:modelValue"],setup(a,{emit:r}){const t=a,l=y(()=>t.modelValue,r);return(n,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("textarea",e.mergeProps({id:n.id,"onUpdate:modelValue":s[0]||(s[0]=p=>e.isRef(l)?l.value=p:null)},{...n.$props,...n.$attrs}),null,16,U)),[[e.vModelText,e.unref(l)]])}}),q=["type"],f=e.defineComponent({__name:"BasicInput",props:{loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},id:{default:void 0},type:{default:"text"},rules:{default:()=>[]}},emits:["update:modelValue"],setup(a,{emit:r}){const t=a,l=y(()=>t.modelValue,r);return(n,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps({"onUpdate:modelValue":s[0]||(s[0]=p=>e.isRef(l)?l.value=p:null),type:n.type},{...n.$props,...n.$attrs}),null,16,q)),[[e.vModelDynamic,e.unref(l)]])}}),_={classes:{"form-row":"form-maker-row","form-column":"form-maker-column","form-label":"form-maker-label","input-group":"form-maker-input-group","input-wrapper":"form-maker-input-wrapper","input-error":"form-maker-input-error",input:"form-maker-input",error:"form-maker-error","help-text":"form-maker-help-text","submit-button":"form-maker-submit"},components:{"form-maker-input-color":f,"form-maker-input-date":f,"form-maker-input-email":f,"form-maker-input-month":f,"form-maker-input-number":f,"form-maker-input-password":f,"form-maker-input-search":f,"form-maker-input-tel":f,"form-maker-input-time":f,"form-maker-input-text":f,"form-maker-input-url":f,"form-maker-input-week":f,"form-maker-input-range":f,"form-maker-input-file":A,"form-maker-input-textarea":W,"form-maker-input-select":z,"form-maker-input-checkbox":M,"form-maker-input-radio":L,"form-maker-label":G,"form-maker-help":g,"form-maker-error":g}};return{install:(a,r={})=>{const t={classes:{..._.classes,...r.classes},components:{..._.components,...r.components}};a.component("FormMaker",j),a.component("FormMakerInput",F),Object.keys(t.classes).forEach(i=>{a.provide(i,t.classes[i])}),Object.keys(t.components).forEach(i=>{a.component(i,t.components[i])})}}}(Vue);
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as w, computed as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as w, computed as y, provide as E, inject as c, resolveComponent as D, openBlock as i, createElementBlock as p, withModifiers as Q, renderSlot as k, createTextVNode as O, createCommentVNode as M, Fragment as A, renderList as F, normalizeClass as B, unref as v, createVNode as X, mergeProps as G, createElementVNode as S, toDisplayString as T, toRaw as Y, ref as Z, watch as ee, createBlock as j, withCtx as W, resolveDynamicComponent as le, isRef as R, h as x, withDirectives as L, vModelSelect as te, vModelText as ae, vModelDynamic as oe } from "vue";
|
|
2
|
+
const re = ["onSubmit"], se = { key: 0 }, ne = ["disabled"], ue = /* @__PURE__ */ w({
|
|
3
3
|
__name: "FormMaker",
|
|
4
4
|
props: {
|
|
5
5
|
loading: { type: Boolean, default: !1 },
|
|
@@ -20,13 +20,13 @@ const ae = ["onSubmit"], se = { key: 0 }, ne = ["disabled"], ue = /* @__PURE__ *
|
|
|
20
20
|
submitButtonText: { default: "Submit" }
|
|
21
21
|
},
|
|
22
22
|
emits: ["submit", "update:modelValue"],
|
|
23
|
-
setup(
|
|
24
|
-
const e =
|
|
25
|
-
let
|
|
26
|
-
return Array.isArray(t) || (
|
|
23
|
+
setup(o, { emit: a }) {
|
|
24
|
+
const e = o, n = a, l = () => n("submit"), r = y(() => e.fields.length > 0 ? e.fields.map((t) => {
|
|
25
|
+
let b = t;
|
|
26
|
+
return Array.isArray(t) || (b = [t]), b.map((C) => ({
|
|
27
27
|
...C,
|
|
28
|
-
id: `formMaker_${(/* @__PURE__ */ new Date()).getTime()}_${C.name}`
|
|
29
|
-
});
|
|
28
|
+
id: C.id || `formMaker_${(/* @__PURE__ */ new Date()).getTime()}_${C.name}`
|
|
29
|
+
}));
|
|
30
30
|
}) : Object.keys(e.modelValue).map((t) => [
|
|
31
31
|
{
|
|
32
32
|
name: t,
|
|
@@ -35,31 +35,31 @@ const ae = ["onSubmit"], se = { key: 0 }, ne = ["disabled"], ue = /* @__PURE__ *
|
|
|
35
35
|
}
|
|
36
36
|
]));
|
|
37
37
|
E("labelClass", e.labelClass || c("form-label")), E("inputGroupClass", e.inputGroupClass || c("input-group")), E("inputWrapperClass", e.inputWrapperClass || c("input-wrapper")), E("inputErrorClass", e.inputErrorClass || c("input-error")), E("inputClass", e.inputClass || c("input")), E("errorClass", e.errorClass || c("error")), E("helpTextClass", e.helpTextClass || c("help-text"));
|
|
38
|
-
const s = e.rowClass || c("form-row"), u = e.columnClass || c("form-column"),
|
|
39
|
-
const
|
|
38
|
+
const s = e.rowClass || c("form-row"), u = e.columnClass || c("form-column"), $ = e.submitButtonClass || c("submit-button"), d = (t) => {
|
|
39
|
+
const b = t.split(".");
|
|
40
40
|
let C = e.modelValue;
|
|
41
|
-
for (let g = 0; g <
|
|
42
|
-
const _ = C[
|
|
41
|
+
for (let g = 0; g < b.length - 1; g += 1) {
|
|
42
|
+
const _ = C[b[g]];
|
|
43
43
|
if (!_)
|
|
44
44
|
break;
|
|
45
45
|
C = _;
|
|
46
46
|
}
|
|
47
47
|
return C;
|
|
48
|
-
},
|
|
49
|
-
const
|
|
50
|
-
return
|
|
48
|
+
}, m = (t) => {
|
|
49
|
+
const b = t.split(".");
|
|
50
|
+
return b[b.length - 1];
|
|
51
51
|
};
|
|
52
|
-
return (t,
|
|
52
|
+
return (t, b) => {
|
|
53
53
|
const C = D("form-maker-input");
|
|
54
54
|
return i(), p("form", {
|
|
55
55
|
class: "form-maker",
|
|
56
56
|
onSubmit: Q(l, ["prevent"])
|
|
57
57
|
}, [
|
|
58
|
-
t.loading ?
|
|
58
|
+
t.loading ? k(t.$slots, "loading", { key: 0 }, () => [
|
|
59
59
|
O(" Loading... ")
|
|
60
60
|
]) : M("", !0),
|
|
61
|
-
|
|
62
|
-
(i(!0), p(A, null, F(
|
|
61
|
+
k(t.$slots, "default", {}, () => [
|
|
62
|
+
(i(!0), p(A, null, F(r.value, (g, _) => (i(), p("div", {
|
|
63
63
|
class: B(v(s)),
|
|
64
64
|
key: `fieldRow_${_}`
|
|
65
65
|
}, [
|
|
@@ -67,49 +67,49 @@ const ae = ["onSubmit"], se = { key: 0 }, ne = ["disabled"], ue = /* @__PURE__ *
|
|
|
67
67
|
class: B([v(u), V.columnClass]),
|
|
68
68
|
key: `field_${_}_${f}`
|
|
69
69
|
}, [
|
|
70
|
-
|
|
70
|
+
k(t.$slots, `${V.name}`, { field: V }, () => [
|
|
71
71
|
X(C, G({
|
|
72
|
-
modelValue:
|
|
73
|
-
"onUpdate:modelValue": (I) =>
|
|
72
|
+
modelValue: d(V.name)[m(V.name)],
|
|
73
|
+
"onUpdate:modelValue": (I) => d(V.name)[m(V.name)] = I
|
|
74
74
|
}, V), null, 16, ["modelValue", "onUpdate:modelValue"])
|
|
75
75
|
])
|
|
76
76
|
], 2))), 128))
|
|
77
77
|
], 2))), 128))
|
|
78
78
|
]),
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
k(t.$slots, "extra"),
|
|
80
|
+
k(t.$slots, "divider", {}, () => [
|
|
81
81
|
t.hasActions && !t.hideDivider ? (i(), p("hr", se)) : M("", !0)
|
|
82
82
|
]),
|
|
83
|
-
t.hasActions ?
|
|
84
|
-
|
|
83
|
+
t.hasActions ? k(t.$slots, "actions", { key: 1 }, () => [
|
|
84
|
+
k(t.$slots, "submit-button", {}, () => [
|
|
85
85
|
S("button", {
|
|
86
|
-
class: B(v(
|
|
86
|
+
class: B(v($)),
|
|
87
87
|
disabled: t.loading,
|
|
88
88
|
type: "submit"
|
|
89
89
|
}, T(t.submitButtonText), 11, ne)
|
|
90
90
|
]),
|
|
91
|
-
|
|
91
|
+
k(t.$slots, "extra-buttons")
|
|
92
92
|
]) : M("", !0)
|
|
93
|
-
], 40,
|
|
93
|
+
], 40, re);
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
}), ie = () => {
|
|
97
|
-
const
|
|
97
|
+
const o = c("labelClass", null), a = c("inputClass", null), e = c("inputWrapperClass", null), n = c("inputGroupClass", null), l = c("inputErrorClass", null), r = c("errorClass", null), s = c("helpTextClass", null);
|
|
98
98
|
return {
|
|
99
|
-
labelClass:
|
|
100
|
-
inputClass:
|
|
99
|
+
labelClass: o,
|
|
100
|
+
inputClass: a,
|
|
101
101
|
inputWrapperClass: e,
|
|
102
102
|
inputGroupClass: n,
|
|
103
103
|
inputErrorClass: l,
|
|
104
|
-
errorClass:
|
|
104
|
+
errorClass: r,
|
|
105
105
|
helpTextClass: s
|
|
106
106
|
};
|
|
107
|
-
}, pe = (
|
|
108
|
-
const e = Y(
|
|
107
|
+
}, pe = (o, a = []) => {
|
|
108
|
+
const e = Y(a), n = Z(null);
|
|
109
109
|
return ee(
|
|
110
|
-
|
|
111
|
-
(l,
|
|
112
|
-
if (n.value = null, l !==
|
|
110
|
+
o,
|
|
111
|
+
(l, r) => {
|
|
112
|
+
if (n.value = null, l !== r)
|
|
113
113
|
for (let s = 0; s < e.length; s += 1) {
|
|
114
114
|
const u = e[s];
|
|
115
115
|
if (!u.validator(l)) {
|
|
@@ -121,68 +121,70 @@ const ae = ["onSubmit"], se = { key: 0 }, ne = ["disabled"], ue = /* @__PURE__ *
|
|
|
121
121
|
{ immediate: !0 }
|
|
122
122
|
), n;
|
|
123
123
|
};
|
|
124
|
-
function U(
|
|
124
|
+
function U(o, a, e) {
|
|
125
125
|
const n = e ?? "modelValue";
|
|
126
|
-
return
|
|
127
|
-
get: () =>
|
|
128
|
-
set: (l) =>
|
|
126
|
+
return y({
|
|
127
|
+
get: () => o(),
|
|
128
|
+
set: (l) => a(`update:${n}`, l)
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
const
|
|
131
|
+
const de = /* @__PURE__ */ w({
|
|
132
132
|
inheritAttrs: !1,
|
|
133
133
|
__name: "FormMakerInput",
|
|
134
134
|
props: {
|
|
135
135
|
loading: { type: Boolean, default: !1 },
|
|
136
|
+
disabled: { type: Boolean, default: !1 },
|
|
136
137
|
modelValue: {},
|
|
137
138
|
error: { default: void 0 },
|
|
138
139
|
helpText: { default: void 0 },
|
|
139
140
|
label: { default: void 0 },
|
|
141
|
+
id: { default: void 0 },
|
|
140
142
|
type: { default: "text" },
|
|
141
143
|
rules: { default: () => [] }
|
|
142
144
|
},
|
|
143
145
|
emits: ["update:modelValue"],
|
|
144
|
-
setup(
|
|
145
|
-
const e =
|
|
146
|
-
labelClass:
|
|
146
|
+
setup(o, { emit: a }) {
|
|
147
|
+
const e = o, l = U(() => e.modelValue, a), {
|
|
148
|
+
labelClass: r,
|
|
147
149
|
inputClass: s,
|
|
148
150
|
inputWrapperClass: u,
|
|
149
|
-
inputGroupClass:
|
|
150
|
-
inputErrorClass:
|
|
151
|
-
errorClass:
|
|
151
|
+
inputGroupClass: $,
|
|
152
|
+
inputErrorClass: d,
|
|
153
|
+
errorClass: m,
|
|
152
154
|
helpTextClass: t
|
|
153
|
-
} = ie(),
|
|
155
|
+
} = ie(), b = y(() => !!e.label), C = y(() => !!e.helpText), g = pe(l, e.rules), _ = y(() => !!e.error || !!g.value), V = y(() => e.error ? e.error : g.value);
|
|
154
156
|
return (f, I) => {
|
|
155
157
|
const z = D("form-maker-label"), H = D("form-maker-help"), J = D("form-maker-error");
|
|
156
158
|
return i(), p("div", {
|
|
157
|
-
class: B([_.value && v(
|
|
159
|
+
class: B([_.value && v(d), v(u)])
|
|
158
160
|
}, [
|
|
159
|
-
f.type !== "checkbox" ?
|
|
160
|
-
|
|
161
|
+
f.type !== "checkbox" ? k(f.$slots, "label", { key: 0 }, () => [
|
|
162
|
+
b.value ? (i(), j(z, {
|
|
161
163
|
key: 0,
|
|
162
164
|
id: f.id,
|
|
163
|
-
class: B(v(
|
|
165
|
+
class: B(v(r)),
|
|
166
|
+
label: f.label
|
|
164
167
|
}, {
|
|
165
168
|
default: W(() => [
|
|
166
169
|
O(T(f.label), 1)
|
|
167
170
|
]),
|
|
168
171
|
_: 1
|
|
169
|
-
}, 8, ["id", "class"])) : M("", !0)
|
|
172
|
+
}, 8, ["id", "class", "label"])) : M("", !0)
|
|
170
173
|
]) : M("", !0),
|
|
171
|
-
|
|
174
|
+
k(f.$slots, "default", {}, () => [
|
|
172
175
|
S("div", {
|
|
173
|
-
class: B([v(
|
|
176
|
+
class: B([v($), _.value && v(d)])
|
|
174
177
|
}, [
|
|
175
|
-
|
|
178
|
+
k(f.$slots, "before"),
|
|
176
179
|
(i(), j(le(`form-maker-input-${f.type}`), G({ ...f.$props, ...f.$attrs }, {
|
|
177
|
-
class: [f.type !== "checkbox" && v(s), _.value && v(
|
|
178
|
-
label: f.label,
|
|
180
|
+
class: [f.type !== "checkbox" && v(s), _.value && v(d)],
|
|
179
181
|
modelValue: v(l),
|
|
180
182
|
"onUpdate:modelValue": I[0] || (I[0] = (K) => R(l) ? l.value = K : null)
|
|
181
|
-
}), null, 16, ["class", "
|
|
182
|
-
|
|
183
|
+
}), null, 16, ["class", "modelValue"])),
|
|
184
|
+
k(f.$slots, "after")
|
|
183
185
|
], 2)
|
|
184
186
|
]),
|
|
185
|
-
|
|
187
|
+
k(f.$slots, "help", {}, () => [
|
|
186
188
|
C.value ? (i(), j(H, {
|
|
187
189
|
key: 0,
|
|
188
190
|
class: B(v(t))
|
|
@@ -193,10 +195,10 @@ const me = /* @__PURE__ */ w({
|
|
|
193
195
|
_: 1
|
|
194
196
|
}, 8, ["class"])) : M("", !0)
|
|
195
197
|
]),
|
|
196
|
-
|
|
198
|
+
k(f.$slots, "errors", {}, () => [
|
|
197
199
|
_.value ? (i(), j(J, {
|
|
198
200
|
key: 0,
|
|
199
|
-
class: B(v(
|
|
201
|
+
class: B(v(m))
|
|
200
202
|
}, {
|
|
201
203
|
default: W(() => [
|
|
202
204
|
O(T(V.value), 1)
|
|
@@ -207,32 +209,40 @@ const me = /* @__PURE__ */ w({
|
|
|
207
209
|
], 2);
|
|
208
210
|
};
|
|
209
211
|
}
|
|
210
|
-
}),
|
|
212
|
+
}), me = ["checked", "value", "onClick"], fe = /* @__PURE__ */ w({
|
|
211
213
|
__name: "CheckboxInput",
|
|
212
214
|
props: {
|
|
213
|
-
options: { type: [Boolean, Array], default: () => [] }
|
|
215
|
+
options: { type: [Boolean, Array], default: () => [] },
|
|
216
|
+
loading: { type: Boolean, default: !1 },
|
|
217
|
+
disabled: { type: Boolean, default: !1 },
|
|
218
|
+
modelValue: {},
|
|
219
|
+
error: { default: void 0 },
|
|
220
|
+
helpText: { default: void 0 },
|
|
221
|
+
label: { default: void 0 },
|
|
222
|
+
type: {},
|
|
223
|
+
rules: { default: () => [] }
|
|
214
224
|
},
|
|
215
225
|
emits: ["update:modelValue"],
|
|
216
|
-
setup(
|
|
217
|
-
const e =
|
|
226
|
+
setup(o, { emit: a }) {
|
|
227
|
+
const e = o, n = a, l = y(() => Array.isArray(e.options) && e.options.length === 0), r = y(() => e.modelValue), s = y(() => (Array.isArray(r.value) ? r.value : [r.value]).filter((m) => !!m)), u = y(() => l.value ? [
|
|
218
228
|
{
|
|
219
229
|
label: e.label,
|
|
220
230
|
value: !0
|
|
221
231
|
}
|
|
222
|
-
] : e.options),
|
|
223
|
-
let
|
|
224
|
-
|
|
232
|
+
] : e.options), $ = (d) => {
|
|
233
|
+
let m = [...s.value];
|
|
234
|
+
m.indexOf(d) === -1 ? m.push(d) : m = m.filter((t) => t !== d), l.value ? n("update:modelValue", m.length > 0) : n("update:modelValue", m);
|
|
225
235
|
};
|
|
226
|
-
return (
|
|
227
|
-
key: `option_${
|
|
236
|
+
return (d, m) => (i(!0), p(A, null, F(u.value, (t, b) => (i(), p("div", {
|
|
237
|
+
key: `option_${b}`
|
|
228
238
|
}, [
|
|
229
239
|
S("label", null, [
|
|
230
|
-
S("input", G(
|
|
240
|
+
S("input", G(d.$props, {
|
|
231
241
|
checked: s.value.indexOf(t.value) !== -1,
|
|
232
242
|
value: t.value,
|
|
233
243
|
type: "checkbox",
|
|
234
|
-
onClick: () =>
|
|
235
|
-
}), null, 16,
|
|
244
|
+
onClick: () => $(t.value)
|
|
245
|
+
}), null, 16, me),
|
|
236
246
|
O(" " + T(t.label), 1)
|
|
237
247
|
])
|
|
238
248
|
]))), 128));
|
|
@@ -241,30 +251,32 @@ const me = /* @__PURE__ */ w({
|
|
|
241
251
|
__name: "FileInput",
|
|
242
252
|
props: {
|
|
243
253
|
loading: { type: Boolean, default: !1 },
|
|
254
|
+
disabled: { type: Boolean, default: !1 },
|
|
244
255
|
modelValue: {},
|
|
245
256
|
error: { default: void 0 },
|
|
246
257
|
helpText: { default: void 0 },
|
|
247
258
|
label: { default: void 0 },
|
|
259
|
+
id: { default: void 0 },
|
|
248
260
|
type: {},
|
|
249
261
|
rules: { default: () => [] }
|
|
250
262
|
},
|
|
251
263
|
emits: ["update:modelValue"],
|
|
252
|
-
setup(
|
|
253
|
-
const e =
|
|
254
|
-
const
|
|
255
|
-
if (
|
|
256
|
-
const s =
|
|
264
|
+
setup(o, { emit: a }) {
|
|
265
|
+
const e = a, n = (l) => {
|
|
266
|
+
const r = l.currentTarget;
|
|
267
|
+
if (r.files && r.files.length) {
|
|
268
|
+
const s = r.files[0];
|
|
257
269
|
e("update:modelValue", s);
|
|
258
270
|
}
|
|
259
271
|
};
|
|
260
|
-
return (l,
|
|
272
|
+
return (l, r) => (i(), p("input", G(l.$props, {
|
|
261
273
|
type: "file",
|
|
262
274
|
onChange: n
|
|
263
275
|
}), null, 16));
|
|
264
276
|
}
|
|
265
277
|
});
|
|
266
|
-
function N(
|
|
267
|
-
return
|
|
278
|
+
function N(o, a) {
|
|
279
|
+
return x(`${o.as ?? "div"}`, a.attrs, a.slots);
|
|
268
280
|
}
|
|
269
281
|
N.props = {
|
|
270
282
|
as: {
|
|
@@ -273,33 +285,35 @@ N.props = {
|
|
|
273
285
|
default: "div"
|
|
274
286
|
}
|
|
275
287
|
};
|
|
276
|
-
function
|
|
277
|
-
return
|
|
288
|
+
function q(o, { slots: a, attrs: e }) {
|
|
289
|
+
return x("label", { ...e, for: o.id }, a.default());
|
|
278
290
|
}
|
|
279
|
-
|
|
291
|
+
q.props = {
|
|
280
292
|
id: {
|
|
281
293
|
type: String,
|
|
282
294
|
default: null
|
|
283
295
|
}
|
|
284
296
|
};
|
|
285
|
-
const ve =
|
|
297
|
+
const ve = q, be = ["checked", "value", "onChange"], ke = /* @__PURE__ */ w({
|
|
286
298
|
__name: "RadioInput",
|
|
287
299
|
props: {
|
|
288
300
|
options: { default: () => [] },
|
|
289
301
|
loading: { type: Boolean, default: !1 },
|
|
302
|
+
disabled: { type: Boolean, default: !1 },
|
|
290
303
|
modelValue: {},
|
|
291
304
|
error: { default: void 0 },
|
|
292
305
|
helpText: { default: void 0 },
|
|
293
306
|
label: { default: void 0 },
|
|
294
307
|
type: {},
|
|
295
|
-
rules: {}
|
|
308
|
+
rules: {},
|
|
309
|
+
id: { default: void 0 }
|
|
296
310
|
},
|
|
297
311
|
emits: ["update:modelValue"],
|
|
298
|
-
setup(
|
|
299
|
-
const e =
|
|
312
|
+
setup(o, { emit: a }) {
|
|
313
|
+
const e = a, n = (l) => {
|
|
300
314
|
e("update:modelValue", l);
|
|
301
315
|
};
|
|
302
|
-
return (l,
|
|
316
|
+
return (l, r) => (i(!0), p(A, null, F(l.options, (s, u) => (i(), p("div", {
|
|
303
317
|
key: `option_${u}`
|
|
304
318
|
}, [
|
|
305
319
|
S("label", null, [
|
|
@@ -307,51 +321,53 @@ const ve = x, ke = ["checked", "value", "onChange"], he = /* @__PURE__ */ w({
|
|
|
307
321
|
checked: s.value === l.modelValue,
|
|
308
322
|
value: s.value,
|
|
309
323
|
type: "radio",
|
|
310
|
-
onChange: (
|
|
311
|
-
}), null, 16,
|
|
324
|
+
onChange: ($) => n(s.value)
|
|
325
|
+
}), null, 16, be),
|
|
312
326
|
O(" " + T(s.label), 1)
|
|
313
327
|
])
|
|
314
328
|
]))), 128));
|
|
315
329
|
}
|
|
316
|
-
}),
|
|
330
|
+
}), he = ["id", "disabled", "name", "placeholder"], Ce = ["label"], ye = ["value"], $e = ["value"], _e = /* @__PURE__ */ w({
|
|
317
331
|
__name: "SelectInput",
|
|
318
332
|
props: {
|
|
319
333
|
options: { default: () => [] },
|
|
320
334
|
optionGroups: { default: () => ({}) },
|
|
321
335
|
loading: { type: Boolean, default: !1 },
|
|
336
|
+
disabled: { type: Boolean, default: !1 },
|
|
322
337
|
modelValue: {},
|
|
323
338
|
error: { default: void 0 },
|
|
324
339
|
helpText: { default: void 0 },
|
|
325
340
|
label: { default: void 0 },
|
|
341
|
+
id: { default: void 0 },
|
|
326
342
|
type: {},
|
|
327
343
|
rules: { default: () => [] }
|
|
328
344
|
},
|
|
329
345
|
emits: ["update:modelValue"],
|
|
330
|
-
setup(
|
|
331
|
-
const e =
|
|
346
|
+
setup(o, { emit: a }) {
|
|
347
|
+
const e = o, l = U(() => e.modelValue, a), r = Object.keys(e.optionGroups).length > 0, s = y(() => e.options.map((u) => typeof u == "object" ? u : {
|
|
332
348
|
label: u,
|
|
333
349
|
value: u
|
|
334
350
|
}));
|
|
335
|
-
return (u,
|
|
351
|
+
return (u, $) => L((i(), p("select", {
|
|
336
352
|
id: u.id,
|
|
337
|
-
"onUpdate:modelValue":
|
|
353
|
+
"onUpdate:modelValue": $[0] || ($[0] = (d) => R(l) ? l.value = d : null),
|
|
338
354
|
disabled: u.disabled,
|
|
339
355
|
name: u.name,
|
|
340
356
|
placeholder: u.placeholder
|
|
341
357
|
}, [
|
|
342
|
-
|
|
343
|
-
key: `optGroup_${
|
|
344
|
-
label:
|
|
358
|
+
r ? (i(!0), p(A, { key: 0 }, F(u.optionGroups, (d, m) => (i(), p("optgroup", {
|
|
359
|
+
key: `optGroup_${m}`,
|
|
360
|
+
label: m
|
|
345
361
|
}, [
|
|
346
|
-
(i(!0), p(A, null, F(
|
|
362
|
+
(i(!0), p(A, null, F(d, (t, b) => (i(), p("option", {
|
|
347
363
|
key: `option_${t}`,
|
|
348
|
-
value:
|
|
349
|
-
}, T(t), 9,
|
|
350
|
-
], 8, Ce))), 128)) : (i(!0), p(A, { key: 1 }, F(s.value, (
|
|
351
|
-
key: `option_${
|
|
352
|
-
value:
|
|
353
|
-
}, T(
|
|
354
|
-
], 8,
|
|
364
|
+
value: b
|
|
365
|
+
}, T(t), 9, ye))), 128))
|
|
366
|
+
], 8, Ce))), 128)) : (i(!0), p(A, { key: 1 }, F(s.value, (d, m) => (i(), p("option", {
|
|
367
|
+
key: `option_${m}`,
|
|
368
|
+
value: d.value
|
|
369
|
+
}, T(d.label), 9, $e))), 128))
|
|
370
|
+
], 8, he)), [
|
|
355
371
|
[te, v(l)]
|
|
356
372
|
]);
|
|
357
373
|
}
|
|
@@ -361,34 +377,36 @@ const ve = x, ke = ["checked", "value", "onChange"], he = /* @__PURE__ */ w({
|
|
|
361
377
|
modelValue: {}
|
|
362
378
|
},
|
|
363
379
|
emits: ["update:modelValue"],
|
|
364
|
-
setup(
|
|
365
|
-
const e =
|
|
366
|
-
return (
|
|
367
|
-
id:
|
|
380
|
+
setup(o, { emit: a }) {
|
|
381
|
+
const e = o, l = U(() => e.modelValue, a);
|
|
382
|
+
return (r, s) => L((i(), p("textarea", G({
|
|
383
|
+
id: r.id,
|
|
368
384
|
"onUpdate:modelValue": s[0] || (s[0] = (u) => R(l) ? l.value = u : null)
|
|
369
|
-
}, { ...
|
|
370
|
-
[
|
|
385
|
+
}, { ...r.$props, ...r.$attrs }), null, 16, Ve)), [
|
|
386
|
+
[ae, v(l)]
|
|
371
387
|
]);
|
|
372
388
|
}
|
|
373
|
-
}), Be = ["type"],
|
|
389
|
+
}), Be = ["type"], h = /* @__PURE__ */ w({
|
|
374
390
|
__name: "BasicInput",
|
|
375
391
|
props: {
|
|
376
392
|
loading: { type: Boolean, default: !1 },
|
|
393
|
+
disabled: { type: Boolean, default: !1 },
|
|
377
394
|
modelValue: {},
|
|
378
395
|
error: { default: void 0 },
|
|
379
396
|
helpText: { default: void 0 },
|
|
380
397
|
label: { default: void 0 },
|
|
398
|
+
id: { default: void 0 },
|
|
381
399
|
type: { default: "text" },
|
|
382
400
|
rules: { default: () => [] }
|
|
383
401
|
},
|
|
384
402
|
emits: ["update:modelValue"],
|
|
385
|
-
setup(
|
|
386
|
-
const e =
|
|
387
|
-
return (
|
|
403
|
+
setup(o, { emit: a }) {
|
|
404
|
+
const e = o, l = U(() => e.modelValue, a);
|
|
405
|
+
return (r, s) => L((i(), p("input", G({
|
|
388
406
|
"onUpdate:modelValue": s[0] || (s[0] = (u) => R(l) ? l.value = u : null),
|
|
389
|
-
type:
|
|
390
|
-
}, { ...
|
|
391
|
-
[
|
|
407
|
+
type: r.type
|
|
408
|
+
}, { ...r.$props, ...r.$attrs }), null, 16, Be)), [
|
|
409
|
+
[oe, v(l)]
|
|
392
410
|
]);
|
|
393
411
|
}
|
|
394
412
|
}), P = {
|
|
@@ -405,41 +423,41 @@ const ve = x, ke = ["checked", "value", "onChange"], he = /* @__PURE__ */ w({
|
|
|
405
423
|
"submit-button": "form-maker-submit"
|
|
406
424
|
},
|
|
407
425
|
components: {
|
|
408
|
-
"form-maker-input-color":
|
|
409
|
-
"form-maker-input-date":
|
|
410
|
-
"form-maker-input-email":
|
|
411
|
-
"form-maker-input-month":
|
|
412
|
-
"form-maker-input-number":
|
|
413
|
-
"form-maker-input-password":
|
|
414
|
-
"form-maker-input-search":
|
|
415
|
-
"form-maker-input-tel":
|
|
416
|
-
"form-maker-input-time":
|
|
417
|
-
"form-maker-input-text":
|
|
418
|
-
"form-maker-input-url":
|
|
419
|
-
"form-maker-input-week":
|
|
420
|
-
"form-maker-input-range":
|
|
426
|
+
"form-maker-input-color": h,
|
|
427
|
+
"form-maker-input-date": h,
|
|
428
|
+
"form-maker-input-email": h,
|
|
429
|
+
"form-maker-input-month": h,
|
|
430
|
+
"form-maker-input-number": h,
|
|
431
|
+
"form-maker-input-password": h,
|
|
432
|
+
"form-maker-input-search": h,
|
|
433
|
+
"form-maker-input-tel": h,
|
|
434
|
+
"form-maker-input-time": h,
|
|
435
|
+
"form-maker-input-text": h,
|
|
436
|
+
"form-maker-input-url": h,
|
|
437
|
+
"form-maker-input-week": h,
|
|
438
|
+
"form-maker-input-range": h,
|
|
421
439
|
"form-maker-input-file": ce,
|
|
422
440
|
"form-maker-input-textarea": ge,
|
|
423
441
|
"form-maker-input-select": _e,
|
|
424
442
|
"form-maker-input-checkbox": fe,
|
|
425
|
-
"form-maker-input-radio":
|
|
443
|
+
"form-maker-input-radio": ke,
|
|
426
444
|
"form-maker-label": ve,
|
|
427
445
|
"form-maker-help": N,
|
|
428
446
|
"form-maker-error": N
|
|
429
447
|
}
|
|
430
448
|
}, we = {
|
|
431
|
-
install: (
|
|
449
|
+
install: (o, a = {}) => {
|
|
432
450
|
const e = {
|
|
433
|
-
classes: { ...P.classes, ...
|
|
451
|
+
classes: { ...P.classes, ...a.classes },
|
|
434
452
|
components: {
|
|
435
453
|
...P.components,
|
|
436
|
-
...
|
|
454
|
+
...a.components
|
|
437
455
|
}
|
|
438
456
|
};
|
|
439
|
-
|
|
440
|
-
|
|
457
|
+
o.component("FormMaker", ue), o.component("FormMakerInput", de), Object.keys(e.classes).forEach((n) => {
|
|
458
|
+
o.provide(n, e.classes[n]);
|
|
441
459
|
}), Object.keys(e.components).forEach((n) => {
|
|
442
|
-
|
|
460
|
+
o.component(n, e.components[n]);
|
|
443
461
|
});
|
|
444
462
|
}
|
|
445
463
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,y){typeof exports=="object"&&typeof module<"u"?module.exports=y(require("vue")):typeof define=="function"&&define.amd?define(["vue"],y):(e=typeof globalThis<"u"?globalThis:e||self,e.FormMaker=y(e.Vue))})(this,function(e){"use strict";const y=["onSubmit"],S={key:0},T=["disabled"],j=e.defineComponent({__name:"FormMaker",props:{loading:{type:Boolean,default:!1},hasActions:{type:Boolean,default:!0},modelValue:{default:()=>({})},fields:{default:()=>[]},hideDivider:{type:Boolean,default:!1},rowClass:{default:null},columnClass:{default:null},labelClass:{default:null},inputGroupClass:{default:null},inputWrapperClass:{default:null},inputErrorClass:{default:null},inputClass:{default:null},errorClass:{default:null},helpTextClass:{default:null},submitButtonClass:{default:null},submitButtonText:{default:"Submit"}},emits:["submit","update:modelValue"],setup(n,{emit:r}){const t=n,i=r,l=()=>i("submit"),a=e.computed(()=>t.fields.length>0?t.fields.map(o=>{let u=o;return Array.isArray(o)||(u=[o]),u.map(k=>k.id?k:{...k,id:`formMaker_${new Date().getTime()}_${k.name}`})}):Object.keys(t.modelValue).map(o=>[{name:o,label:o,id:`formMaker_${o}`}]));e.provide("labelClass",t.labelClass||e.inject("form-label")),e.provide("inputGroupClass",t.inputGroupClass||e.inject("input-group")),e.provide("inputWrapperClass",t.inputWrapperClass||e.inject("input-wrapper")),e.provide("inputErrorClass",t.inputErrorClass||e.inject("input-error")),e.provide("inputClass",t.inputClass||e.inject("input")),e.provide("errorClass",t.errorClass||e.inject("error")),e.provide("helpTextClass",t.helpTextClass||e.inject("help-text"));const s=t.rowClass||e.inject("form-row"),p=t.columnClass||e.inject("form-column"),C=t.submitButtonClass||e.inject("submit-button"),m=o=>{const u=o.split(".");let k=t.modelValue;for(let B=0;B<u.length-1;B+=1){const h=k[u[B]];if(!h)break;k=h}return k},d=o=>{const u=o.split(".");return u[u.length-1]};return(o,u)=>{const k=e.resolveComponent("form-maker-input");return e.openBlock(),e.createElementBlock("form",{class:"form-maker",onSubmit:e.withModifiers(l,["prevent"])},[o.loading?e.renderSlot(o.$slots,"loading",{key:0},()=>[e.createTextVNode(" Loading... ")]):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"default",{},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(B,h)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(s)),key:`fieldRow_${h}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B,(b,c)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([e.unref(p),b.columnClass]),key:`field_${h}_${c}`},[e.renderSlot(o.$slots,`${b.name}`,{field:b},()=>[e.createVNode(k,e.mergeProps({modelValue:m(b.name)[d(b.name)],"onUpdate:modelValue":g=>m(b.name)[d(b.name)]=g},b),null,16,["modelValue","onUpdate:modelValue"])])],2))),128))],2))),128))]),e.renderSlot(o.$slots,"extra"),e.renderSlot(o.$slots,"divider",{},()=>[o.hasActions&&!o.hideDivider?(e.openBlock(),e.createElementBlock("hr",S)):e.createCommentVNode("",!0)]),o.hasActions?e.renderSlot(o.$slots,"actions",{key:1},()=>[e.renderSlot(o.$slots,"submit-button",{},()=>[e.createElementVNode("button",{class:e.normalizeClass(e.unref(C)),disabled:o.loading,type:"submit"},e.toDisplayString(o.submitButtonText),11,T)]),e.renderSlot(o.$slots,"extra-buttons")]):e.createCommentVNode("",!0)],40,y)}}}),w=()=>{const n=e.inject("labelClass",null),r=e.inject("inputClass",null),t=e.inject("inputWrapperClass",null),i=e.inject("inputGroupClass",null),l=e.inject("inputErrorClass",null),a=e.inject("errorClass",null),s=e.inject("helpTextClass",null);return{labelClass:n,inputClass:r,inputWrapperClass:t,inputGroupClass:i,inputErrorClass:l,errorClass:a,helpTextClass:s}},N=(n,r=[])=>{const t=e.toRaw(r),i=e.ref(null);return e.watch(n,(l,a)=>{if(i.value=null,l!==a)for(let s=0;s<t.length;s+=1){const p=t[s];if(!p.validator(l)){i.value=p.message;break}}},{immediate:!0}),i};function V(n,r,t){const i=t??"modelValue";return e.computed({get:()=>n(),set:l=>r(`update:${i}`,l)})}const F=e.defineComponent({inheritAttrs:!1,__name:"FormMakerInput",props:{loading:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{default:"text"},rules:{default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,l=V(()=>t.modelValue,r),{labelClass:a,inputClass:s,inputWrapperClass:p,inputGroupClass:C,inputErrorClass:m,errorClass:d,helpTextClass:o}=w(),u=e.computed(()=>!!t.label),k=e.computed(()=>!!t.helpText),B=N(l,t.rules),h=e.computed(()=>!!t.error||!!B.value),b=e.computed(()=>t.error?t.error:B.value);return(c,g)=>{const H=e.resolveComponent("form-maker-label"),J=e.resolveComponent("form-maker-help"),K=e.resolveComponent("form-maker-error");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([h.value&&e.unref(m),e.unref(p)])},[c.type!=="checkbox"?e.renderSlot(c.$slots,"label",{key:0},()=>[u.value?(e.openBlock(),e.createBlock(H,{key:0,id:c.id,class:e.normalizeClass(e.unref(a))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.label),1)]),_:1},8,["id","class"])):e.createCommentVNode("",!0)]):e.createCommentVNode("",!0),e.renderSlot(c.$slots,"default",{},()=>[e.createElementVNode("div",{class:e.normalizeClass([e.unref(C),h.value&&e.unref(m)])},[e.renderSlot(c.$slots,"before"),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(`form-maker-input-${c.type}`),e.mergeProps({...c.$props,...c.$attrs},{class:[c.type!=="checkbox"&&e.unref(s),h.value&&e.unref(m)],label:c.label,modelValue:e.unref(l),"onUpdate:modelValue":g[0]||(g[0]=Q=>e.isRef(l)?l.value=Q:null)}),null,16,["class","label","modelValue"])),e.renderSlot(c.$slots,"after")],2)]),e.renderSlot(c.$slots,"help",{},()=>[k.value?(e.openBlock(),e.createBlock(J,{key:0,class:e.normalizeClass(e.unref(o))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.helpText),1)]),_:1},8,["class"])):e.createCommentVNode("",!0)]),e.renderSlot(c.$slots,"errors",{},()=>[h.value?(e.openBlock(),e.createBlock(K,{key:0,class:e.normalizeClass(e.unref(d))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(b.value),1)]),_:1},8,["class"])):e.createCommentVNode("",!0)])],2)}}}),D=["checked","value","onClick"],M=e.defineComponent({__name:"CheckboxInput",props:{options:{type:[Boolean,Array],default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,i=r,l=e.computed(()=>Array.isArray(t.options)&&t.options.length===0),a=e.computed(()=>t.modelValue),s=e.computed(()=>(Array.isArray(a.value)?a.value:[a.value]).filter(d=>!!d)),p=e.computed(()=>l.value?[{label:t.label,value:!0}]:t.options),C=m=>{let d=[...s.value];d.indexOf(m)===-1?d.push(m):d=d.filter(o=>o!==m),l.value?i("update:modelValue",d.length>0):i("update:modelValue",d)};return(m,d)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(o,u)=>(e.openBlock(),e.createElementBlock("div",{key:`option_${u}`},[e.createElementVNode("label",null,[e.createElementVNode("input",e.mergeProps(m.$props,{checked:s.value.indexOf(o.value)!==-1,value:o.value,type:"checkbox",onClick:()=>C(o.value)}),null,16,D),e.createTextVNode(" "+e.toDisplayString(o.label),1)])]))),128))}}),A=e.defineComponent({__name:"FileInput",props:{loading:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{},rules:{default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=r,i=l=>{const a=l.currentTarget;if(a.files&&a.files.length){const s=a.files[0];t("update:modelValue",s)}};return(l,a)=>(e.openBlock(),e.createElementBlock("input",e.mergeProps(l.$props,{type:"file",onChange:i}),null,16))}});function $(n,r){return e.h(`${n.as??"div"}`,r.attrs,r.slots)}$.props={as:{type:String,required:!1,default:"div"}};function _(n,{slots:r,attrs:t}){return e.h("label",{...t,for:n.id},r.default())}_.props={id:{type:String,default:null}};const G=_,O=["checked","value","onChange"],L=e.defineComponent({__name:"RadioInput",props:{options:{default:()=>[]},loading:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{},rules:{}},emits:["update:modelValue"],setup(n,{emit:r}){const t=r,i=l=>{t("update:modelValue",l)};return(l,a)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,(s,p)=>(e.openBlock(),e.createElementBlock("div",{key:`option_${p}`},[e.createElementVNode("label",null,[e.createElementVNode("input",e.mergeProps(l.$props,{checked:s.value===l.modelValue,value:s.value,type:"radio",onChange:C=>i(s.value)}),null,16,O),e.createTextVNode(" "+e.toDisplayString(s.label),1)])]))),128))}}),x=["id","disabled","name","placeholder"],I=["label"],P=["value"],R=["value"],z=e.defineComponent({__name:"SelectInput",props:{options:{default:()=>[]},optionGroups:{default:()=>({})},loading:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{},rules:{default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,l=V(()=>t.modelValue,r),a=Object.keys(t.optionGroups).length>0,s=e.computed(()=>t.options.map(p=>typeof p=="object"?p:{label:p,value:p}));return(p,C)=>e.withDirectives((e.openBlock(),e.createElementBlock("select",{id:p.id,"onUpdate:modelValue":C[0]||(C[0]=m=>e.isRef(l)?l.value=m:null),disabled:p.disabled,name:p.name,placeholder:p.placeholder},[a?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(p.optionGroups,(m,d)=>(e.openBlock(),e.createElementBlock("optgroup",{key:`optGroup_${d}`,label:d},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m,(o,u)=>(e.openBlock(),e.createElementBlock("option",{key:`option_${o}`,value:u},e.toDisplayString(o),9,P))),128))],8,I))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(s.value,(m,d)=>(e.openBlock(),e.createElementBlock("option",{key:`option_${d}`,value:m.value},e.toDisplayString(m.label),9,R))),128))],8,x)),[[e.vModelSelect,e.unref(l)]])}}),U=["id"],W=e.defineComponent({__name:"TextAreaInput",props:{modelValue:{}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,l=V(()=>t.modelValue,r);return(a,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("textarea",e.mergeProps({id:a.id,"onUpdate:modelValue":s[0]||(s[0]=p=>e.isRef(l)?l.value=p:null)},{...a.$props,...a.$attrs}),null,16,U)),[[e.vModelText,e.unref(l)]])}}),q=["type"],f=e.defineComponent({__name:"BasicInput",props:{loading:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{default:"text"},rules:{default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,l=V(()=>t.modelValue,r);return(a,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps({"onUpdate:modelValue":s[0]||(s[0]=p=>e.isRef(l)?l.value=p:null),type:a.type},{...a.$props,...a.$attrs}),null,16,q)),[[e.vModelDynamic,e.unref(l)]])}}),E={classes:{"form-row":"form-maker-row","form-column":"form-maker-column","form-label":"form-maker-label","input-group":"form-maker-input-group","input-wrapper":"form-maker-input-wrapper","input-error":"form-maker-input-error",input:"form-maker-input",error:"form-maker-error","help-text":"form-maker-help-text","submit-button":"form-maker-submit"},components:{"form-maker-input-color":f,"form-maker-input-date":f,"form-maker-input-email":f,"form-maker-input-month":f,"form-maker-input-number":f,"form-maker-input-password":f,"form-maker-input-search":f,"form-maker-input-tel":f,"form-maker-input-time":f,"form-maker-input-text":f,"form-maker-input-url":f,"form-maker-input-week":f,"form-maker-input-range":f,"form-maker-input-file":A,"form-maker-input-textarea":W,"form-maker-input-select":z,"form-maker-input-checkbox":M,"form-maker-input-radio":L,"form-maker-label":G,"form-maker-help":$,"form-maker-error":$}};return{install:(n,r={})=>{const t={classes:{...E.classes,...r.classes},components:{...E.components,...r.components}};n.component("FormMaker",j),n.component("FormMakerInput",F),Object.keys(t.classes).forEach(i=>{n.provide(i,t.classes[i])}),Object.keys(t.components).forEach(i=>{n.component(i,t.components[i])})}}});
|
|
1
|
+
(function(e,y){typeof exports=="object"&&typeof module<"u"?module.exports=y(require("vue")):typeof define=="function"&&define.amd?define(["vue"],y):(e=typeof globalThis<"u"?globalThis:e||self,e.FormMaker=y(e.Vue))})(this,function(e){"use strict";const y=["onSubmit"],S={key:0},T=["disabled"],j=e.defineComponent({__name:"FormMaker",props:{loading:{type:Boolean,default:!1},hasActions:{type:Boolean,default:!0},modelValue:{default:()=>({})},fields:{default:()=>[]},hideDivider:{type:Boolean,default:!1},rowClass:{default:null},columnClass:{default:null},labelClass:{default:null},inputGroupClass:{default:null},inputWrapperClass:{default:null},inputErrorClass:{default:null},inputClass:{default:null},errorClass:{default:null},helpTextClass:{default:null},submitButtonClass:{default:null},submitButtonText:{default:"Submit"}},emits:["submit","update:modelValue"],setup(n,{emit:r}){const t=n,i=r,l=()=>i("submit"),a=e.computed(()=>t.fields.length>0?t.fields.map(o=>{let u=o;return Array.isArray(o)||(u=[o]),u.map(k=>({...k,id:k.id||`formMaker_${new Date().getTime()}_${k.name}`}))}):Object.keys(t.modelValue).map(o=>[{name:o,label:o,id:`formMaker_${o}`}]));e.provide("labelClass",t.labelClass||e.inject("form-label")),e.provide("inputGroupClass",t.inputGroupClass||e.inject("input-group")),e.provide("inputWrapperClass",t.inputWrapperClass||e.inject("input-wrapper")),e.provide("inputErrorClass",t.inputErrorClass||e.inject("input-error")),e.provide("inputClass",t.inputClass||e.inject("input")),e.provide("errorClass",t.errorClass||e.inject("error")),e.provide("helpTextClass",t.helpTextClass||e.inject("help-text"));const s=t.rowClass||e.inject("form-row"),p=t.columnClass||e.inject("form-column"),C=t.submitButtonClass||e.inject("submit-button"),d=o=>{const u=o.split(".");let k=t.modelValue;for(let B=0;B<u.length-1;B+=1){const h=k[u[B]];if(!h)break;k=h}return k},m=o=>{const u=o.split(".");return u[u.length-1]};return(o,u)=>{const k=e.resolveComponent("form-maker-input");return e.openBlock(),e.createElementBlock("form",{class:"form-maker",onSubmit:e.withModifiers(l,["prevent"])},[o.loading?e.renderSlot(o.$slots,"loading",{key:0},()=>[e.createTextVNode(" Loading... ")]):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"default",{},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(B,h)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(s)),key:`fieldRow_${h}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B,(b,c)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([e.unref(p),b.columnClass]),key:`field_${h}_${c}`},[e.renderSlot(o.$slots,`${b.name}`,{field:b},()=>[e.createVNode(k,e.mergeProps({modelValue:d(b.name)[m(b.name)],"onUpdate:modelValue":g=>d(b.name)[m(b.name)]=g},b),null,16,["modelValue","onUpdate:modelValue"])])],2))),128))],2))),128))]),e.renderSlot(o.$slots,"extra"),e.renderSlot(o.$slots,"divider",{},()=>[o.hasActions&&!o.hideDivider?(e.openBlock(),e.createElementBlock("hr",S)):e.createCommentVNode("",!0)]),o.hasActions?e.renderSlot(o.$slots,"actions",{key:1},()=>[e.renderSlot(o.$slots,"submit-button",{},()=>[e.createElementVNode("button",{class:e.normalizeClass(e.unref(C)),disabled:o.loading,type:"submit"},e.toDisplayString(o.submitButtonText),11,T)]),e.renderSlot(o.$slots,"extra-buttons")]):e.createCommentVNode("",!0)],40,y)}}}),w=()=>{const n=e.inject("labelClass",null),r=e.inject("inputClass",null),t=e.inject("inputWrapperClass",null),i=e.inject("inputGroupClass",null),l=e.inject("inputErrorClass",null),a=e.inject("errorClass",null),s=e.inject("helpTextClass",null);return{labelClass:n,inputClass:r,inputWrapperClass:t,inputGroupClass:i,inputErrorClass:l,errorClass:a,helpTextClass:s}},N=(n,r=[])=>{const t=e.toRaw(r),i=e.ref(null);return e.watch(n,(l,a)=>{if(i.value=null,l!==a)for(let s=0;s<t.length;s+=1){const p=t[s];if(!p.validator(l)){i.value=p.message;break}}},{immediate:!0}),i};function V(n,r,t){const i=t??"modelValue";return e.computed({get:()=>n(),set:l=>r(`update:${i}`,l)})}const F=e.defineComponent({inheritAttrs:!1,__name:"FormMakerInput",props:{loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},id:{default:void 0},type:{default:"text"},rules:{default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,l=V(()=>t.modelValue,r),{labelClass:a,inputClass:s,inputWrapperClass:p,inputGroupClass:C,inputErrorClass:d,errorClass:m,helpTextClass:o}=w(),u=e.computed(()=>!!t.label),k=e.computed(()=>!!t.helpText),B=N(l,t.rules),h=e.computed(()=>!!t.error||!!B.value),b=e.computed(()=>t.error?t.error:B.value);return(c,g)=>{const H=e.resolveComponent("form-maker-label"),J=e.resolveComponent("form-maker-help"),K=e.resolveComponent("form-maker-error");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([h.value&&e.unref(d),e.unref(p)])},[c.type!=="checkbox"?e.renderSlot(c.$slots,"label",{key:0},()=>[u.value?(e.openBlock(),e.createBlock(H,{key:0,id:c.id,class:e.normalizeClass(e.unref(a)),label:c.label},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.label),1)]),_:1},8,["id","class","label"])):e.createCommentVNode("",!0)]):e.createCommentVNode("",!0),e.renderSlot(c.$slots,"default",{},()=>[e.createElementVNode("div",{class:e.normalizeClass([e.unref(C),h.value&&e.unref(d)])},[e.renderSlot(c.$slots,"before"),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(`form-maker-input-${c.type}`),e.mergeProps({...c.$props,...c.$attrs},{class:[c.type!=="checkbox"&&e.unref(s),h.value&&e.unref(d)],modelValue:e.unref(l),"onUpdate:modelValue":g[0]||(g[0]=Q=>e.isRef(l)?l.value=Q:null)}),null,16,["class","modelValue"])),e.renderSlot(c.$slots,"after")],2)]),e.renderSlot(c.$slots,"help",{},()=>[k.value?(e.openBlock(),e.createBlock(J,{key:0,class:e.normalizeClass(e.unref(o))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.helpText),1)]),_:1},8,["class"])):e.createCommentVNode("",!0)]),e.renderSlot(c.$slots,"errors",{},()=>[h.value?(e.openBlock(),e.createBlock(K,{key:0,class:e.normalizeClass(e.unref(m))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(b.value),1)]),_:1},8,["class"])):e.createCommentVNode("",!0)])],2)}}}),D=["checked","value","onClick"],M=e.defineComponent({__name:"CheckboxInput",props:{options:{type:[Boolean,Array],default:()=>[]},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{},rules:{default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,i=r,l=e.computed(()=>Array.isArray(t.options)&&t.options.length===0),a=e.computed(()=>t.modelValue),s=e.computed(()=>(Array.isArray(a.value)?a.value:[a.value]).filter(m=>!!m)),p=e.computed(()=>l.value?[{label:t.label,value:!0}]:t.options),C=d=>{let m=[...s.value];m.indexOf(d)===-1?m.push(d):m=m.filter(o=>o!==d),l.value?i("update:modelValue",m.length>0):i("update:modelValue",m)};return(d,m)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(o,u)=>(e.openBlock(),e.createElementBlock("div",{key:`option_${u}`},[e.createElementVNode("label",null,[e.createElementVNode("input",e.mergeProps(d.$props,{checked:s.value.indexOf(o.value)!==-1,value:o.value,type:"checkbox",onClick:()=>C(o.value)}),null,16,D),e.createTextVNode(" "+e.toDisplayString(o.label),1)])]))),128))}}),A=e.defineComponent({__name:"FileInput",props:{loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},id:{default:void 0},type:{},rules:{default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=r,i=l=>{const a=l.currentTarget;if(a.files&&a.files.length){const s=a.files[0];t("update:modelValue",s)}};return(l,a)=>(e.openBlock(),e.createElementBlock("input",e.mergeProps(l.$props,{type:"file",onChange:i}),null,16))}});function $(n,r){return e.h(`${n.as??"div"}`,r.attrs,r.slots)}$.props={as:{type:String,required:!1,default:"div"}};function _(n,{slots:r,attrs:t}){return e.h("label",{...t,for:n.id},r.default())}_.props={id:{type:String,default:null}};const G=_,O=["checked","value","onChange"],x=e.defineComponent({__name:"RadioInput",props:{options:{default:()=>[]},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},type:{},rules:{},id:{default:void 0}},emits:["update:modelValue"],setup(n,{emit:r}){const t=r,i=l=>{t("update:modelValue",l)};return(l,a)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,(s,p)=>(e.openBlock(),e.createElementBlock("div",{key:`option_${p}`},[e.createElementVNode("label",null,[e.createElementVNode("input",e.mergeProps(l.$props,{checked:s.value===l.modelValue,value:s.value,type:"radio",onChange:C=>i(s.value)}),null,16,O),e.createTextVNode(" "+e.toDisplayString(s.label),1)])]))),128))}}),L=["id","disabled","name","placeholder"],I=["label"],P=["value"],R=["value"],z=e.defineComponent({__name:"SelectInput",props:{options:{default:()=>[]},optionGroups:{default:()=>({})},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},id:{default:void 0},type:{},rules:{default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,l=V(()=>t.modelValue,r),a=Object.keys(t.optionGroups).length>0,s=e.computed(()=>t.options.map(p=>typeof p=="object"?p:{label:p,value:p}));return(p,C)=>e.withDirectives((e.openBlock(),e.createElementBlock("select",{id:p.id,"onUpdate:modelValue":C[0]||(C[0]=d=>e.isRef(l)?l.value=d:null),disabled:p.disabled,name:p.name,placeholder:p.placeholder},[a?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(p.optionGroups,(d,m)=>(e.openBlock(),e.createElementBlock("optgroup",{key:`optGroup_${m}`,label:m},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d,(o,u)=>(e.openBlock(),e.createElementBlock("option",{key:`option_${o}`,value:u},e.toDisplayString(o),9,P))),128))],8,I))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(s.value,(d,m)=>(e.openBlock(),e.createElementBlock("option",{key:`option_${m}`,value:d.value},e.toDisplayString(d.label),9,R))),128))],8,L)),[[e.vModelSelect,e.unref(l)]])}}),U=["id"],W=e.defineComponent({__name:"TextAreaInput",props:{modelValue:{}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,l=V(()=>t.modelValue,r);return(a,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("textarea",e.mergeProps({id:a.id,"onUpdate:modelValue":s[0]||(s[0]=p=>e.isRef(l)?l.value=p:null)},{...a.$props,...a.$attrs}),null,16,U)),[[e.vModelText,e.unref(l)]])}}),q=["type"],f=e.defineComponent({__name:"BasicInput",props:{loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:void 0},helpText:{default:void 0},label:{default:void 0},id:{default:void 0},type:{default:"text"},rules:{default:()=>[]}},emits:["update:modelValue"],setup(n,{emit:r}){const t=n,l=V(()=>t.modelValue,r);return(a,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps({"onUpdate:modelValue":s[0]||(s[0]=p=>e.isRef(l)?l.value=p:null),type:a.type},{...a.$props,...a.$attrs}),null,16,q)),[[e.vModelDynamic,e.unref(l)]])}}),E={classes:{"form-row":"form-maker-row","form-column":"form-maker-column","form-label":"form-maker-label","input-group":"form-maker-input-group","input-wrapper":"form-maker-input-wrapper","input-error":"form-maker-input-error",input:"form-maker-input",error:"form-maker-error","help-text":"form-maker-help-text","submit-button":"form-maker-submit"},components:{"form-maker-input-color":f,"form-maker-input-date":f,"form-maker-input-email":f,"form-maker-input-month":f,"form-maker-input-number":f,"form-maker-input-password":f,"form-maker-input-search":f,"form-maker-input-tel":f,"form-maker-input-time":f,"form-maker-input-text":f,"form-maker-input-url":f,"form-maker-input-week":f,"form-maker-input-range":f,"form-maker-input-file":A,"form-maker-input-textarea":W,"form-maker-input-select":z,"form-maker-input-checkbox":M,"form-maker-input-radio":x,"form-maker-label":G,"form-maker-help":$,"form-maker-error":$}};return{install:(n,r={})=>{const t={classes:{...E.classes,...r.classes},components:{...E.components,...r.components}};n.component("FormMaker",j),n.component("FormMakerInput",F),Object.keys(t.classes).forEach(i=>{n.provide(i,t.classes[i])}),Object.keys(t.components).forEach(i=>{n.component(i,t.components[i])})}}});
|
|
@@ -38,13 +38,10 @@ const formFields: ComputedRef<InputType[][]> = computed(() => {
|
|
|
38
38
|
newRow = [row];
|
|
39
39
|
}
|
|
40
40
|
return newRow.map((fieldSpec: InputType) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return fieldSpec;
|
|
41
|
+
return {
|
|
42
|
+
...fieldSpec,
|
|
43
|
+
id: fieldSpec.id || `formMaker_${new Date().getTime()}_${fieldSpec.name}`,
|
|
44
|
+
};
|
|
48
45
|
});
|
|
49
46
|
});
|
|
50
47
|
}
|
|
@@ -63,6 +63,7 @@ const realError = computed(() => {
|
|
|
63
63
|
v-if="hasLabel"
|
|
64
64
|
:id="id"
|
|
65
65
|
:class="labelClass"
|
|
66
|
+
:label="label"
|
|
66
67
|
>
|
|
67
68
|
{{ label }}
|
|
68
69
|
</form-maker-label>
|
|
@@ -74,7 +75,6 @@ const realError = computed(() => {
|
|
|
74
75
|
:is="`form-maker-input-${type}`"
|
|
75
76
|
v-bind="{ ...$props, ...$attrs}"
|
|
76
77
|
:class="[type !== 'checkbox' && inputClass, hasErrors && inputErrorClass]"
|
|
77
|
-
:label="label"
|
|
78
78
|
v-model="value"
|
|
79
79
|
/>
|
|
80
80
|
<slot name="after" />
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, type ComputedRef } from 'vue';
|
|
3
|
-
import type { FormMakerInputProps, SelectOption } from 'lib/model';
|
|
3
|
+
import type { FormMakerInputProps, RuleValidator, SelectOption } from 'lib/model';
|
|
4
4
|
|
|
5
5
|
interface CheckInputProps extends /* @vue-ignore */ FormMakerInputProps {
|
|
6
6
|
options?: boolean | SelectOption[]
|
|
7
|
+
loading?: boolean | undefined
|
|
8
|
+
disabled?: boolean | undefined
|
|
9
|
+
modelValue: any
|
|
10
|
+
error?: string | undefined
|
|
11
|
+
helpText?: string | undefined
|
|
12
|
+
label?: string | undefined
|
|
13
|
+
type?: string
|
|
14
|
+
rules?: RuleValidator[]
|
|
7
15
|
}
|
|
8
16
|
|
|
9
17
|
const props = withDefaults(defineProps<CheckInputProps>(), {
|
|
@@ -19,6 +27,7 @@ const props = withDefaults(defineProps<CheckInputProps>(), {
|
|
|
19
27
|
});
|
|
20
28
|
const emit = defineEmits(['update:modelValue'])
|
|
21
29
|
|
|
30
|
+
|
|
22
31
|
const isBinary = computed(() => {
|
|
23
32
|
return Array.isArray(props.options) && props.options.length === 0
|
|
24
33
|
})
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { FormMakerInputProps, SelectOption } from 'lib/model';
|
|
2
|
+
import type { FormMakerInputProps, RuleValidator, SelectOption } from 'lib/model';
|
|
3
3
|
|
|
4
4
|
interface RadioInputProps extends FormMakerInputProps {
|
|
5
5
|
options?: SelectOption[]
|
|
6
|
+
loading?: boolean | undefined
|
|
7
|
+
disabled?: boolean | undefined
|
|
8
|
+
modelValue: any
|
|
9
|
+
error?: string | undefined
|
|
10
|
+
helpText?: string | undefined
|
|
11
|
+
label?: string | undefined
|
|
12
|
+
type?: string
|
|
13
|
+
rules?: RuleValidator[]
|
|
6
14
|
}
|
|
7
15
|
|
|
8
16
|
withDefaults(defineProps<RadioInputProps>(), {
|
package/lib/model.d.ts
CHANGED
|
@@ -39,10 +39,12 @@ export interface FormMakerProps {
|
|
|
39
39
|
|
|
40
40
|
export interface FormMakerInputProps extends /* @vue-ignore */ InputHTMLAttributes{
|
|
41
41
|
loading?: boolean | undefined
|
|
42
|
+
disabled?: boolean | undefined
|
|
42
43
|
modelValue: any,
|
|
43
44
|
error?: string | undefined
|
|
44
45
|
helpText?: string | undefined
|
|
45
46
|
label?: string | undefined
|
|
47
|
+
id?: string | undefined
|
|
46
48
|
type?: string,
|
|
47
49
|
rules?: RuleValidator[]
|
|
48
50
|
}
|
|
@@ -55,4 +57,4 @@ export interface SelectOption {
|
|
|
55
57
|
export interface RuleValidator {
|
|
56
58
|
message: string
|
|
57
59
|
validator: (val: any) => boolean
|
|
58
|
-
}
|
|
60
|
+
}
|