@volverjs/ui-vue 0.0.9-beta.17 → 0.0.9-beta.19
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/components/VvCombobox/VvCombobox.es.js +10 -7
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.es.js +149 -96
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +10 -37
- package/dist/components/VvInputText/index.d.ts +18 -35
- package/dist/components/VvTextarea/VvTextarea.es.js +8 -5
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/index.es.js +167 -108
- package/dist/components/index.umd.js +1 -1
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/stories/InputText/InputText.settings.d.ts +4 -30
- package/dist/stories/InputText/InputText.stories.d.ts +0 -1
- package/dist/stories/InputText/InputTextMask.stories.d.ts +12 -0
- package/package.json +49 -48
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvCombobox/VvCombobox.vue +11 -7
- package/src/components/VvInputText/VvInputText.vue +138 -55
- package/src/components/VvInputText/index.ts +25 -34
- package/src/components/VvTextarea/VvTextarea.vue +8 -5
- package/src/stories/InputText/InputText.settings.ts +7 -33
- package/src/stories/InputText/InputText.stories.ts +4 -12
- package/src/stories/InputText/InputText.test.ts +31 -15
- package/src/stories/InputText/InputTextMask.stories.ts +122 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("maska"),require("@iconify/vue"),require("nanoid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","maska","@iconify/vue","nanoid","@vueuse/core"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvInputText=t(e.vue,e.maska,e.vue$1,e.nanoid,e.core)}(this,(function(e,t,o,l,n){"use strict";function a(t){return null==(o=e.unref(t))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length;var o}function i(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const r={color:String,width:{type:[String,Number]},height:{type:[String,Number]},name:{type:String,required:!0},provider:{type:String},prefix:{type:String,default:"normal"},src:String,horizontalFlip:Boolean,verticalFlip:Boolean,flip:String,mode:String,inline:Boolean,rotate:[Number,String],onLoad:Function,svg:String,modifiers:{type:[String,Array]}};var u=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(u||{}),s=(e=>(e.before="before",e.after="after",e))(s||{}),d=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(d||{});const c=Symbol.for("volver");function p(){return e.inject(c)}function v(t,o,l){return e.computed((()=>{const n={[t]:!0},a="string"==typeof(null==o?void 0:o.value)?o.value.split(" "):null==o?void 0:o.value;return a&&Array.isArray(a)&&a.forEach((e=>{e&&(n[`${t}--${e}`]=!0)})),l&&Object.keys(l.value).forEach((o=>{n[`${t}--${o}`]=e.unref(l.value[o])})),n}))}const m=e.defineComponent({name:"VvIcon",props:r,setup(t){const l=t,n=e.computed((()=>"string"==typeof l.rotate?parseFloat(l.rotate):l.rotate)),a=e.ref(!0),i=p(),{modifiers:r}=e.toRefs(l),u=v("vv-icon",r),s=e.computed((()=>l.provider||(null==i?void 0:i.iconsProvider))),d=e.computed((()=>{const e=l.name??"",t=`@${s.value}:${l.prefix}:${e}`;if(o.iconExists(t))return t;const n=null==i?void 0:i.iconsCollections.find((t=>{const l=`@${s.value}:${t.prefix}:${e}`;return o.iconExists(l)}));return n?`@${s.value}:${n.prefix}:${e}`:e}));function c(e){const t=function(e){let t;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),n=(null==t?void 0:t.innerHTML.trim())||"";t&&n&&o.addIcon(`@${s.value}:${l.prefix}:${l.name}`,{body:n,height:t.viewBox.baseVal.height,width:t.viewBox.baseVal.width})}return i&&l.src&&!o.iconExists(`@${s.value}:${l.prefix}:${l.name}`)&&(a.value=!1,i.fetchIcon(l.src).then((e=>{e&&(c(e),a.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),l.svg&&c(l.svg),(t,l)=>e.unref(a)?(e.openBlock(),e.createBlock(e.unref(o.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:t.inline,width:t.width,height:t.height,horizontalFlip:t.horizontalFlip,verticalFlip:t.verticalFlip,flip:t.flip,rotate:e.unref(n),color:t.color,onLoad:t.onLoad,icon:e.unref(d)}),null,16,["class"])):e.createCommentVNode("",!0)}}),f={valid:Boolean,validLabel:[String,Array]},h={invalid:Boolean,invalidLabel:[String,Array]},b={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},g={disabled:Boolean},S=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},w={modifiers:[String,Array]},k={hintLabel:{type:String,default:""}},B={count:{type:[Boolean,String],default:!1,validator:e=>[!0,!1,"limit","countdown"].includes(e)}},L={debounce:[Number,String]},E={icon:{type:[String,Object]},iconPosition:{type:String,default:s.before,validation:e=>Object.values(s).includes(e)}},x={tabindex:{type:[String,Number],default:0}},P={floating:Boolean},T={id:[String,Number]};u.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const C={...{...T,name:{type:String,required:!0}},...{autofocus:Boolean},...{autocomplete:{type:String,default:"off"}},...x,...g,...y,...f,...h,...k,...b,...w,...B,...L,...E,...P,...S,minlength:[String,Number],maxlength:[String,Number],placeholder:String,required:Boolean};d.button;const A={TEXT:"text",PASSWORD:"password",NUMBER:"number",EMAIL:"email",TEL:"tel",URL:"url",COLOR:"color",SEARCH:"search",DATE:"date",TIME:"time",DATETIME_LOCAL:"datetime-local",MONTH:"month",WEEK:"week"},$="eye-on",O="eye-off",I="calendar",V="time",_="color",N={...C,modelValue:[String,Number],type:{type:String,default:A.TEXT,validator:e=>Object.values(A).includes(e)},min:[Number,Date,String],max:[Number,Date,String],step:{type:[String,Number],default:1},pattern:String,multiple:Boolean,iconShowPassword:{type:String,default:$},iconHidePassword:{type:String,default:O},iconClear:{type:String,default:"close"},labelStepUp:{type:String,default:"Increase value"},labelStepDown:{type:String,default:"Decrease value"},labelShowPassword:{type:String,default:"Show password"},labelHidePassword:{type:String,default:"Hide password"},labelClear:{type:String,default:"Clear"},mask:{type:String,default:void 0},maskEager:{type:Boolean,default:!1},maskReversed:{type:Boolean,default:!1},maskTokens:{type:Object,default:void 0},maskTokensReplace:{type:Boolean,default:!1},autoWidth:{type:Boolean,default:!1},hideActions:{type:Boolean,default:!1},unit:{type:String},selectOnFocus:{type:Boolean,default:!1}},R=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},labelShow:{type:String,default:"Show password"},labelHide:{type:String,default:"Hide password"},iconShow:{type:String,default:$},iconHide:{type:String,default:O}},emits:["toggle-password"],setup(t,{emit:o}){const l=e.ref(!1),n=e.computed((()=>l.value?t.iconHide:t.iconShow));return{active:l,activeIcon:n,onClick:function(e){null==e||e.stopPropagation(),t.disabled||(l.value=!l.value,o("toggle-password",l.value))}}},render(){const t=e.h(m,{name:this.activeIcon,class:"vv-input-text__icon"});return e.h("button",{disabled:this.disabled,class:"vv-input-text__action",ariaLabel:this.active?this.labelHide:this.labelShow,type:"button",onClick:this.onClick},t)}}),D=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},label:{type:String},mode:{type:String,validator:e=>["up","down"].includes(e),default:"up"}},emits:["step-up","step-down"],setup(t,{emit:o}){const l=e.computed((()=>"up"===t.mode));return{isUp:l,onClick:e=>{null==e||e.stopPropagation(),t.disabled||o(l.value?"step-up":"step-down")}}},render(){return e.h("button",{class:["vv-input-text__action vv-input-text__action-chevron",this.isUp&&"vv-input-text__action-chevron-up"],disabled:this.disabled,ariaLabel:this.label,type:"button",onClick:this.onClick})}}),H=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},label:{type:String,default:"Clear"},icon:{type:String,default:"close"}},emits:["clear"],setup:(e,{emit:t})=>({onClick:function(o){null==o||o.stopPropagation(),e.disabled||t("clear")}}),render(){const t=e.h(m,{name:this.icon,class:"vv-input-text__icon"});return e.h("button",{disabled:this.disabled,class:"vv-input-text__action",ariaLabel:this.label,type:"button",onClick:this.onClick},t)}});function M(t,o){return{name:"VvInputTextActions",components:{VvIcon:m,VvInputPasswordAction:R,VvInputStepAction:D,VvInputClearAction:H},setup:()=>({isDisabled:e.computed((()=>o.disabled||o.readonly)),labelStepUp:o.labelStepUp,labelStepDown:o.labelStepDown,labelShowPassword:o.labelShowPassword,labelHidePassword:o.labelHidePassword,labelClear:o.labelClear,iconShowPassword:o.iconShowPassword,iconHidePassword:o.iconHidePassword}),render(){let l=null;switch(t){case A.SEARCH:{const{onClear:t}=this.$attrs;l=[e.h(H,{disabled:this.isDisabled,label:this.labelShowPassword,onClear:t})];break}case A.PASSWORD:{const{onTogglePassword:t}=this.$attrs;l=[e.h(R,{disabled:this.isDisabled,onTogglePassword:t,labelShow:this.labelShowPassword,labelHide:this.labelHidePassword,iconShow:this.iconShowPassword,iconHide:this.iconHidePassword})];break}case A.NUMBER:{const{onStepUp:t,onStepDown:n}=this.$attrs;l=[e.h(D,{mode:"up",disabled:this.isDisabled||void 0!==o.max&&o.modelValue===o.max,label:this.labelStepUp,onStepUp:t,onStepDown:n}),e.h(D,{mode:"down",disabled:this.isDisabled||void 0!==o.min&&o.modelValue===o.min,label:this.labelStepDown,onStepUp:t,onStepDown:n})];break}}return Array.isArray(l)?e.h("div",{class:"vv-input-text__actions-group"},l):l}}}const U=["for"],j={class:"vv-input-text__wrapper"},W={key:0,class:"vv-input-text__input-before"},q=["onClick"],z=["id"],F={key:1,class:"vv-input-text__unit"},X={key:5,class:"vv-input-text__input-after"},K={key:6,class:"vv-input-text__limit"};return e.defineComponent({name:"VvInputText",props:N,emits:["update:modelValue","focus","blur","keyup"],setup(o,{expose:r,emit:d}){const c=o,f=e.useSlots(),h=function(t,o,l){const n=p(),a=e.computed((()=>{var e;if(n&&(null==(e=n.defaults.value)?void 0:e[t]))return n.defaults.value[t]}));return e.computed((()=>{if(void 0===a.value)return l;const e=a.value,t=o,n=l;return Object.keys(t).reduce(((o,l)=>{const a=n[l];if(o[l]=a,l in e){if(Array.isArray(t[l])){const n=t[l];n.length&&n[0]===a&&(o[l]=e[l])}if("function"==typeof t[l]&&(0,t[l])()===a&&(o[l]=e[l]),"object"==typeof t[l]){let n=t[l].default;"function"==typeof n&&(n=n()),"object"==typeof n?JSON.stringify(n)===JSON.stringify(a)&&(o[l]=e[l]):n===a&&(o[l]=e[l])}}return o}),{})}))}("VvInputText",N,c),b=e.ref(),g=e.ref();r({$inner:g});const{id:S,icon:y,iconPosition:w,label:k,modelValue:B,count:L,valid:E,invalid:x,loading:P}=e.toRefs(c),T=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(S),C=e.computed((()=>`${T.value}-hint`)),$=e.computed((()=>c.floating&&a(c.placeholder)?" ":c.placeholder)),O=function(t,o,l=0,{getter:n=(e=>e),setter:a=(e=>e)}={}){let i;return"string"==typeof l&&(l=parseInt(l)),e.computed({get:()=>n(null==t?void 0:t.value),set:e=>{i&&clearTimeout(i),i=setTimeout((()=>{o("update:modelValue",a(e))}),l)}})}(B,d,c.debounce,{getter:e=>Le.value?Le.value.masked(e??""):e,setter:e=>(Le.value&&(e=Le.value.unmasked(e)),c.type===A.NUMBER?Number(e):e)}),{focused:R}=function(t,o){const{focused:l}=n.useFocus(t);return e.watch(l,(l=>{o(l?"focus":"blur",e.unref(t))})),{focused:l}}(b,d),D=e.computed((()=>R.value&&!c.disabled&&!c.readonly));e.watch(D,(e=>{e&&h.value.selectOnFocus&&b.value&&b.value.select()}));const H=n.useElementVisibility(b);e.watch(H,(e=>{e&&c.autofocus&&!c.disabled&&!c.readonly&&(R.value=!0)}));const J=e.ref(!1),G=e.computed((()=>c.type===A.PASSWORD)),Q=()=>{J.value=!J.value},Y=e.computed((()=>c.type===A.TIME||c.type===A.DATETIME_LOCAL||c.type===A.DATE||c.type===A.WEEK||c.type===A.MONTH)),Z=e.computed((()=>c.type===A.NUMBER)),ee=()=>{se.value&&(b.value.stepUp(),O.value=e.unref(b).value)},te=()=>{se.value&&(b.value.stepDown(),O.value=e.unref(b).value)},oe=e.computed((()=>c.type===A.SEARCH)),le=()=>{O.value=void 0},{hasIcon:ne,hasIconBefore:ae,hasIconAfter:ie}=function(t,o){const l=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===s.before))),n=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===s.after))),a=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.left))),i=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.right))),r=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.top))),d=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==t?void 0:t.value)?{name:null==t?void 0:t.value}:null==t?void 0:t.value)),hasIconLeft:a,hasIconRight:i,hasIconTop:r,hasIconBottom:d,hasIconBefore:l,hasIconAfter:n}}(y,w),re=e.computed((()=>{switch(c.type){case A.COLOR:return{name:_};case A.DATE:case A.DATETIME_LOCAL:case A.WEEK:case A.MONTH:return{name:I};case A.TIME:return{name:V};default:return""}})),{formatted:ue}=function(t,o){const l=e.computed((()=>(e.unref(t)??"").length)),n=e.computed((()=>void 0!==(null==o?void 0:o.lowerLimit)&&l.value<(null==o?void 0:o.lowerLimit)?l.value-o.lowerLimit:void 0!==(null==o?void 0:o.upperLimit)&&l.value<(null==o?void 0:o.upperLimit)?o.upperLimit-l.value:0)),a=e.computed((()=>{if(!1===(null==o?void 0:o.mode))return"";if("limit"===(null==o?void 0:o.mode)&&(null==o?void 0:o.upperLimit))return`${l.value} / ${o.lowerLimit?`${o.lowerLimit}-`:""}${o.upperLimit}`;if("countdown"===(null==o?void 0:o.mode)){if(0===n.value)return;return n}return l.value}));return{length:l,gap:n,formatted:a}}(O,{mode:c.count,upperLimit:Number(c.maxlength),lowerLimit:Number(c.minlength)}),se=e.computed((()=>!c.disabled&&!c.readonly)),de=e.computed((()=>se.value?c.tabindex:-1)),ce=e.computed((()=>!a(B))),pe=e.computed((()=>!0===x.value||!0!==E.value&&void 0)),{modifiers:ve}=e.toRefs(c),me=v("vv-input-text",ve,e.computed((()=>({valid:E.value,invalid:x.value,loading:P.value,disabled:c.disabled,readonly:c.readonly,"icon-before":ae.value,"icon-after":ie.value||!a(re),floating:c.floating&&!a(c.label),dirty:ce.value,focus:D.value,"auto-width":c.autoWidth})))),fe=e.computed((()=>{const e=G.value&&J.value?A.TEXT:!Y.value||ce.value||R.value?c.type:A.TEXT,t={type:e,name:c.name,tabindex:de.value,disabled:c.disabled,readonly:c.readonly,required:c.required,autocomplete:c.autocomplete,"aria-invalid":pe.value,"aria-describedby":ge.value?C.value:void 0,"aria-errormessage":Se.value?C.value:void 0};return e!==A.DATE&&e!==A.MONTH&&e!==A.WEEK&&e!==A.TIME&&e!==A.DATETIME_LOCAL&&e!==A.NUMBER||(t.step=c.step,t.max=void 0!==c.max?String(c.max):void 0,t.min=void 0!==c.min?String(c.min):void 0),e!==A.TEXT&&e!==A.SEARCH&&e!==A.URL&&e!==A.TEL&&e!==A.EMAIL&&e!==A.PASSWORD&&e!==A.NUMBER||(t.placeholder=$.value),e!==A.TEXT&&e!==A.SEARCH&&e!==A.URL&&e!==A.TEL&&e!==A.EMAIL&&e!==A.PASSWORD||(t.minlength=c.minlength,t.maxlength=c.maxlength,t.pattern=c.pattern),e===A.EMAIL&&(t.multiple=c.multiple),t})),he=e.computed((()=>({valid:c.valid,invalid:c.invalid,modelValue:c.modelValue,togglePassword:Q,stepUp:ee,stepDown:te,clear:le}))),{HintSlot:be,hasHintLabelOrSlot:ge,hasInvalidLabelOrSlot:Se,hintSlotScope:ye}=function(t,o){const l=e.computed((()=>e.isRef(t)?t.value:t)),n=e.computed((()=>i(l.value.invalidLabel))),a=e.computed((()=>i(l.value.validLabel))),r=e.computed((()=>l.value.loadingLabel)),u=e.computed((()=>l.value.hintLabel)),s=e.computed((()=>Boolean(l.value.loading&&(o.loading||r.value)))),d=e.computed((()=>!s.value&&Boolean(l.value.invalid&&(o.invalid||n.value)))),c=e.computed((()=>!s.value&&!d.value&&Boolean(l.value.valid&&(o.valid||a.value)))),p=e.computed((()=>!s.value&&!d.value&&!c.value&&Boolean(o.hint||u.value))),v=e.computed((()=>d.value||c.value||s.value||p.value)),m=e.computed((()=>({modelValue:l.value.modelValue,valid:l.value.valid,invalid:l.value.invalid,loading:l.value.loading}))),f=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:v,invalidLabel:n,validLabel:a,loadingLabel:r,hintLabel:u,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:s,hasHintLabelOrSlot:p}),render(){var t,o,l,n,a,i,r,u;if(this.isVisible){let s;return this.hasInvalidLabelOrSlot&&(s="alert"),this.hasValidLabelOrSlot&&(s="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:s},(null==(o=(t=this.$slots).loading)?void 0:o.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:s},(null==(n=(l=this.$slots).invalid)?void 0:n.call(l))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:s},(null==(i=(a=this.$slots).valid)?void 0:i.call(a))??this.validLabel):e.h(this.tag,{role:s},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:p,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:s,hintSlotScope:m,HintSlot:f}}(h,f),we=M(A.PASSWORD,c),ke=M(A.NUMBER,c),Be=M(A.SEARCH,c),Le=e.ref();e.watch([()=>c.mask,()=>c.type,()=>c.maskEager,()=>c.maskReversed,()=>c.maskTokens,()=>c.maskTokensReplace],(([e,o,l,n,a,i])=>{Le.value=e&&o===A.TEXT?new t.Mask({mask:e,eager:l,reversed:n,tokens:a,tokensReplace:i}):void 0}),{immediate:!0});const Ee=()=>{se.value&&(R.value=!0)},xe=e.computed((()=>{if(c.autoWidth)return{width:void 0!==O.value?`${String(O.value).length+1}ch`:void 0}}));return(t,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(me))},[e.unref(k)?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(T),class:"vv-input-text__label"},e.toDisplayString(e.unref(k)),9,U)):e.createCommentVNode("",!0),e.createElementVNode("div",j,[t.$slots.before?(e.openBlock(),e.createElementBlock("div",W,[e.renderSlot(t.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(he))))])):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"innerEl",ref:g,class:"vv-input-text__inner",onClick:e.withModifiers(Ee,["stop"])},[e.unref(ae)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:0,class:"vv-input-text__icon"},e.unref(ne)),null,16)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({id:e.unref(T),ref_key:"inputEl",ref:b,"onUpdate:modelValue":o[0]||(o[0]=t=>e.isRef(O)?O.value=t:null)},e.unref(fe),{style:e.unref(xe),onKeyup:o[1]||(o[1]=e=>d("keyup",e))}),null,16,z),[[e.vModelDynamic,e.unref(O)]]),(t.unit||t.$slots.unit)&&e.unref(ce)?(e.openBlock(),e.createElementBlock("div",F,[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps(e.unref(he))),(()=>[e.createTextVNode(e.toDisplayString(t.unit),1)]))])):e.createCommentVNode("",!0)],8,q),e.unref(ie)||e.unref(re)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:1,class:"vv-input-text__icon vv-input-text__icon-after"},e.unref(ie)?e.unref(ne):e.unref(re)),null,16)):e.unref(G)&&!t.hideActions&&e.unref(se)?(e.openBlock(),e.createBlock(e.unref(we),{key:2,onTogglePassword:Q})):e.unref(Z)&&!t.hideActions&&e.unref(se)?(e.openBlock(),e.createBlock(e.unref(ke),{key:3,onStepUp:ee,onStepDown:te})):e.unref(oe)&&!t.hideActions&&e.unref(se)?(e.openBlock(),e.createBlock(e.unref(Be),{key:4,onClear:le})):e.createCommentVNode("",!0),t.$slots.after?(e.openBlock(),e.createElementBlock("div",X,[e.renderSlot(t.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(he))))])):e.createCommentVNode("",!0),e.unref(L)?(e.openBlock(),e.createElementBlock("span",K,[e.renderSlot(t.$slots,"count",e.normalizeProps(e.guardReactiveProps(e.unref(he))),(()=>[e.createTextVNode(e.toDisplayString(e.unref(ue)),1)]))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(be),{id:e.unref(C),class:"vv-input-text__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(ye))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(ye))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(ye))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(ye))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("vue-imask"),require("@iconify/vue"),require("nanoid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","vue-imask","@iconify/vue","nanoid","@vueuse/core"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvInputText=t(e.vue,e.vueImask,e.vue$1,e.nanoid,e.core)}(this,(function(e,t,l,o,a){"use strict";function n(t){return null==(l=e.unref(t))||""===l||Array.isArray(l)&&0===l.length||!(l instanceof Date)&&"object"==typeof l&&0===Object.keys(l).length;var l}function i(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const r={color:String,width:{type:[String,Number]},height:{type:[String,Number]},name:{type:String,required:!0},provider:{type:String},prefix:{type:String,default:"normal"},src:String,horizontalFlip:Boolean,verticalFlip:Boolean,flip:String,mode:String,inline:Boolean,rotate:[Number,String],onLoad:Function,svg:String,modifiers:{type:[String,Array]}};var u=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(u||{}),s=(e=>(e.before="before",e.after="after",e))(s||{}),d=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(d||{});const c=Symbol.for("volver");function v(){return e.inject(c)}function p(t,l,o){return e.computed((()=>{const a={[t]:!0},n="string"==typeof(null==l?void 0:l.value)?l.value.split(" "):null==l?void 0:l.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(a[`${t}--${e}`]=!0)})),o&&Object.keys(o.value).forEach((l=>{a[`${t}--${l}`]=e.unref(o.value[l])})),a}))}const m=e.defineComponent({name:"VvIcon",props:r,setup(t){const o=t,a=e.computed((()=>"string"==typeof o.rotate?parseFloat(o.rotate):o.rotate)),n=e.ref(!0),i=v(),{modifiers:r}=e.toRefs(o),u=p("vv-icon",r),s=e.computed((()=>o.provider||(null==i?void 0:i.iconsProvider))),d=e.computed((()=>{const e=o.name??"",t=`@${s.value}:${o.prefix}:${e}`;if(l.iconExists(t))return t;const a=null==i?void 0:i.iconsCollections.find((t=>{const o=`@${s.value}:${t.prefix}:${e}`;return l.iconExists(o)}));return a?`@${s.value}:${a.prefix}:${e}`:e}));function c(e){const t=function(e){let t;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),a=(null==t?void 0:t.innerHTML.trim())||"";t&&a&&l.addIcon(`@${s.value}:${o.prefix}:${o.name}`,{body:a,height:t.viewBox.baseVal.height,width:t.viewBox.baseVal.width})}return i&&o.src&&!l.iconExists(`@${s.value}:${o.prefix}:${o.name}`)&&(n.value=!1,i.fetchIcon(o.src).then((e=>{e&&(c(e),n.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),o.svg&&c(o.svg),(t,o)=>e.unref(n)?(e.openBlock(),e.createBlock(e.unref(l.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:t.inline,width:t.width,height:t.height,horizontalFlip:t.horizontalFlip,verticalFlip:t.verticalFlip,flip:t.flip,rotate:e.unref(a),color:t.color,onLoad:t.onLoad,icon:e.unref(d)}),null,16,["class"])):e.createCommentVNode("",!0)}}),f={valid:Boolean,validLabel:[String,Array]},h={invalid:Boolean,invalidLabel:[String,Array]},b={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},g={disabled:Boolean},S=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},w={modifiers:[String,Array]},k={hintLabel:{type:String,default:""}},L={count:{type:[Boolean,String],default:!1,validator:e=>[!0,!1,"limit","countdown"].includes(e)}},B={debounce:[Number,String]},E={icon:{type:[String,Object]},iconPosition:{type:String,default:s.before,validation:e=>Object.values(s).includes(e)}},$={tabindex:{type:[String,Number],default:0}},x={floating:Boolean},A={id:[String,Number]};u.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const T={...{...A,name:{type:String,required:!0}},...{autofocus:Boolean},...{autocomplete:{type:String,default:"off"}},...$,...g,...y,...f,...h,...k,...b,...w,...L,...B,...E,...x,...S,minlength:[String,Number],maxlength:[String,Number],placeholder:String,required:Boolean};d.button;const P={TEXT:"text",PASSWORD:"password",NUMBER:"number",EMAIL:"email",TEL:"tel",URL:"url",COLOR:"color",SEARCH:"search",DATE:"date",TIME:"time",DATETIME_LOCAL:"datetime-local",MONTH:"month",WEEK:"week"},C="eye-on",D="eye-off",I="calendar",O="time",V="color",_={...T,modelValue:[String,Number],type:{type:String,default:P.TEXT,validator:e=>Object.values(P).includes(e)},min:[Number,Date,String],max:[Number,Date,String],step:{type:[String,Number],default:1},pattern:String,multiple:Boolean,iconShowPassword:{type:String,default:C},iconHidePassword:{type:String,default:D},iconClear:{type:String,default:"close"},labelStepUp:{type:String,default:"Increase value"},labelStepDown:{type:String,default:"Decrease value"},labelShowPassword:{type:String,default:"Show password"},labelHidePassword:{type:String,default:"Hide password"},labelClear:{type:String,default:"Clear"},iMask:{type:Object,default:void 0},masked:{type:String,default:void 0},autoWidth:{type:Boolean,default:!1},hideActions:{type:Boolean,default:!1},unit:{type:String},selectOnFocus:{type:Boolean,default:!1}},N=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},labelShow:{type:String,default:"Show password"},labelHide:{type:String,default:"Hide password"},iconShow:{type:String,default:C},iconHide:{type:String,default:D}},emits:["toggle-password"],setup(t,{emit:l}){const o=e.ref(!1),a=e.computed((()=>o.value?t.iconHide:t.iconShow));return{active:o,activeIcon:a,onClick:function(e){null==e||e.stopPropagation(),t.disabled||(o.value=!o.value,l("toggle-password",o.value))}}},render(){const t=e.h(m,{name:this.activeIcon,class:"vv-input-text__icon"});return e.h("button",{disabled:this.disabled,class:"vv-input-text__action",ariaLabel:this.active?this.labelHide:this.labelShow,type:"button",onClick:this.onClick},t)}}),M=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},label:{type:String},mode:{type:String,validator:e=>["up","down"].includes(e),default:"up"}},emits:["step-up","step-down"],setup(t,{emit:l}){const o=e.computed((()=>"up"===t.mode));return{isUp:o,onClick:e=>{null==e||e.stopPropagation(),t.disabled||l(o.value?"step-up":"step-down")}}},render(){return e.h("button",{class:["vv-input-text__action vv-input-text__action-chevron",this.isUp&&"vv-input-text__action-chevron-up"],disabled:this.disabled,ariaLabel:this.label,type:"button",onClick:this.onClick})}}),R=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},label:{type:String,default:"Clear"},icon:{type:String,default:"close"}},emits:["clear"],setup:(e,{emit:t})=>({onClick:function(l){null==l||l.stopPropagation(),e.disabled||t("clear")}}),render(){const t=e.h(m,{name:this.icon,class:"vv-input-text__icon"});return e.h("button",{disabled:this.disabled,class:"vv-input-text__action",ariaLabel:this.label,type:"button",onClick:this.onClick},t)}});function H(t,l){return{name:"VvInputTextActions",components:{VvIcon:m,VvInputPasswordAction:N,VvInputStepAction:M,VvInputClearAction:R},setup:()=>({isDisabled:e.computed((()=>l.disabled||l.readonly)),labelStepUp:l.labelStepUp,labelStepDown:l.labelStepDown,labelShowPassword:l.labelShowPassword,labelHidePassword:l.labelHidePassword,labelClear:l.labelClear,iconShowPassword:l.iconShowPassword,iconHidePassword:l.iconHidePassword}),render(){let o=null;switch(t){case P.SEARCH:{const{onClear:t}=this.$attrs;o=[e.h(R,{disabled:this.isDisabled,label:this.labelShowPassword,onClear:t})];break}case P.PASSWORD:{const{onTogglePassword:t}=this.$attrs;o=[e.h(N,{disabled:this.isDisabled,onTogglePassword:t,labelShow:this.labelShowPassword,labelHide:this.labelHidePassword,iconShow:this.iconShowPassword,iconHide:this.iconHidePassword})];break}case P.NUMBER:{const{onStepUp:t,onStepDown:a}=this.$attrs;o=[e.h(M,{mode:"up",disabled:this.isDisabled||void 0!==l.max&&l.modelValue===l.max,label:this.labelStepUp,onStepUp:t,onStepDown:a}),e.h(M,{mode:"down",disabled:this.isDisabled||void 0!==l.min&&l.modelValue===l.min,label:this.labelStepDown,onStepUp:t,onStepDown:a})];break}}return Array.isArray(o)?e.h("div",{class:"vv-input-text__actions-group"},o):o}}}const U=["for"],j={class:"vv-input-text__wrapper"},F={key:0,class:"vv-input-text__input-before"},W=["onClick"],q=["id"],z={key:1,class:"vv-input-text__unit"},K={key:5,class:"vv-input-text__input-after"},X={key:6,class:"vv-input-text__limit"};return e.defineComponent({name:"VvInputText",props:_,emits:["update:modelValue","update:masked","accept","accept:typed","accept:masked","accept:unmasked","complete","complete:typed","complete:masked","complete:unmasked","focus","blur","keyup","keydown","keypress"],setup(l,{expose:r,emit:d}){const c=l,f=e.useSlots(),h=function(t,l,o){const a=v(),n=e.computed((()=>{var e;if(a&&(null==(e=a.defaults.value)?void 0:e[t]))return a.defaults.value[t]}));return e.computed((()=>{if(void 0===n.value)return o;const e=n.value,t=l,a=o;return Object.keys(t).reduce(((l,o)=>{const n=a[o];if(l[o]=n,o in e){if(Array.isArray(t[o])){const a=t[o];a.length&&a[0]===n&&(l[o]=e[o])}if("function"==typeof t[o]&&(0,t[o])()===n&&(l[o]=e[o]),"object"==typeof t[o]){let a=t[o].default;"function"==typeof a&&(a=a()),"object"==typeof a?JSON.stringify(a)===JSON.stringify(n)&&(l[o]=e[o]):a===n&&(l[o]=e[o])}}return l}),{})}))}("VvInputText",_,c),{id:b,icon:g,iconPosition:S,label:y,modelValue:w,count:k,valid:L,invalid:B,loading:E,debounce:$,maxlength:x,minlength:A,type:T,iMask:C,step:D}=e.toRefs(c),N=(t=>e.computed((()=>String((null==t?void 0:t.value)||o.nanoid()))))(b),M=e.computed((()=>`${N.value}-hint`)),R=e.computed((()=>c.floating&&n(c.placeholder)?" ":c.placeholder)),J=e.ref(!1),{el:Y,mask:G,typed:Q,masked:Z,unmasked:ee}=t.useIMask(e.computed((()=>(null==C?void 0:C.value)??{mask:/./})),{emit:d,onAccept:()=>{if(J.value){if(d("update:masked",Z.value),T.value===P.NUMBER)return"number"!=typeof Q.value?void(oe.value=Number(Q.value)):void(oe.value=Q.value);if(T.value===P.DATE){if(Y.value instanceof HTMLInputElement&&"date"===Y.value.type)return void(oe.value=Y.value.value);let e=Q.value;return e instanceof Date||(e=new Date(e)),void(oe.value=`${e.getFullYear()}-${("0"+(e.getMonth()+1)).slice(-2)}-${("0"+e.getDate()).slice(-2)}`)}if(T.value===P.DATETIME_LOCAL){if(Y.value instanceof HTMLInputElement&&"datetime-local"===Y.value.type)return void(oe.value=Y.value.value);let e=Q.value;return Q.value instanceof Date||(e=new Date(e)),void(oe.value=`${e.getFullYear()}-${("0"+(e.getMonth()+1)).slice(-2)}-${("0"+e.getDate()).slice(-2)}T${("0"+e.getHours()).slice(-2)}:${("0"+e.getMinutes()).slice(-2)}`)}oe.value=ee.value}}});e.onMounted((()=>{G.value&&(J.value=!0,Q.value=oe.value??"")})),e.watch((()=>c.modelValue),(e=>{var t;G.value&&(Q.value=e&&(null==(t=null==C?void 0:C.value)?void 0:t.mask)===Date?new Date(e):e??null)})),e.watch((()=>c.masked),(e=>{Z.value=e??""}));const te=Y,le=e.ref();r({$inner:le});const oe=function(t,l,o=0,{getter:a=(e=>e),setter:n=(e=>e)}={}){let i;return"string"==typeof o&&(o=parseInt(o)),e.computed({get:()=>a(null==t?void 0:t.value),set:e=>{i&&clearTimeout(i),i=setTimeout((()=>{l("update:modelValue",n(e))}),o)}})}(w,d,(null==$?void 0:$.value)??0),{focused:ae}=function(t,l){const{focused:o}=a.useFocus(t);return e.watch(o,(o=>{l(o?"focus":"blur",e.unref(t))})),{focused:o}}(te,d),ne=e.computed((()=>ae.value&&!c.disabled&&!c.readonly));e.watch(ne,(e=>{e&&h.value.selectOnFocus&&te.value&&te.value.select()}));const ie=a.useElementVisibility(te);e.watch(ie,(e=>{e&&c.autofocus&&!c.disabled&&!c.readonly&&(ae.value=!0)}));const re=e.ref(!1),ue=e.computed((()=>c.type===P.PASSWORD)),se=()=>{re.value=!re.value},de=e.computed((()=>c.type===P.TIME||c.type===P.DATETIME_LOCAL||c.type===P.DATE||c.type===P.WEEK||c.type===P.MONTH)),ce=e.computed((()=>c.type===P.NUMBER)),ve=()=>{if(we.value){if(null==C?void 0:C.value)return void(Q.value=Q.value+Number((null==D?void 0:D.value)??1));te.value.stepUp(),oe.value=e.unref(te).value}},pe=()=>{if(we.value){if(null==C?void 0:C.value)return void(Q.value=Q.value-Number((null==D?void 0:D.value)??1));te.value.stepDown(),oe.value=e.unref(te).value}},me=e.computed((()=>c.type===P.SEARCH)),fe=()=>{oe.value=""},{hasIcon:he,hasIconBefore:be,hasIconAfter:ge}=function(t,l){const o=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===s.before))),a=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===s.after))),n=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===u.left))),i=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===u.right))),r=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===u.top))),d=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===u.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==t?void 0:t.value)?{name:null==t?void 0:t.value}:null==t?void 0:t.value)),hasIconLeft:n,hasIconRight:i,hasIconTop:r,hasIconBottom:d,hasIconBefore:o,hasIconAfter:a}}(g,S),Se=e.computed((()=>{switch(c.type){case P.COLOR:return{name:V};case P.DATE:case P.DATETIME_LOCAL:case P.WEEK:case P.MONTH:return{name:I};case P.TIME:return{name:O};default:return""}})),{formatted:ye}=function(t,l){const o=e.computed((()=>(e.unref(t)??"").length)),a=e.computed((()=>void 0!==(null==l?void 0:l.lowerLimit)&&o.value<(null==l?void 0:l.lowerLimit)?o.value-l.lowerLimit:void 0!==(null==l?void 0:l.upperLimit)&&o.value<(null==l?void 0:l.upperLimit)?l.upperLimit-o.value:0)),n=e.computed((()=>{if(!1===(null==l?void 0:l.mode))return"";if("limit"===(null==l?void 0:l.mode)&&(null==l?void 0:l.upperLimit))return`${o.value} / ${l.lowerLimit?`${l.lowerLimit}-`:""}${l.upperLimit}`;if("countdown"===(null==l?void 0:l.mode)){if(0===a.value)return;return a}return o.value}));return{length:o,gap:a,formatted:n}}(oe,{mode:k.value,upperLimit:Number(null==x?void 0:x.value),lowerLimit:Number(null==A?void 0:A.value)}),we=e.computed((()=>!c.disabled&&!c.readonly)),ke=e.computed((()=>we.value?c.tabindex:-1)),Le=e.computed((()=>!n(w))),Be=e.computed((()=>!0===B.value||!0!==L.value&&void 0)),{modifiers:Ee}=e.toRefs(c),$e=p("vv-input-text",Ee,e.computed((()=>({valid:L.value,invalid:B.value,loading:E.value,disabled:c.disabled,readonly:c.readonly,"icon-before":be.value,"icon-after":ge.value||!n(Se),floating:c.floating&&!n(c.label),dirty:Le.value,focus:ne.value,"auto-width":c.autoWidth})))),xe=e.computed((()=>{const e=ue.value&&re.value?P.TEXT:!de.value||Le.value||ae.value?(null==C?void 0:C.value)?P.TEXT:c.type:P.TEXT,t={type:e,name:c.name,tabindex:ke.value,disabled:c.disabled,readonly:c.readonly,required:c.required,autocomplete:c.autocomplete,"aria-invalid":Be.value,"aria-describedby":Pe.value?M.value:void 0,"aria-errormessage":Ce.value?M.value:void 0};return e!==P.DATE&&e!==P.MONTH&&e!==P.WEEK&&e!==P.TIME&&e!==P.DATETIME_LOCAL&&e!==P.NUMBER||(t.step=c.step,t.max=void 0!==c.max?String(c.max):void 0,t.min=void 0!==c.min?String(c.min):void 0),e!==P.TEXT&&e!==P.SEARCH&&e!==P.URL&&e!==P.TEL&&e!==P.EMAIL&&e!==P.PASSWORD&&e!==P.NUMBER||(t.placeholder=R.value),e!==P.TEXT&&e!==P.SEARCH&&e!==P.URL&&e!==P.TEL&&e!==P.EMAIL&&e!==P.PASSWORD||(t.minlength=c.minlength,t.maxlength=c.maxlength,t.pattern=c.pattern),e===P.EMAIL&&(t.multiple=c.multiple),t})),Ae=e.computed((()=>({valid:c.valid,invalid:c.invalid,modelValue:c.modelValue,togglePassword:se,stepUp:ve,stepDown:pe,clear:fe}))),{HintSlot:Te,hasHintLabelOrSlot:Pe,hasInvalidLabelOrSlot:Ce,hintSlotScope:De}=function(t,l){const o=e.computed((()=>e.isRef(t)?t.value:t)),a=e.computed((()=>i(o.value.invalidLabel))),n=e.computed((()=>i(o.value.validLabel))),r=e.computed((()=>o.value.loadingLabel)),u=e.computed((()=>o.value.hintLabel)),s=e.computed((()=>Boolean(o.value.loading&&(l.loading||r.value)))),d=e.computed((()=>!s.value&&Boolean(o.value.invalid&&(l.invalid||a.value)))),c=e.computed((()=>!s.value&&!d.value&&Boolean(o.value.valid&&(l.valid||n.value)))),v=e.computed((()=>!s.value&&!d.value&&!c.value&&Boolean(l.hint||u.value))),p=e.computed((()=>d.value||c.value||s.value||v.value)),m=e.computed((()=>({modelValue:o.value.modelValue,valid:o.value.valid,invalid:o.value.invalid,loading:o.value.loading}))),f=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:p,invalidLabel:a,validLabel:n,loadingLabel:r,hintLabel:u,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:s,hasHintLabelOrSlot:v}),render(){var t,l,o,a,n,i,r,u;if(this.isVisible){let s;return this.hasInvalidLabelOrSlot&&(s="alert"),this.hasValidLabelOrSlot&&(s="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:s},(null==(l=(t=this.$slots).loading)?void 0:l.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:s},(null==(a=(o=this.$slots).invalid)?void 0:a.call(o))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:s},(null==(i=(n=this.$slots).valid)?void 0:i.call(n))??this.validLabel):e.h(this.tag,{role:s},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:v,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:s,hintSlotScope:m,HintSlot:f}}(h,f),Ie=H(P.PASSWORD,c),Oe=H(P.NUMBER,c),Ve=H(P.SEARCH,c),_e=()=>{we.value&&(ae.value=!0)},Ne=e.computed((()=>{if(c.autoWidth)return{width:void 0!==oe.value?`${String(oe.value).length+1}ch`:void 0}})),Me=e=>{switch(e.code){case"ArrowUp":ce.value&&(ve(),e.preventDefault());break;case"ArrowDown":ce.value&&(pe(),e.preventDefault())}d("keydown",e)};return(t,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref($e))},[e.unref(y)?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(N),class:"vv-input-text__label"},e.toDisplayString(e.unref(y)),9,U)):e.createCommentVNode("",!0),e.createElementVNode("div",j,[t.$slots.before?(e.openBlock(),e.createElementBlock("div",F,[e.renderSlot(t.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(Ae))))])):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"innerEl",ref:le,class:"vv-input-text__inner",onClick:e.withModifiers(_e,["stop"])},[e.unref(be)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:0,class:"vv-input-text__icon"},e.unref(he)),null,16)):e.createCommentVNode("",!0),e.createElementVNode("input",e.mergeProps({id:e.unref(N),ref_key:"inputEl",ref:te},e.unref(xe),{style:e.unref(Ne),onKeyup:l[0]||(l[0]=e=>d("keyup",e)),onKeydown:Me,onKeypress:l[1]||(l[1]=e=>d("keypress",e))}),null,16,q),(t.unit||t.$slots.unit)&&e.unref(Le)?(e.openBlock(),e.createElementBlock("div",z,[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps(e.unref(Ae))),(()=>[e.createTextVNode(e.toDisplayString(t.unit),1)]))])):e.createCommentVNode("",!0)],8,W),e.unref(ge)||e.unref(Se)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:1,class:"vv-input-text__icon vv-input-text__icon-after"},e.unref(ge)?e.unref(he):e.unref(Se)),null,16)):e.unref(ue)&&!t.hideActions&&e.unref(we)?(e.openBlock(),e.createBlock(e.unref(Ie),{key:2,onTogglePassword:se})):e.unref(ce)&&!t.hideActions&&e.unref(we)?(e.openBlock(),e.createBlock(e.unref(Oe),{key:3,onStepUp:ve,onStepDown:pe})):e.unref(me)&&!t.hideActions&&e.unref(we)?(e.openBlock(),e.createBlock(e.unref(Ve),{key:4,onClear:fe})):e.createCommentVNode("",!0),t.$slots.after?(e.openBlock(),e.createElementBlock("div",K,[e.renderSlot(t.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(Ae))))])):e.createCommentVNode("",!0),e.unref(k)?(e.openBlock(),e.createElementBlock("span",X,[e.renderSlot(t.$slots,"count",e.normalizeProps(e.guardReactiveProps(e.unref(Ae))),(()=>[e.createTextVNode(e.toDisplayString(e.unref(ye)),1)]))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(Te),{id:e.unref(M),class:"vv-input-text__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(De))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(De))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(De))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(De))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|
|
@@ -45,26 +45,14 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
45
45
|
type: StringConstructor;
|
|
46
46
|
default: string;
|
|
47
47
|
};
|
|
48
|
-
|
|
49
|
-
type:
|
|
48
|
+
iMask: {
|
|
49
|
+
type: globalThis.PropType<import("imask/esm/index").FactoryOpts>;
|
|
50
50
|
default: undefined;
|
|
51
51
|
};
|
|
52
|
-
|
|
53
|
-
type:
|
|
54
|
-
default: boolean;
|
|
55
|
-
};
|
|
56
|
-
maskReversed: {
|
|
57
|
-
type: BooleanConstructor;
|
|
58
|
-
default: boolean;
|
|
59
|
-
};
|
|
60
|
-
maskTokens: {
|
|
61
|
-
type: globalThis.PropType<import("maska").MaskTokens>;
|
|
52
|
+
masked: {
|
|
53
|
+
type: StringConstructor;
|
|
62
54
|
default: undefined;
|
|
63
55
|
};
|
|
64
|
-
maskTokensReplace: {
|
|
65
|
-
type: BooleanConstructor;
|
|
66
|
-
default: boolean;
|
|
67
|
-
};
|
|
68
56
|
autoWidth: {
|
|
69
57
|
type: BooleanConstructor;
|
|
70
58
|
default: boolean;
|
|
@@ -179,26 +167,14 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
179
167
|
type: StringConstructor;
|
|
180
168
|
default: string;
|
|
181
169
|
};
|
|
182
|
-
|
|
183
|
-
type:
|
|
170
|
+
iMask: {
|
|
171
|
+
type: globalThis.PropType<import("imask/esm/index").FactoryOpts>;
|
|
184
172
|
default: undefined;
|
|
185
173
|
};
|
|
186
|
-
|
|
187
|
-
type:
|
|
188
|
-
default: boolean;
|
|
189
|
-
};
|
|
190
|
-
maskReversed: {
|
|
191
|
-
type: BooleanConstructor;
|
|
192
|
-
default: boolean;
|
|
193
|
-
};
|
|
194
|
-
maskTokens: {
|
|
195
|
-
type: globalThis.PropType<import("maska").MaskTokens>;
|
|
174
|
+
masked: {
|
|
175
|
+
type: StringConstructor;
|
|
196
176
|
default: undefined;
|
|
197
177
|
};
|
|
198
|
-
maskTokensReplace: {
|
|
199
|
-
type: BooleanConstructor;
|
|
200
|
-
default: boolean;
|
|
201
|
-
};
|
|
202
178
|
autoWidth: {
|
|
203
179
|
type: BooleanConstructor;
|
|
204
180
|
default: boolean;
|
|
@@ -270,7 +246,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
270
246
|
disabled: boolean;
|
|
271
247
|
floating: boolean;
|
|
272
248
|
type: import("../VvInputText").InputType;
|
|
273
|
-
mask: string;
|
|
274
249
|
tabindex: string | number;
|
|
275
250
|
required: boolean;
|
|
276
251
|
iconPosition: "before" | "after";
|
|
@@ -292,10 +267,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
292
267
|
labelShowPassword: string;
|
|
293
268
|
labelHidePassword: string;
|
|
294
269
|
labelClear: string;
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
maskTokens: import("maska").MaskTokens;
|
|
298
|
-
maskTokensReplace: boolean;
|
|
270
|
+
iMask: import("imask/esm/index").FactoryOpts;
|
|
271
|
+
masked: string;
|
|
299
272
|
autoWidth: boolean;
|
|
300
273
|
hideActions: boolean;
|
|
301
274
|
selectOnFocus: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
-
import type {
|
|
2
|
+
import type { FactoryOpts } from 'imask';
|
|
3
3
|
export declare const INPUT_TYPES: {
|
|
4
4
|
readonly TEXT: "text";
|
|
5
5
|
readonly PASSWORD: "password";
|
|
@@ -133,45 +133,20 @@ export declare const VvInputTextProps: {
|
|
|
133
133
|
default: string;
|
|
134
134
|
};
|
|
135
135
|
/**
|
|
136
|
-
*
|
|
137
|
-
* @see https://
|
|
136
|
+
* iMask options
|
|
137
|
+
* @see https://imask.js.org/guide.html
|
|
138
138
|
*/
|
|
139
|
-
|
|
140
|
-
type:
|
|
139
|
+
iMask: {
|
|
140
|
+
type: PropType<FactoryOpts>;
|
|
141
141
|
default: undefined;
|
|
142
142
|
};
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
145
|
-
* @see https://beholdr.github.io/maska/#/?id=maskinput-options
|
|
144
|
+
* Masked value
|
|
146
145
|
*/
|
|
147
|
-
|
|
148
|
-
type:
|
|
149
|
-
default: boolean;
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* Write values reverse (ex. for numbers)
|
|
153
|
-
* @see https://beholdr.github.io/maska/#/?id=maskinput-options
|
|
154
|
-
*/
|
|
155
|
-
maskReversed: {
|
|
156
|
-
type: BooleanConstructor;
|
|
157
|
-
default: boolean;
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Add mask custom tokens
|
|
161
|
-
* @see https://beholdr.github.io/maska/#/?id=custom-tokens
|
|
162
|
-
*/
|
|
163
|
-
maskTokens: {
|
|
164
|
-
type: PropType<MaskTokens>;
|
|
146
|
+
masked: {
|
|
147
|
+
type: StringConstructor;
|
|
165
148
|
default: undefined;
|
|
166
149
|
};
|
|
167
|
-
/**
|
|
168
|
-
* Replace default tokens
|
|
169
|
-
* @see https://beholdr.github.io/maska/#/?id=custom-tokens
|
|
170
|
-
*/
|
|
171
|
-
maskTokensReplace: {
|
|
172
|
-
type: BooleanConstructor;
|
|
173
|
-
default: boolean;
|
|
174
|
-
};
|
|
175
150
|
/**
|
|
176
151
|
* Adjust input width to content
|
|
177
152
|
*/
|
|
@@ -219,12 +194,20 @@ export declare const VvInputTextProps: {
|
|
|
219
194
|
default: boolean;
|
|
220
195
|
validator: (value: string) => boolean;
|
|
221
196
|
};
|
|
222
|
-
modifiers: PropType<string | string[]>;
|
|
197
|
+
modifiers: PropType<string | string[]>; /**
|
|
198
|
+
* Pattern the value must match to be valid
|
|
199
|
+
* Available for input types: text, search, url, tel, email and password
|
|
200
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#pattern
|
|
201
|
+
*/
|
|
223
202
|
loading: BooleanConstructor;
|
|
224
203
|
loadingLabel: {
|
|
225
204
|
type: StringConstructor;
|
|
226
205
|
default: string;
|
|
227
|
-
};
|
|
206
|
+
}; /**
|
|
207
|
+
* Minimum value
|
|
208
|
+
* Available for input types: date, month, week, time, datetime-local, number, range.
|
|
209
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min
|
|
210
|
+
*/
|
|
228
211
|
hintLabel: {
|
|
229
212
|
type: StringConstructor;
|
|
230
213
|
default: string;
|
|
@@ -952,14 +952,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
952
952
|
valid,
|
|
953
953
|
invalid,
|
|
954
954
|
loading,
|
|
955
|
-
modifiers
|
|
955
|
+
modifiers,
|
|
956
|
+
debounce,
|
|
957
|
+
minlength,
|
|
958
|
+
maxlength
|
|
956
959
|
} = toRefs(props);
|
|
957
960
|
const hasId = useUniqueId(id);
|
|
958
961
|
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
959
962
|
const hasPlaceholder = computed(
|
|
960
963
|
() => props.floating && isEmpty(props.placeholder) ? " " : props.placeholder
|
|
961
964
|
);
|
|
962
|
-
const localModelValue = useDebouncedInput(modelValue, emit,
|
|
965
|
+
const localModelValue = useDebouncedInput(modelValue, emit, debounce == null ? void 0 : debounce.value);
|
|
963
966
|
const { hasIcon, hasIconBefore, hasIconAfter } = useComponentIcon(
|
|
964
967
|
icon,
|
|
965
968
|
iconPosition
|
|
@@ -972,9 +975,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
972
975
|
}
|
|
973
976
|
});
|
|
974
977
|
const { formatted: countFormatted } = useTextCount(localModelValue, {
|
|
975
|
-
mode:
|
|
976
|
-
upperLimit: Number(
|
|
977
|
-
lowerLimit: Number(
|
|
978
|
+
mode: count == null ? void 0 : count.value,
|
|
979
|
+
upperLimit: Number(maxlength == null ? void 0 : maxlength.value),
|
|
980
|
+
lowerLimit: Number(minlength == null ? void 0 : minlength.value)
|
|
978
981
|
});
|
|
979
982
|
const isClickable = computed(() => !props.disabled && !props.readonly);
|
|
980
983
|
const hasTabindex = computed(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@iconify/vue"),require("nanoid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","@iconify/vue","nanoid","@vueuse/core"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvTextarea=t(e.vue,e.vue$1,e.nanoid,e.core)}(this,(function(e,t,o,l){"use strict";function a(t){return null==(o=e.unref(t))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length;var o}function n(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const i={color:String,width:{type:[String,Number]},height:{type:[String,Number]},name:{type:String,required:!0},provider:{type:String},prefix:{type:String,default:"normal"},src:String,horizontalFlip:Boolean,verticalFlip:Boolean,flip:String,mode:String,inline:Boolean,rotate:[Number,String],onLoad:Function,svg:String,modifiers:{type:[String,Array]}};var r=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(r||{}),u=(e=>(e.before="before",e.after="after",e))(u||{}),d=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(d||{});const s=Symbol.for("volver");function c(){return e.inject(s)}function v(t,o,l){return e.computed((()=>{const a={[t]:!0},n="string"==typeof(null==o?void 0:o.value)?o.value.split(" "):null==o?void 0:o.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(a[`${t}--${e}`]=!0)})),l&&Object.keys(l.value).forEach((o=>{a[`${t}--${o}`]=e.unref(l.value[o])})),a}))}const f=e.defineComponent({name:"VvIcon",props:i,setup(o){const l=o,a=e.computed((()=>"string"==typeof l.rotate?parseFloat(l.rotate):l.rotate)),n=e.ref(!0),i=c(),{modifiers:r}=e.toRefs(l),u=v("vv-icon",r),d=e.computed((()=>l.provider||(null==i?void 0:i.iconsProvider))),s=e.computed((()=>{const e=l.name??"",o=`@${d.value}:${l.prefix}:${e}`;if(t.iconExists(o))return o;const a=null==i?void 0:i.iconsCollections.find((o=>{const l=`@${d.value}:${o.prefix}:${e}`;return t.iconExists(l)}));return a?`@${d.value}:${a.prefix}:${e}`:e}));function f(e){const o=function(e){let t;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),a=(null==o?void 0:o.innerHTML.trim())||"";o&&a&&t.addIcon(`@${d.value}:${l.prefix}:${l.name}`,{body:a,height:o.viewBox.baseVal.height,width:o.viewBox.baseVal.width})}return i&&l.src&&!t.iconExists(`@${d.value}:${l.prefix}:${l.name}`)&&(n.value=!1,i.fetchIcon(l.src).then((e=>{e&&(f(e),n.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),l.svg&&f(l.svg),(o,l)=>e.unref(n)?(e.openBlock(),e.createBlock(e.unref(t.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:o.inline,width:o.width,height:o.height,horizontalFlip:o.horizontalFlip,verticalFlip:o.verticalFlip,flip:o.flip,rotate:e.unref(a),color:o.color,onLoad:o.onLoad,icon:e.unref(s)}),null,16,["class"])):e.createCommentVNode("",!0)}}),p={valid:Boolean,validLabel:[String,Array]},m={invalid:Boolean,invalidLabel:[String,Array]},h={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},g={disabled:Boolean},b=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},S={modifiers:[String,Array]},B={hintLabel:{type:String,default:""}},L={count:{type:[Boolean,String],default:!1,validator:e=>[!0,!1,"limit","countdown"].includes(e)}},x={debounce:[Number,String]},$={icon:{type:[String,Object]},iconPosition:{type:String,default:u.before,validation:e=>Object.values(u).includes(e)}},w={tabindex:{type:[String,Number],default:0}},k={floating:Boolean},V={id:[String,Number]};r.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const N={...{...V,name:{type:String,required:!0}},...{autofocus:Boolean},...{autocomplete:{type:String,default:"off"}},...w,...g,...y,...p,...m,...B,...h,...S,...L,...x,...$,...k,...b,minlength:[String,Number],maxlength:[String,Number],placeholder:String,required:Boolean};d.button;const O={...N,modelValue:String,cols:{type:[String,Number],default:20},rows:{type:[String,Number],default:2},wrap:{type:String,default:"soft"},spellcheck:{type:[Boolean,String],default:"default"},resizable:Boolean};const P=["for"],_={class:"vv-textarea__wrapper"},I={key:0,class:"vv-textarea__input-before"},C={class:"vv-textarea__inner"},E=["id"],z={key:1,class:"vv-textarea__input-after"},A={key:2,class:"vv-textarea__limit"};return e.defineComponent({name:"VvTextarea",props:O,emits:["update:modelValue","focus","blur","keyup"],setup(t,{emit:i}){const d=t,s=e.useSlots(),p=function(t,o,l){const a=c(),n=e.computed((()=>{var e;if(a&&(null==(e=a.defaults.value)?void 0:e[t]))return a.defaults.value[t]}));return e.computed((()=>{if(void 0===n.value)return l;const e=n.value,t=o,a=l;return Object.keys(t).reduce(((o,l)=>{const n=a[l];if(o[l]=n,l in e){if(Array.isArray(t[l])){const a=t[l];a.length&&a[0]===n&&(o[l]=e[l])}if("function"==typeof t[l]&&(0,t[l])()===n&&(o[l]=e[l]),"object"==typeof t[l]){let a=t[l].default;"function"==typeof a&&(a=a()),"object"==typeof a?JSON.stringify(a)===JSON.stringify(n)&&(o[l]=e[l]):a===n&&(o[l]=e[l])}}return o}),{})}))}("VvTextarea",O,d),m=e.ref(),{id:h,icon:g,iconPosition:b,label:y,modelValue:S,count:B,valid:L,invalid:x,loading:$,modifiers:w}=e.toRefs(d),k=(t=>e.computed((()=>String((null==t?void 0:t.value)||o.nanoid()))))(h),V=e.computed((()=>`${k.value}-hint`)),N=e.computed((()=>d.floating&&a(d.placeholder)?" ":d.placeholder)),j=function(t,o,l=0,{getter:a=(e=>e),setter:n=(e=>e)}={}){let i;return"string"==typeof l&&(l=parseInt(l)),e.computed({get:()=>a(null==t?void 0:t.value),set:e=>{i&&clearTimeout(i),i=setTimeout((()=>{o("update:modelValue",n(e))}),l)}})}(S,i,d.debounce),{hasIcon:R,hasIconBefore:q,hasIconAfter:T}=function(t,o){const l=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.before))),a=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.after))),n=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===r.left))),i=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===r.right))),d=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===r.top))),s=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===r.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==t?void 0:t.value)?{name:null==t?void 0:t.value}:null==t?void 0:t.value)),hasIconLeft:n,hasIconRight:i,hasIconTop:d,hasIconBottom:s,hasIconBefore:l,hasIconAfter:a}}(g,b),{focused:F}=function(t,o){const{focused:a}=l.useFocus(t);return e.watch(a,(l=>{o(l?"focus":"blur",e.unref(t))})),{focused:a}}(m,i),D=l.useElementVisibility(m);e.watch(D,(e=>{e&&d.autofocus&&(F.value=!0)}));const{formatted:H}=function(t,o){const l=e.computed((()=>(e.unref(t)??"").length)),a=e.computed((()=>void 0!==(null==o?void 0:o.lowerLimit)&&l.value<(null==o?void 0:o.lowerLimit)?l.value-o.lowerLimit:void 0!==(null==o?void 0:o.upperLimit)&&l.value<(null==o?void 0:o.upperLimit)?o.upperLimit-l.value:0)),n=e.computed((()=>{if(!1===(null==o?void 0:o.mode))return"";if("limit"===(null==o?void 0:o.mode)&&(null==o?void 0:o.upperLimit))return`${l.value} / ${o.lowerLimit?`${o.lowerLimit}-`:""}${o.upperLimit}`;if("countdown"===(null==o?void 0:o.mode)){if(0===a.value)return;return a}return l.value}));return{length:l,gap:a,formatted:n}}(j,{mode:d.count,upperLimit:Number(d.maxlength),lowerLimit:Number(d.minlength)}),M=e.computed((()=>!d.disabled&&!d.readonly)),J=e.computed((()=>M.value?d.tabindex:-1)),K=e.computed((()=>!a(S))),U=e.computed((()=>!0===d.invalid||!0!==d.valid&&void 0)),{HintSlot:G,hasHintLabelOrSlot:Q,hasInvalidLabelOrSlot:W,hintSlotScope:X}=function(t,o){const l=e.computed((()=>e.isRef(t)?t.value:t)),a=e.computed((()=>n(l.value.invalidLabel))),i=e.computed((()=>n(l.value.validLabel))),r=e.computed((()=>l.value.loadingLabel)),u=e.computed((()=>l.value.hintLabel)),d=e.computed((()=>Boolean(l.value.loading&&(o.loading||r.value)))),s=e.computed((()=>!d.value&&Boolean(l.value.invalid&&(o.invalid||a.value)))),c=e.computed((()=>!d.value&&!s.value&&Boolean(l.value.valid&&(o.valid||i.value)))),v=e.computed((()=>!d.value&&!s.value&&!c.value&&Boolean(o.hint||u.value))),f=e.computed((()=>s.value||c.value||d.value||v.value)),p=e.computed((()=>({modelValue:l.value.modelValue,valid:l.value.valid,invalid:l.value.invalid,loading:l.value.loading}))),m=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:f,invalidLabel:a,validLabel:i,loadingLabel:r,hintLabel:u,hasInvalidLabelOrSlot:s,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:d,hasHintLabelOrSlot:v}),render(){var t,o,l,a,n,i,r,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(o=(t=this.$slots).loading)?void 0:o.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:d},(null==(a=(l=this.$slots).invalid)?void 0:a.call(l))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(i=(n=this.$slots).valid)?void 0:i.call(n))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:s,hasHintLabelOrSlot:v,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:d,hintSlotScope:p,HintSlot:m}}(p,s),Y=v("vv-textarea",w,e.computed((()=>({valid:L.value,invalid:x.value,loading:$.value,disabled:d.disabled,readonly:d.readonly,"icon-before":q.value,"icon-after":T.value,floating:d.floating&&!a(d.label),dirty:K.value,focused:F.value,resizable:d.resizable})))),Z=e.computed((()=>({name:d.name,placeholder:N.value,tabindex:J.value,disabled:d.disabled,readonly:d.readonly,required:d.required,autocomplete:d.autocomplete,minlength:d.minlength,maxlength:d.maxlength,cols:d.cols,rows:d.rows,wrap:d.wrap,spellcheck:d.spellcheck,"aria-invalid":U.value,"aria-describedby":Q.value?V.value:void 0,"aria-errormessage":W.value?V.value:void 0}))),ee=e.computed((()=>({valid:d.valid,invalid:d.invalid,modelValue:d.modelValue,hintLabel:d.hintLabel,maxlength:d.maxlength,minlength:d.minlength,clear:te}))),te=()=>{j.value=void 0};return(t,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(Y))},[e.unref(y)?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(k),class:"vv-textarea__label"},e.toDisplayString(e.unref(y)),9,P)):e.createCommentVNode("",!0),e.createElementVNode("div",_,[t.$slots.before?(e.openBlock(),e.createElementBlock("div",I,[e.renderSlot(t.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(ee))))])):e.createCommentVNode("",!0),e.createElementVNode("div",C,[e.unref(q)?(e.openBlock(),e.createBlock(f,e.mergeProps({key:0,class:"vv-textarea__icon"},e.unref(R)),null,16)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("textarea",e.mergeProps({id:e.unref(k),ref_key:"textarea",ref:m,"onUpdate:modelValue":o[0]||(o[0]=t=>e.isRef(j)?j.value=t:null)},e.unref(Z),{onKeyup:o[1]||(o[1]=e=>i("keyup",e))}),null,16,E),[[e.vModelText,e.unref(j)]]),e.unref(T)?(e.openBlock(),e.createBlock(f,e.mergeProps({key:1,class:"vv-textarea__icon vv-textarea__icon-after"},e.unref(R)),null,16)):e.createCommentVNode("",!0)]),t.$slots.after?(e.openBlock(),e.createElementBlock("div",z,[e.renderSlot(t.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(ee))))])):e.createCommentVNode("",!0),e.unref(B)?(e.openBlock(),e.createElementBlock("span",A,[e.renderSlot(t.$slots,"count",e.normalizeProps(e.guardReactiveProps(e.unref(ee))),(()=>[e.createTextVNode(e.toDisplayString(e.unref(H)),1)]))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(G),{id:e.unref(V),class:"vv-textarea__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(X))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(X))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(X))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(X))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@iconify/vue"),require("nanoid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","@iconify/vue","nanoid","@vueuse/core"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvTextarea=t(e.vue,e.vue$1,e.nanoid,e.core)}(this,(function(e,t,l,o){"use strict";function a(t){return null==(l=e.unref(t))||""===l||Array.isArray(l)&&0===l.length||!(l instanceof Date)&&"object"==typeof l&&0===Object.keys(l).length;var l}function n(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const i={color:String,width:{type:[String,Number]},height:{type:[String,Number]},name:{type:String,required:!0},provider:{type:String},prefix:{type:String,default:"normal"},src:String,horizontalFlip:Boolean,verticalFlip:Boolean,flip:String,mode:String,inline:Boolean,rotate:[Number,String],onLoad:Function,svg:String,modifiers:{type:[String,Array]}};var r=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(r||{}),u=(e=>(e.before="before",e.after="after",e))(u||{}),d=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(d||{});const s=Symbol.for("volver");function v(){return e.inject(s)}function c(t,l,o){return e.computed((()=>{const a={[t]:!0},n="string"==typeof(null==l?void 0:l.value)?l.value.split(" "):null==l?void 0:l.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(a[`${t}--${e}`]=!0)})),o&&Object.keys(o.value).forEach((l=>{a[`${t}--${l}`]=e.unref(o.value[l])})),a}))}const f=e.defineComponent({name:"VvIcon",props:i,setup(l){const o=l,a=e.computed((()=>"string"==typeof o.rotate?parseFloat(o.rotate):o.rotate)),n=e.ref(!0),i=v(),{modifiers:r}=e.toRefs(o),u=c("vv-icon",r),d=e.computed((()=>o.provider||(null==i?void 0:i.iconsProvider))),s=e.computed((()=>{const e=o.name??"",l=`@${d.value}:${o.prefix}:${e}`;if(t.iconExists(l))return l;const a=null==i?void 0:i.iconsCollections.find((l=>{const o=`@${d.value}:${l.prefix}:${e}`;return t.iconExists(o)}));return a?`@${d.value}:${a.prefix}:${e}`:e}));function f(e){const l=function(e){let t;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),a=(null==l?void 0:l.innerHTML.trim())||"";l&&a&&t.addIcon(`@${d.value}:${o.prefix}:${o.name}`,{body:a,height:l.viewBox.baseVal.height,width:l.viewBox.baseVal.width})}return i&&o.src&&!t.iconExists(`@${d.value}:${o.prefix}:${o.name}`)&&(n.value=!1,i.fetchIcon(o.src).then((e=>{e&&(f(e),n.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),o.svg&&f(o.svg),(l,o)=>e.unref(n)?(e.openBlock(),e.createBlock(e.unref(t.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:l.inline,width:l.width,height:l.height,horizontalFlip:l.horizontalFlip,verticalFlip:l.verticalFlip,flip:l.flip,rotate:e.unref(a),color:l.color,onLoad:l.onLoad,icon:e.unref(s)}),null,16,["class"])):e.createCommentVNode("",!0)}}),p={valid:Boolean,validLabel:[String,Array]},m={invalid:Boolean,invalidLabel:[String,Array]},h={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},g={disabled:Boolean},b=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},S={modifiers:[String,Array]},B={hintLabel:{type:String,default:""}},L={count:{type:[Boolean,String],default:!1,validator:e=>[!0,!1,"limit","countdown"].includes(e)}},x={debounce:[Number,String]},$={icon:{type:[String,Object]},iconPosition:{type:String,default:u.before,validation:e=>Object.values(u).includes(e)}},w={tabindex:{type:[String,Number],default:0}},k={floating:Boolean},V={id:[String,Number]};r.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const N={...{...V,name:{type:String,required:!0}},...{autofocus:Boolean},...{autocomplete:{type:String,default:"off"}},...w,...g,...y,...p,...m,...B,...h,...S,...L,...x,...$,...k,...b,minlength:[String,Number],maxlength:[String,Number],placeholder:String,required:Boolean};d.button;const O={...N,modelValue:String,cols:{type:[String,Number],default:20},rows:{type:[String,Number],default:2},wrap:{type:String,default:"soft"},spellcheck:{type:[Boolean,String],default:"default"},resizable:Boolean};const P=["for"],_={class:"vv-textarea__wrapper"},I={key:0,class:"vv-textarea__input-before"},C={class:"vv-textarea__inner"},E=["id"],z={key:1,class:"vv-textarea__input-after"},A={key:2,class:"vv-textarea__limit"};return e.defineComponent({name:"VvTextarea",props:O,emits:["update:modelValue","focus","blur","keyup"],setup(t,{emit:i}){const d=t,s=e.useSlots(),p=function(t,l,o){const a=v(),n=e.computed((()=>{var e;if(a&&(null==(e=a.defaults.value)?void 0:e[t]))return a.defaults.value[t]}));return e.computed((()=>{if(void 0===n.value)return o;const e=n.value,t=l,a=o;return Object.keys(t).reduce(((l,o)=>{const n=a[o];if(l[o]=n,o in e){if(Array.isArray(t[o])){const a=t[o];a.length&&a[0]===n&&(l[o]=e[o])}if("function"==typeof t[o]&&(0,t[o])()===n&&(l[o]=e[o]),"object"==typeof t[o]){let a=t[o].default;"function"==typeof a&&(a=a()),"object"==typeof a?JSON.stringify(a)===JSON.stringify(n)&&(l[o]=e[o]):a===n&&(l[o]=e[o])}}return l}),{})}))}("VvTextarea",O,d),m=e.ref(),{id:h,icon:g,iconPosition:b,label:y,modelValue:S,count:B,valid:L,invalid:x,loading:$,modifiers:w,debounce:k,minlength:V,maxlength:N}=e.toRefs(d),j=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(h),R=e.computed((()=>`${j.value}-hint`)),q=e.computed((()=>d.floating&&a(d.placeholder)?" ":d.placeholder)),T=function(t,l,o=0,{getter:a=(e=>e),setter:n=(e=>e)}={}){let i;return"string"==typeof o&&(o=parseInt(o)),e.computed({get:()=>a(null==t?void 0:t.value),set:e=>{i&&clearTimeout(i),i=setTimeout((()=>{l("update:modelValue",n(e))}),o)}})}(S,i,null==k?void 0:k.value),{hasIcon:F,hasIconBefore:D,hasIconAfter:H}=function(t,l){const o=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===u.before))),a=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===u.after))),n=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===r.left))),i=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===r.right))),d=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===r.top))),s=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===r.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==t?void 0:t.value)?{name:null==t?void 0:t.value}:null==t?void 0:t.value)),hasIconLeft:n,hasIconRight:i,hasIconTop:d,hasIconBottom:s,hasIconBefore:o,hasIconAfter:a}}(g,b),{focused:M}=function(t,l){const{focused:a}=o.useFocus(t);return e.watch(a,(o=>{l(o?"focus":"blur",e.unref(t))})),{focused:a}}(m,i),J=o.useElementVisibility(m);e.watch(J,(e=>{e&&d.autofocus&&(M.value=!0)}));const{formatted:K}=function(t,l){const o=e.computed((()=>(e.unref(t)??"").length)),a=e.computed((()=>void 0!==(null==l?void 0:l.lowerLimit)&&o.value<(null==l?void 0:l.lowerLimit)?o.value-l.lowerLimit:void 0!==(null==l?void 0:l.upperLimit)&&o.value<(null==l?void 0:l.upperLimit)?l.upperLimit-o.value:0)),n=e.computed((()=>{if(!1===(null==l?void 0:l.mode))return"";if("limit"===(null==l?void 0:l.mode)&&(null==l?void 0:l.upperLimit))return`${o.value} / ${l.lowerLimit?`${l.lowerLimit}-`:""}${l.upperLimit}`;if("countdown"===(null==l?void 0:l.mode)){if(0===a.value)return;return a}return o.value}));return{length:o,gap:a,formatted:n}}(T,{mode:null==B?void 0:B.value,upperLimit:Number(null==N?void 0:N.value),lowerLimit:Number(null==V?void 0:V.value)}),U=e.computed((()=>!d.disabled&&!d.readonly)),G=e.computed((()=>U.value?d.tabindex:-1)),Q=e.computed((()=>!a(S))),W=e.computed((()=>!0===d.invalid||!0!==d.valid&&void 0)),{HintSlot:X,hasHintLabelOrSlot:Y,hasInvalidLabelOrSlot:Z,hintSlotScope:ee}=function(t,l){const o=e.computed((()=>e.isRef(t)?t.value:t)),a=e.computed((()=>n(o.value.invalidLabel))),i=e.computed((()=>n(o.value.validLabel))),r=e.computed((()=>o.value.loadingLabel)),u=e.computed((()=>o.value.hintLabel)),d=e.computed((()=>Boolean(o.value.loading&&(l.loading||r.value)))),s=e.computed((()=>!d.value&&Boolean(o.value.invalid&&(l.invalid||a.value)))),v=e.computed((()=>!d.value&&!s.value&&Boolean(o.value.valid&&(l.valid||i.value)))),c=e.computed((()=>!d.value&&!s.value&&!v.value&&Boolean(l.hint||u.value))),f=e.computed((()=>s.value||v.value||d.value||c.value)),p=e.computed((()=>({modelValue:o.value.modelValue,valid:o.value.valid,invalid:o.value.invalid,loading:o.value.loading}))),m=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:f,invalidLabel:a,validLabel:i,loadingLabel:r,hintLabel:u,hasInvalidLabelOrSlot:s,hasValidLabelOrSlot:v,hasLoadingLabelOrSlot:d,hasHintLabelOrSlot:c}),render(){var t,l,o,a,n,i,r,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(l=(t=this.$slots).loading)?void 0:l.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:d},(null==(a=(o=this.$slots).invalid)?void 0:a.call(o))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(i=(n=this.$slots).valid)?void 0:i.call(n))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:s,hasHintLabelOrSlot:c,hasValidLabelOrSlot:v,hasLoadingLabelOrSlot:d,hintSlotScope:p,HintSlot:m}}(p,s),te=c("vv-textarea",w,e.computed((()=>({valid:L.value,invalid:x.value,loading:$.value,disabled:d.disabled,readonly:d.readonly,"icon-before":D.value,"icon-after":H.value,floating:d.floating&&!a(d.label),dirty:Q.value,focused:M.value,resizable:d.resizable})))),le=e.computed((()=>({name:d.name,placeholder:q.value,tabindex:G.value,disabled:d.disabled,readonly:d.readonly,required:d.required,autocomplete:d.autocomplete,minlength:d.minlength,maxlength:d.maxlength,cols:d.cols,rows:d.rows,wrap:d.wrap,spellcheck:d.spellcheck,"aria-invalid":W.value,"aria-describedby":Y.value?R.value:void 0,"aria-errormessage":Z.value?R.value:void 0}))),oe=e.computed((()=>({valid:d.valid,invalid:d.invalid,modelValue:d.modelValue,hintLabel:d.hintLabel,maxlength:d.maxlength,minlength:d.minlength,clear:ae}))),ae=()=>{T.value=void 0};return(t,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(te))},[e.unref(y)?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(j),class:"vv-textarea__label"},e.toDisplayString(e.unref(y)),9,P)):e.createCommentVNode("",!0),e.createElementVNode("div",_,[t.$slots.before?(e.openBlock(),e.createElementBlock("div",I,[e.renderSlot(t.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(oe))))])):e.createCommentVNode("",!0),e.createElementVNode("div",C,[e.unref(D)?(e.openBlock(),e.createBlock(f,e.mergeProps({key:0,class:"vv-textarea__icon"},e.unref(F)),null,16)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("textarea",e.mergeProps({id:e.unref(j),ref_key:"textarea",ref:m,"onUpdate:modelValue":l[0]||(l[0]=t=>e.isRef(T)?T.value=t:null)},e.unref(le),{onKeyup:l[1]||(l[1]=e=>i("keyup",e))}),null,16,E),[[e.vModelText,e.unref(T)]]),e.unref(H)?(e.openBlock(),e.createBlock(f,e.mergeProps({key:1,class:"vv-textarea__icon vv-textarea__icon-after"},e.unref(F)),null,16)):e.createCommentVNode("",!0)]),t.$slots.after?(e.openBlock(),e.createElementBlock("div",z,[e.renderSlot(t.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(oe))))])):e.createCommentVNode("",!0),e.unref(B)?(e.openBlock(),e.createElementBlock("span",A,[e.renderSlot(t.$slots,"count",e.normalizeProps(e.guardReactiveProps(e.unref(oe))),(()=>[e.createTextVNode(e.toDisplayString(e.unref(K)),1)]))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(X),{id:e.unref(R),class:"vv-textarea__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(ee))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(ee))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(ee))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(ee))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|