@volverjs/ui-vue 0.0.9-beta.15 → 0.0.9-beta.17
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/VvDialog/VvDialog.es.js +8 -4
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.es.js +12 -0
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +9 -0
- package/dist/components/VvInputText/index.d.ts +7 -0
- package/dist/components/index.es.js +20 -4
- 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 +48 -0
- package/package.json +1 -1
- 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/VvDialog/VvDialog.vue +6 -2
- package/src/components/VvInputText/VvInputText.vue +5 -0
- package/src/components/VvInputText/index.ts +7 -0
- package/src/stories/InputText/InputText.settings.ts +48 -1
|
@@ -532,14 +532,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
532
532
|
const transitioName = computed(() => `vv-dialog--${props.transition}`);
|
|
533
533
|
const dialogTransitionHandlers = {
|
|
534
534
|
"before-enter": () => {
|
|
535
|
-
var _a;
|
|
536
|
-
(_a = dialogEl.value) == null ? void 0 : _a.
|
|
535
|
+
var _a, _b;
|
|
536
|
+
if (!((_a = dialogEl.value) == null ? void 0 : _a.open)) {
|
|
537
|
+
(_b = dialogEl.value) == null ? void 0 : _b.showModal();
|
|
538
|
+
}
|
|
537
539
|
emit("open");
|
|
538
540
|
emit("before-enter");
|
|
539
541
|
},
|
|
540
542
|
"after-leave": () => {
|
|
541
|
-
var _a;
|
|
542
|
-
(_a = dialogEl.value) == null ? void 0 : _a.
|
|
543
|
+
var _a, _b;
|
|
544
|
+
if ((_a = dialogEl.value) == null ? void 0 : _a.open) {
|
|
545
|
+
(_b = dialogEl.value) == null ? void 0 : _b.close();
|
|
546
|
+
}
|
|
543
547
|
emit("close");
|
|
544
548
|
emit("after-leave");
|
|
545
549
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("vue"),require("@iconify/vue"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","@iconify/vue","@vueuse/core"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).VvDialog=o(e.vue,e.vue$1,e.core)}(this,(function(e,o,t){"use strict";const n={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||{}),l=(e=>(e.before="before",e.after="after",e))(l||{}),i=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(i||{});const a=Symbol.for("volver");const c=e.defineComponent({name:"VvIcon",props:n,setup(t){const n=t,r=e.computed((()=>"string"==typeof n.rotate?parseFloat(n.rotate):n.rotate)),l=e.ref(!0),i=e.inject(a),{modifiers:c}=e.toRefs(n),s=function(o,t,n){return e.computed((()=>{const r={[o]:!0},l="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return l&&Array.isArray(l)&&l.forEach((e=>{e&&(r[`${o}--${e}`]=!0)})),n&&Object.keys(n.value).forEach((t=>{r[`${o}--${t}`]=e.unref(n.value[t])})),r}))}("vv-icon",c),u=e.computed((()=>n.provider||(null==i?void 0:i.iconsProvider))),d=e.computed((()=>{const e=n.name??"",t=`@${u.value}:${n.prefix}:${e}`;if(o.iconExists(t))return t;const r=null==i?void 0:i.iconsCollections.find((t=>{const n=`@${u.value}:${t.prefix}:${e}`;return o.iconExists(n)}));return r?`@${u.value}:${r.prefix}:${e}`:e}));function
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("vue"),require("@iconify/vue"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","@iconify/vue","@vueuse/core"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).VvDialog=o(e.vue,e.vue$1,e.core)}(this,(function(e,o,t){"use strict";const n={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||{}),l=(e=>(e.before="before",e.after="after",e))(l||{}),i=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(i||{});const a=Symbol.for("volver");const c=e.defineComponent({name:"VvIcon",props:n,setup(t){const n=t,r=e.computed((()=>"string"==typeof n.rotate?parseFloat(n.rotate):n.rotate)),l=e.ref(!0),i=e.inject(a),{modifiers:c}=e.toRefs(n),s=function(o,t,n){return e.computed((()=>{const r={[o]:!0},l="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return l&&Array.isArray(l)&&l.forEach((e=>{e&&(r[`${o}--${e}`]=!0)})),n&&Object.keys(n.value).forEach((t=>{r[`${o}--${t}`]=e.unref(n.value[t])})),r}))}("vv-icon",c),u=e.computed((()=>n.provider||(null==i?void 0:i.iconsProvider))),d=e.computed((()=>{const e=n.name??"",t=`@${u.value}:${n.prefix}:${e}`;if(o.iconExists(t))return t;const r=null==i?void 0:i.iconsCollections.find((t=>{const n=`@${u.value}:${t.prefix}:${e}`;return o.iconExists(n)}));return r?`@${u.value}:${r.prefix}:${e}`:e}));function v(e){const t=function(e){let o;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");o=(new e).window}return(o?new o.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),r=(null==t?void 0:t.innerHTML.trim())||"";t&&r&&o.addIcon(`@${u.value}:${n.prefix}:${n.name}`,{body:r,height:t.viewBox.baseVal.height,width:t.viewBox.baseVal.width})}return i&&n.src&&!o.iconExists(`@${u.value}:${n.prefix}:${n.name}`)&&(l.value=!1,i.fetchIcon(n.src).then((e=>{e&&(v(e),l.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),n.svg&&v(n.svg),(t,n)=>e.unref(l)?(e.openBlock(),e.createBlock(e.unref(o.Icon),e.mergeProps({key:0,class:e.unref(s)},{inline:t.inline,width:t.width,height:t.height,horizontalFlip:t.horizontalFlip,verticalFlip:t.verticalFlip,flip:t.flip,rotate:e.unref(r),color:t.color,onLoad:t.onLoad,icon:e.unref(d)}),null,16,["class"])):e.createCommentVNode("",!0)}});Boolean,Boolean,Boolean;l.before;const s={id:[String,Number]};r.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,i.button;const u={...s,title:String,modelValue:{type:Boolean,default:void 0},transition:{type:String,default:"fade-block"},size:String,keepOpen:{type:Boolean,default:!1}},d=["onCancel"],v={key:0,class:"vv-dialog__header"},f={class:"vv-dialog__content"},p={key:1,class:"vv-dialog__footer"};return e.defineComponent({name:"VvDialog",props:u,emits:["open","close","update:modelValue","before-enter","after-leave","enter","after-enter","enter-cancelled","before-leave","leave","leave-cancelled"],setup(o,{expose:n,emit:r}){const l=o,i=e.ref(),a=t.useVModel(l,"modelValue",r),s=e.ref(!1),u=e.computed({get:()=>a.value??s.value,set:e=>{void 0!==a.value?a.value=e:s.value=e}}),m=e.ref(null),g=e.computed((()=>{const{id:e}=l;return{id:e}})),h=e.computed((()=>l.size?["vv-dialog",`vv-dialog--${l.size}`]:"vv-dialog")),b=e.computed((()=>`vv-dialog--${l.transition}`)),y={"before-enter":()=>{var e,o;(null==(e=i.value)?void 0:e.open)||null==(o=i.value)||o.showModal(),r("open"),r("before-enter")},"after-leave":()=>{var e,o;(null==(e=i.value)?void 0:e.open)&&(null==(o=i.value)||o.close()),r("close"),r("after-leave")},enter:()=>{r("enter")},"after-enter":()=>{r("after-enter")},"enter-cancelled":()=>{r("enter-cancelled")},"before-leave":()=>{r("before-leave")},leave:()=>{r("leave")},"leave-cancelled":()=>{r("leave-cancelled")}};function $(){u.value=!1}t.onClickOutside(m,(()=>{l.keepOpen||$()})),n({close:$,open:function(){u.value=!0}});const B=()=>{l.keepOpen||$()};return(o,t)=>(e.openBlock(),e.createBlock(e.Transition,e.mergeProps({name:e.unref(b)},e.toHandlers(y)),{default:e.withCtx((()=>[e.withDirectives(e.createElementVNode("dialog",e.mergeProps(e.unref(g),{ref_key:"dialogEl",ref:i,class:e.unref(h),onCancel:e.withModifiers(B,["stop","prevent"])}),[e.createElementVNode("article",{ref_key:"modalWrapper",ref:m,class:"vv-dialog__wrapper"},[o.$slots.header||o.title?(e.openBlock(),e.createElementBlock("header",v,[e.renderSlot(o.$slots,"header",{},(()=>[e.createTextVNode(e.toDisplayString(o.title)+" ",1),e.createElementVNode("button",{type:"button","aria-label":"Close",class:"vv-dialog__close",onClickPassive:$},[e.createVNode(c,{name:"close"})],32)]))])):e.createCommentVNode("",!0),e.createElementVNode("div",f,[e.renderSlot(o.$slots,"default")]),o.$slots.footer?(e.openBlock(),e.createElementBlock("footer",p,[e.renderSlot(o.$slots,"footer")])):e.createCommentVNode("",!0)],512)],16,d),[[e.vShow,e.unref(u)]])])),_:3},16,["name"]))}})}));
|
|
@@ -905,6 +905,13 @@ const VvInputTextProps = {
|
|
|
905
905
|
*/
|
|
906
906
|
unit: {
|
|
907
907
|
type: String
|
|
908
|
+
},
|
|
909
|
+
/**
|
|
910
|
+
* Select input text on focus
|
|
911
|
+
*/
|
|
912
|
+
selectOnFocus: {
|
|
913
|
+
type: Boolean,
|
|
914
|
+
default: false
|
|
908
915
|
}
|
|
909
916
|
};
|
|
910
917
|
const VvInputPasswordAction = defineComponent({
|
|
@@ -1372,6 +1379,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1372
1379
|
const isFocused = computed(
|
|
1373
1380
|
() => focused.value && !props.disabled && !props.readonly
|
|
1374
1381
|
);
|
|
1382
|
+
watch(isFocused, (newValue) => {
|
|
1383
|
+
if (newValue && propsDefaults.value.selectOnFocus && inputEl.value) {
|
|
1384
|
+
inputEl.value.select();
|
|
1385
|
+
}
|
|
1386
|
+
});
|
|
1375
1387
|
const isVisible = useElementVisibility(inputEl);
|
|
1376
1388
|
watch(isVisible, (newValue) => {
|
|
1377
1389
|
if (newValue && props.autofocus && !props.disabled && !props.readonly) {
|
|
@@ -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",I="eye-off",V="calendar",O="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:I},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}},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:I}},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)),I=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)),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(),I.value=e.unref(b).value)},te=()=>{se.value&&(b.value.stepDown(),I.value=e.unref(b).value)},oe=e.computed((()=>c.type===A.SEARCH)),le=()=>{I.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:V};case A.TIME:return{name:O};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}}(I,{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!==I.value?`${String(I.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(I)?I.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(I)]]),(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("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))}})}));
|
|
@@ -76,6 +76,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
76
76
|
unit: {
|
|
77
77
|
type: StringConstructor;
|
|
78
78
|
};
|
|
79
|
+
selectOnFocus: {
|
|
80
|
+
type: BooleanConstructor;
|
|
81
|
+
default: boolean;
|
|
82
|
+
};
|
|
79
83
|
minlength: (StringConstructor | NumberConstructor)[];
|
|
80
84
|
maxlength: (StringConstructor | NumberConstructor)[];
|
|
81
85
|
placeholder: StringConstructor;
|
|
@@ -206,6 +210,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
206
210
|
unit: {
|
|
207
211
|
type: StringConstructor;
|
|
208
212
|
};
|
|
213
|
+
selectOnFocus: {
|
|
214
|
+
type: BooleanConstructor;
|
|
215
|
+
default: boolean;
|
|
216
|
+
};
|
|
209
217
|
minlength: (StringConstructor | NumberConstructor)[];
|
|
210
218
|
maxlength: (StringConstructor | NumberConstructor)[];
|
|
211
219
|
placeholder: StringConstructor;
|
|
@@ -290,6 +298,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
290
298
|
maskTokensReplace: boolean;
|
|
291
299
|
autoWidth: boolean;
|
|
292
300
|
hideActions: boolean;
|
|
301
|
+
selectOnFocus: boolean;
|
|
293
302
|
count: string | boolean;
|
|
294
303
|
}, {}>, {
|
|
295
304
|
before?(_: {
|
|
@@ -192,6 +192,13 @@ export declare const VvInputTextProps: {
|
|
|
192
192
|
unit: {
|
|
193
193
|
type: StringConstructor;
|
|
194
194
|
};
|
|
195
|
+
/**
|
|
196
|
+
* Select input text on focus
|
|
197
|
+
*/
|
|
198
|
+
selectOnFocus: {
|
|
199
|
+
type: BooleanConstructor;
|
|
200
|
+
default: boolean;
|
|
201
|
+
};
|
|
195
202
|
minlength: (StringConstructor | NumberConstructor)[];
|
|
196
203
|
maxlength: (StringConstructor | NumberConstructor)[];
|
|
197
204
|
placeholder: StringConstructor;
|
|
@@ -4209,14 +4209,18 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
4209
4209
|
const transitioName = computed(() => `vv-dialog--${props.transition}`);
|
|
4210
4210
|
const dialogTransitionHandlers = {
|
|
4211
4211
|
"before-enter": () => {
|
|
4212
|
-
var _a;
|
|
4213
|
-
(_a = dialogEl.value) == null ? void 0 : _a.
|
|
4212
|
+
var _a, _b;
|
|
4213
|
+
if (!((_a = dialogEl.value) == null ? void 0 : _a.open)) {
|
|
4214
|
+
(_b = dialogEl.value) == null ? void 0 : _b.showModal();
|
|
4215
|
+
}
|
|
4214
4216
|
emit("open");
|
|
4215
4217
|
emit("before-enter");
|
|
4216
4218
|
},
|
|
4217
4219
|
"after-leave": () => {
|
|
4218
|
-
var _a;
|
|
4219
|
-
(_a = dialogEl.value) == null ? void 0 : _a.
|
|
4220
|
+
var _a, _b;
|
|
4221
|
+
if ((_a = dialogEl.value) == null ? void 0 : _a.open) {
|
|
4222
|
+
(_b = dialogEl.value) == null ? void 0 : _b.close();
|
|
4223
|
+
}
|
|
4220
4224
|
emit("close");
|
|
4221
4225
|
emit("after-leave");
|
|
4222
4226
|
},
|
|
@@ -4487,6 +4491,13 @@ const VvInputTextProps = {
|
|
|
4487
4491
|
*/
|
|
4488
4492
|
unit: {
|
|
4489
4493
|
type: String
|
|
4494
|
+
},
|
|
4495
|
+
/**
|
|
4496
|
+
* Select input text on focus
|
|
4497
|
+
*/
|
|
4498
|
+
selectOnFocus: {
|
|
4499
|
+
type: Boolean,
|
|
4500
|
+
default: false
|
|
4490
4501
|
}
|
|
4491
4502
|
};
|
|
4492
4503
|
const VvInputPasswordAction = defineComponent({
|
|
@@ -4856,6 +4867,11 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
4856
4867
|
const isFocused = computed(
|
|
4857
4868
|
() => focused.value && !props.disabled && !props.readonly
|
|
4858
4869
|
);
|
|
4870
|
+
watch(isFocused, (newValue) => {
|
|
4871
|
+
if (newValue && propsDefaults.value.selectOnFocus && inputEl.value) {
|
|
4872
|
+
inputEl.value.select();
|
|
4873
|
+
}
|
|
4874
|
+
});
|
|
4859
4875
|
const isVisible = useElementVisibility(inputEl);
|
|
4860
4876
|
watch(isVisible, (newValue) => {
|
|
4861
4877
|
if (newValue && props.autofocus && !props.disabled && !props.readonly) {
|