@foormjs/vue 0.2.0 → 0.2.2

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.
@@ -1,3 +1,3 @@
1
- (function(h,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(h=typeof globalThis<"u"?globalThis:h||self,e(h.index={},h.Vue))})(this,function(h,e){"use strict";var Z=Object.defineProperty;var ee=(h,e,f)=>e in h?Z(h,e,{enumerable:!0,configurable:!0,writable:!0,value:f}):h[e]=f;var L=(h,e,f)=>ee(h,typeof e!="symbol"?e+"":e,f);function f(l,o){return typeof l=="function"?l(o):l}function q(l){var o;const n={};for(const a of l)a.type!=="action"&&(n[a.field]=(o=a.value)!==null&&o!==void 0?o:void 0);return n}function w(l,o){return l.fields.some(n=>n.altAction===o)}function $(l,o){if(!l)return;const n={};for(const[a,s]of Object.entries(l))n[a]=f(s,o);return n}const T=e.defineComponent({__name:"VuilessField",props:e.mergeModels({rules:{}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(l){const o=l,n=e.useModel(l,"modelValue"),a=e.inject("vuiless"),s=e.ref(),d=e.ref(!1),y=e.ref(!1),g=e.computed(()=>{var m;if((m=a==null?void 0:a.value)!=null&&m.firstValidation)switch(a.value.firstValidation){case"on-change":return a.value.firstSubmitHappened||d.value;case"touched-on-blur":return a.value.firstSubmitHappened||y.value&&d.value;case"on-blur":return a.value.firstSubmitHappened||y.value;case"on-submit":return a.value.firstSubmitHappened;case"none":return!1}return!1}),x=e.computed(()=>{if(g.value||s.value)return B()});e.watch([n],()=>{s.value=void 0,d.value=!0}),e.onUnmounted(()=>{var m;(m=a==null?void 0:a.value)==null||m.unregister(e.getCurrentInstance())}),a!=null&&a.value&&a.value.register(e.getCurrentInstance(),{validate:()=>(s.value=B(),s.value||!0),clearErrors:()=>{d.value=!1,y.value=!1,s.value=void 0},reset:()=>{n.value=""}});function B(){var m,r,i;if((m=o.rules)!=null&&m.length)for(const v of o.rules){const t=v(n.value,(r=a==null?void 0:a.value)==null?void 0:r.formData,(i=a==null?void 0:a.value)==null?void 0:i.formContext);if(t!==!0)return t||"Wrong value"}}function u(){y.value=!0}const c={v:e.computed({get:()=>n.value,set:m=>n.value=m})};return(m,r)=>{var i,v;return e.renderSlot(m.$slots,"default",{onBlur:u,error:x.value,formData:(i=e.unref(a))==null?void 0:i.formData,formContext:(v=e.unref(a))==null?void 0:v.formContext,model:c.v})}}}),M=e.defineComponent({__name:"VuilessForm",props:{formData:{},formContext:{},firstValidation:{default:"on-change"}},emits:["submit"],setup(l,{emit:o}){const n=l,a=o,s=new Map,d=e.ref(!1),y=e.computed(()=>({firstSubmitHappened:d.value,firstValidation:n.firstValidation,register:(u,c)=>{s.set(u,c)},unregister:u=>s.delete(u),formData:n.formData,formContext:n.formContext}));e.provide("vuiless",y);function g(){d.value=!1;for(const{clearErrors:u}of s.values())u()}async function x(){for(const{reset:u}of s.values())u();await e.nextTick(),g()}function B(){d.value=!0;let u=!1;if(n.firstValidation!=="none")for(const{validate:c}of s.values())c()!==!0&&(u=!0);u||a("submit",n.formData)}return(u,c)=>(e.openBlock(),e.createElementBlock("form",{onSubmit:e.withModifiers(B,["prevent"])},[e.renderSlot(u.$slots,"default",{clearErrors:g,reset:x})],32))}}),A=e.defineComponent({__name:"oo-field",props:{field:{},type:{},component:{},autocomplete:{},altAction:{},order:{},name:{},label:{type:[String,Function]},description:{type:[String,Function]},hint:{type:[String,Function]},placeholder:{type:[String,Function]},optional:{type:[Boolean,Function]},disabled:{type:[Boolean,Function]},hidden:{type:[Boolean,Function]},classes:{type:[String,Object,Function]},styles:{type:[String,Object,Function]},options:{type:[Array,Function]},attrs:{},value:{},validators:{},maxLength:{},minLength:{},min:{},max:{},error:{}},setup(l){const o=l,n=e.inject("vuiless"),a=e.computed(()=>({v:n.value.formData[o.field],data:n.value.formData,context:n.value.formContext??{}})),s=e.computed(()=>f(o.optional,a.value)),d=e.computed(()=>f(o.disabled,a.value)),y=e.computed(()=>f(o.hidden,a.value)),g=e.computed(()=>({...a.value,entry:{field:o.field,type:o.type,component:o.component,name:o.name||o.field,disabled:d.value,optional:s.value,hidden:y.value}})),x=e.computed(()=>f(o.label,g.value)),B=e.computed(()=>f(o.description,g.value)),u=e.computed(()=>f(o.hint,g.value)),c=e.computed(()=>f(o.placeholder,g.value)),m=e.computed(()=>f(o.options,g.value)),r=e.computed(()=>{const S=f(o.classes,g.value);return typeof S=="string"?{[S]:!0,disabled:d.value,required:!s.value}:{...S||{},disabled:d.value,required:!s.value}}),i=e.computed(()=>f(o.styles,g.value)),v=e.computed(()=>$(o.attrs,g.value)),t=e.computed(()=>o.validators.map(S=>(D,b,C)=>S({v:D,data:b,context:C??{},entry:g.value.entry})));return(S,D)=>(e.openBlock(),e.createBlock(e.unref(T),{modelValue:e.unref(n).formData[o.field],"onUpdate:modelValue":D[0]||(D[0]=b=>e.unref(n).formData[o.field]=b),rules:t.value},{default:e.withCtx(b=>[e.renderSlot(S.$slots,"default",{onBlur:b.onBlur,error:l.error||b.error,model:b.model,formData:e.unref(n).formData,formContext:e.unref(n).formContext,label:x.value,description:B.value,hint:u.value,placeholder:c.value,classes:{...r.value,error:!!l.error||!!b.error},styles:i.value,optional:s.value,disabled:d.value,hidden:y.value,type:l.type,altAction:l.altAction,component:l.component,vName:l.name,field:l.field,options:m.value,maxLength:l.maxLength,required:!s.value,autocomplete:l.autocomplete,attrs:v.value})]),_:3},8,["modelValue","rules"]))}}),N={key:0},j={key:1},I={key:0},O=["onUpdate:modelValue","onBlur","placeholder","autocomplete","name","type"],U={class:"oo-error-slot"},P={key:4},H={key:5},z=["disabled"],G=e.defineComponent({__name:"oo-form",props:{form:{},formData:{},formContext:{},firstValidation:{},components:{},types:{},errors:{}},emits:["submit","action","unsupported-action"],setup(l,{emit:o}){const n=l,a=e.ref({}),s=e.computed(()=>n.formData||a.value),d=e.computed(()=>({v:void 0,data:s.value,context:n.formContext??{}})),y=e.computed(()=>f(n.form.title,d.value)),g=e.computed(()=>f(n.form.submit.text,d.value)),x=e.computed(()=>f(n.form.submit.disabled,d.value));function B(c){w(n.form,c)?u("action",c,s.value):u("unsupported-action",c,s.value)}const u=o;return(c,m)=>(e.openBlock(),e.createBlock(e.unref(M),{"first-validation":l.firstValidation,onSubmit:m[0]||(m[0]=r=>u("submit",r)),"form-data":s.value,"form-context":l.formContext},{default:e.withCtx(r=>[e.renderSlot(c.$slots,"form.header",{clearErrors:r.clearErrors,reset:r.reset,title:y.value,formContext:l.formContext,disabled:x.value},()=>[y.value?(e.openBlock(),e.createElementBlock("h2",N,e.toDisplayString(y.value),1)):e.createCommentVNode("",!0)]),e.renderSlot(c.$slots,"form.before",{clearErrors:r.clearErrors,reset:r.reset}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.form.fields,i=>{var v;return e.openBlock(),e.createBlock(A,e.mergeProps({key:i.field},{ref_for:!0},i,{error:(v=l.errors)==null?void 0:v[i.field]}),{default:e.withCtx(t=>[e.renderSlot(c.$slots,`field:${t.type}`,e.mergeProps({ref_for:!0},t),()=>{var S,D,b;return[i.component&&((S=n.components)!=null&&S[i.component])?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.components[i.component]),e.mergeProps({key:0,"on-blur":t.onBlur,error:t.error,model:t.model,"form-data":t.formData,"form-context":t.formContext,label:t.label,description:t.description,hint:t.hint,placeholder:t.placeholder,class:t.classes,style:t.styles,optional:t.optional,required:!t.required,disabled:t.disabled,hidden:t.hidden,type:t.type,"alt-action":t.altAction,name:t.vName,field:t,options:t.options,"max-length":t.maxLength,autocomplete:t.autocomplete,onAction:B},{ref_for:!0},t.attrs,{modelValue:t.model.value,"onUpdate:modelValue":C=>t.model.value=C}),null,16,["on-blur","error","model","form-data","form-context","label","description","hint","placeholder","class","style","optional","required","disabled","hidden","type","alt-action","name","field","options","max-length","autocomplete","modelValue","onUpdate:modelValue"])):i.component&&!((D=n.components)!=null&&D[i.component])?(e.openBlock(),e.createElementBlock("div",j," ["+e.toDisplayString(t.label)+'] Component "'+e.toDisplayString(t.component)+'" not supplied ',1)):(b=n.types)!=null&&b[i.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.types[i.type]),e.mergeProps({key:2,"on-blur":t.onBlur,error:t.error,model:t.model,"form-data":t.formData,"form-context":t.formContext,label:t.label,description:t.description,hint:t.hint,placeholder:t.placeholder,class:t.classes,style:t.styles,optional:t.optional,required:!t.required,disabled:t.disabled,hidden:t.hidden,type:t.type,"alt-action":t.altAction,name:t.vName,field:t,options:t.options,"max-length":t.maxLength,autocomplete:t.autocomplete,onAction:B},{ref_for:!0},t.attrs,{modelValue:t.model.value,"onUpdate:modelValue":C=>t.model.value=C}),null,16,["on-blur","error","model","form-data","form-context","label","description","hint","placeholder","class","style","optional","required","disabled","hidden","type","alt-action","name","field","options","max-length","autocomplete","modelValue","onUpdate:modelValue"])):["text","password","number"].includes(t.type)?(e.openBlock(),e.createElementBlock("div",{key:3,class:e.normalizeClass(["oo-default-field",t.classes])},[e.createElementVNode("label",null,e.toDisplayString(t.label),1),t.description?(e.openBlock(),e.createElementBlock("span",I,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":C=>t.model.value=C,onBlur:t.onBlur,placeholder:t.placeholder,autocomplete:t.autocomplete,name:t.vName,type:t.type},null,40,O),[[e.vModelDynamic,t.model.value]]),e.createElementVNode("div",U,e.toDisplayString(t.error||t.hint),1)],2)):t.type==="paragraph"?(e.openBlock(),e.createElementBlock("p",P,e.toDisplayString(t.description),1)):(e.openBlock(),e.createElementBlock("div",H," ["+e.toDisplayString(t.label)+'] Not supported field type "'+e.toDisplayString(t.type)+'" '+e.toDisplayString(t.component),1))]})]),_:2},1040,["error"])}),128)),e.renderSlot(c.$slots,"form.after",{clearErrors:r.clearErrors,reset:r.reset,disabled:x.value,formContext:l.formContext}),e.renderSlot(c.$slots,"form.submit",{disabled:x.value,text:g.value,clearErrors:r.clearErrors,reset:r.reset,formContext:l.formContext},()=>[e.createElementVNode("button",{disabled:x.value},e.toDisplayString(g.value),9,z)]),e.renderSlot(c.$slots,"form.footer",{disabled:x.value,clearErrors:r.clearErrors,reset:r.reset,formContext:l.formContext})]),_:3},8,["first-validation","form-data","form-context"]))}}),X={global:null,process:null,Buffer:null,require:null,__filename:null,__dirname:null,exports:null,module:null,setImmediate:null,clearImmediate:null,setTimeout:null,clearTimeout:null,setInterval:null,clearInterval:null,queueMicrotask:null,queueGlobalMicrotask:null,globalThis:null,window:null,self:null,document:null,localStorage:null,sessionStorage:null,indexedDB:null,caches:null,console:null,performance:null,fetch:null,XMLHttpRequest:null,Image:null,Audio:null,navigator:null,navigation:null,location:null,history:null,screen:null,requestAnimationFrame:null,cancelAnimationFrame:null,cancelIdleCallback:null,captureEvents:null,chrome:null,clientInformation:null,addEventListener:null,removeEventListener:null,blur:null,close:null,closed:null,confirm:null,alert:null,customElements:null,dispatchEvent:null,debug:null,focus:null,find:null,frames:null,getSelection:null,getScreenDetails:null,getEventListeners:null,keys:null,launchQueue:null,parent:null,postMessage:null,print:null,profile:null,profileEnd:null,prompt:null,queryLocalFonts:null,queryObjects:null,releaseEvents:null,reportError:null,resizeBy:null,resizeTo:null,scheduler:null,stop:null,scroll:null,scrollBy:null,scrollTo:null,scrollY:null,scrollX:null,top:null,eval:null,__ctx__:null};class Q{constructor(){L(this,"cache",new Map)}call(o,n){return this.getFn(o)(n)}getFn(o){let n=this.cache.get(o);return n||(n=R(o),this.cache.set(o,n)),n}}function R(l){const o=`with(__ctx__){
2
- ${l}
3
- }`,n=new Function("__ctx__",o);return a=>{const s=Object.freeze(Object.assign({},X,a));return n(s)}}const _=new Q;function k(l){const o=`return (${l})(v, data, context, entry)`;return _.getFn(o)}function F(l){const o=`return (${l})(data, context)`;return _.getFn(o)}function W(l){const o=`return (${l})(v, data, context)`;return _.getFn(o)}function V(l,o,n,a,s){const d=n.get(o);if(typeof d=="string")return a(d);const y=n.get(l);return y!==void 0?y:s}function Y(l){var o,n,a;const s=l.metadata,d=l.type.props,y=V("foorm.title","foorm.fn.title",s,F,""),g=V("foorm.submit.text","foorm.fn.submit.text",s,F,"Submit"),x=(()=>{const c=s.get("foorm.fn.submit.disabled");return typeof c=="string"?F(c):!1})(),B={text:g,disabled:x},u=[];for(const[c,m]of d.entries()){const r=m.metadata,i=(o=m.type)===null||o===void 0?void 0:o.tags,v=r.get("foorm.type"),t=(n=i==null?void 0:i.has("action"))!==null&&n!==void 0?n:!1,S=(a=i==null?void 0:i.has("paragraph"))!==null&&a!==void 0?a:!1,D=v??(t?"action":S?"paragraph":"text"),b=[],C=r.get("foorm.validate");if(C){const p=Array.isArray(C)?C:[C];for(const E of p)typeof E=="string"&&b.push(W(E))}const K={field:c,type:D,component:r.get("foorm.component"),autocomplete:r.get("foorm.autocomplete"),altAction:r.get("foorm.altAction"),order:r.get("foorm.order"),name:c,label:V("meta.label","foorm.fn.label",r,k,c),description:V("meta.description","foorm.fn.description",r,k,""),hint:V("meta.hint","foorm.fn.hint",r,k,""),placeholder:V("meta.placeholder","foorm.fn.placeholder",r,k,""),optional:(()=>{var p;const E=r.get("foorm.fn.optional");return typeof E=="string"?k(E):(p=m.optional)!==null&&p!==void 0?p:!1})(),disabled:(()=>{const p=r.get("foorm.fn.disabled");return typeof p=="string"?k(p):r.get("foorm.disabled")!==void 0})(),hidden:(()=>{const p=r.get("foorm.fn.hidden");return typeof p=="string"?k(p):r.get("foorm.hidden")!==void 0})(),classes:(()=>{const p=r.get("foorm.fn.classes");if(typeof p=="string")return k(p)})(),styles:(()=>{const p=r.get("foorm.fn.styles");if(typeof p=="string")return k(p)})(),options:(()=>{const p=r.get("foorm.fn.options");if(typeof p=="string")return k(p)})(),value:r.get("foorm.value"),validators:b,maxLength:r.get("expect.maxLength"),minLength:r.get("expect.minLength"),min:r.get("expect.min"),max:r.get("expect.max")};u.push(K)}return u.sort((c,m)=>{var r,i;return((r=c.order)!==null&&r!==void 0?r:1/0)-((i=m.order)!==null&&i!==void 0?i:1/0)}),{title:y,submit:B,fields:u}}function J(l){const o=Y(l),n=e.reactive(q(o.fields));return{form:o,formData:n}}h.OoField=A,h.OoForm=G,h.useFoorm=J,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
1
+ (function(k,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(k=typeof globalThis<"u"?globalThis:k||self,e(k.index={},k.Vue))})(this,function(k,e){"use strict";var we=Object.defineProperty;var Ae=(k,e,V)=>e in k?we(k,e,{enumerable:!0,configurable:!0,writable:!0,value:V}):k[e]=V;var v=(k,e,V)=>Ae(k,typeof e!="symbol"?e+"":e,V);function V(n,t){return typeof n=="function"?n(t):n}const O=new Set(["action","paragraph"]);function U(n){var t;const o={};for(const s of n)if(!O.has(s.type)){const a={v:void 0,data:o,context:{},entry:{field:s.field,type:s.type,component:s.component,name:s.name||s.field}};o[s.field]=(t=V(s.value,a))!==null&&t!==void 0?t:void 0}return o}function q(n,t){return n.fields.some(o=>o.altAction===t)}function M(n,t){if(!n)return;const o={};for(const[s,a]of Object.entries(n))o[s]=V(a,t);return o}const I=e.defineComponent({__name:"VuilessField",props:e.mergeModels({rules:{}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const t=n,o=e.useModel(n,"modelValue"),s=e.inject("vuiless"),a=e.ref(),l=e.ref(!1),i=e.ref(!1),d=e.computed(()=>{var p;if((p=s==null?void 0:s.value)!=null&&p.firstValidation)switch(s.value.firstValidation){case"on-change":return s.value.firstSubmitHappened||l.value;case"touched-on-blur":return s.value.firstSubmitHappened||i.value&&l.value;case"on-blur":return s.value.firstSubmitHappened||i.value;case"on-submit":return s.value.firstSubmitHappened;case"none":return!1}return!1}),f=e.computed(()=>{if(d.value||a.value)return u()});e.watch([o],()=>{a.value=void 0,l.value=!0}),e.onUnmounted(()=>{var p;(p=s==null?void 0:s.value)==null||p.unregister(e.getCurrentInstance())}),s!=null&&s.value&&s.value.register(e.getCurrentInstance(),{validate:()=>(a.value=u(),a.value||!0),clearErrors:()=>{l.value=!1,i.value=!1,a.value=void 0},reset:()=>{o.value=""}});function u(){var p,m,S;if((p=t.rules)!=null&&p.length)for(const g of t.rules){const x=g(o.value,(m=s==null?void 0:s.value)==null?void 0:m.formData,(S=s==null?void 0:s.value)==null?void 0:S.formContext);if(x!==!0)return x||"Wrong value"}}function h(){i.value=!0}const y={v:e.computed({get:()=>o.value,set:p=>o.value=p})};return(p,m)=>{var S,g;return e.renderSlot(p.$slots,"default",{onBlur:h,error:f.value,formData:(S=e.unref(s))==null?void 0:S.formData,formContext:(g=e.unref(s))==null?void 0:g.formContext,model:y.v})}}}),z=e.defineComponent({__name:"VuilessForm",props:{formData:{},formContext:{},firstValidation:{default:"on-change"}},emits:["submit"],setup(n,{emit:t}){const o=n,s=t,a=new Map,l=e.ref(!1),i=e.computed(()=>({firstSubmitHappened:l.value,firstValidation:o.firstValidation,register:(h,y)=>{a.set(h,y)},unregister:h=>a.delete(h),formData:o.formData,formContext:o.formContext}));e.provide("vuiless",i);function d(){l.value=!1;for(const{clearErrors:h}of a.values())h()}async function f(){for(const{reset:h}of a.values())h();await e.nextTick(),d()}function u(){l.value=!0;let h=!1;if(o.firstValidation!=="none")for(const{validate:y}of a.values())y()!==!0&&(h=!0);h||s("submit",o.formData)}return(h,y)=>(e.openBlock(),e.createElementBlock("form",{onSubmit:e.withModifiers(u,["prevent"])},[e.renderSlot(h.$slots,"default",{clearErrors:d,reset:f})],32))}}),F=e.defineComponent({__name:"oo-field",props:{field:{},type:{},component:{},autocomplete:{},altAction:{},order:{},name:{},label:{type:[String,Function]},description:{type:[String,Function]},hint:{type:[String,Function]},placeholder:{type:[String,Function]},optional:{type:[Boolean,Function]},disabled:{type:[Boolean,Function]},hidden:{type:[Boolean,Function]},readonly:{type:[Boolean,Function]},classes:{type:[String,Object,Function]},styles:{type:[String,Object,Function]},options:{type:[Array,Function]},attrs:{},value:{type:Function},validators:{},maxLength:{},minLength:{},min:{},max:{},error:{}},setup(n){const t=n,o=e.inject("vuiless");function s(c,b,B){return typeof c=="function"?e.computed(()=>c(b.value)):c??B}const a=c=>typeof c=="object"&&c!==null&&"value"in c?c.value:c,l=e.computed(()=>({v:o.value.formData[t.field],data:o.value.formData,context:o.value.formContext??{},entry:void 0})),i=s(t.optional,l,!1),d=s(t.disabled,l,!1),f=s(t.hidden,l,!1),u=s(t.readonly,l,!1),h=e.computed(()=>!a(i)),y=e.computed(()=>({v:o.value.formData[t.field],data:o.value.formData,context:o.value.formContext??{},entry:{field:t.field,type:t.type,component:t.component,name:t.name||t.field,optional:a(i),disabled:a(d),hidden:a(f),readonly:a(u)}})),p=s(t.label,y,void 0),m=s(t.description,y,void 0),S=s(t.hint,y,void 0),g=s(t.placeholder,y,void 0),x=s(t.options,y,void 0),_=s(t.styles,y,void 0),r=e.computed(()=>{const c=typeof t.classes=="function"?t.classes(y.value):t.classes;return typeof c=="string"?{[c]:!0,disabled:a(d),required:!a(i)}:{...c,disabled:a(d),required:!a(i)}});function C(c,b){return{...r.value,error:!!c||!!b}}const $=e.computed(()=>M(t.attrs,y.value));if(typeof t.value=="function"){const c=e.computed(()=>{if(a(u))return t.value(y.value)});e.watch(c,b=>{b!==void 0&&a(u)&&(o.value.formData[t.field]=b)},{immediate:!0})}const w=t.validators.map(c=>(b,B,P)=>c({v:b,data:B,context:P??{},entry:y.value.entry}));return(c,b)=>(e.openBlock(),e.createBlock(e.unref(I),{modelValue:e.unref(o).formData[t.field],"onUpdate:modelValue":b[0]||(b[0]=B=>e.unref(o).formData[t.field]=B),rules:e.unref(w)},{default:e.withCtx(B=>[e.renderSlot(c.$slots,"default",{onBlur:B.onBlur,error:n.error||B.error,model:B.model,formData:e.unref(o).formData,formContext:e.unref(o).formContext,label:e.unref(p),description:e.unref(m),hint:e.unref(S),placeholder:e.unref(g),classes:C(n.error,B.error),styles:e.unref(_),optional:e.unref(i),disabled:e.unref(d),hidden:e.unref(f),readonly:e.unref(u),type:n.type,altAction:n.altAction,component:n.component,vName:n.name,field:n.field,options:e.unref(x),maxLength:n.maxLength,required:h.value,autocomplete:n.autocomplete,attrs:$.value})]),_:3},8,["modelValue","rules"]))}}),H={key:0},R={key:1},G={key:0},K=["onUpdate:modelValue","onBlur","placeholder","autocomplete","name","type","disabled","readonly"],W={class:"oo-error-slot"},X={key:4},Y={key:0},Q=["onUpdate:modelValue","onBlur","name","disabled","readonly"],J={key:0,value:"",disabled:""},Z=["value"],ee={class:"oo-error-slot"},te={class:"oo-field-label"},oe={key:0},ne={class:"oo-radio-group"},re=["value","onUpdate:modelValue","onBlur","name","disabled","readonly"],se={class:"oo-error-slot"},ae=["onUpdate:modelValue","onBlur","name","disabled","readonly"],le={key:0},ie={class:"oo-error-slot"},ce=["onClick"],pe={key:9},de=["disabled"],ue=e.defineComponent({__name:"oo-form",props:{form:{},formData:{},formContext:{},firstValidation:{},components:{},types:{},errors:{}},emits:["submit","action","unsupported-action"],setup(n,{emit:t}){const o=n,s=e.ref({}),a=e.computed(()=>o.formData||s.value),l=e.computed(()=>({v:void 0,data:a.value,context:o.formContext??{},entry:void 0})),i=e.computed(()=>V(o.form.title,l.value)),d=e.computed(()=>V(o.form.submit.text,l.value)),f=e.computed(()=>V(o.form.submit.disabled,l.value));function u(m){q(o.form,m)?h("action",m,a.value):h("unsupported-action",m,a.value)}const h=t;function y(m){return typeof m=="string"?m:m.key}function p(m){return typeof m=="string"?m:m.label}return(m,S)=>(e.openBlock(),e.createBlock(e.unref(z),{"first-validation":n.firstValidation,onSubmit:S[0]||(S[0]=g=>h("submit",g)),"form-data":a.value,"form-context":n.formContext},{default:e.withCtx(g=>[e.renderSlot(m.$slots,"form.header",{clearErrors:g.clearErrors,reset:g.reset,title:i.value,formContext:n.formContext,disabled:f.value},()=>[i.value?(e.openBlock(),e.createElementBlock("h2",H,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)]),e.renderSlot(m.$slots,"form.before",{clearErrors:g.clearErrors,reset:g.reset}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.form.fields,x=>{var _;return e.openBlock(),e.createBlock(F,e.mergeProps({key:x.field},{ref_for:!0},x,{error:(_=n.errors)==null?void 0:_[x.field]}),{default:e.withCtx(r=>[e.renderSlot(m.$slots,`field:${r.type}`,e.mergeProps({ref_for:!0},r),()=>{var C,$,w;return[x.component&&((C=o.components)!=null&&C[x.component])?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.components[x.component]),e.mergeProps({key:0,"on-blur":r.onBlur,error:r.error,model:r.model,"form-data":r.formData,"form-context":r.formContext,label:r.label,description:r.description,hint:r.hint,placeholder:r.placeholder,class:r.classes,style:r.styles,optional:r.optional,required:!r.required,disabled:r.disabled,hidden:r.hidden,type:r.type,"alt-action":r.altAction,name:r.vName,field:r,options:r.options,"max-length":r.maxLength,autocomplete:r.autocomplete,onAction:u},{ref_for:!0},r.attrs,{modelValue:r.model.value,"onUpdate:modelValue":c=>r.model.value=c}),null,16,["on-blur","error","model","form-data","form-context","label","description","hint","placeholder","class","style","optional","required","disabled","hidden","type","alt-action","name","field","options","max-length","autocomplete","modelValue","onUpdate:modelValue"])):x.component&&!(($=o.components)!=null&&$[x.component])?(e.openBlock(),e.createElementBlock("div",R," ["+e.toDisplayString(r.label)+'] Component "'+e.toDisplayString(r.component)+'" not supplied ',1)):(w=o.types)!=null&&w[x.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.types[x.type]),e.mergeProps({key:2,"on-blur":r.onBlur,error:r.error,model:r.model,"form-data":r.formData,"form-context":r.formContext,label:r.label,description:r.description,hint:r.hint,placeholder:r.placeholder,class:r.classes,style:r.styles,optional:r.optional,required:!r.required,disabled:r.disabled,hidden:r.hidden,type:r.type,"alt-action":r.altAction,name:r.vName,field:r,options:r.options,"max-length":r.maxLength,autocomplete:r.autocomplete,onAction:u},{ref_for:!0},r.attrs,{modelValue:r.model.value,"onUpdate:modelValue":c=>r.model.value=c}),null,16,["on-blur","error","model","form-data","form-context","label","description","hint","placeholder","class","style","optional","required","disabled","hidden","type","alt-action","name","field","options","max-length","autocomplete","modelValue","onUpdate:modelValue"])):["text","password","number"].includes(r.type)?e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:3,class:e.normalizeClass(["oo-default-field",r.classes])},[e.createElementVNode("label",null,e.toDisplayString(r.label),1),r.description?(e.openBlock(),e.createElementBlock("span",G,e.toDisplayString(r.description),1)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({"onUpdate:modelValue":c=>r.model.value=c,onBlur:r.onBlur,placeholder:r.placeholder,autocomplete:r.autocomplete,name:r.vName,type:r.type,disabled:r.disabled,readonly:r.readonly},{ref_for:!0},r.attrs),null,16,K),[[e.vModelDynamic,r.model.value]]),e.createElementVNode("div",W,e.toDisplayString(r.error||r.hint),1)],2)),[[e.vShow,!r.hidden]]):r.type==="paragraph"?(e.openBlock(),e.createElementBlock("p",X,e.toDisplayString(r.description),1)):r.type==="select"?e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:5,class:e.normalizeClass(["oo-default-field",r.classes])},[e.createElementVNode("label",null,e.toDisplayString(r.label),1),r.description?(e.openBlock(),e.createElementBlock("span",Y,e.toDisplayString(r.description),1)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("select",e.mergeProps({"onUpdate:modelValue":c=>r.model.value=c,onBlur:r.onBlur,name:r.vName,disabled:r.disabled,readonly:r.readonly},{ref_for:!0},r.attrs),[r.placeholder?(e.openBlock(),e.createElementBlock("option",J,e.toDisplayString(r.placeholder),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.options,c=>(e.openBlock(),e.createElementBlock("option",{key:y(c),value:y(c)},e.toDisplayString(p(c)),9,Z))),128))],16,Q),[[e.vModelSelect,r.model.value]]),e.createElementVNode("div",ee,e.toDisplayString(r.error||r.hint),1)],2)),[[e.vShow,!r.hidden]]):r.type==="radio"?e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:6,class:e.normalizeClass(["oo-default-field oo-radio-field",r.classes])},[e.createElementVNode("span",te,e.toDisplayString(r.label),1),r.description?(e.openBlock(),e.createElementBlock("span",oe,e.toDisplayString(r.description),1)):e.createCommentVNode("",!0),e.createElementVNode("div",ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.options,c=>(e.openBlock(),e.createElementBlock("label",{key:y(c)},[e.withDirectives(e.createElementVNode("input",e.mergeProps({type:"radio",value:y(c),"onUpdate:modelValue":b=>r.model.value=b,onBlur:r.onBlur,name:r.vName,disabled:r.disabled,readonly:r.readonly},{ref_for:!0},r.attrs),null,16,re),[[e.vModelRadio,r.model.value]]),e.createTextVNode(" "+e.toDisplayString(p(c)),1)]))),128))]),e.createElementVNode("div",se,e.toDisplayString(r.error||r.hint),1)],2)),[[e.vShow,!r.hidden]]):r.type==="checkbox"?e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:7,class:e.normalizeClass(["oo-default-field oo-checkbox-field",r.classes])},[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",e.mergeProps({type:"checkbox","onUpdate:modelValue":c=>r.model.value=c,onBlur:r.onBlur,name:r.vName,disabled:r.disabled,readonly:r.readonly},{ref_for:!0},r.attrs),null,16,ae),[[e.vModelCheckbox,r.model.value]]),e.createTextVNode(" "+e.toDisplayString(r.label),1)]),r.description?(e.openBlock(),e.createElementBlock("span",le,e.toDisplayString(r.description),1)):e.createCommentVNode("",!0),e.createElementVNode("div",ie,e.toDisplayString(r.error||r.hint),1)],2)),[[e.vShow,!r.hidden]]):r.type==="action"?(e.openBlock(),e.createElementBlock("div",{key:8,class:e.normalizeClass(["oo-default-field oo-action-field",r.classes])},[e.createElementVNode("button",{type:"button",onClick:c=>u(r.altAction)},e.toDisplayString(r.label),9,ce)],2)):(e.openBlock(),e.createElementBlock("div",pe," ["+e.toDisplayString(r.label)+'] Not supported field type "'+e.toDisplayString(r.type)+'" '+e.toDisplayString(r.component),1))]})]),_:2},1040,["error"])}),128)),e.renderSlot(m.$slots,"form.after",{clearErrors:g.clearErrors,reset:g.reset,disabled:f.value,formContext:n.formContext}),e.renderSlot(m.$slots,"form.submit",{disabled:f.value,text:d.value,clearErrors:g.clearErrors,reset:g.reset,formContext:n.formContext},()=>[e.createElementVNode("button",{disabled:f.value},e.toDisplayString(d.value),9,de)]),e.renderSlot(m.$slots,"form.footer",{disabled:f.value,clearErrors:g.clearErrors,reset:g.reset,formContext:n.formContext})]),_:3},8,["first-validation","form-data","form-context"]))}}),me={global:null,process:null,Buffer:null,require:null,__filename:null,__dirname:null,exports:null,module:null,setImmediate:null,clearImmediate:null,setTimeout:null,clearTimeout:null,setInterval:null,clearInterval:null,queueMicrotask:null,queueGlobalMicrotask:null,globalThis:null,window:null,self:null,document:null,localStorage:null,sessionStorage:null,indexedDB:null,caches:null,console:null,performance:null,fetch:null,XMLHttpRequest:null,Image:null,Audio:null,navigator:null,navigation:null,location:null,history:null,screen:null,requestAnimationFrame:null,cancelAnimationFrame:null,cancelIdleCallback:null,captureEvents:null,chrome:null,clientInformation:null,addEventListener:null,removeEventListener:null,blur:null,close:null,closed:null,confirm:null,alert:null,customElements:null,dispatchEvent:null,debug:null,focus:null,find:null,frames:null,getSelection:null,getScreenDetails:null,getEventListeners:null,keys:null,launchQueue:null,parent:null,postMessage:null,print:null,profile:null,profileEnd:null,prompt:null,queryLocalFonts:null,queryObjects:null,releaseEvents:null,reportError:null,resizeBy:null,resizeTo:null,scheduler:null,stop:null,scroll:null,scrollBy:null,scrollTo:null,scrollY:null,scrollX:null,top:null,eval:null,__ctx__:null};class fe{constructor(){v(this,"cache",new Map)}call(t,o){return this.getFn(t)(o)}getFn(t){let o=this.cache.get(t);return o||(o=he(t),this.cache.set(t,o)),o}}function he(n){const t=`with(__ctx__){
2
+ ${n}
3
+ }`,o=new Function("__ctx__",t);return s=>{const a=Object.freeze(Object.assign({},me,s));return o(a)}}const A=new fe;function N(n){const t=`return (${n})(v, data, context, entry)`;return A.getFn(t)}function T(n){const t=`return (${n})(data, context)`;return A.getFn(t)}function ye(n){const t=`return (${n})(v, data, context, entry)`;return A.getFn(t)}function ge(n,t){switch(n.type.kind){case"":{const o=n;return t.phantom&&o.type.designType==="phantom"?t.phantom(o):t.final(o)}case"object":return t.object(n);case"array":return t.array(n);case"union":return t.union(n);case"intersection":return t.intersection(n);case"tuple":return t.tuple(n);default:throw new Error(`Unknown type kind "${n.type.kind}"`)}}function D(n,t,o){return t in n?Object.defineProperty(n,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[t]=o,n}const j=new Map;var be=class{isLimitExceeded(){return this.stackErrors.length>0?this.stackErrors[this.stackErrors.length-1].length>=this.opts.errorLimit:this.errors.length>=this.opts.errorLimit}push(n){this.stackPath.push(n),this.stackErrors.push([])}pop(n){this.stackPath.pop();const t=this.stackErrors.pop();return n&&(t!=null&&t.length)&&t.forEach(o=>{this.error(o.message,o.path,o.details)}),t}clear(){this.stackErrors[this.stackErrors.length-1]=[]}error(n,t,o){const s=this.stackErrors[this.stackErrors.length-1]||this.errors,a={path:t||this.path,message:n};o!=null&&o.length&&(a.details=o),s.push(a)}throw(){throw new xe(this.errors)}validate(n,t){this.push(""),this.errors=[],this.stackErrors=[];const o=this.validateSafe(this.def,n);if(this.pop(!o),!o){if(t)return!1;this.throw()}return!0}validateSafe(n,t){if(this.isLimitExceeded())return!1;if(!ke(n))throw new Error("Can not validate not-annotated type");if(typeof this.opts.replace=="function"&&(n=this.opts.replace(n,this.path)),n.optional&&t===void 0)return!0;for(const o of this.opts.plugins){const s=o(this,n,t);if(s===!1||s===!0)return s}return this.validateAnnotatedType(n,t)}get path(){return this.stackPath.slice(1).join(".")}validateAnnotatedType(n,t){return ge(n,{final:o=>this.validatePrimitive(o,t),phantom:()=>!0,object:o=>this.validateObject(o,t),array:o=>this.validateArray(o,t),union:o=>this.validateUnion(o,t),intersection:o=>this.validateIntersection(o,t),tuple:o=>this.validateTuple(o,t)})}validateUnion(n,t){let o=0;const s=[];for(const l of n.type.items){if(this.push(`[${l.type.kind||l.type.designType}(${o})]`),this.validateSafe(l,t))return this.pop(!1),!0;const i=this.pop(!1);i&&s.push(...i),o++}this.clear();const a=n.type.items.map((l,i)=>`[${l.type.kind||l.type.designType}(${i})]`).join(", ");return this.error(`Value does not match any of the allowed types: ${a}`,void 0,s),!1}validateIntersection(n,t){for(const o of n.type.items)if(!this.validateSafe(o,t))return!1;return!0}validateTuple(n,t){if(!Array.isArray(t)||t.length!==n.type.items.length)return this.error(`Expected array of length ${n.type.items.length}`),!1;let o=0;for(const s of n.type.items){if(this.push(`[${o}]`),!this.validateSafe(s,t[o]))return this.pop(!0),!1;this.pop(!1),o++}return!0}validateArray(n,t){if(!Array.isArray(t))return this.error("Expected array"),!1;const o=n.metadata.get("expect.minLength");if(o){const i=typeof o=="number"?o:o.length;if(t.length<i){const d=typeof o=="object"&&o.message?o.message:`Expected minimum length of ${i} items, got ${t.length} items`;return this.error(d),!1}}const s=n.metadata.get("expect.maxLength");if(s){const i=typeof s=="number"?s:s.length;if(t.length>i){const d=typeof s=="object"&&s.message?s.message:`Expected maximum length of ${i} items, got ${t.length} items`;return this.error(d),!1}}let a=0,l=!0;for(const i of t){if(this.push(`[${a}]`),this.validateSafe(n.type.of,i))this.pop(!1);else if(l=!1,this.pop(!0),this.isLimitExceeded())return!1;a++}return l}validateObject(n,t){if(typeof t!="object"||t===null||Array.isArray(t))return this.error("Expected object"),!1;let o=!0;const s=new Set(Object.keys(t)),a=new Set,l=new Set;if(this.opts.skipList){const d=this.stackPath.length>1?`${this.path}.`:"";this.opts.skipList.forEach(f=>{if(f.startsWith(d)){const u=f.slice(d.length);l.add(u),s.delete(u)}})}let i=!1;typeof this.opts.partial=="function"&&(i=this.opts.partial(n,this.path));for(const[d,f]of n.type.props.entries())if(!(l.has(d)||Ee(f))&&(a.add(d),!(t[d]===void 0&&(i||this.opts.partial==="deep"||this.opts.partial===!0&&this.stackPath.length<=1)))){if(this.push(d),this.validateSafe(f,t[d]))this.pop(!1);else if(o=!1,this.pop(!0),this.isLimitExceeded())return!1}for(const d of s)if(!a.has(d)){const f=[];for(const{pattern:u,def:h}of n.type.propsPatterns)u.test(d)&&f.push({pattern:u,def:h});if(f.length){let u=!1;for(const{def:h}of f)if(this.validateSafe(h,t[d])){this.pop(!1),u=!0;break}if(!u&&(this.push(d),this.validateSafe(f[0].def,t[d]),this.pop(!0),o=!1,this.isLimitExceeded()))return!1}else if(this.opts.unknwonProps!=="ignore")if(this.opts.unknwonProps==="error"){if(this.push(d),this.error("Unexpected property"),this.pop(!0),this.isLimitExceeded())return!1;o=!1}else this.opts.unknwonProps==="strip"&&delete t[d]}return o}validatePrimitive(n,t){if(typeof n.type.value<"u")return t!==n.type.value?(this.error(`Expected ${n.type.value}, got ${t}`),!1):!0;const o=Array.isArray(t)?"array":typeof t;switch(n.type.designType){case"never":return this.error("This type is impossible, must be an internal problem"),!1;case"any":return!0;case"string":return o!==n.type.designType?(this.error(`Expected ${n.type.designType}, got ${o}`),!1):this.validateString(n,t);case"number":return o!==n.type.designType?(this.error(`Expected ${n.type.designType}, got ${o}`),!1):this.validateNumber(n,t);case"boolean":return o!==n.type.designType?(this.error(`Expected ${n.type.designType}, got ${o}`),!1):!0;case"undefined":return t!==void 0?(this.error(`Expected ${n.type.designType}, got ${o}`),!1):!0;case"null":return t!==null?(this.error(`Expected ${n.type.designType}, got ${o}`),!1):!0;default:throw new Error(`Unknown type "${n.type.designType}"`)}}validateString(n,t){const o=n.metadata.get("expect.minLength");if(o){const l=typeof o=="number"?o:o.length;if(t.length<l){const i=typeof o=="object"&&o.message?o.message:`Expected minimum length of ${l} characters, got ${t.length} characters`;return this.error(i),!1}}const s=n.metadata.get("expect.maxLength");if(s){const l=typeof s=="number"?s:s.length;if(t.length>l){const i=typeof s=="object"&&s.message?s.message:`Expected maximum length of ${l} characters, got ${t.length} characters`;return this.error(i),!1}}const a=n.metadata.get("expect.pattern");for(const{pattern:l,flags:i,message:d}of a||[]){if(!l)continue;const f=`${l}//${i||""}`;let u=j.get(f);if(u||(u=new RegExp(l,i),j.set(f,u)),!u.test(t))return this.error(d||`Value is expected to match pattern "${l}"`),!1}return!0}validateNumber(n,t){const o=n.metadata.get("expect.int");if(o&&t%1!==0){const l=typeof o=="object"&&o.message?o.message:`Expected integer, got ${t}`;return this.error(l),!1}const s=n.metadata.get("expect.min");if(s){const l=typeof s=="number"?s:s.minValue;if(t<l){const i=typeof s=="object"&&s.message?s.message:`Expected minimum ${l}, got ${t}`;return this.error(i),!1}}const a=n.metadata.get("expect.max");if(a){const l=typeof a=="number"?a:a.maxValue;if(t>l){const i=typeof a=="object"&&a.message?a.message:`Expected maximum ${l}, got ${t}`;return this.error(i),!1}}return!0}constructor(n,t){D(this,"def",void 0),D(this,"opts",void 0),D(this,"errors",void 0),D(this,"stackErrors",void 0),D(this,"stackPath",void 0),this.def=n,this.errors=[],this.stackErrors=[],this.stackPath=[],this.opts={partial:!1,unknwonProps:"error",errorLimit:10,...t,plugins:(t==null?void 0:t.plugins)||[]}}},xe=class extends Error{constructor(n){super(`${n[0].path?n[0].path+": ":""}${n[0].message}`),D(this,"errors",void 0),D(this,"name",void 0),this.errors=n,this.name="Validation Error"}};function ke(n){return n&&n.__is_atscript_annotated_type}function Ee(n){return n.type.kind===""&&n.type.designType==="phantom"}const Se=new Set(["action","paragraph","select","radio","checkbox"]);function Be(n){return(Array.isArray(n)?n:[n]).map(o=>{if(typeof o=="object"&&o!==null&&"label"in o){const{label:s,value:a}=o;return a!==void 0?{key:a,label:s}:s}return String(o)})}function E(n,t,o,s){const{transform:a,defaultValue:l,staticAsBoolean:i=!1,compiler:d=N}=s??{},f=o.get(n);if(typeof f=="string")return d(f);if(t!==void 0){const u=o.get(t);if(u!==void 0)return i?!0:a?a(u):u}return l}function Ve(n,t){var o,s,a,l;return{optional:(o=E("foorm.fn.optional",void 0,n))!==null&&o!==void 0?o:t??!1,disabled:(s=E("foorm.fn.disabled","foorm.disabled",n,{staticAsBoolean:!0}))!==null&&s!==void 0?s:!1,hidden:(a=E("foorm.fn.hidden","foorm.hidden",n,{staticAsBoolean:!0}))!==null&&a!==void 0?a:!1,readonly:(l=E("foorm.fn.readonly","foorm.readonly",n,{staticAsBoolean:!0}))!==null&&l!==void 0?l:!1}}function _e(n,t){return{label:E("foorm.fn.label","meta.label",n,{defaultValue:t}),description:E("foorm.fn.description","meta.description",n),hint:E("foorm.fn.hint","meta.hint",n),placeholder:E("foorm.fn.placeholder","meta.placeholder",n)}}function De(n){const t=n.get("foorm.attr"),o=n.get("foorm.fn.attr");if(!t&&!o)return;const s={};if(t){const a=Array.isArray(t)?t:[t];for(const l of a)if(typeof l=="object"&&l!==null&&"name"in l&&"value"in l){const{name:i,value:d}=l;s[i]=d}}if(o){const a=Array.isArray(o)?o:[o];for(const l of a)if(typeof l=="object"&&l!==null&&"name"in l&&"fn"in l){const{name:i,fn:d}=l;s[i]=N(d)}}return Object.keys(s).length>0?s:void 0}function Ce(n){var t,o;const s=n.metadata,a=n.type.props,l=E("foorm.fn.title","foorm.title",s,{compiler:T,defaultValue:""}),i=E("foorm.fn.submit.text","foorm.submit.text",s,{compiler:T,defaultValue:"Submit"}),d=E("foorm.fn.submit.disabled","foorm.submit.disabled",s,{compiler:T,defaultValue:!1}),f={text:i,disabled:d},u=[];for(const[h,y]of a.entries()){const p=y.metadata,m=(t=y.type)===null||t===void 0?void 0:t.tags,S=p.get("foorm.type"),g=m?[...m].find(c=>Se.has(c)):void 0,x=(o=S??g)!==null&&o!==void 0?o:"text",_=[],r=p.get("foorm.validate");if(r){const c=Array.isArray(r)?r:[r];for(const b of c)typeof b=="string"&&_.push(ye(b))}const C=p.get("expect.pattern")!==void 0||p.get("expect.min")!==void 0||p.get("expect.max")!==void 0||p.get("expect.minLength")!==void 0||p.get("expect.maxLength")!==void 0||p.get("expect.int")!==void 0,$=m&&m.size>0;if(C||$){const c=new be(y);_.push(b=>{var B;if(c.validate(b.v,!0))return!0;const L=(B=c.errors)===null||B===void 0?void 0:B[0];return(L==null?void 0:L.message)||"Validation failed"})}const w=Object.assign(Object.assign(Object.assign({field:h,type:x,component:p.get("foorm.component"),autocomplete:p.get("foorm.autocomplete"),altAction:p.get("foorm.altAction"),order:p.get("foorm.order"),name:h},_e(p,h)),Ve(p,y.optional)),{classes:E("foorm.fn.classes",void 0,p),styles:E("foorm.fn.styles",void 0,p),options:E("foorm.fn.options","foorm.options",p,{transform:Be}),value:E("foorm.fn.value","foorm.value",p),validators:_,attrs:De(p),maxLength:p.get("expect.maxLength"),minLength:p.get("expect.minLength"),min:p.get("expect.min"),max:p.get("expect.max")});u.push(w)}return u.sort((h,y)=>{var p,m;return((p=h.order)!==null&&p!==void 0?p:1/0)-((m=y.order)!==null&&m!==void 0?m:1/0)}),{title:l,submit:f,fields:u}}function $e(n){const t=Ce(n),o=e.reactive(U(t.fields));return{form:t,formData:o}}k.OoField=F,k.OoForm=ue,k.useFoorm=$e,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .oo-default-field{display:flex;flex-direction:column;gap:4px}.oo-default-field.required label:after{content:" *";color:red}.oo-default-field.error input{outline:1px solid red}.oo-default-field .oo-error-slot{height:14px;line-height:12px;font-size:12px}.oo-default-field.error .oo-error-slot{color:red}
1
+ .oo-default-field{display:flex;flex-direction:column;gap:4px;margin-bottom:4px}.oo-default-field label{font-size:13px;font-weight:600;color:#374151}.oo-default-field.required label:after{content:" *";color:#ef4444}.oo-default-field span{font-size:12px;color:#6b7280}.oo-default-field input,.oo-default-field select{padding:8px 12px;border:1px solid #d1d5db;border-radius:6px;font-size:14px;color:#1d1d1f;background:#fff;transition:border-color .15s,box-shadow .15s;outline:none}.oo-default-field input::placeholder{color:#9ca3af}.oo-default-field input:focus,.oo-default-field select:focus{border-color:#6366f1;box-shadow:0 0 0 3px #6366f126}.oo-default-field input:disabled,.oo-default-field select:disabled{background:#f3f4f6;color:#9ca3af;cursor:not-allowed}.oo-default-field.error input,.oo-default-field.error select{border-color:#ef4444}.oo-default-field.error input:focus,.oo-default-field.error select:focus{box-shadow:0 0 0 3px #ef444426}.oo-default-field .oo-field-label{font-size:13px;font-weight:600;color:#374151}.oo-radio-group{display:flex;flex-direction:column;gap:6px}.oo-radio-group label{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:400;color:#1d1d1f;cursor:pointer}.oo-radio-group input[type=radio]{padding:0;border:none;box-shadow:none}.oo-checkbox-field>label{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:400;color:#1d1d1f;cursor:pointer}.oo-checkbox-field>label input[type=checkbox]{padding:0;border:none;box-shadow:none}.oo-default-field .oo-error-slot{min-height:16px;line-height:16px;font-size:12px;color:#6b7280}.oo-default-field.error .oo-error-slot{color:#ef4444}.oo-default-field.oo-action-field button{padding:8px 16px;border:1px solid #d1d5db;border-radius:6px;background:#fff;font-size:13px;font-weight:500;color:#374151;cursor:pointer;transition:background .15s,border-color .15s}.oo-default-field.oo-action-field button:hover{background:#f9fafb;border-color:#9ca3af}h2{margin:0 0 8px;font-size:20px;font-weight:700;color:#111827}p{margin:0 0 4px;font-size:14px;color:#6b7280}button[type=submit],button:not([type]){margin-top:8px;padding:10px 20px;border:none;border-radius:6px;background:#6366f1;color:#fff;font-size:14px;font-weight:600;cursor:pointer;transition:background .15s}button[type=submit]:hover,button:not([type]):hover{background:#4f46e5}button[type=submit]:disabled,button:not([type]):disabled{background:#c7d2fe;cursor:not-allowed}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foormjs/vue",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "@foormjs/vue",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -42,16 +42,16 @@
42
42
  "dependencies": {
43
43
  "vue": "^3.5.28",
44
44
  "vuiless-forms": "^0.0.3",
45
- "@foormjs/atscript": "^0.2.0",
46
- "foorm": "^0.2.0"
45
+ "@foormjs/atscript": "^0.2.2",
46
+ "foorm": "^0.2.2"
47
47
  },
48
48
  "peerDependencies": {
49
- "@atscript/core": "^0.1.6",
50
- "@atscript/typescript": "^0.1.6"
49
+ "@atscript/core": "^0.1.8",
50
+ "@atscript/typescript": "^0.1.8"
51
51
  },
52
52
  "devDependencies": {
53
- "@atscript/core": "^0.1.6",
54
- "@atscript/typescript": "^0.1.6",
53
+ "@atscript/core": "^0.1.8",
54
+ "@atscript/typescript": "^0.1.8",
55
55
  "@playwright/test": "^1.58.2",
56
56
  "@tsconfig/node20": "^20.1.9",
57
57
  "@types/node": "^20.19.33",
@@ -59,7 +59,7 @@
59
59
  "@vue/tsconfig": "^0.5.1",
60
60
  "npm-run-all2": "^6.2.6",
61
61
  "typescript": "~5.4.5",
62
- "unplugin-atscript": "^0.1.3",
62
+ "unplugin-atscript": "^0.1.8",
63
63
  "vite": "^5.4.21",
64
64
  "vite-plugin-dts": "^3.9.1",
65
65
  "vue-tsc": "^2.2.12"