@oneb/ui-vue 0.0.12 → 0.0.13
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/dist/form/index.cjs +1 -1
- package/dist/form/index.js +147 -176
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/form/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),w={id:{type:String,required:!1},validation:{type:Object,required:!1}},V={id:{type:String,required:!1},label:{type:String,required:!1},name:{type:String,required:!1},hint:{type:String,required:!1,default:""},errors:{type:Array,required:!1}},C={name:{type:String,required:!1},errors:{type:Array,required:!1}},F={label:{type:String,required:!1}},N={id:{type:String,required:!1},name:{type:String,required:!1},placeholder:{type:String,default:""},icon:{type:[Function,Object]},type:{type:String,default:"text"},inputClass:{required:!1,type:[Array,String]},modelValue:{required:!1,type:[String,Number,Array,Boolean,Object,null]},autofocus:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},clearable:{type:Boolean,default:!1},rounded:{type:Boolean,default:!1},large:{type:Boolean,default:!1},invalid:{type:Boolean,required:!1,default:!1},options:{type:Array,required:!1,default:[]}},k=()=>e.inject("BaseForm",()=>({formId:e.computed(()=>{}),validation:e.computed(()=>{})}),!0),f=()=>e.inject("BaseFormField",()=>({inputId:e.computed(()=>{}),inputName:e.computed(()=>{}),hasError:e.computed(()=>!1)}),!0),S=["onSubmit","id"],_=e.defineComponent({__name:"OneForm",props:w,emits:["submit"],setup(a,{emit:t}){const o=a;e.provide("BaseForm",{formId:e.computed(()=>o.id),validation:e.computed(()=>o.validation)});const d=()=>{t("submit")};return(l,n)=>(e.openBlock(),e.createElementBlock("form",{onSubmit:e.withModifiers(d,["prevent"]),id:l.id,class:"space-y-3"},[e.renderSlot(l.$slots,"default")],40,S))}}),$=["for"],v=e.defineComponent({__name:"OneFormLabel",props:F,setup(a){const{inputId:t}=f();return(o,d)=>(e.openBlock(),e.createElementBlock("label",{for:e.unref(t),class:"block text-sm font-medium text-primary-content select-none"},[e.renderSlot(o.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(o.label),1)])],8,$))}}),q={key:0,class:"text-danger-content text-xs space-y-1"},h=e.defineComponent({__name:"OneFormFeedback",props:C,setup(a){const t=a,{validation:o}=k(),{inputName:d}=f(),l=e.computed(()=>d.value==null&&t.name==null?t.errors??[]:o.value==null?t.errors??[]:(o.value??{})[t.name||d.value]??t.errors??[]);return(n,i)=>l.value.length>0?(e.openBlock(),e.createElementBlock("div",q,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,u=>(e.openBlock(),e.createElementBlock("div",{key:u},e.toDisplayString(u),1))),128))])):e.createCommentVNode("",!0)}});function O(a,t){return e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.8",stroke:"currentColor","aria-hidden":"true"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})])}function j(a,t){return e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.8",stroke:"currentColor","aria-hidden":"true"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"})])}function I(a,t){return e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.8",stroke:"currentColor","aria-hidden":"true"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})])}function M(a,t){return e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.8",stroke:"currentColor","aria-hidden":"true"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})])}const L={key:0,class:"w-full onebselect relative group"},z=["id","disabled"],A=["selected"],D=["selected","value"],P={class:"absolute p-2 px-3 rounded-md h-full flex items-center right-1 top-0 select-none pointer-events-none"},x=["name","id","value","placeholder","disabled","readonly"],T={key:2,class:"flex w-full space-x-3 items-center"},G=["type","name","id","disabled","readonly","checked"],H=["for"],J={key:3,class:"w-full space-y-1"},K=["name","id","value","disabled","readonly","checked"],Q=["for"],R={key:4,class:"relative"},U={class:"absolute p-2 px-3 rounded-md h-full flex items-center select-none"},W=["type","name","id","value","placeholder","disabled","readonly"],b=e.defineComponent({__name:"OneFormInput",props:N,emits:["update:modelValue"],setup(a,{emit:t}){const o=a,{inputId:d,inputName:l,hasError:n}=f(),i=e.ref(null),u=e.ref(!1);e.onMounted(()=>{o.autofocus&&i.value&&i.value.focus()});const B=e.computed(()=>o.modelValue!=null&&o.modelValue!==""),c=e.computed(()=>{if(o.id)return o.id;const r=(d==null?void 0:d.value)||"";return o.name?`${r}-${o.name}`:r||""}),g=()=>{t("update:modelValue","")},E=e.computed(()=>{const r={"shadow-sm":o.type!=="range","border-danger-base":n.value||o.invalid,"pl-10":o.icon!=null,"pr-10":o.type==="password","rounded-full":o.rounded,"rounded-md":!o.rounded,"text-lg":o.large,"py-2.5":o.large,"py-2":!o.large};return o.inputClass!=null&&(typeof o.inputClass=="string"?r[o.inputClass]=!0:o.inputClass instanceof Array&&o.inputClass.forEach(m=>{r[m]=!0})),r}),p=r=>{o.type==="checkbox"?t("update:modelValue",r.target.checked):t("update:modelValue",r.target.value)};return(r,m)=>r.type==="select"?(e.openBlock(),e.createElementBlock("div",L,[e.createElementVNode("select",{id:c.value,ref_key:"inputElement",ref:i,class:e.normalizeClass(["border border-primary-stroke px-3 w-full",{"border-danger-base":e.unref(n)||r.invalid,"text-secondary-content":r.modelValue===""||r.modelValue==null,"rounded-full":r.rounded,"rounded-md":!r.rounded,"text-lg":r.large,"py-2.5":r.large,"py-2":!r.large}]),disabled:r.disabled},[r.placeholder?(e.openBlock(),e.createElementBlock("option",{key:0,selected:r.modelValue===""||r.modelValue==null,disabled:"",hidden:""},e.toDisplayString(r.placeholder),9,A)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.options,s=>(e.openBlock(),e.createElementBlock("option",{selected:s.key===r.modelValue,key:s.key,value:s.key},e.toDisplayString(s.value),9,D))),128))],10,z),e.createElementVNode("div",P,[e.createVNode(e.unref(M),{class:e.normalizeClass(["w-4 h-4 text-secondary-content",{"group-hover:text-primary-base":!r.disabled,"opacity-50":r.disabled}])},null,8,["class"])])])):r.type==="textarea"?(e.openBlock(),e.createElementBlock("textarea",{key:1,name:r.name||e.unref(l),id:c.value,value:r.modelValue,onInput:p,rows:"3",class:e.normalizeClass(["border border-primary-stroke px-3 w-full",{"border-danger-base":e.unref(n),"rounded-3xl":r.rounded,"rounded-md":!r.rounded,"text-lg":r.large,"py-2.5":r.large,"py-2":!r.large}]),placeholder:r.placeholder,disabled:r.disabled,readonly:r.readonly,ref_key:"inputElement",ref:i},null,42,x)):r.type==="checkbox"?(e.openBlock(),e.createElementBlock("div",T,[e.createElementVNode("input",{type:r.type,name:r.name||e.unref(l),id:c.value,value:!0,onInput:p,disabled:r.disabled,readonly:r.readonly,class:e.normalizeClass(["rounded-md border border-primary-stroke px-3 py-2 shadow-sm",{"border-danger-base":e.unref(n)||r.invalid}]),checked:r.modelValue===!0,ref_key:"inputElement",ref:i},null,42,G),e.createElementVNode("label",{for:c.value,class:"text-primary-content select-none"},e.toDisplayString(r.placeholder),9,H)])):r.type==="radio"?(e.openBlock(),e.createElementBlock("div",J,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.options,(s,y)=>(e.openBlock(),e.createElementBlock("div",{key:s.key,class:"flex w-full space-x-3 items-center"},[e.createElementVNode("input",{type:"radio",name:r.name||e.unref(l),id:`${c.value}-${y}`,value:s.key,onInput:p,disabled:r.disabled,readonly:r.readonly,class:e.normalizeClass(["rounded-md border border-primary-stroke px-3 py-2 shadow-sm",{"border-danger-base":e.unref(n)||r.invalid}]),checked:s.key===r.modelValue,ref_for:!0,ref_key:"inputElement",ref:i},null,42,K),e.createElementVNode("label",{for:`${c.value}-${y}`,class:"text-primary-content select-none"},e.toDisplayString(s.value),9,Q)]))),128))])):(e.openBlock(),e.createElementBlock("div",R,[e.createElementVNode("div",U,[r.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.icon),{key:0,class:"w-5 h-5 text-primary-content"})):e.createCommentVNode("",!0)]),e.createElementVNode("input",{type:u.value?"text":r.type,name:r.name||e.unref(l),id:c.value,value:r.modelValue,onInput:p,placeholder:r.placeholder,disabled:r.disabled,readonly:r.readonly,class:e.normalizeClass(["border border-primary-stroke w-full px-3",E.value]),ref_key:"inputElement",ref:i},null,42,W),r.clearable&&B.value?(e.openBlock(),e.createElementBlock("div",{key:0,onClick:g,class:"absolute p-2 px-3 rounded-md h-full flex items-center right-0 top-0 hover:cursor-pointer select-none"},[e.createVNode(e.unref(I),{class:"w-5 h-5 text-secondary-content hover:text-primary-base"})])):r.type==="password"?(e.openBlock(),e.createElementBlock("div",{key:1,onClick:m[0]||(m[0]=s=>u.value=!u.value),class:"absolute p-2 px-3 rounded-md h-full flex items-center right-0 top-0 hover:cursor-pointer select-none"},[u.value?(e.openBlock(),e.createBlock(e.unref(j),{key:0,class:"w-5 h-5 text-primary-content hover:text-primary-base"})):(e.openBlock(),e.createBlock(e.unref(O),{key:1,class:"w-5 h-5 text-secondary-content hover:text-primary-base"}))])):e.createCommentVNode("",!0)]))}});const X={class:"space-y-1"},Y={key:2,class:"text-xs text-secondary-content select-none"},Z=e.defineComponent({__name:"OneFormField",props:V,setup(a){const t=a,{formId:o,validation:d}=k(),l=e.computed(()=>t.errors!=null&&t.errors.length>0?!0:t.name==null?!1:(d.value??{})[t.name]!=null);return e.provide("BaseFormField",{inputId:e.computed(()=>{const n=o.value||"form";if(t.id!=null)return`${n}-${t.id}`;if(t.name!=null)return`${n}-field-${t.name}`}),inputName:e.computed(()=>t.name),hasError:l}),(n,i)=>(e.openBlock(),e.createElementBlock("div",X,[n.label?(e.openBlock(),e.createBlock(v,{key:0,label:n.label},null,8,["label"])):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"default",{},()=>[e.createVNode(b)]),l.value?(e.openBlock(),e.createBlock(h,{key:1,errors:n.errors},null,8,["errors"])):n.hint.length>0?(e.openBlock(),e.createElementBlock("p",Y,e.toDisplayString(n.hint),1)):e.createCommentVNode("",!0)]))}});exports.OneForm=_;exports.OneFormFeedback=h;exports.OneFormField=Z;exports.OneFormInput=b;exports.OneFormLabel=v;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),w={id:{type:String,required:!1},validation:{type:Object,required:!1}},V={id:{type:String,required:!1},label:{type:String,required:!1},name:{type:String,required:!1},hint:{type:String,required:!1,default:""},errors:{type:Array,required:!1}},C={name:{type:String,required:!1},errors:{type:Array,required:!1}},F={label:{type:String,required:!1}},S={id:{type:String,required:!1},name:{type:String,required:!1},placeholder:{type:String,default:""},icon:{type:[Function,Object]},type:{type:String,default:"text"},inputClass:{required:!1,type:[Array,String]},modelValue:{required:!1,type:[String,Number,Array,Boolean,Object,null]},autofocus:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},clearable:{type:Boolean,default:!1},rounded:{type:Boolean,default:!1},large:{type:Boolean,default:!1},invalid:{type:Boolean,required:!1,default:!1},options:{type:Array,required:!1,default:[]}},k=()=>e.inject("BaseForm",()=>({formId:e.computed(()=>{}),validation:e.computed(()=>{})}),!0),f=()=>e.inject("BaseFormField",()=>({inputId:e.computed(()=>{}),inputName:e.computed(()=>{}),hasError:e.computed(()=>!1)}),!0),$=["onSubmit","id"],N=e.defineComponent({__name:"OneForm",props:w,emits:["submit"],setup(a,{emit:l}){const o=a;e.provide("BaseForm",{formId:e.computed(()=>o.id),validation:e.computed(()=>o.validation)});const d=()=>{l("submit")};return(n,t)=>(e.openBlock(),e.createElementBlock("form",{onSubmit:e.withModifiers(d,["prevent"]),id:n.id,class:"space-y-3"},[e.renderSlot(n.$slots,"default")],40,$))}}),q=["for"],v=e.defineComponent({__name:"OneFormLabel",props:F,setup(a){const{inputId:l}=f();return(o,d)=>(e.openBlock(),e.createElementBlock("label",{for:e.unref(l),class:"block text-sm font-medium text-primary-content select-none"},[e.renderSlot(o.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(o.label),1)])],8,q))}}),_={key:0,class:"text-danger-content text-xs space-y-1"},h=e.defineComponent({__name:"OneFormFeedback",props:C,setup(a){const l=a,{validation:o}=k(),{inputName:d}=f(),n=e.computed(()=>d.value==null&&l.name==null?l.errors??[]:o.value==null?l.errors??[]:(o.value??{})[l.name||d.value]??l.errors??[]);return(t,i)=>n.value.length>0?(e.openBlock(),e.createElementBlock("div",_,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,u=>(e.openBlock(),e.createElementBlock("div",{key:u},e.toDisplayString(u),1))),128))])):e.createCommentVNode("",!0)}});function O(a,l){return e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.8",stroke:"currentColor","aria-hidden":"true"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})])}function j(a,l){return e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.8",stroke:"currentColor","aria-hidden":"true"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"})])}function I(a,l){return e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.8",stroke:"currentColor","aria-hidden":"true"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})])}const L=["id","disabled"],M=["selected"],A=["selected","value"],D=["name","id","value","placeholder","disabled","readonly"],z={key:2,class:"flex w-full space-x-3 items-center"},P=["type","name","id","disabled","readonly","checked"],T=["for"],G={key:3,class:"w-full space-y-1"},H=["name","id","value","disabled","readonly","checked"],J=["for"],K={key:4,class:"relative"},Q={class:"absolute p-2 px-3 rounded-md h-full flex items-center select-none"},R=["type","name","id","value","placeholder","disabled","readonly"],b=e.defineComponent({__name:"OneFormInput",props:S,emits:["update:modelValue"],setup(a,{emit:l}){const o=a,{inputId:d,inputName:n,hasError:t}=f(),i=e.ref(null),u=e.ref(!1);e.onMounted(()=>{o.autofocus&&i.value&&i.value.focus()});const B=e.computed(()=>o.modelValue!=null&&o.modelValue!==""),c=e.computed(()=>{if(o.id)return o.id;const r=(d==null?void 0:d.value)||"";return o.name?`${r}-${o.name}`:r||""}),g=()=>{l("update:modelValue","")},E=e.computed(()=>{const r={"shadow-sm":o.type!=="range","border-danger-base":t.value||o.invalid,"pl-10":o.icon!=null,"pr-10":o.type==="password","rounded-full":o.rounded,"rounded-md":!o.rounded,"text-lg":o.large,"py-2.5":o.large,"py-2":!o.large};return o.inputClass!=null&&(typeof o.inputClass=="string"?r[o.inputClass]=!0:o.inputClass instanceof Array&&o.inputClass.forEach(m=>{r[m]=!0})),r}),p=r=>{o.type==="checkbox"?l("update:modelValue",r.target.checked):l("update:modelValue",r.target.value)};return(r,m)=>r.type==="select"?(e.openBlock(),e.createElementBlock("select",{key:0,id:c.value,ref_key:"inputElement",ref:i,class:e.normalizeClass(["border border-primary-stroke px-3 w-full",{"border-danger-base":e.unref(t)||r.invalid,"text-secondary-content":r.modelValue===""||r.modelValue==null,"rounded-full":r.rounded,"rounded-md":!r.rounded,"text-lg":r.large,"py-2.5":r.large,"py-2":!r.large}]),disabled:r.disabled},[r.placeholder?(e.openBlock(),e.createElementBlock("option",{key:0,selected:r.modelValue===""||r.modelValue==null,disabled:"",hidden:""},e.toDisplayString(r.placeholder),9,M)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.options,s=>(e.openBlock(),e.createElementBlock("option",{selected:s.key===r.modelValue,key:s.key,value:s.key},e.toDisplayString(s.value),9,A))),128))],10,L)):r.type==="textarea"?(e.openBlock(),e.createElementBlock("textarea",{key:1,name:r.name||e.unref(n),id:c.value,value:r.modelValue,onInput:p,rows:"3",class:e.normalizeClass(["border border-primary-stroke px-3 w-full",{"border-danger-base":e.unref(t),"rounded-3xl":r.rounded,"rounded-md":!r.rounded,"text-lg":r.large,"py-2.5":r.large,"py-2":!r.large}]),placeholder:r.placeholder,disabled:r.disabled,readonly:r.readonly,ref_key:"inputElement",ref:i},null,42,D)):r.type==="checkbox"?(e.openBlock(),e.createElementBlock("div",z,[e.createElementVNode("input",{type:r.type,name:r.name||e.unref(n),id:c.value,value:!0,onInput:p,disabled:r.disabled,readonly:r.readonly,class:e.normalizeClass(["rounded-md border border-primary-stroke px-3 py-2 shadow-sm",{"border-danger-base":e.unref(t)||r.invalid}]),checked:r.modelValue===!0,ref_key:"inputElement",ref:i},null,42,P),e.createElementVNode("label",{for:c.value,class:"text-primary-content select-none"},e.toDisplayString(r.placeholder),9,T)])):r.type==="radio"?(e.openBlock(),e.createElementBlock("div",G,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.options,(s,y)=>(e.openBlock(),e.createElementBlock("div",{key:s.key,class:"flex w-full space-x-3 items-center"},[e.createElementVNode("input",{type:"radio",name:r.name||e.unref(n),id:`${c.value}-${y}`,value:s.key,onInput:p,disabled:r.disabled,readonly:r.readonly,class:e.normalizeClass(["rounded-md border border-primary-stroke px-3 py-2 shadow-sm",{"border-danger-base":e.unref(t)||r.invalid}]),checked:s.key===r.modelValue,ref_for:!0,ref_key:"inputElement",ref:i},null,42,H),e.createElementVNode("label",{for:`${c.value}-${y}`,class:"text-primary-content select-none"},e.toDisplayString(s.value),9,J)]))),128))])):(e.openBlock(),e.createElementBlock("div",K,[e.createElementVNode("div",Q,[r.icon?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.icon),{key:0,class:"w-5 h-5 text-primary-content"})):e.createCommentVNode("",!0)]),e.createElementVNode("input",{type:u.value?"text":r.type,name:r.name||e.unref(n),id:c.value,value:r.modelValue,onInput:p,placeholder:r.placeholder,disabled:r.disabled,readonly:r.readonly,class:e.normalizeClass(["border border-primary-stroke w-full px-3",E.value]),ref_key:"inputElement",ref:i},null,42,R),r.clearable&&B.value?(e.openBlock(),e.createElementBlock("div",{key:0,onClick:g,class:"absolute p-2 px-3 rounded-md h-full flex items-center right-0 top-0 hover:cursor-pointer select-none"},[e.createVNode(e.unref(I),{class:"w-5 h-5 text-secondary-content hover:text-primary-base"})])):r.type==="password"?(e.openBlock(),e.createElementBlock("div",{key:1,onClick:m[0]||(m[0]=s=>u.value=!u.value),class:"absolute p-2 px-3 rounded-md h-full flex items-center right-0 top-0 hover:cursor-pointer select-none"},[u.value?(e.openBlock(),e.createBlock(e.unref(j),{key:0,class:"w-5 h-5 text-primary-content hover:text-primary-base"})):(e.openBlock(),e.createBlock(e.unref(O),{key:1,class:"w-5 h-5 text-secondary-content hover:text-primary-base"}))])):e.createCommentVNode("",!0)]))}}),U={class:"space-y-1"},W={key:2,class:"text-xs text-secondary-content select-none"},X=e.defineComponent({__name:"OneFormField",props:V,setup(a){const l=a,{formId:o,validation:d}=k(),n=e.computed(()=>l.errors!=null&&l.errors.length>0?!0:l.name==null?!1:(d.value??{})[l.name]!=null);return e.provide("BaseFormField",{inputId:e.computed(()=>{const t=o.value||"form";if(l.id!=null)return`${t}-${l.id}`;if(l.name!=null)return`${t}-field-${l.name}`}),inputName:e.computed(()=>l.name),hasError:n}),(t,i)=>(e.openBlock(),e.createElementBlock("div",U,[t.label?(e.openBlock(),e.createBlock(v,{key:0,label:t.label},null,8,["label"])):e.createCommentVNode("",!0),e.renderSlot(t.$slots,"default",{},()=>[e.createVNode(b)]),n.value?(e.openBlock(),e.createBlock(h,{key:1,errors:t.errors},null,8,["errors"])):t.hint.length>0?(e.openBlock(),e.createElementBlock("p",W,e.toDisplayString(t.hint),1)):e.createCommentVNode("",!0)]))}});exports.OneForm=N;exports.OneFormFeedback=h;exports.OneFormField=X;exports.OneFormInput=b;exports.OneFormLabel=v;
|
package/dist/form/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { inject as
|
|
2
|
-
const
|
|
1
|
+
import { inject as _, computed as t, defineComponent as g, provide as E, openBlock as l, createElementBlock as o, withModifiers as A, renderSlot as C, unref as d, createTextVNode as L, toDisplayString as v, Fragment as $, renderList as V, createCommentVNode as h, createElementVNode as c, ref as q, onMounted as P, normalizeClass as b, createBlock as k, resolveDynamicComponent as z, createVNode as O } from "vue";
|
|
2
|
+
const D = {
|
|
3
3
|
id: {
|
|
4
4
|
type: String,
|
|
5
5
|
required: !1
|
|
@@ -8,7 +8,7 @@ const z = {
|
|
|
8
8
|
type: Object,
|
|
9
9
|
required: !1
|
|
10
10
|
}
|
|
11
|
-
},
|
|
11
|
+
}, T = {
|
|
12
12
|
id: {
|
|
13
13
|
type: String,
|
|
14
14
|
required: !1
|
|
@@ -30,7 +30,7 @@ const z = {
|
|
|
30
30
|
type: Array,
|
|
31
31
|
required: !1
|
|
32
32
|
}
|
|
33
|
-
},
|
|
33
|
+
}, G = {
|
|
34
34
|
name: {
|
|
35
35
|
type: String,
|
|
36
36
|
required: !1
|
|
@@ -39,12 +39,12 @@ const z = {
|
|
|
39
39
|
type: Array,
|
|
40
40
|
required: !1
|
|
41
41
|
}
|
|
42
|
-
},
|
|
42
|
+
}, H = {
|
|
43
43
|
label: {
|
|
44
44
|
type: String,
|
|
45
45
|
required: !1
|
|
46
46
|
}
|
|
47
|
-
},
|
|
47
|
+
}, J = {
|
|
48
48
|
id: {
|
|
49
49
|
type: String,
|
|
50
50
|
required: !1
|
|
@@ -106,75 +106,75 @@ const z = {
|
|
|
106
106
|
required: !1,
|
|
107
107
|
default: []
|
|
108
108
|
}
|
|
109
|
-
}, I = () =>
|
|
109
|
+
}, I = () => _(
|
|
110
110
|
"BaseForm",
|
|
111
111
|
() => ({
|
|
112
|
-
formId:
|
|
112
|
+
formId: t(() => {
|
|
113
113
|
}),
|
|
114
|
-
validation:
|
|
114
|
+
validation: t(() => {
|
|
115
115
|
})
|
|
116
116
|
}),
|
|
117
117
|
!0
|
|
118
|
-
), B = () =>
|
|
118
|
+
), B = () => _(
|
|
119
119
|
"BaseFormField",
|
|
120
120
|
() => ({
|
|
121
|
-
inputId:
|
|
121
|
+
inputId: t(() => {
|
|
122
122
|
}),
|
|
123
|
-
inputName:
|
|
123
|
+
inputName: t(() => {
|
|
124
124
|
}),
|
|
125
|
-
hasError:
|
|
125
|
+
hasError: t(() => !1)
|
|
126
126
|
}),
|
|
127
127
|
!0
|
|
128
|
-
),
|
|
128
|
+
), K = ["onSubmit", "id"], ve = /* @__PURE__ */ g({
|
|
129
129
|
__name: "OneForm",
|
|
130
|
-
props:
|
|
130
|
+
props: D,
|
|
131
131
|
emits: ["submit"],
|
|
132
|
-
setup(
|
|
133
|
-
const r =
|
|
132
|
+
setup(i, { emit: n }) {
|
|
133
|
+
const r = i;
|
|
134
134
|
E("BaseForm", {
|
|
135
|
-
formId:
|
|
136
|
-
validation:
|
|
135
|
+
formId: t(() => r.id),
|
|
136
|
+
validation: t(() => r.validation)
|
|
137
137
|
});
|
|
138
|
-
const
|
|
138
|
+
const u = () => {
|
|
139
139
|
n("submit");
|
|
140
140
|
};
|
|
141
|
-
return (s,
|
|
142
|
-
onSubmit: A(
|
|
141
|
+
return (s, a) => (l(), o("form", {
|
|
142
|
+
onSubmit: A(u, ["prevent"]),
|
|
143
143
|
id: s.id,
|
|
144
144
|
class: "space-y-3"
|
|
145
145
|
}, [
|
|
146
|
-
|
|
147
|
-
], 40,
|
|
146
|
+
C(s.$slots, "default")
|
|
147
|
+
], 40, K));
|
|
148
148
|
}
|
|
149
|
-
}),
|
|
149
|
+
}), Q = ["for"], R = /* @__PURE__ */ g({
|
|
150
150
|
__name: "OneFormLabel",
|
|
151
|
-
props:
|
|
152
|
-
setup(
|
|
151
|
+
props: H,
|
|
152
|
+
setup(i) {
|
|
153
153
|
const { inputId: n } = B();
|
|
154
|
-
return (r,
|
|
154
|
+
return (r, u) => (l(), o("label", {
|
|
155
155
|
for: d(n),
|
|
156
156
|
class: "block text-sm font-medium text-primary-content select-none"
|
|
157
157
|
}, [
|
|
158
|
-
|
|
159
|
-
L(
|
|
158
|
+
C(r.$slots, "default", {}, () => [
|
|
159
|
+
L(v(r.label), 1)
|
|
160
160
|
])
|
|
161
|
-
], 8,
|
|
161
|
+
], 8, Q));
|
|
162
162
|
}
|
|
163
|
-
}),
|
|
163
|
+
}), U = {
|
|
164
164
|
key: 0,
|
|
165
165
|
class: "text-danger-content text-xs space-y-1"
|
|
166
|
-
},
|
|
166
|
+
}, W = /* @__PURE__ */ g({
|
|
167
167
|
__name: "OneFormFeedback",
|
|
168
|
-
props:
|
|
169
|
-
setup(
|
|
170
|
-
const n =
|
|
171
|
-
return (
|
|
172
|
-
(l(!0),
|
|
173
|
-
])) :
|
|
168
|
+
props: G,
|
|
169
|
+
setup(i) {
|
|
170
|
+
const n = i, { validation: r } = I(), { inputName: u } = B(), s = t(() => u.value == null && n.name == null ? n.errors ?? [] : r.value == null ? n.errors ?? [] : (r.value ?? {})[n.name || u.value] ?? n.errors ?? []);
|
|
171
|
+
return (a, m) => s.value.length > 0 ? (l(), o("div", U, [
|
|
172
|
+
(l(!0), o($, null, V(s.value, (f) => (l(), o("div", { key: f }, v(f), 1))), 128))
|
|
173
|
+
])) : h("", !0);
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
|
-
function
|
|
177
|
-
return l(),
|
|
176
|
+
function X(i, n) {
|
|
177
|
+
return l(), o("svg", {
|
|
178
178
|
xmlns: "http://www.w3.org/2000/svg",
|
|
179
179
|
fill: "none",
|
|
180
180
|
viewBox: "0 0 24 24",
|
|
@@ -182,20 +182,20 @@ function W(u, n) {
|
|
|
182
182
|
stroke: "currentColor",
|
|
183
183
|
"aria-hidden": "true"
|
|
184
184
|
}, [
|
|
185
|
-
|
|
185
|
+
c("path", {
|
|
186
186
|
"stroke-linecap": "round",
|
|
187
187
|
"stroke-linejoin": "round",
|
|
188
188
|
d: "M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"
|
|
189
189
|
}),
|
|
190
|
-
|
|
190
|
+
c("path", {
|
|
191
191
|
"stroke-linecap": "round",
|
|
192
192
|
"stroke-linejoin": "round",
|
|
193
193
|
d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
|
194
194
|
})
|
|
195
195
|
]);
|
|
196
196
|
}
|
|
197
|
-
function
|
|
198
|
-
return l(),
|
|
197
|
+
function Y(i, n) {
|
|
198
|
+
return l(), o("svg", {
|
|
199
199
|
xmlns: "http://www.w3.org/2000/svg",
|
|
200
200
|
fill: "none",
|
|
201
201
|
viewBox: "0 0 24 24",
|
|
@@ -203,15 +203,15 @@ function X(u, n) {
|
|
|
203
203
|
stroke: "currentColor",
|
|
204
204
|
"aria-hidden": "true"
|
|
205
205
|
}, [
|
|
206
|
-
|
|
206
|
+
c("path", {
|
|
207
207
|
"stroke-linecap": "round",
|
|
208
208
|
"stroke-linejoin": "round",
|
|
209
209
|
d: "M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"
|
|
210
210
|
})
|
|
211
211
|
]);
|
|
212
212
|
}
|
|
213
|
-
function
|
|
214
|
-
return l(),
|
|
213
|
+
function Z(i, n) {
|
|
214
|
+
return l(), o("svg", {
|
|
215
215
|
xmlns: "http://www.w3.org/2000/svg",
|
|
216
216
|
fill: "none",
|
|
217
217
|
viewBox: "0 0 24 24",
|
|
@@ -219,61 +219,42 @@ function Y(u, n) {
|
|
|
219
219
|
stroke: "currentColor",
|
|
220
220
|
"aria-hidden": "true"
|
|
221
221
|
}, [
|
|
222
|
-
|
|
222
|
+
c("path", {
|
|
223
223
|
"stroke-linecap": "round",
|
|
224
224
|
"stroke-linejoin": "round",
|
|
225
225
|
d: "M6 18L18 6M6 6l12 12"
|
|
226
226
|
})
|
|
227
227
|
]);
|
|
228
228
|
}
|
|
229
|
-
|
|
230
|
-
return l(), t("svg", {
|
|
231
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
232
|
-
fill: "none",
|
|
233
|
-
viewBox: "0 0 24 24",
|
|
234
|
-
"stroke-width": "1.8",
|
|
235
|
-
stroke: "currentColor",
|
|
236
|
-
"aria-hidden": "true"
|
|
237
|
-
}, [
|
|
238
|
-
i("path", {
|
|
239
|
-
"stroke-linecap": "round",
|
|
240
|
-
"stroke-linejoin": "round",
|
|
241
|
-
d: "M19.5 8.25l-7.5 7.5-7.5-7.5"
|
|
242
|
-
})
|
|
243
|
-
]);
|
|
244
|
-
}
|
|
245
|
-
const ee = {
|
|
246
|
-
key: 0,
|
|
247
|
-
class: "w-full onebselect relative group"
|
|
248
|
-
}, re = ["id", "disabled"], le = ["selected"], ne = ["selected", "value"], te = { class: "absolute p-2 px-3 rounded-md h-full flex items-center right-1 top-0 select-none pointer-events-none" }, oe = ["name", "id", "value", "placeholder", "disabled", "readonly"], ae = {
|
|
229
|
+
const x = ["id", "disabled"], ee = ["selected"], re = ["selected", "value"], le = ["name", "id", "value", "placeholder", "disabled", "readonly"], ne = {
|
|
249
230
|
key: 2,
|
|
250
231
|
class: "flex w-full space-x-3 items-center"
|
|
251
|
-
},
|
|
232
|
+
}, oe = ["type", "name", "id", "disabled", "readonly", "checked"], ae = ["for"], te = {
|
|
252
233
|
key: 3,
|
|
253
234
|
class: "w-full space-y-1"
|
|
254
|
-
},
|
|
235
|
+
}, se = ["name", "id", "value", "disabled", "readonly", "checked"], de = ["for"], ie = {
|
|
255
236
|
key: 4,
|
|
256
237
|
class: "relative"
|
|
257
|
-
},
|
|
238
|
+
}, ue = { class: "absolute p-2 px-3 rounded-md h-full flex items-center select-none" }, pe = ["type", "name", "id", "value", "placeholder", "disabled", "readonly"], ce = /* @__PURE__ */ g({
|
|
258
239
|
__name: "OneFormInput",
|
|
259
|
-
props:
|
|
240
|
+
props: J,
|
|
260
241
|
emits: ["update:modelValue"],
|
|
261
|
-
setup(
|
|
262
|
-
const r =
|
|
242
|
+
setup(i, { emit: n }) {
|
|
243
|
+
const r = i, { inputId: u, inputName: s, hasError: a } = B(), m = q(null), f = q(!1);
|
|
263
244
|
P(() => {
|
|
264
245
|
r.autofocus && m.value && m.value.focus();
|
|
265
246
|
});
|
|
266
|
-
const j =
|
|
247
|
+
const j = t(() => r.modelValue != null && r.modelValue !== ""), y = t(() => {
|
|
267
248
|
if (r.id)
|
|
268
249
|
return r.id;
|
|
269
|
-
const e = (
|
|
250
|
+
const e = (u == null ? void 0 : u.value) || "";
|
|
270
251
|
return r.name ? `${e}-${r.name}` : e || "";
|
|
271
252
|
}), M = () => {
|
|
272
253
|
n("update:modelValue", "");
|
|
273
|
-
}, N =
|
|
254
|
+
}, N = t(() => {
|
|
274
255
|
const e = {
|
|
275
256
|
"shadow-sm": r.type !== "range",
|
|
276
|
-
"border-danger-base":
|
|
257
|
+
"border-danger-base": a.value || r.invalid,
|
|
277
258
|
"pl-10": r.icon != null,
|
|
278
259
|
"pr-10": r.type === "password",
|
|
279
260
|
"rounded-full": r.rounded,
|
|
@@ -288,51 +269,42 @@ const ee = {
|
|
|
288
269
|
}), w = (e) => {
|
|
289
270
|
r.type === "checkbox" ? n("update:modelValue", e.target.checked) : n("update:modelValue", e.target.value);
|
|
290
271
|
};
|
|
291
|
-
return (e, F) => e.type === "select" ? (l(),
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
i("div", te, [
|
|
320
|
-
C(d(Z), {
|
|
321
|
-
class: v(["w-4 h-4 text-secondary-content", {
|
|
322
|
-
"group-hover:text-primary-base": !e.disabled,
|
|
323
|
-
"opacity-50": e.disabled
|
|
324
|
-
}])
|
|
325
|
-
}, null, 8, ["class"])
|
|
326
|
-
])
|
|
327
|
-
])) : e.type === "textarea" ? (l(), t("textarea", {
|
|
272
|
+
return (e, F) => e.type === "select" ? (l(), o("select", {
|
|
273
|
+
key: 0,
|
|
274
|
+
id: y.value,
|
|
275
|
+
ref_key: "inputElement",
|
|
276
|
+
ref: m,
|
|
277
|
+
class: b(["border border-primary-stroke px-3 w-full", {
|
|
278
|
+
"border-danger-base": d(a) || e.invalid,
|
|
279
|
+
"text-secondary-content": e.modelValue === "" || e.modelValue == null,
|
|
280
|
+
"rounded-full": e.rounded,
|
|
281
|
+
"rounded-md": !e.rounded,
|
|
282
|
+
"text-lg": e.large,
|
|
283
|
+
"py-2.5": e.large,
|
|
284
|
+
"py-2": !e.large
|
|
285
|
+
}]),
|
|
286
|
+
disabled: e.disabled
|
|
287
|
+
}, [
|
|
288
|
+
e.placeholder ? (l(), o("option", {
|
|
289
|
+
key: 0,
|
|
290
|
+
selected: e.modelValue === "" || e.modelValue == null,
|
|
291
|
+
disabled: "",
|
|
292
|
+
hidden: ""
|
|
293
|
+
}, v(e.placeholder), 9, ee)) : h("", !0),
|
|
294
|
+
(l(!0), o($, null, V(e.options, (p) => (l(), o("option", {
|
|
295
|
+
selected: p.key === e.modelValue,
|
|
296
|
+
key: p.key,
|
|
297
|
+
value: p.key
|
|
298
|
+
}, v(p.value), 9, re))), 128))
|
|
299
|
+
], 10, x)) : e.type === "textarea" ? (l(), o("textarea", {
|
|
328
300
|
key: 1,
|
|
329
301
|
name: e.name || d(s),
|
|
330
302
|
id: y.value,
|
|
331
303
|
value: e.modelValue,
|
|
332
304
|
onInput: w,
|
|
333
305
|
rows: "3",
|
|
334
|
-
class:
|
|
335
|
-
"border-danger-base": d(
|
|
306
|
+
class: b(["border border-primary-stroke px-3 w-full", {
|
|
307
|
+
"border-danger-base": d(a),
|
|
336
308
|
"rounded-3xl": e.rounded,
|
|
337
309
|
"rounded-md": !e.rounded,
|
|
338
310
|
"text-lg": e.large,
|
|
@@ -344,8 +316,8 @@ const ee = {
|
|
|
344
316
|
readonly: e.readonly,
|
|
345
317
|
ref_key: "inputElement",
|
|
346
318
|
ref: m
|
|
347
|
-
}, null, 42,
|
|
348
|
-
|
|
319
|
+
}, null, 42, le)) : e.type === "checkbox" ? (l(), o("div", ne, [
|
|
320
|
+
c("input", {
|
|
349
321
|
type: e.type,
|
|
350
322
|
name: e.name || d(s),
|
|
351
323
|
id: y.value,
|
|
@@ -353,51 +325,51 @@ const ee = {
|
|
|
353
325
|
onInput: w,
|
|
354
326
|
disabled: e.disabled,
|
|
355
327
|
readonly: e.readonly,
|
|
356
|
-
class:
|
|
357
|
-
"border-danger-base": d(
|
|
328
|
+
class: b(["rounded-md border border-primary-stroke px-3 py-2 shadow-sm", {
|
|
329
|
+
"border-danger-base": d(a) || e.invalid
|
|
358
330
|
}]),
|
|
359
331
|
checked: e.modelValue === !0,
|
|
360
332
|
ref_key: "inputElement",
|
|
361
333
|
ref: m
|
|
362
|
-
}, null, 42,
|
|
363
|
-
|
|
334
|
+
}, null, 42, oe),
|
|
335
|
+
c("label", {
|
|
364
336
|
for: y.value,
|
|
365
337
|
class: "text-primary-content select-none"
|
|
366
|
-
},
|
|
367
|
-
])) : e.type === "radio" ? (l(),
|
|
368
|
-
(l(!0),
|
|
369
|
-
key:
|
|
338
|
+
}, v(e.placeholder), 9, ae)
|
|
339
|
+
])) : e.type === "radio" ? (l(), o("div", te, [
|
|
340
|
+
(l(!0), o($, null, V(e.options, (p, S) => (l(), o("div", {
|
|
341
|
+
key: p.key,
|
|
370
342
|
class: "flex w-full space-x-3 items-center"
|
|
371
343
|
}, [
|
|
372
|
-
|
|
344
|
+
c("input", {
|
|
373
345
|
type: "radio",
|
|
374
346
|
name: e.name || d(s),
|
|
375
347
|
id: `${y.value}-${S}`,
|
|
376
|
-
value:
|
|
348
|
+
value: p.key,
|
|
377
349
|
onInput: w,
|
|
378
350
|
disabled: e.disabled,
|
|
379
351
|
readonly: e.readonly,
|
|
380
|
-
class:
|
|
381
|
-
"border-danger-base": d(
|
|
352
|
+
class: b(["rounded-md border border-primary-stroke px-3 py-2 shadow-sm", {
|
|
353
|
+
"border-danger-base": d(a) || e.invalid
|
|
382
354
|
}]),
|
|
383
|
-
checked:
|
|
355
|
+
checked: p.key === e.modelValue,
|
|
384
356
|
ref_for: !0,
|
|
385
357
|
ref_key: "inputElement",
|
|
386
358
|
ref: m
|
|
387
|
-
}, null, 42,
|
|
388
|
-
|
|
359
|
+
}, null, 42, se),
|
|
360
|
+
c("label", {
|
|
389
361
|
for: `${y.value}-${S}`,
|
|
390
362
|
class: "text-primary-content select-none"
|
|
391
|
-
},
|
|
363
|
+
}, v(p.value), 9, de)
|
|
392
364
|
]))), 128))
|
|
393
|
-
])) : (l(),
|
|
394
|
-
|
|
395
|
-
e.icon ? (l(), k(
|
|
365
|
+
])) : (l(), o("div", ie, [
|
|
366
|
+
c("div", ue, [
|
|
367
|
+
e.icon ? (l(), k(z(e.icon), {
|
|
396
368
|
key: 0,
|
|
397
369
|
class: "w-5 h-5 text-primary-content"
|
|
398
|
-
})) :
|
|
370
|
+
})) : h("", !0)
|
|
399
371
|
]),
|
|
400
|
-
|
|
372
|
+
c("input", {
|
|
401
373
|
type: f.value ? "text" : e.type,
|
|
402
374
|
name: e.name || d(s),
|
|
403
375
|
id: y.value,
|
|
@@ -406,71 +378,70 @@ const ee = {
|
|
|
406
378
|
placeholder: e.placeholder,
|
|
407
379
|
disabled: e.disabled,
|
|
408
380
|
readonly: e.readonly,
|
|
409
|
-
class:
|
|
381
|
+
class: b(["border border-primary-stroke w-full px-3", N.value]),
|
|
410
382
|
ref_key: "inputElement",
|
|
411
383
|
ref: m
|
|
412
|
-
}, null, 42,
|
|
413
|
-
e.clearable && j.value ? (l(),
|
|
384
|
+
}, null, 42, pe),
|
|
385
|
+
e.clearable && j.value ? (l(), o("div", {
|
|
414
386
|
key: 0,
|
|
415
387
|
onClick: M,
|
|
416
388
|
class: "absolute p-2 px-3 rounded-md h-full flex items-center right-0 top-0 hover:cursor-pointer select-none"
|
|
417
389
|
}, [
|
|
418
|
-
|
|
419
|
-
])) : e.type === "password" ? (l(),
|
|
390
|
+
O(d(Z), { class: "w-5 h-5 text-secondary-content hover:text-primary-base" })
|
|
391
|
+
])) : e.type === "password" ? (l(), o("div", {
|
|
420
392
|
key: 1,
|
|
421
|
-
onClick: F[0] || (F[0] = (
|
|
393
|
+
onClick: F[0] || (F[0] = (p) => f.value = !f.value),
|
|
422
394
|
class: "absolute p-2 px-3 rounded-md h-full flex items-center right-0 top-0 hover:cursor-pointer select-none"
|
|
423
395
|
}, [
|
|
424
|
-
f.value ? (l(), k(d(
|
|
396
|
+
f.value ? (l(), k(d(Y), {
|
|
425
397
|
key: 0,
|
|
426
398
|
class: "w-5 h-5 text-primary-content hover:text-primary-base"
|
|
427
|
-
})) : (l(), k(d(
|
|
399
|
+
})) : (l(), k(d(X), {
|
|
428
400
|
key: 1,
|
|
429
401
|
class: "w-5 h-5 text-secondary-content hover:text-primary-base"
|
|
430
402
|
}))
|
|
431
|
-
])) :
|
|
403
|
+
])) : h("", !0)
|
|
432
404
|
]));
|
|
433
405
|
}
|
|
434
|
-
})
|
|
435
|
-
const he = { class: "space-y-1" }, ve = {
|
|
406
|
+
}), me = { class: "space-y-1" }, fe = {
|
|
436
407
|
key: 2,
|
|
437
408
|
class: "text-xs text-secondary-content select-none"
|
|
438
|
-
},
|
|
409
|
+
}, he = /* @__PURE__ */ g({
|
|
439
410
|
__name: "OneFormField",
|
|
440
|
-
props:
|
|
441
|
-
setup(
|
|
442
|
-
const n =
|
|
443
|
-
() => n.errors != null && n.errors.length > 0 ? !0 : n.name == null ? !1 : (
|
|
411
|
+
props: T,
|
|
412
|
+
setup(i) {
|
|
413
|
+
const n = i, { formId: r, validation: u } = I(), s = t(
|
|
414
|
+
() => n.errors != null && n.errors.length > 0 ? !0 : n.name == null ? !1 : (u.value ?? {})[n.name] != null
|
|
444
415
|
);
|
|
445
416
|
return E("BaseFormField", {
|
|
446
|
-
inputId:
|
|
447
|
-
const
|
|
417
|
+
inputId: t(() => {
|
|
418
|
+
const a = r.value || "form";
|
|
448
419
|
if (n.id != null)
|
|
449
|
-
return `${
|
|
420
|
+
return `${a}-${n.id}`;
|
|
450
421
|
if (n.name != null)
|
|
451
|
-
return `${
|
|
422
|
+
return `${a}-field-${n.name}`;
|
|
452
423
|
}),
|
|
453
|
-
inputName:
|
|
424
|
+
inputName: t(() => n.name),
|
|
454
425
|
hasError: s
|
|
455
|
-
}), (
|
|
456
|
-
|
|
426
|
+
}), (a, m) => (l(), o("div", me, [
|
|
427
|
+
a.label ? (l(), k(R, {
|
|
457
428
|
key: 0,
|
|
458
|
-
label:
|
|
459
|
-
}, null, 8, ["label"])) :
|
|
460
|
-
|
|
461
|
-
|
|
429
|
+
label: a.label
|
|
430
|
+
}, null, 8, ["label"])) : h("", !0),
|
|
431
|
+
C(a.$slots, "default", {}, () => [
|
|
432
|
+
O(ce)
|
|
462
433
|
]),
|
|
463
|
-
s.value ? (l(), k(
|
|
434
|
+
s.value ? (l(), k(W, {
|
|
464
435
|
key: 1,
|
|
465
|
-
errors:
|
|
466
|
-
}, null, 8, ["errors"])) :
|
|
436
|
+
errors: a.errors
|
|
437
|
+
}, null, 8, ["errors"])) : a.hint.length > 0 ? (l(), o("p", fe, v(a.hint), 1)) : h("", !0)
|
|
467
438
|
]));
|
|
468
439
|
}
|
|
469
440
|
});
|
|
470
441
|
export {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
442
|
+
ve as OneForm,
|
|
443
|
+
W as OneFormFeedback,
|
|
444
|
+
he as OneFormField,
|
|
445
|
+
ce as OneFormInput,
|
|
446
|
+
R as OneFormLabel
|
|
476
447
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@keyframes one-sp-ico-rot{to{transform:rotate(360deg)}}@keyframes one-sp-ico-dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}
|
|
1
|
+
@keyframes one-sp-ico-rot{to{transform:rotate(360deg)}}@keyframes one-sp-ico-dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}
|