@volverjs/ui-vue 0.0.10-beta.23 → 0.0.10-beta.24
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/VvAccordion/VvAccordion.es.js +119 -79
- package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
- package/dist/components/VvAccordion/VvAccordion.vue.d.ts +18 -4
- package/dist/components/VvAccordion/index.d.ts +4 -8
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +250 -119
- package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
- package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +18 -6
- package/dist/components/VvAccordionGroup/index.d.ts +3 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +1 -1
- package/dist/components/VvAlert/VvAlert.vue.d.ts +1 -1
- package/dist/components/VvButton/VvButton.es.js +92 -98
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +7 -7
- package/dist/components/VvButton/index.d.ts +11 -11
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +7 -13
- package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
- package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +3 -3
- package/dist/components/VvCheckbox/VvCheckbox.es.js +81 -87
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +6 -6
- package/dist/components/VvCheckbox/index.d.ts +2 -2
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +15 -29
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +5 -5
- package/dist/components/VvCombobox/VvCombobox.es.js +13 -16
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +11 -11
- package/dist/components/VvCombobox/index.d.ts +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +5 -5
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +1 -1
- package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +1 -1
- package/dist/components/VvDropdown/index.d.ts +1 -1
- package/dist/components/VvInputFile/VvInputFile.es.js +183 -168
- package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
- package/dist/components/VvInputFile/VvInputFile.vue.d.ts +16 -9
- package/dist/components/VvInputFile/index.d.ts +12 -3
- package/dist/components/VvInputText/VvInputClearAction.d.ts +1 -1
- package/dist/components/VvInputText/VvInputStepAction.d.ts +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +6 -6
- package/dist/components/VvProgress/VvProgress.vue.d.ts +1 -1
- package/dist/components/VvRadio/VvRadio.es.js +64 -70
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +6 -6
- package/dist/components/VvRadio/index.d.ts +6 -6
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +15 -29
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +5 -5
- package/dist/components/VvSelect/VvSelect.vue.d.ts +8 -8
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +5 -5
- package/dist/components/VvTooltip/VvTooltip.vue.d.ts +3 -3
- package/dist/components/VvTooltip/index.d.ts +1 -1
- package/dist/components/index.es.js +462 -323
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/alert/useInjectAlert.d.ts +1 -6
- package/dist/composables/group/useInjectedGroupState.d.ts +4 -5
- package/dist/composables/group/useProvideGroupState.d.ts +3 -3
- package/dist/constants.d.ts +6 -10
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/index.es.js +3 -2
- package/dist/index.umd.js +1 -1
- package/dist/props/index.d.ts +1 -1
- package/dist/resolvers/unplugin.es.js +3 -2
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +38 -14
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +259 -101
- package/dist/types/group.d.ts +37 -15
- package/package.json +37 -36
- 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/VvAccordion/VvAccordion.vue +119 -56
- package/src/components/VvAccordion/index.ts +8 -23
- package/src/components/VvAccordionGroup/VvAccordionGroup.vue +140 -41
- package/src/components/VvAccordionGroup/index.ts +3 -1
- package/src/components/VvButton/index.ts +7 -12
- package/src/components/VvButtonGroup/VvButtonGroup.vue +1 -2
- package/src/components/VvCheckbox/index.ts +2 -2
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +1 -2
- package/src/components/VvInputFile/VvInputFile.vue +71 -47
- package/src/components/VvInputFile/index.ts +5 -4
- package/src/components/VvRadio/index.ts +5 -5
- package/src/components/VvRadioGroup/VvRadioGroup.vue +1 -2
- package/src/composables/group/useInjectedGroupState.ts +20 -16
- package/src/composables/group/useProvideGroupState.ts +10 -15
- package/src/constants.ts +19 -14
- package/src/stories/AccordionGroup/AccordionGroup.test.ts +15 -9
- package/src/stories/AccordionGroup/AccordionGroupSlots.stories.ts +1 -1
- package/src/types/group.ts +22 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("@vueuse/core"),require("@iconify/vue"),require("uid")):"function"==typeof define&&define.amd?define(["vue","@vueuse/core","@iconify/vue","uid"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvInputFile=l(e.vue,e.core,e.vue$1,e.uid)}(this,(function(e,l,t,o){"use strict";const a="add",n="edit",r="download",i={prefix:"normal"};var u=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(u||{}),d=(e=>(e.before="before",e.after="after",e))(d||{}),s=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(s||{}),c=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(c||{}),v=(e=>(e._blank="_blank",e._self="_self",e._parent="_parent",e._top="_top",e))(v||{});const p=Symbol.for("volver"),f=Symbol.for("buttonGroup"),m=Symbol.for("dropdownTrigger"),g=Symbol.for("dropdownAction");function y(){return e.inject(p)}function b(l,t,o){return e.computed((()=>{const a={[l]:!0},n="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(a[`${l}--${e}`]=!0)})),o&&Object.keys(o.value).forEach((t=>{a[`${l}--${t}`]=e.unref(o.value[t])})),a}))}const h=e.defineComponent({name:"VvIcon",props:e.mergeDefaults({name:{},color:{},width:{},height:{},provider:{},prefix:{},src:{},horizontalFlip:{type:Boolean},verticalFlip:{type:Boolean},flip:{},mode:{},inline:{type:Boolean},rotate:{},onLoad:{type:Function},svg:{},modifiers:{}},i),setup(l){const o=l,a=e.computed((()=>"string"==typeof o.rotate?parseFloat(o.rotate):o.rotate)),n=e.ref(!0),r=y(),{modifiers:i}=e.toRefs(o),u=b("vv-icon",i),d=e.computed((()=>o.provider||(null==r?void 0:r.iconsProvider))),s=e.computed((()=>{const e=o.name??"",l=`@${d.value}:${o.prefix}:${e}`;if(t.iconExists(l))return l;const a=null==r?void 0:r.iconsCollections.find((l=>{const o=`@${d.value}:${l.prefix}:${e}`;return t.iconExists(o)}));return a?`@${d.value}:${a.prefix}:${e}`:e}));function c(e){const l=function(e){let l;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");l=(new e).window}return(l?new l.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 r&&o.src&&!t.iconExists(`@${d.value}:${o.prefix}:${o.name}`)&&(n.value=!1,r.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),(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("v-if",!0)}}),k={to:{type:[String,Object]},href:String,target:{type:String,default:void 0,validator:e=>Object.values(v).includes(e)},rel:{type:String,default:"noopener noreferrer"}},S={valid:{type:Boolean,default:!1},validLabel:{type:[String,Array],default:void 0}},B={invalid:{type:Boolean,default:!1},invalidLabel:{type:[String,Array],default:void 0}},L={loading:{type:Boolean,default:!1},loadingLabel:{type:String,default:"Loading..."}},V={disabled:{type:Boolean,default:!1}},w={active:{type:Boolean,default:!1}},A={current:{type:Boolean,default:!1}},$={pressed:{type:Boolean,default:!1}},O={label:{type:[String,Number],default:void 0}},_={readonly:{type:Boolean,default:!1}},C={modifiers:{type:[String,Array],default:void 0}},x={hintLabel:{type:String,default:""}},j={icon:{type:[String,Object],default:void 0},iconPosition:{type:String,default:d.before,validation:e=>Object.values(d).includes(e)}},N={unselectable:{type:Boolean,default:!0}},R={id:[String,Number]};u.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const P={...R,name:{type:String,required:!0}},E={...V,...O,...$,...w,...A,...k,type:{type:String,default:s.button,validator:e=>Object.values(s).includes(e)},ariaLabel:{type:String,default:void 0},defaultTag:{type:String,default:c.button}},I=E;const D=e.defineComponent({name:"VvAction",props:I,emits:["click","mouseover","mouseleave"],setup(l,{expose:t,emit:o}){const a=l,n=o,r=y(),i=e.ref(null);t({$el:i});const{reference:u,bus:d,aria:s,expanded:v}=e.inject(m,{});e.watch((()=>i.value),(e=>{u&&(u.value=e)}));const p=e.computed((()=>a.pressed||(null==v?void 0:v.value))),{role:f}=e.inject(g,{}),b=e.computed((()=>{switch(!0){case a.disabled:return c.button;case void 0!==a.to:return(null==r?void 0:r.nuxt)?c.nuxtLink:c.routerLink;case void 0!==a.href:return c.a;default:return a.defaultTag}})),h=e.computed((()=>{const e={...null==s?void 0:s.value,ariaPressed:!!p.value||void 0,ariaLabel:a.ariaLabel,role:null==f?void 0:f.value};switch(b.value){case c.a:return{...e,href:a.href,target:a.target,rel:a.rel};case c.routerLink:case c.nuxtLink:return{...e,to:a.to,target:a.target};case c.button:return{...e,type:a.type,disabled:a.disabled};default:return e}})),k=e=>{a.disabled?e.preventDefault():(null==d||d.emit("click",e),n("click",e))},S=e=>{null==d||d.emit("mouseover",e),n("mouseover",e)},B=e=>{null==d||d.emit("mouseleave",e),n("mouseleave",e)};return(l,t)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(b)),e.mergeProps(e.unref(h),{ref_key:"element",ref:i,class:{active:l.active,pressed:e.unref(p),disabled:l.disabled,current:l.current},onClickPassive:k,onMouseoverPassive:S,onMouseleavePassive:B}),{default:e.withCtx((()=>[e.renderSlot(l.$slots,"default",{},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)]))])),_:3},16,["class"]))}});function M(e,l,t){return t?z(e,t)===z(l,t):F(e,l)}function F(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){const t=Array.isArray(e),o=Array.isArray(l);let a,n,r;if(t&&o){if(n=e.length,n!=l.length)return!1;for(a=n;0!=a--;)if(!F(e[a],l[a]))return!1;return!0}if(t!=o)return!1;const i=e instanceof Date,u=l instanceof Date;if(i!=u)return!1;if(i&&u)return e.getTime()==l.getTime();const d=e instanceof RegExp,s=l instanceof RegExp;if(d!=s)return!1;if(d&&s)return e.toString()==l.toString();const c=Object.keys(e);if(n=c.length,n!==Object.keys(l).length)return!1;for(a=n;0!=a--;)if(!Object.prototype.hasOwnProperty.call(l,c[a]))return!1;for(a=n;0!=a--;)if(r=c[a],!F(e[r],l[r]))return!1;return!0}return e!=e&&l!=l}function z(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const t=l.split(".");let o=e;for(let l=0,a=t.length;l<a;++l){if(null==e)return null;o=o[t[l]]}return o}}return null}function T(e,l){if(null!=e&&l&&l.length)for(const t of l)if(M(e,t))return!0;return!1}function U(l){const t=e.inject(l,void 0),o=e.computed((()=>{return l=t,!(null==(o=e.unref(l))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length);var l,o}));return{group:t,isInGroup:o,getGroupOrLocalRef:function(l,o,a){if(null==t?void 0:t.value){const o=e.unref(t.value)[l];return e.computed({get:()=>null==o?void 0:o.value,set(e){o.value=e}})}const n=e.toRef(o,l);return e.computed({get:()=>n.value,set(e){a&&a(`update:${l}`,e)}})}}}const q={...E,...R,...C,...N,...L,...j,iconPosition:{type:String,default:u.left,validator:e=>Object.values(u).includes(e)},loadingIcon:{type:String,default:"eos-icons:bubble-loading"},toggle:{type:Boolean,default:!1},value:{type:[String,Number,Boolean],default:void 0},uncheckedValue:{type:[String,Number,Boolean],default:void 0},modelValue:{type:[String,Number,Boolean],default:void 0}};const H=l=>e.computed((()=>String((null==l?void 0:l.value)||o.uid())));function G(l,t){const o=e.computed((()=>"string"==typeof(null==l?void 0:l.value)?{name:null==l?void 0:l.value}:null==l?void 0:l.value)),a=e.computed((()=>(null==t?void 0:t.value)===d.before?o.value:void 0)),n=e.computed((()=>(null==t?void 0:t.value)===d.after?o.value:void 0)),r=e.computed((()=>(null==t?void 0:t.value)===u.left?o.value:void 0)),i=e.computed((()=>(null==t?void 0:t.value)===u.right?o.value:void 0)),s=e.computed((()=>(null==t?void 0:t.value)===u.top?o.value:void 0)),c=e.computed((()=>(null==t?void 0:t.value)===u.bottom?o.value:void 0));return{hasIcon:o,hasIconLeft:r,hasIconRight:i,hasIconTop:s,hasIconBottom:c,hasIconBefore:a,hasIconAfter:n}}const J={key:1,class:"vv-button__label"},K={key:1,class:"vv-button__label"},Q=e.defineComponent({name:"VvButton",props:q,emits:["update:modelValue"],setup(l,{expose:t,emit:o}){const a=l,n=e.useAttrs(),r=e.useSlots(),i=o,{id:d,modifiers:s,iconPosition:c,icon:v,label:p,modelValue:m,disabled:g,toggle:y,unselectable:k}=function(l,t){const{group:o,isInGroup:a,getGroupOrLocalRef:n}=U(f),{id:r,iconPosition:i,icon:u,label:d,pressed:s}=e.toRefs(l),c=n("modelValue",l,t),v=n("toggle",l),p=n("unselectable",l),m=e.computed((()=>(null==o?void 0:o.value.multiple.value)??!1)),g=e.computed((()=>{let e=l.modifiers,t=null==o?void 0:o.value.modifiers.value;const a=new Set;return e&&(Array.isArray(e)||(e=e.split(" ")),e.forEach((e=>a.add(e)))),t&&(Array.isArray(t)||(t=t.split(" ")),t.forEach((e=>a.add(e)))),Array.from(a)})),y=e.computed((()=>{var e;return Boolean(l.disabled||(null==(e=null==o?void 0:o.value)?void 0:e.disabled.value))}));return{group:o,isInGroup:a,modelValue:c,toggle:v,unselectable:p,multiple:m,modifiers:g,disabled:y,id:r,pressed:s,iconPosition:i,icon:u,label:d}}(a,i),S=H(d),B=e.computed((()=>(null==n?void 0:n.name)||S.value)),L=e.ref(null);t({$el:e.computed((()=>{var e;return null==(e=L.value)?void 0:e.$el}))});const V=e.computed((()=>y.value?Array.isArray(m.value)?T(B.value,m.value):M(B.value,m.value):a.pressed)),w=b("vv-button",s,e.computed((()=>({reverse:[u.right,u.bottom].includes(c.value),column:[u.top,u.bottom].includes(c.value),"icon-only":Boolean((null==v?void 0:v.value)&&!(null==p?void 0:p.value)&&!r.default)})))),{hasIcon:A}=G(v),$=e.computed((()=>void 0!==a.value?a.value:B.value)),O=()=>{if(y.value){if(Array.isArray(m.value))return T($.value,m.value)?void(k.value&&(m.value=m.value.filter((e=>e!==$.value)))):void m.value.push($.value);if($.value===m.value&&k.value)return void(m.value=a.uncheckedValue);m.value=$.value}};return(l,t)=>(e.openBlock(),e.createBlock(D,e.mergeProps({disabled:e.unref(g),pressed:e.unref(V),active:l.active,type:l.type,to:l.to,href:l.href,target:l.target,rel:l.rel,ariaLabel:l.ariaLabel},{id:e.unref(S),ref_key:"element",ref:L,class:e.unref(w),onClick:O}),{default:e.withCtx((()=>[e.renderSlot(l.$slots,"default",{},(()=>[l.loading?e.renderSlot(l.$slots,"loading",{key:0},(()=>[l.loadingIcon?(e.openBlock(),e.createBlock(h,{key:0,class:"vv-button__loading-icon",name:l.loadingIcon},null,8,["name"])):e.createCommentVNode("v-if",!0),l.loadingLabel?(e.openBlock(),e.createElementBlock("span",J,e.toDisplayString(l.loadingLabel),1)):e.createCommentVNode("v-if",!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.renderSlot(l.$slots,"before"),e.unref(A)?(e.openBlock(),e.createBlock(h,e.mergeProps({key:0},e.unref(A),{class:"vv-button__icon"}),null,16)):e.createCommentVNode("v-if",!0),e.unref(p)?(e.openBlock(),e.createElementBlock("span",K,[e.renderSlot(l.$slots,"label",{},(()=>[e.createTextVNode(e.toDisplayString(e.unref(p)),1)]))])):e.createCommentVNode("v-if",!0),e.renderSlot(l.$slots,"after")],64))]))])),_:3},16,["id","class"]))}});function W(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}const X={...P,...C,...S,...B,...x,...O,...L,..._,...j,modelValue:{type:Object,required:!0},progress:{type:[Number,String],default:void 0},placeholder:{type:String,default:void 0},accept:{type:String,default:"*"},multiple:{type:Boolean,default:!1},capture:{type:String,default:void 0,validation:e=>void 0===e||["user","environment"].includes(e)},max:{type:[Number,String],default:void 0},dropArea:{type:Boolean,default:!1},labelAdd:{type:String,default:"Add file"},iconAdd:{type:[String,Object],default:a},labelReplace:{type:String,default:"Replace file"},iconReplace:{type:[String,Object],default:n},labelDownload:{type:String,default:"Downlaod file"},iconDownload:{type:[String,Object],default:r},labelRemove:{type:String,default:"Remove file"}};const Y=["for"],Z={class:"vv-input-file__preview"},ee=["src","alt"],le={class:"vv-input-file__wrapper"},te=["id","readonly","placeholder","aria-describedby","aria-invalid","aria-errormessage","multiple","accept","capture","name"],oe=["value"],ae={class:"vv-input-file__list"},ne=["onClick"],re=["title","onClick"],ie={class:"vv-input-file__item-name"},ue={class:"vv-input-file__item-info"},de=["title","onClick"];return e.defineComponent({name:"VvInputFile",props:X,emits:["update:modelValue"],setup(t,{emit:o}){const a=t,n=o,r=e.useSlots(),i=function(l,t,o){const a=y(),n=e.computed((()=>{var e;if(a&&(null==(e=a.defaults.value)?void 0:e[l]))return a.defaults.value[l]}));return e.computed((()=>{if(void 0===n.value)return o;const e=n.value,l=t,a=o;return Object.keys(l).reduce(((t,o)=>{const n=a[o];if(t[o]=n,o in e){if(Array.isArray(l[o])){const a=l[o];a.length&&a[0]===n&&(t[o]=e[o])}if("function"==typeof l[o]&&(0,l[o])()===n&&(t[o]=e[o]),"object"==typeof l[o]){let a=l[o].default;"function"==typeof a&&(a=a()),"object"==typeof a?JSON.stringify(a)===JSON.stringify(n)&&(t[o]=e[o]):a===n&&(t[o]=e[o])}}return t}),{})}))}("VvInputFile",X,a),{modifiers:u,id:d,readonly:s,icon:c,iconPosition:v,iconDownload:p}=e.toRefs(a),f=H(d),m=e.computed((()=>`${f.value}-hint`)),g=e.computed((()=>{if(!a.progress)return!1;const e="string"==typeof a.progress?parseInt(a.progress):a.progress;return e>0&&e<100})),{hasIconBefore:k,hasIconAfter:S}=G(c,v),{hasIcon:B}=G(p),L=b("vv-input-file",u,e.computed((()=>({dragging:N.value,loading:a.loading&&!g.value,valid:!0===a.valid,invalid:!0===a.invalid,"icon-before":!!k.value,"icon-after":!!S.value,"drop-area":x.value})))),{HintSlot:V,hasHintLabelOrSlot:w,hasInvalidLabelOrSlot:A,hintSlotScope:$}=function(l,t){const o=e.computed((()=>e.isRef(l)?l.value:l)),a=e.computed((()=>W(o.value.invalidLabel))),n=e.computed((()=>W(o.value.validLabel))),r=e.computed((()=>o.value.loadingLabel)),i=e.computed((()=>o.value.hintLabel)),u=e.computed((()=>Boolean(o.value.loading&&(t.loading||r.value)))),d=e.computed((()=>!u.value&&Boolean(o.value.invalid&&(t.invalid||a.value)))),s=e.computed((()=>!u.value&&!d.value&&Boolean(o.value.valid&&(t.valid||n.value)))),c=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(t.hint||i.value))),v=e.computed((()=>d.value||s.value||u.value||c.value)),p=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:v,invalidLabel:a,validLabel:n,loadingLabel:r,hintLabel:i,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:c}),render(){var l,t,o,a,n,r,i,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(t=(l=this.$slots).loading)?void 0:t.call(l))??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==(r=(n=this.$slots).valid)?void 0:r.call(n))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(i=this.$slots).hint)?void 0:u.call(i))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:c,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hintSlotScope:p,HintSlot:f}}(i,r),O=l.useVModel(a,"modelValue",n),_=e.computed((()=>{var e;return O.value&&(Array.isArray(O.value)||(null==(e=O.value)?void 0:e.name))?Array.isArray(O.value)?O.value:[O.value]:[]})),C=e.computed((()=>"string"==typeof a.max?parseInt(a.max):a.max)),x=e.computed((()=>a.dropArea&&!s.value)),j=e.computed((()=>!!a.multiple&&(!C.value||C.value-_.value.length>1))),N=e.ref(!1),R=e.ref(),P=()=>{N.value=!0},E=()=>{N.value=!1},I=e=>{var l,t;(null==(l=e.dataTransfer)?void 0:l.files)&&(N.value=!1,M(null==(t=e.dataTransfer)?void 0:t.files))},D=()=>{var e;(null==(e=R.value)?void 0:e.files)&&(M(R.value.files),R.value.value="")},M=e=>{if(!a.multiple)return Array.isArray(O.value)?void(O.value=[...e]):void(O.value=e[0]);let l=[];l=!Array.isArray(O.value)&&O.value?[O.value]:O.value&&Array.isArray(O.value)?[...O.value]:l;for(const t of e){if(C.value&&l.length>=C.value)break;l.push(t)}O.value=l,z.value=l.length-1},F=()=>{R.value&&(s.value||R.value.click())},z=e.ref(0),T=["image/jpeg","image/png"],U=e.computed((()=>{if(0===_.value.length)return;if(!_.value[z.value])return;if(_.value[z.value]instanceof File){const e=_.value[z.value];if(!T.includes(e.type))return;return URL.createObjectURL(e)}const e=_.value[z.value];return e.thumbnailUrl?e.thumbnailUrl:T.includes(e.type)?e.url:void 0}));e.watch(U,((e,l)=>{l&&URL.revokeObjectURL(l)})),e.onBeforeUnmount((()=>{U.value&&URL.revokeObjectURL(U.value)}));const q=e=>{if(e)return Math.floor(e/1024)},J=e.computed((()=>0===_.value.length||j.value?a.labelAdd:a.labelReplace)),K=e.computed((()=>0===_.value.length||j.value?a.iconAdd:a.iconReplace));return(l,t)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(L))},[l.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(f)},e.toDisplayString(l.label),9,Y)):e.createCommentVNode("v-if",!0),x.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vv-input-file__drop-area",onDragenter:e.withModifiers(P,["prevent","stop"]),onDragleave:e.withModifiers(E,["prevent","stop"]),onDrop:e.withModifiers(I,["prevent","stop"]),onDragover:t[0]||(t[0]=e.withModifiers((()=>{}),["prevent","stop"])),onClick:e.withModifiers(F,["stop"])},[e.renderSlot(l.$slots,"drop-area",{},(()=>[e.createElementVNode("picture",Z,[U.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:U.value,alt:_.value[z.value].name},null,8,ee)):e.createCommentVNode("v-if",!0)]),e.unref(s)?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createBlock(Q,{key:0,modifiers:"action",label:U.value?void 0:J.value,title:U.value?J.value:void 0,class:e.normalizeClass({"vv-input-file__drop-area-action":U.value}),icon:K.value,onClick:e.withModifiers(F,["stop"])},null,8,["label","title","class","icon"]))]))],32)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",le,[e.unref(k)?(e.openBlock(),e.createBlock(h,e.normalizeProps(e.mergeProps({key:0},e.unref(k))),null,16)):e.createCommentVNode("v-if",!0),e.createElementVNode("input",{id:e.unref(f),ref_key:"inputEl",ref:R,type:"file",readonly:e.unref(s),placeholder:l.placeholder,"aria-describedby":e.unref(w)?m.value:void 0,"aria-invalid":l.invalid,"aria-errormessage":e.unref(A)?m.value:void 0,multiple:j.value,accept:l.accept,capture:l.capture,name:l.name,onChange:D},null,40,te),g.value?(e.openBlock(),e.createElementBlock("progress",{key:1,class:"vv-input-file__progress",value:l.progress,max:"100"},e.toDisplayString(l.progress)+"% ",9,oe)):e.createCommentVNode("v-if",!0),e.unref(S)?(e.openBlock(),e.createBlock(h,e.normalizeProps(e.mergeProps({key:2},e.unref(S))),null,16)):e.createCommentVNode("v-if",!0)]),e.createElementVNode("ul",ae,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,((t,o)=>(e.openBlock(),e.createElementBlock("li",{key:o,class:e.normalizeClass(["vv-input-file__item",{active:o===z.value&&x.value&&_.value.length>1}]),onClick:e.withModifiers((e=>(e=>{z.value=e})(o)),["stop"])},[e.unref(B)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"vv-input-file__item-action",title:l.labelDownload,onClick:e.withModifiers((e=>(e=>{const l=document.createElement("a");e instanceof File?l.href=URL.createObjectURL(e):e.url&&(l.href=e.url),l.setAttribute("download",e.name),document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(l.href)})(t)),["stop"])},[e.createVNode(h,e.normalizeProps(e.guardReactiveProps(e.unref(B))),null,16)],8,re)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",ie,e.toDisplayString(t.name),1),e.createElementVNode("small",ue,e.toDisplayString(q(t.size))+" KB ",1),e.unref(s)?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"vv-input-file__item-remove",title:l.labelRemove,onClick:e.withModifiers((e=>(e=>{if(!Array.isArray(O.value))return void(O.value=void 0);z.value===e&&(z.value=0);const l=[...O.value];l.splice(e,1),O.value=l})(o)),["stop"])},null,8,de))],10,ne)))),128))]),e.createVNode(e.unref(V),{id:m.value,class:"vv-input-file__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref($))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref($))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref($))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref($))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|
|
1
|
+
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("@vueuse/core"),require("@iconify/vue"),require("uid"),require("vuedraggable")):"function"==typeof define&&define.amd?define(["vue","@vueuse/core","@iconify/vue","uid","vuedraggable"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvInputFile=l(e.vue,e.core,e.vue$1,e.uid,e.Sortable)}(this,(function(e,l,t,o,a){"use strict";const n="add",r="edit",i="download",u={prefix:"normal"};var d=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(d||{}),s=(e=>(e.before="before",e.after="after",e))(s||{}),v=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(v||{}),c=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(c||{}),p=(e=>(e._blank="_blank",e._self="_self",e._parent="_parent",e._top="_top",e))(p||{});const f=Symbol.for("volver"),m=Symbol.for("buttonGroup"),g=Symbol.for("dropdownTrigger"),b=Symbol.for("dropdownAction");function y(){return e.inject(f)}function h(l,t,o){return e.computed((()=>{const a={[l]:!0},n="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(a[`${l}--${e}`]=!0)})),o&&Object.keys(o.value).forEach((t=>{a[`${l}--${t}`]=e.unref(o.value[t])})),a}))}const k=e.defineComponent({name:"VvIcon",props:e.mergeDefaults({name:{},color:{},width:{},height:{},provider:{},prefix:{},src:{},horizontalFlip:{type:Boolean},verticalFlip:{type:Boolean},flip:{},mode:{},inline:{type:Boolean},rotate:{},onLoad:{type:Function},svg:{},modifiers:{}},u),setup(l){const o=l,a=e.computed((()=>"string"==typeof o.rotate?parseFloat(o.rotate):o.rotate)),n=e.ref(!0),r=y(),{modifiers:i}=e.toRefs(o),u=h("vv-icon",i),d=e.computed((()=>o.provider||(null==r?void 0:r.iconsProvider))),s=e.computed((()=>{const e=o.name??"",l=`@${d.value}:${o.prefix}:${e}`;if(t.iconExists(l))return l;const a=null==r?void 0:r.iconsCollections.find((l=>{const o=`@${d.value}:${l.prefix}:${e}`;return t.iconExists(o)}));return a?`@${d.value}:${a.prefix}:${e}`:e}));function v(e){const l=function(e){let l;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");l=(new e).window}return(l?new l.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 r&&o.src&&!t.iconExists(`@${d.value}:${o.prefix}:${o.name}`)&&(n.value=!1,r.fetchIcon(o.src).then((e=>{e&&(v(e),n.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),o.svg&&v(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("v-if",!0)}}),S={to:{type:[String,Object]},href:String,target:{type:String,default:void 0,validator:e=>Object.values(p).includes(e)},rel:{type:String,default:"noopener noreferrer"}},B={valid:{type:Boolean,default:!1},validLabel:{type:[String,Array],default:void 0}},L={invalid:{type:Boolean,default:!1},invalidLabel:{type:[String,Array],default:void 0}},V={loading:{type:Boolean,default:!1},loadingLabel:{type:String,default:"Loading..."}},w={disabled:{type:Boolean,default:!1}},A={active:{type:Boolean,default:!1}},$={current:{type:Boolean,default:!1}},_={pressed:{type:Boolean,default:!1}},O={label:{type:[String,Number],default:void 0}},C={readonly:{type:Boolean,default:!1}},x={modifiers:{type:[String,Array],default:void 0}},N={hintLabel:{type:String,default:""}},j={icon:{type:[String,Object],default:void 0},iconPosition:{type:String,default:s.before,validation:e=>Object.values(s).includes(e)}},R={unselectable:{type:Boolean,default:!0}},I={id:[String,Number]};d.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const P={...I,name:{type:String,required:!0}},E={...w,...O,..._,...A,...$,...S,type:{type:String,default:v.button,validator:e=>Object.values(v).includes(e)},ariaLabel:{type:String,default:void 0},defaultTag:{type:String,default:c.button}},D=E;const M=e.defineComponent({name:"VvAction",props:D,emits:["click","mouseover","mouseleave"],setup(l,{expose:t,emit:o}){const a=l,n=o,r=y(),i=e.ref(null);t({$el:i});const{reference:u,bus:d,aria:s,expanded:v}=e.inject(g,{});e.watch((()=>i.value),(e=>{u&&(u.value=e)}));const p=e.computed((()=>a.pressed||(null==v?void 0:v.value))),{role:f}=e.inject(b,{}),m=e.computed((()=>{switch(!0){case a.disabled:return c.button;case void 0!==a.to:return(null==r?void 0:r.nuxt)?c.nuxtLink:c.routerLink;case void 0!==a.href:return c.a;default:return a.defaultTag}})),h=e.computed((()=>{const e={...null==s?void 0:s.value,ariaPressed:!!p.value||void 0,ariaLabel:a.ariaLabel,role:null==f?void 0:f.value};switch(m.value){case c.a:return{...e,href:a.href,target:a.target,rel:a.rel};case c.routerLink:case c.nuxtLink:return{...e,to:a.to,target:a.target};case c.button:return{...e,type:a.type,disabled:a.disabled};default:return e}})),k=e=>{a.disabled?e.preventDefault():(null==d||d.emit("click",e),n("click",e))},S=e=>{null==d||d.emit("mouseover",e),n("mouseover",e)},B=e=>{null==d||d.emit("mouseleave",e),n("mouseleave",e)};return(l,t)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(m)),e.mergeProps(e.unref(h),{ref_key:"element",ref:i,class:{active:l.active,pressed:e.unref(p),disabled:l.disabled,current:l.current},onClickPassive:k,onMouseoverPassive:S,onMouseleavePassive:B}),{default:e.withCtx((()=>[e.renderSlot(l.$slots,"default",{},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)]))])),_:3},16,["class"]))}});const F={...E,...I,...x,...R,...V,...j,iconPosition:{type:String,default:d.left,validator:e=>Object.values(d).includes(e)},loadingIcon:{type:String,default:"eos-icons:bubble-loading"},toggle:{type:Boolean,default:!1},value:{type:[String,Number,Boolean],default:void 0},uncheckedValue:{type:[String,Number,Boolean],default:void 0},modelValue:{type:[String,Number,Boolean],default:void 0}};function z(l,t){const{group:o,isInGroup:a,getGroupOrLocalRef:n}=function(l){const t=e.inject(l,void 0),o=e.computed((()=>void 0!==t));return{group:t,isInGroup:o,getGroupOrLocalRef:function(l,o,a){const n=null==t?void 0:t[l];if(n)return e.computed({get:()=>n.value,set(e){n.value=e}});const r=e.toRef(o,l);return e.computed({get:()=>r.value,set(e){a&&a(`update:${l}`,e)}})}}}(m),{id:r,iconPosition:i,icon:u,label:d,pressed:s}=e.toRefs(l),v=n("modelValue",l,t),c=n("toggle",l),p=n("unselectable",l),f=e.computed((()=>(null==o?void 0:o.multiple.value)??!1)),g=e.computed((()=>{let e=l.modifiers,t=null==o?void 0:o.modifiers.value;const a=new Set;return e&&(Array.isArray(e)||(e=e.split(" ")),e.forEach((e=>a.add(e)))),t&&(Array.isArray(t)||(t=t.split(" ")),t.forEach((e=>a.add(e)))),Array.from(a)})),b=e.computed((()=>Boolean(l.disabled||(null==o?void 0:o.disabled.value))));return{group:o,isInGroup:a,modelValue:v,toggle:c,unselectable:p,multiple:f,modifiers:g,disabled:b,id:r,pressed:s,iconPosition:i,icon:u,label:d}}const U=l=>e.computed((()=>String((null==l?void 0:l.value)||o.uid())));function T(e,l,t){return t?H(e,t)===H(l,t):q(e,l)}function q(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){const t=Array.isArray(e),o=Array.isArray(l);let a,n,r;if(t&&o){if(n=e.length,n!=l.length)return!1;for(a=n;0!=a--;)if(!q(e[a],l[a]))return!1;return!0}if(t!=o)return!1;const i=e instanceof Date,u=l instanceof Date;if(i!=u)return!1;if(i&&u)return e.getTime()==l.getTime();const d=e instanceof RegExp,s=l instanceof RegExp;if(d!=s)return!1;if(d&&s)return e.toString()==l.toString();const v=Object.keys(e);if(n=v.length,n!==Object.keys(l).length)return!1;for(a=n;0!=a--;)if(!Object.prototype.hasOwnProperty.call(l,v[a]))return!1;for(a=n;0!=a--;)if(r=v[a],!q(e[r],l[r]))return!1;return!0}return e!=e&&l!=l}function H(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const t=l.split(".");let o=e;for(let l=0,a=t.length;l<a;++l){if(null==e)return null;o=o[t[l]]}return o}}return null}function G(e,l){if(null!=e&&l&&l.length)for(const t of l)if(T(e,t))return!0;return!1}function J(l,t){const o=e.computed((()=>"string"==typeof(null==l?void 0:l.value)?{name:null==l?void 0:l.value}:null==l?void 0:l.value)),a=e.computed((()=>(null==t?void 0:t.value)===s.before?o.value:void 0)),n=e.computed((()=>(null==t?void 0:t.value)===s.after?o.value:void 0)),r=e.computed((()=>(null==t?void 0:t.value)===d.left?o.value:void 0)),i=e.computed((()=>(null==t?void 0:t.value)===d.right?o.value:void 0)),u=e.computed((()=>(null==t?void 0:t.value)===d.top?o.value:void 0)),v=e.computed((()=>(null==t?void 0:t.value)===d.bottom?o.value:void 0));return{hasIcon:o,hasIconLeft:r,hasIconRight:i,hasIconTop:u,hasIconBottom:v,hasIconBefore:a,hasIconAfter:n}}const K={key:1,class:"vv-button__label"},Q={key:1,class:"vv-button__label"},W=e.defineComponent({name:"VvButton",props:F,emits:["update:modelValue"],setup(l,{expose:t,emit:o}){const a=l,n=e.useAttrs(),r=e.useSlots(),i=o,{id:u,modifiers:s,iconPosition:v,icon:c,label:p,modelValue:f,disabled:m,toggle:g,unselectable:b}=z(a,i),y=U(u),S=e.computed((()=>(null==n?void 0:n.name)||y.value)),B=e.ref(null);t({$el:e.computed((()=>{var e;return null==(e=B.value)?void 0:e.$el}))});const L=e.computed((()=>g.value?Array.isArray(f.value)?G(S.value,f.value):T(S.value,f.value):a.pressed)),V=h("vv-button",s,e.computed((()=>({reverse:[d.right,d.bottom].includes(v.value),column:[d.top,d.bottom].includes(v.value),"icon-only":Boolean((null==c?void 0:c.value)&&!(null==p?void 0:p.value)&&!r.default)})))),{hasIcon:w}=J(c),A=e.computed((()=>void 0!==a.value?a.value:S.value)),$=()=>{if(g.value){if(Array.isArray(f.value))return G(A.value,f.value)?void(b.value&&(f.value=f.value.filter((e=>e!==A.value)))):void f.value.push(A.value);if(A.value===f.value&&b.value)return void(f.value=a.uncheckedValue);f.value=A.value}};return(l,t)=>(e.openBlock(),e.createBlock(M,e.mergeProps({disabled:e.unref(m),pressed:e.unref(L),active:l.active,type:l.type,to:l.to,href:l.href,target:l.target,rel:l.rel,ariaLabel:l.ariaLabel},{id:e.unref(y),ref_key:"element",ref:B,class:e.unref(V),onClick:$}),{default:e.withCtx((()=>[e.renderSlot(l.$slots,"default",{},(()=>[l.loading?e.renderSlot(l.$slots,"loading",{key:0},(()=>[l.loadingIcon?(e.openBlock(),e.createBlock(k,{key:0,class:"vv-button__loading-icon",name:l.loadingIcon},null,8,["name"])):e.createCommentVNode("v-if",!0),l.loadingLabel?(e.openBlock(),e.createElementBlock("span",K,e.toDisplayString(l.loadingLabel),1)):e.createCommentVNode("v-if",!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.renderSlot(l.$slots,"before"),e.unref(w)?(e.openBlock(),e.createBlock(k,e.mergeProps({key:0},e.unref(w),{class:"vv-button__icon"}),null,16)):e.createCommentVNode("v-if",!0),e.unref(p)?(e.openBlock(),e.createElementBlock("span",Q,[e.renderSlot(l.$slots,"label",{},(()=>[e.createTextVNode(e.toDisplayString(e.unref(p)),1)]))])):e.createCommentVNode("v-if",!0),e.renderSlot(l.$slots,"after")],64))]))])),_:3},16,["id","class"]))}});function X(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}const Y={...P,...x,...B,...L,...N,...O,...V,...C,...j,modelValue:{type:Object},progress:{type:[Number,String],default:void 0},placeholder:{type:String,default:void 0},accept:{type:String,default:"*"},multiple:{type:Boolean,default:!1},capture:{type:String,default:void 0,validation:e=>void 0===e||["user","environment"].includes(e)},max:{type:[Number,String],default:void 0},dropArea:{type:Boolean,default:!1},sortable:{type:Boolean,default:!1},labelAdd:{type:String,default:"Add file"},iconAdd:{type:[String,Object],default:n},labelReplace:{type:String,default:"Replace file"},iconReplace:{type:[String,Object],default:r},labelDownload:{type:String,default:"Downlaod file"},iconDownload:{type:[String,Object],default:i},labelRemove:{type:String,default:"Remove file"}};const Z=["for"],ee={class:"vv-input-file__preview"},le=["src","alt"],te={class:"vv-input-file__wrapper"},oe=["id","readonly","placeholder","aria-describedby","aria-invalid","aria-errormessage","multiple","accept","capture","name"],ae=["value"],ne=["onClick"],re=["title","onClick"],ie={class:"vv-input-file__item-name"},ue={class:"vv-input-file__item-info"},de=["title","onClick"];return e.defineComponent({name:"VvInputFile",props:Y,emits:["update:modelValue"],setup(t,{emit:o}){const n=t,r=o,i=e.useSlots(),u=function(l,t,o){const a=y(),n=e.computed((()=>{var e;if(a&&(null==(e=a.defaults.value)?void 0:e[l]))return a.defaults.value[l]}));return e.computed((()=>{if(void 0===n.value)return o;const e=n.value,l=t,a=o;return Object.keys(l).reduce(((t,o)=>{const n=a[o];if(t[o]=n,o in e){if(Array.isArray(l[o])){const a=l[o];a.length&&a[0]===n&&(t[o]=e[o])}if("function"==typeof l[o]&&(0,l[o])()===n&&(t[o]=e[o]),"object"==typeof l[o]){let a=l[o].default;"function"==typeof a&&(a=a()),"object"==typeof a?JSON.stringify(a)===JSON.stringify(n)&&(t[o]=e[o]):a===n&&(t[o]=e[o])}}return t}),{})}))}("VvInputFile",Y,n),{modifiers:d,id:s,readonly:v,icon:c,iconPosition:p,iconDownload:f}=e.toRefs(n),m=U(s),g=e.computed((()=>`${m.value}-hint`)),b=e.computed((()=>{if(!n.progress)return!1;const e="string"==typeof n.progress?parseInt(n.progress):n.progress;return e>0&&e<100})),{hasIconBefore:S,hasIconAfter:B}=J(c,p),{hasIcon:L}=J(f),V=h("vv-input-file",d,e.computed((()=>({dragging:R.value,loading:n.loading&&!b.value,valid:!0===n.valid,invalid:!0===n.invalid,"icon-before":!!S.value,"icon-after":!!B.value,"drop-area":N.value})))),{HintSlot:w,hasHintLabelOrSlot:A,hasInvalidLabelOrSlot:$,hintSlotScope:_}=function(l,t){const o=e.computed((()=>e.isRef(l)?l.value:l)),a=e.computed((()=>X(o.value.invalidLabel))),n=e.computed((()=>X(o.value.validLabel))),r=e.computed((()=>o.value.loadingLabel)),i=e.computed((()=>o.value.hintLabel)),u=e.computed((()=>Boolean(o.value.loading&&(t.loading||r.value)))),d=e.computed((()=>!u.value&&Boolean(o.value.invalid&&(t.invalid||a.value)))),s=e.computed((()=>!u.value&&!d.value&&Boolean(o.value.valid&&(t.valid||n.value)))),v=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(t.hint||i.value))),c=e.computed((()=>d.value||s.value||u.value||v.value)),p=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:c,invalidLabel:a,validLabel:n,loadingLabel:r,hintLabel:i,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:v}),render(){var l,t,o,a,n,r,i,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(t=(l=this.$slots).loading)?void 0:t.call(l))??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==(r=(n=this.$slots).valid)?void 0:r.call(n))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(i=this.$slots).hint)?void 0:u.call(i))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:v,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hintSlotScope:p,HintSlot:f}}(u,i),O=l.useVModel(n,"modelValue",r),C=e.computed({get:()=>{var e;return O.value&&(Array.isArray(O.value)||(null==(e=O.value)?void 0:e.name))?Array.isArray(O.value)?O.value:[O.value]:[]},set:e=>{j.value?O.value=e:O.value=null==e?void 0:e[0]}}),x=e.computed((()=>"string"==typeof n.max?parseInt(n.max):n.max)),N=e.computed((()=>n.dropArea&&!v.value)),j=e.computed((()=>!!n.multiple&&(!x.value||x.value-C.value.length>1))),R=e.ref(!1),I=e.ref(),P=()=>{R.value=!0},E=()=>{R.value=!1},D=e=>{var l,t;(null==(l=e.dataTransfer)?void 0:l.files)&&(R.value=!1,F(null==(t=e.dataTransfer)?void 0:t.files))},M=()=>{var e;(null==(e=I.value)?void 0:e.files)&&(F(I.value.files),I.value.value="")},F=e=>{if(!n.multiple)return Array.isArray(O.value)?void(O.value=[...e]):void(O.value=e[0]);let l=[];l=!Array.isArray(O.value)&&O.value?[O.value]:O.value&&Array.isArray(O.value)?[...O.value]:l;for(const t of e){if(x.value&&l.length>=x.value)break;l.push(t)}O.value=l,T.value=l.length-1},z=()=>{I.value&&(v.value||I.value.click())},T=e.ref(0),q=["image/jpeg","image/png"],H=e.computed((()=>{if(0===C.value.length)return;if(!C.value[T.value])return;if(C.value[T.value]instanceof File){const e=C.value[T.value];if(!q.includes(e.type))return;return URL.createObjectURL(e)}const e=C.value[T.value];return e.thumbnailUrl?e.thumbnailUrl:q.includes(e.type)?e.url:void 0}));e.watch(H,((e,l)=>{l&&URL.revokeObjectURL(l)})),e.onBeforeUnmount((()=>{H.value&&URL.revokeObjectURL(H.value)}));const G=e=>{if(e)return Math.floor(e/1024)},K=e.computed((()=>0===C.value.length||j.value?n.labelAdd:n.labelReplace)),Q=e.computed((()=>0===C.value.length||j.value?n.iconAdd:n.iconReplace)),se=({newIndex:e})=>{null!==e&&(T.value=e)};return(l,t)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(V))},[l.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(m)},e.toDisplayString(l.label),9,Z)):e.createCommentVNode("v-if",!0),N.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vv-input-file__drop-area",onDragenter:e.withModifiers(P,["prevent","stop"]),onDragleave:e.withModifiers(E,["prevent","stop"]),onDrop:e.withModifiers(D,["prevent","stop"]),onDragover:t[0]||(t[0]=e.withModifiers((()=>{}),["prevent","stop"])),onClick:e.withModifiers(z,["stop"])},[e.renderSlot(l.$slots,"drop-area",{},(()=>[e.createElementVNode("picture",ee,[H.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:H.value,alt:C.value[T.value].name},null,8,le)):e.createCommentVNode("v-if",!0)]),e.unref(v)?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createBlock(W,{key:0,modifiers:"action",label:H.value?void 0:K.value,title:H.value?K.value:void 0,class:e.normalizeClass({"vv-input-file__drop-area-action":H.value}),icon:Q.value,onClick:e.withModifiers(z,["stop"])},null,8,["label","title","class","icon"]))]))],32)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",te,[e.unref(S)?(e.openBlock(),e.createBlock(k,e.normalizeProps(e.mergeProps({key:0},e.unref(S))),null,16)):e.createCommentVNode("v-if",!0),e.createElementVNode("input",{id:e.unref(m),ref_key:"inputEl",ref:I,type:"file",readonly:e.unref(v),placeholder:l.placeholder,"aria-describedby":e.unref(A)?g.value:void 0,"aria-invalid":l.invalid,"aria-errormessage":e.unref($)?g.value:void 0,multiple:j.value,accept:l.accept,capture:l.capture,name:l.name,onChange:M},null,40,oe),b.value?(e.openBlock(),e.createElementBlock("progress",{key:1,class:"vv-input-file__progress",value:l.progress,max:"100"},e.toDisplayString(l.progress)+"% ",9,ae)):e.createCommentVNode("v-if",!0),e.unref(B)?(e.openBlock(),e.createBlock(k,e.normalizeProps(e.mergeProps({key:2},e.unref(B))),null,16)):e.createCommentVNode("v-if",!0)]),e.createVNode(e.unref(a),{modelValue:C.value,"onUpdate:modelValue":t[1]||(t[1]=e=>C.value=e),tag:"ul",class:"vv-input-file__list","item-key":"name",move:()=>l.sortable,onEnd:se},{item:e.withCtx((({element:t,index:o})=>[e.createElementVNode("li",{class:e.normalizeClass(["vv-input-file__item",{active:o===T.value&&N.value&&C.value.length>1,"cursor-move":l.sortable}]),onClick:e.withModifiers((e=>(e=>{T.value=e})(o)),["stop"])},[e.unref(L)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"vv-input-file__item-action",title:l.labelDownload,onClick:e.withModifiers((e=>(e=>{const l=document.createElement("a");e instanceof File?l.href=URL.createObjectURL(e):e.url&&(l.href=e.url),l.setAttribute("download",e.name),document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(l.href)})(t)),["stop"])},[e.createVNode(k,e.normalizeProps(e.guardReactiveProps(e.unref(L))),null,16)],8,re)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",ie,e.toDisplayString(t.name),1),e.createElementVNode("small",ue,e.toDisplayString(G(t.size))+" KB ",1),e.unref(v)?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"vv-input-file__item-remove",title:l.labelRemove,onClick:e.withModifiers((e=>(e=>{if(!Array.isArray(O.value))return void(O.value=void 0);T.value===e&&(T.value=0);const l=[...O.value];l.splice(e,1),O.value=l})(o)),["stop"])},null,8,de))],10,ne)])),_:1},8,["modelValue","move"]),e.createVNode(e.unref(w),{id:g.value,class:"vv-input-file__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(_))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(_))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(_))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(_))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|
|
@@ -14,8 +14,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
14
14
|
url: string;
|
|
15
15
|
thumbnailUrl?: string | undefined;
|
|
16
16
|
lastModified?: number | undefined;
|
|
17
|
-
} | File)[]
|
|
18
|
-
required: boolean;
|
|
17
|
+
} | File)[]>;
|
|
19
18
|
};
|
|
20
19
|
progress: {
|
|
21
20
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -46,6 +45,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
46
45
|
type: BooleanConstructor;
|
|
47
46
|
default: boolean;
|
|
48
47
|
};
|
|
48
|
+
sortable: {
|
|
49
|
+
type: BooleanConstructor;
|
|
50
|
+
default: boolean;
|
|
51
|
+
};
|
|
49
52
|
labelAdd: {
|
|
50
53
|
type: StringConstructor;
|
|
51
54
|
default: string;
|
|
@@ -160,8 +163,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
160
163
|
url: string;
|
|
161
164
|
thumbnailUrl?: string | undefined;
|
|
162
165
|
lastModified?: number | undefined;
|
|
163
|
-
} | File)[]
|
|
164
|
-
required: boolean;
|
|
166
|
+
} | File)[]>;
|
|
165
167
|
};
|
|
166
168
|
progress: {
|
|
167
169
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -192,6 +194,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
192
194
|
type: BooleanConstructor;
|
|
193
195
|
default: boolean;
|
|
194
196
|
};
|
|
197
|
+
sortable: {
|
|
198
|
+
type: BooleanConstructor;
|
|
199
|
+
default: boolean;
|
|
200
|
+
};
|
|
195
201
|
labelAdd: {
|
|
196
202
|
type: StringConstructor;
|
|
197
203
|
default: string;
|
|
@@ -291,25 +297,26 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
291
297
|
lastModified?: number | undefined;
|
|
292
298
|
} | File)[] | undefined) => any) | undefined;
|
|
293
299
|
}, {
|
|
294
|
-
readonly: boolean;
|
|
295
|
-
valid: boolean;
|
|
296
|
-
invalid: boolean;
|
|
297
|
-
multiple: boolean;
|
|
298
|
-
modifiers: string | string[];
|
|
299
300
|
label: string | number;
|
|
301
|
+
modifiers: string | string[];
|
|
300
302
|
progress: string | number;
|
|
301
303
|
icon: string | import("../VvIcon").VvIconProps;
|
|
302
304
|
iconPosition: "before" | "after";
|
|
303
305
|
loading: boolean;
|
|
304
306
|
loadingLabel: string;
|
|
307
|
+
multiple: boolean;
|
|
308
|
+
readonly: boolean;
|
|
305
309
|
hintLabel: string;
|
|
310
|
+
invalid: boolean;
|
|
306
311
|
invalidLabel: string | unknown[];
|
|
312
|
+
valid: boolean;
|
|
307
313
|
validLabel: string | unknown[];
|
|
308
314
|
placeholder: string;
|
|
309
315
|
accept: string;
|
|
310
316
|
capture: "user" | "environment";
|
|
311
317
|
max: string | number;
|
|
312
318
|
dropArea: boolean;
|
|
319
|
+
sortable: boolean;
|
|
313
320
|
labelAdd: string;
|
|
314
321
|
iconAdd: string | import("../VvIcon").VvIconProps;
|
|
315
322
|
labelReplace: string;
|
|
@@ -24,8 +24,7 @@ export declare const VvInputFileProps: {
|
|
|
24
24
|
url: string;
|
|
25
25
|
thumbnailUrl?: string | undefined;
|
|
26
26
|
lastModified?: number | undefined;
|
|
27
|
-
} | File)[]
|
|
28
|
-
required: boolean;
|
|
27
|
+
} | File)[]>;
|
|
29
28
|
};
|
|
30
29
|
/**
|
|
31
30
|
* Whether to show progress bar
|
|
@@ -82,6 +81,13 @@ export declare const VvInputFileProps: {
|
|
|
82
81
|
type: BooleanConstructor;
|
|
83
82
|
default: boolean;
|
|
84
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* Enable sorting
|
|
86
|
+
*/
|
|
87
|
+
sortable: {
|
|
88
|
+
type: BooleanConstructor;
|
|
89
|
+
default: boolean;
|
|
90
|
+
};
|
|
85
91
|
/**
|
|
86
92
|
* Label for add button
|
|
87
93
|
*/
|
|
@@ -174,7 +180,10 @@ export declare const VvInputFileProps: {
|
|
|
174
180
|
valid: {
|
|
175
181
|
type: BooleanConstructor;
|
|
176
182
|
default: boolean;
|
|
177
|
-
};
|
|
183
|
+
}; /**
|
|
184
|
+
* Whether to allow multiple values
|
|
185
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#multiple
|
|
186
|
+
*/
|
|
178
187
|
validLabel: {
|
|
179
188
|
type: (ArrayConstructor | StringConstructor)[];
|
|
180
189
|
default: undefined;
|
|
@@ -31,8 +31,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
31
31
|
}>> & {
|
|
32
32
|
onClear?: ((...args: any[]) => any) | undefined;
|
|
33
33
|
}, {
|
|
34
|
-
disabled: boolean;
|
|
35
34
|
label: string;
|
|
35
|
+
disabled: boolean;
|
|
36
36
|
icon: string | VvIconProps;
|
|
37
37
|
}, {}>;
|
|
38
38
|
export default _default;
|
|
@@ -31,7 +31,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
31
31
|
"onStep-up"?: ((...args: any[]) => any) | undefined;
|
|
32
32
|
"onStep-down"?: ((...args: any[]) => any) | undefined;
|
|
33
33
|
}, {
|
|
34
|
-
disabled: boolean;
|
|
35
34
|
mode: string;
|
|
35
|
+
disabled: boolean;
|
|
36
36
|
}, {}>;
|
|
37
37
|
export default _default;
|
|
@@ -341,22 +341,22 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
341
341
|
};
|
|
342
342
|
id: (StringConstructor | NumberConstructor)[];
|
|
343
343
|
}>>, {
|
|
344
|
-
readonly: boolean;
|
|
345
|
-
disabled: boolean;
|
|
346
|
-
valid: boolean;
|
|
347
|
-
invalid: boolean;
|
|
348
|
-
multiple: boolean;
|
|
349
|
-
modifiers: string | string[];
|
|
350
344
|
floating: boolean;
|
|
351
345
|
label: string | number;
|
|
346
|
+
disabled: boolean;
|
|
347
|
+
modifiers: string | string[];
|
|
352
348
|
type: import("../VvInputText").InputType;
|
|
353
349
|
required: boolean;
|
|
354
350
|
icon: string | import("../VvIcon").VvIconProps;
|
|
355
351
|
iconPosition: "before" | "after";
|
|
356
352
|
loading: boolean;
|
|
357
353
|
loadingLabel: string;
|
|
354
|
+
multiple: boolean;
|
|
355
|
+
readonly: boolean;
|
|
358
356
|
hintLabel: string;
|
|
357
|
+
invalid: boolean;
|
|
359
358
|
invalidLabel: string | unknown[];
|
|
359
|
+
valid: boolean;
|
|
360
360
|
validLabel: string | unknown[];
|
|
361
361
|
tabindex: string | number;
|
|
362
362
|
placeholder: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { inject, computed, toRef, toRefs, isRef, defineComponent, h, unref, useSlots, ref, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, vModelRadio, renderSlot, createTextVNode, toDisplayString, createVNode, createSlots, withCtx, normalizeProps, guardReactiveProps } from "vue";
|
|
2
2
|
import { uid } from "uid";
|
|
3
3
|
var Strategy = /* @__PURE__ */ ((Strategy2) => {
|
|
4
4
|
Strategy2["absolute"] = "absolute";
|
|
@@ -49,7 +49,9 @@ var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
|
|
|
49
49
|
return AnchorTarget2;
|
|
50
50
|
})(AnchorTarget || {});
|
|
51
51
|
const INJECTION_KEY_VOLVER = Symbol.for("volver");
|
|
52
|
-
const INJECTION_KEY_RADIO_GROUP = Symbol.for(
|
|
52
|
+
const INJECTION_KEY_RADIO_GROUP = Symbol.for(
|
|
53
|
+
"radioGroup"
|
|
54
|
+
);
|
|
53
55
|
const LinkProps = {
|
|
54
56
|
/**
|
|
55
57
|
* The router-link/nuxt-link property, if it is defined the button is rendered as a ruouter-link or nuxt-link.
|
|
@@ -375,6 +377,66 @@ const CheckboxRadioProps = {
|
|
|
375
377
|
default: ActionTag.button
|
|
376
378
|
}
|
|
377
379
|
});
|
|
380
|
+
function useInjectedGroupState(groupKey) {
|
|
381
|
+
const group = inject(groupKey, void 0);
|
|
382
|
+
const isInGroup = computed(() => group !== void 0);
|
|
383
|
+
function getGroupOrLocalRef(propName, props, emit) {
|
|
384
|
+
const groupPropValue = group == null ? void 0 : group[propName];
|
|
385
|
+
if (groupPropValue) {
|
|
386
|
+
return computed({
|
|
387
|
+
get() {
|
|
388
|
+
return groupPropValue.value;
|
|
389
|
+
},
|
|
390
|
+
set(value) {
|
|
391
|
+
groupPropValue.value = value;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
const propRef = toRef(props, propName);
|
|
396
|
+
return computed({
|
|
397
|
+
get() {
|
|
398
|
+
return propRef.value;
|
|
399
|
+
},
|
|
400
|
+
set(value) {
|
|
401
|
+
if (emit) {
|
|
402
|
+
emit(`update:${propName}`, value);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
return {
|
|
408
|
+
group,
|
|
409
|
+
isInGroup,
|
|
410
|
+
getGroupOrLocalRef
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
const VvRadioProps = CheckboxRadioProps;
|
|
414
|
+
const VvRadioEvents = ["click", "update:modelValue", "change", "blur"];
|
|
415
|
+
function useGroupProps(props, emit) {
|
|
416
|
+
const { id } = toRefs(props);
|
|
417
|
+
const { group, isInGroup, getGroupOrLocalRef } = useInjectedGroupState(INJECTION_KEY_RADIO_GROUP);
|
|
418
|
+
const modelValue = getGroupOrLocalRef("modelValue", props, emit);
|
|
419
|
+
const valid = getGroupOrLocalRef("valid", props);
|
|
420
|
+
const invalid = getGroupOrLocalRef("invalid", props);
|
|
421
|
+
const readonly = computed(
|
|
422
|
+
() => Boolean(props.readonly || (group == null ? void 0 : group.readonly.value))
|
|
423
|
+
);
|
|
424
|
+
const disabled = computed(
|
|
425
|
+
() => Boolean(props.disabled || (group == null ? void 0 : group.disabled.value))
|
|
426
|
+
);
|
|
427
|
+
return {
|
|
428
|
+
// local props
|
|
429
|
+
id,
|
|
430
|
+
// global props
|
|
431
|
+
group,
|
|
432
|
+
isInGroup,
|
|
433
|
+
modelValue,
|
|
434
|
+
valid,
|
|
435
|
+
invalid,
|
|
436
|
+
readonly,
|
|
437
|
+
disabled
|
|
438
|
+
};
|
|
439
|
+
}
|
|
378
440
|
function equals(obj1, obj2, field) {
|
|
379
441
|
if (field) {
|
|
380
442
|
return resolveFieldData(obj1, field) === resolveFieldData(obj2, field);
|
|
@@ -454,77 +516,9 @@ function contains(value, list) {
|
|
|
454
516
|
}
|
|
455
517
|
return false;
|
|
456
518
|
}
|
|
457
|
-
function isEmpty(value) {
|
|
458
|
-
return ((value2) => value2 === null || value2 === void 0 || value2 === "" || Array.isArray(value2) && value2.length === 0 || !(value2 instanceof Date) && typeof value2 === "object" && Object.keys(value2).length === 0)(unref(value));
|
|
459
|
-
}
|
|
460
519
|
function isString(value) {
|
|
461
520
|
return typeof value === "string" || value instanceof String;
|
|
462
521
|
}
|
|
463
|
-
function useInjectedGroupState(groupKey) {
|
|
464
|
-
const group = inject(groupKey, void 0);
|
|
465
|
-
const isInGroup = computed(() => !isEmpty(group));
|
|
466
|
-
function getGroupOrLocalRef(propName, props, emit) {
|
|
467
|
-
if (group == null ? void 0 : group.value) {
|
|
468
|
-
const groupPropValue = unref(group.value)[propName];
|
|
469
|
-
return computed({
|
|
470
|
-
get() {
|
|
471
|
-
return groupPropValue == null ? void 0 : groupPropValue.value;
|
|
472
|
-
},
|
|
473
|
-
set(value) {
|
|
474
|
-
groupPropValue.value = value;
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
const propRef = toRef(props, propName);
|
|
479
|
-
return computed({
|
|
480
|
-
get() {
|
|
481
|
-
return propRef.value;
|
|
482
|
-
},
|
|
483
|
-
set(value) {
|
|
484
|
-
if (emit)
|
|
485
|
-
emit(`update:${propName}`, value);
|
|
486
|
-
}
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
return {
|
|
490
|
-
group,
|
|
491
|
-
isInGroup,
|
|
492
|
-
getGroupOrLocalRef
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
const VvRadioProps = CheckboxRadioProps;
|
|
496
|
-
const VvRadioEvents = ["click", "update:modelValue", "change", "blur"];
|
|
497
|
-
function useGroupProps(props, emit) {
|
|
498
|
-
const { id } = toRefs(props);
|
|
499
|
-
const { group, isInGroup, getGroupOrLocalRef } = useInjectedGroupState(INJECTION_KEY_RADIO_GROUP);
|
|
500
|
-
const modelValue = getGroupOrLocalRef("modelValue", props, emit);
|
|
501
|
-
const valid = getGroupOrLocalRef("valid", props);
|
|
502
|
-
const invalid = getGroupOrLocalRef("invalid", props);
|
|
503
|
-
const readonly = computed(
|
|
504
|
-
() => {
|
|
505
|
-
var _a;
|
|
506
|
-
return Boolean(props.readonly || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.readonly.value));
|
|
507
|
-
}
|
|
508
|
-
);
|
|
509
|
-
const disabled = computed(
|
|
510
|
-
() => {
|
|
511
|
-
var _a;
|
|
512
|
-
return Boolean(props.disabled || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.disabled.value));
|
|
513
|
-
}
|
|
514
|
-
);
|
|
515
|
-
return {
|
|
516
|
-
// local props
|
|
517
|
-
id,
|
|
518
|
-
// global props
|
|
519
|
-
group,
|
|
520
|
-
isInGroup,
|
|
521
|
-
modelValue,
|
|
522
|
-
valid,
|
|
523
|
-
invalid,
|
|
524
|
-
readonly,
|
|
525
|
-
disabled
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
522
|
function joinLines(items) {
|
|
529
523
|
if (Array.isArray(items)) {
|
|
530
524
|
return items.filter((item) => isString(item)).join(" ");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("uid")):"function"==typeof define&&define.amd?define(["vue","uid"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvRadio=t(e.vue,e.uid)}(this,(function(e,t){"use strict";var l=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(l||{}),a=(e=>(e.before="before",e.after="after",e))(a||{}),
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("uid")):"function"==typeof define&&define.amd?define(["vue","uid"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvRadio=t(e.vue,e.uid)}(this,(function(e,t){"use strict";var l=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(l||{}),a=(e=>(e.before="before",e.after="after",e))(a||{}),o=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(o||{}),i=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(i||{});const n=Symbol.for("volver"),r=Symbol.for("radioGroup"),u={valid:{type:Boolean,default:!1},validLabel:{type:[String,Array],default:void 0}},d={invalid:{type:Boolean,default:!1},invalidLabel:{type:[String,Array],default:void 0}},s={loading:{type:Boolean,default:!1},loadingLabel:{type:String,default:"Loading..."}},v={disabled:{type:Boolean,default:!1}},f=(Boolean,Boolean,Boolean,{label:{type:[String,Number],default:void 0}}),c={readonly:{type:Boolean,default:!1}},p={modifiers:{type:[String,Array],default:void 0}},b={hintLabel:{type:String,default:""}};a.before;const m={tabindex:{type:[String,Number],default:0}},g={id:[String,Number]};l.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const h={...{...g,name:{type:String,required:!0}},...m,...u,...d,...b,...v,...c,...p,...f,...s,value:{type:[String,Number,Boolean],default:void 0},modelValue:{type:[Object,Number,Boolean,String],default:void 0}};o.button,i.button;const y=h;function S(t,l){const{id:a}=e.toRefs(t),{group:o,isInGroup:i,getGroupOrLocalRef:n}=function(t){const l=e.inject(t,void 0),a=e.computed((()=>void 0!==l));return{group:l,isInGroup:a,getGroupOrLocalRef:function(t,a,o){const i=null==l?void 0:l[t];if(i)return e.computed({get:()=>i.value,set(e){i.value=e}});const n=e.toRef(a,t);return e.computed({get:()=>n.value,set(e){o&&o(`update:${t}`,e)}})}}}(r),u=n("modelValue",t,l),d=n("valid",t),s=n("invalid",t),v=e.computed((()=>Boolean(t.readonly||(null==o?void 0:o.readonly.value)))),f=e.computed((()=>Boolean(t.disabled||(null==o?void 0:o.disabled.value))));return{id:a,group:o,isInGroup:i,modelValue:u,valid:d,invalid:s,readonly:v,disabled:f}}function L(e,t,l){return l?B(e,l)===B(t,l):O(e,t)}function O(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){const l=Array.isArray(e),a=Array.isArray(t);let o,i,n;if(l&&a){if(i=e.length,i!=t.length)return!1;for(o=i;0!=o--;)if(!O(e[o],t[o]))return!1;return!0}if(l!=a)return!1;const r=e instanceof Date,u=t instanceof Date;if(r!=u)return!1;if(r&&u)return e.getTime()==t.getTime();const d=e instanceof RegExp,s=t instanceof RegExp;if(d!=s)return!1;if(d&&s)return e.toString()==t.toString();const v=Object.keys(e);if(i=v.length,i!==Object.keys(t).length)return!1;for(o=i;0!=o--;)if(!Object.prototype.hasOwnProperty.call(t,v[o]))return!1;for(o=i;0!=o--;)if(n=v[o],!O(e[n],t[n]))return!1;return!0}return e!=e&&t!=t}function B(e,t){if(e&&Object.keys(e).length&&t){if(-1===t.indexOf("."))return e[t];{const l=t.split(".");let a=e;for(let t=0,o=l.length;t<o;++t){if(null==e)return null;a=a[l[t]]}return a}}return null}function $(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}function V(t,l,a){const o=e.inject(n),i=e.computed((()=>{var e;if(o&&(null==(e=o.defaults.value)?void 0:e[t]))return o.defaults.value[t]}));return e.computed((()=>{if(void 0===i.value)return a;const e=i.value,t=l,o=a;return Object.keys(t).reduce(((l,a)=>{const i=o[a];if(l[a]=i,a in e){if(Array.isArray(t[a])){const o=t[a];if(o.length){o[0]===i&&(l[a]=e[a])}}if("function"==typeof t[a]){(0,t[a])()===i&&(l[a]=e[a])}if("object"==typeof t[a]){let o=t[a].default;"function"==typeof o&&(o=o()),"object"==typeof o?JSON.stringify(o)===JSON.stringify(i)&&(l[a]=e[a]):o===i&&(l[a]=e[a])}}return l}),{})}))}const k=["for"],A=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"];return e.defineComponent({name:"VvRadio",props:y,emits:["click","update:modelValue","change","blur"],setup(l,{emit:a}){const o=l,i=a,n=e.useSlots(),r=V("VvRadio",y,o),{id:u,disabled:d,readonly:s,modelValue:v,valid:f,invalid:c}=S(o,i),p=(l=>e.computed((()=>String((null==l?void 0:l.value)||t.uid()))))(u),b=e.computed((()=>`${p.value}-hint`)),m=e.computed((()=>h.value?-1:o.tabindex)),g=e.ref(),h=e.computed((()=>d.value||s.value)),O=e.computed((()=>!0===c.value||!0!==f.value&&void 0)),B=e.computed((()=>Array.isArray(v.value)?function(e,t){if(null!=e&&t&&t.length)for(const l of t)if(L(e,l))return!0;return!1}(o.value,v.value):L(o.value,v.value))),R=e.computed((()=>!["string","number","boolean"].includes(typeof o.value)||o.value)),x=e.computed({get:()=>B.value?R.value:null,set(e){Array.isArray(v.value)?v.value=[o.value]:v.value=o.value,i("change",e)}}),{modifiers:j}=e.toRefs(o),N=function(t,l,a){return e.computed((()=>{const o={[t]:!0},i="string"==typeof(null==l?void 0:l.value)?l.value.split(" "):null==l?void 0:l.value;return i&&Array.isArray(i)&&i.forEach((e=>{e&&(o[`${t}--${e}`]=!0)})),a&&Object.keys(a.value).forEach((l=>{o[`${t}--${l}`]=e.unref(a.value[l])})),o}))}("vv-radio",j,e.computed((()=>({valid:f.value,invalid:c.value,disabled:d.value,readonly:s.value})))),{HintSlot:P,hasHintLabelOrSlot:I,hasInvalidLabelOrSlot:C,hintSlotScope:w}=function(t,l){const a=e.computed((()=>e.isRef(t)?t.value:t)),o=e.computed((()=>$(a.value.invalidLabel))),i=e.computed((()=>$(a.value.validLabel))),n=e.computed((()=>a.value.loadingLabel)),r=e.computed((()=>a.value.hintLabel)),u=e.computed((()=>Boolean(a.value.loading&&(l.loading||n.value)))),d=e.computed((()=>!u.value&&Boolean(a.value.invalid&&(l.invalid||o.value)))),s=e.computed((()=>!u.value&&!d.value&&Boolean(a.value.valid&&(l.valid||i.value)))),v=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(l.hint||r.value))),f=e.computed((()=>d.value||s.value||u.value||v.value)),c=e.computed((()=>({modelValue:a.value.modelValue,valid:a.value.valid,invalid:a.value.invalid,loading:a.value.loading}))),p=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:f,invalidLabel:o,validLabel:i,loadingLabel:n,hintLabel:r,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:v}),render(){var t,l,a,o,i,n,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==(o=(a=this.$slots).invalid)?void 0:o.call(a))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(n=(i=this.$slots).valid)?void 0:n.call(i))??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:d,hasHintLabelOrSlot:v,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hintSlotScope:c,HintSlot:p}}(r,n);return(t,l)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(N)),for:e.unref(p)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(p),ref_key:"input",ref:g,"onUpdate:modelValue":l[0]||(l[0]=t=>e.isRef(x)?x.value=t:null),type:"radio",class:"vv-radio__input",name:t.name,disabled:e.unref(h),value:e.unref(R),tabindex:e.unref(m),"aria-invalid":e.unref(O),"aria-describedby":e.unref(I)?e.unref(b):void 0,"aria-errormessage":e.unref(C)?e.unref(b):void 0},null,8,A),[[e.vModelRadio,e.unref(x)]]),e.renderSlot(t.$slots,"default",{value:e.unref(v)},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)])),e.createVNode(e.unref(P),{id:e.unref(b),class:"vv-radio__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"3"}:void 0]),1032,["id"])],10,k))}})}));
|
|
@@ -125,23 +125,23 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
125
125
|
};
|
|
126
126
|
id: (StringConstructor | NumberConstructor)[];
|
|
127
127
|
}>>, {
|
|
128
|
-
|
|
128
|
+
label: string | number;
|
|
129
|
+
value: string | number | boolean;
|
|
129
130
|
disabled: boolean;
|
|
130
|
-
valid: boolean;
|
|
131
|
-
invalid: boolean;
|
|
132
131
|
modelValue: string | number | boolean | Record<string, any>;
|
|
133
132
|
modifiers: string | string[];
|
|
134
|
-
label: string | number;
|
|
135
|
-
value: string | number | boolean;
|
|
136
133
|
loading: boolean;
|
|
137
134
|
loadingLabel: string;
|
|
135
|
+
readonly: boolean;
|
|
138
136
|
hintLabel: string;
|
|
137
|
+
invalid: boolean;
|
|
139
138
|
invalidLabel: string | unknown[];
|
|
139
|
+
valid: boolean;
|
|
140
140
|
validLabel: string | unknown[];
|
|
141
141
|
tabindex: string | number;
|
|
142
142
|
}, {}>, {
|
|
143
143
|
default?(_: {
|
|
144
|
-
value:
|
|
144
|
+
value: unknown;
|
|
145
145
|
}): any;
|
|
146
146
|
hint?(_: {
|
|
147
147
|
modelValue: unknown;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtractPropTypes
|
|
1
|
+
import type { ExtractPropTypes } from 'vue';
|
|
2
2
|
import type { InputGroupState } from '../../types/group';
|
|
3
3
|
export declare const VvRadioProps: {
|
|
4
4
|
value: {
|
|
@@ -69,12 +69,12 @@ export type VvRadioPropsType = ExtractPropTypes<typeof VvRadioProps>;
|
|
|
69
69
|
* Merges local and group props
|
|
70
70
|
*/
|
|
71
71
|
export declare function useGroupProps(props: VvRadioPropsType, emit: (event: (typeof VvRadioEvents)[number], value: unknown) => void): {
|
|
72
|
-
id: Ref<string | number | undefined> | undefined;
|
|
73
|
-
group:
|
|
72
|
+
id: globalThis.Ref<string | number | undefined> | undefined;
|
|
73
|
+
group: InputGroupState | undefined;
|
|
74
74
|
isInGroup: globalThis.ComputedRef<boolean>;
|
|
75
|
-
modelValue: globalThis.
|
|
76
|
-
valid: Ref<boolean>;
|
|
77
|
-
invalid: Ref<boolean>;
|
|
75
|
+
modelValue: globalThis.Ref<unknown>;
|
|
76
|
+
valid: globalThis.Ref<boolean>;
|
|
77
|
+
invalid: globalThis.Ref<boolean>;
|
|
78
78
|
readonly: globalThis.ComputedRef<boolean>;
|
|
79
79
|
disabled: globalThis.ComputedRef<boolean>;
|
|
80
80
|
};
|