@volverjs/ui-vue 0.0.10-beta.16 → 0.0.10-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.
@@ -1215,9 +1215,11 @@ const _hoisted_4 = ["src", "alt"];
1215
1215
  const _hoisted_5 = { class: "vv-input-file__wrapper" };
1216
1216
  const _hoisted_6 = ["id", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "name"];
1217
1217
  const _hoisted_7 = { class: "vv-input-file__list" };
1218
- const _hoisted_8 = { class: "vv-input-file__item-name" };
1219
- const _hoisted_9 = { class: "vv-input-file__item-info" };
1220
- const _hoisted_10 = ["onClick"];
1218
+ const _hoisted_8 = ["onClick"];
1219
+ const _hoisted_9 = ["onClick"];
1220
+ const _hoisted_10 = { class: "vv-input-file__item-name cursor-pointer" };
1221
+ const _hoisted_11 = { class: "vv-input-file__item-info" };
1222
+ const _hoisted_12 = ["onClick"];
1221
1223
  const __default__ = {
1222
1224
  name: "VvInputFile"
1223
1225
  };
@@ -1340,14 +1342,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1340
1342
  toReturn.splice(index, 1);
1341
1343
  localModelValue.value = toReturn;
1342
1344
  };
1345
+ const currentFileIndex = ref(0);
1343
1346
  const previewSrc = computed(() => {
1344
1347
  if (files.value.length === 0) {
1345
1348
  return;
1346
1349
  }
1347
- if (files.value[0] instanceof File) {
1348
- return URL.createObjectURL(files.value[0]);
1350
+ if (files.value[currentFileIndex.value] instanceof File) {
1351
+ return URL.createObjectURL(
1352
+ files.value[currentFileIndex.value]
1353
+ );
1349
1354
  }
1350
- return files.value[0].url;
1355
+ return files.value[currentFileIndex.value].url;
1351
1356
  });
1352
1357
  onBeforeUnmount(() => {
1353
1358
  if (previewSrc.value) {
@@ -1360,6 +1365,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1360
1365
  }
1361
1366
  return Math.floor(size / 1024);
1362
1367
  };
1368
+ const onClickDownloadFile = (file) => {
1369
+ const link = document.createElement("a");
1370
+ if (file instanceof File) {
1371
+ link.href = URL.createObjectURL(file);
1372
+ } else if (file.url) {
1373
+ link.href = file.url;
1374
+ }
1375
+ link.setAttribute("download", file.name);
1376
+ document.body.appendChild(link);
1377
+ link.click();
1378
+ };
1363
1379
  return (_ctx, _cache) => {
1364
1380
  return openBlock(), createElementBlock(
1365
1381
  "div",
@@ -1389,14 +1405,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1389
1405
  class: normalizeClass([{
1390
1406
  "absolute top-8 right-8": previewSrc.value
1391
1407
  }, "z-1"]),
1392
- icon: !previewSrc.value ? "image" : "edit",
1408
+ icon: !previewSrc.value ? "image" : isMultiple.value ? "add" : "edit",
1393
1409
  onClick: withModifiers(onClick, ["stop"])
1394
1410
  }, null, 8, ["label", "class", "icon", "onClick"]),
1395
1411
  createElementVNode("picture", _hoisted_3, [
1396
1412
  previewSrc.value ? (openBlock(), createElementBlock("img", {
1397
1413
  key: 0,
1398
1414
  src: previewSrc.value,
1399
- alt: files.value[0].name
1415
+ alt: files.value[currentFileIndex.value].name
1400
1416
  }, null, 8, _hoisted_4)) : createCommentVNode("v-if", true)
1401
1417
  ])
1402
1418
  ])
@@ -1432,22 +1448,28 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1432
1448
  renderList(files.value, (file, index) => {
1433
1449
  return openBlock(), createElementBlock("li", {
1434
1450
  key: index,
1435
- class: "vv-input-file__item"
1451
+ class: "vv-input-file__item",
1452
+ onClick: withModifiers(($event) => currentFileIndex.value = index, ["stop"])
1436
1453
  }, [
1437
- createVNode(_sfc_main$3, {
1438
- class: "vv-input-file__item-icon",
1439
- name: "akar-icons:file"
1440
- }),
1454
+ createElementVNode("button", {
1455
+ type: "button",
1456
+ class: "vv-input-file__item-icon cursor-pointer",
1457
+ title: "Download",
1458
+ "aria-label": "download-file",
1459
+ onClick: withModifiers(($event) => onClickDownloadFile(file), ["stop"])
1460
+ }, [
1461
+ createVNode(_sfc_main$3, { name: "download" })
1462
+ ], 8, _hoisted_9),
1441
1463
  createElementVNode(
1442
1464
  "div",
1443
- _hoisted_8,
1465
+ _hoisted_10,
1444
1466
  toDisplayString(file.name),
1445
1467
  1
1446
1468
  /* TEXT */
1447
1469
  ),
1448
1470
  createElementVNode(
1449
1471
  "small",
1450
- _hoisted_9,
1472
+ _hoisted_11,
1451
1473
  toDisplayString(sizeInKiB(file.size)) + " KB ",
1452
1474
  1
1453
1475
  /* TEXT */
@@ -1458,8 +1480,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1458
1480
  title: "Remove",
1459
1481
  "aria-label": "remove-file",
1460
1482
  onClick: withModifiers(($event) => onClickRemoveFile(index), ["stop"])
1461
- }, null, 8, _hoisted_10)
1462
- ]);
1483
+ }, null, 8, _hoisted_12)
1484
+ ], 8, _hoisted_8);
1463
1485
  }),
1464
1486
  128
1465
1487
  /* KEYED_FRAGMENT */
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@vueuse/core"),require("@iconify/vue"),require("uid")):"function"==typeof define&&define.amd?define(["vue","@vueuse/core","@iconify/vue","uid"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvInputFile=t(e.vue,e.core,e.vue$1,e.uid)}(this,(function(e,t,l,o){"use strict";var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),n=(e=>(e.before="before",e.after="after",e))(n||{}),i=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(i||{}),r=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(r||{}),u=(e=>(e._blank="_blank",e._self="_self",e._parent="_parent",e._top="_top",e))(u||{});const s=Symbol.for("volver"),d=Symbol.for("buttonGroup"),v=Symbol.for("dropdownTrigger"),c=Symbol.for("dropdownAction");function f(){return e.inject(s)}function p(t,l,o){return e.computed((()=>{const a={[t]:!0},n="string"==typeof(null==l?void 0:l.value)?l.value.split(" "):null==l?void 0:l.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(a[`${t}--${e}`]=!0)})),o&&Object.keys(o.value).forEach((l=>{a[`${t}--${l}`]=e.unref(o.value[l])})),a}))}const m=e.defineComponent({name:"VvIcon",props: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:{}},{prefix:"normal"}),setup(t){const o=t,a=e.computed((()=>"string"==typeof o.rotate?parseFloat(o.rotate):o.rotate)),n=e.ref(!0),i=f(),{modifiers:r}=e.toRefs(o),u=p("vv-icon",r),s=e.computed((()=>o.provider||(null==i?void 0:i.iconsProvider))),d=e.computed((()=>{const e=o.name??"",t=`@${s.value}:${o.prefix}:${e}`;if(l.iconExists(t))return t;const a=null==i?void 0:i.iconsCollections.find((t=>{const o=`@${s.value}:${t.prefix}:${e}`;return l.iconExists(o)}));return a?`@${s.value}:${a.prefix}:${e}`:e}));function v(e){const t=function(e){let t;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),a=(null==t?void 0:t.innerHTML.trim())||"";t&&a&&l.addIcon(`@${s.value}:${o.prefix}:${o.name}`,{body:a,height:t.viewBox.baseVal.height,width:t.viewBox.baseVal.width})}return i&&o.src&&!l.iconExists(`@${s.value}:${o.prefix}:${o.name}`)&&(n.value=!1,i.fetchIcon(o.src).then((e=>{e&&(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),(t,o)=>e.unref(n)?(e.openBlock(),e.createBlock(e.unref(l.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:t.inline,width:t.width,height:t.height,horizontalFlip:t.horizontalFlip,verticalFlip:t.verticalFlip,flip:t.flip,rotate:e.unref(a),color:t.color,onLoad:t.onLoad,icon:e.unref(d)}),null,16,["class"])):e.createCommentVNode("v-if",!0)}}),g={to:{type:[String,Object]},href:String,target:{type:String,default:void 0,validator:e=>Object.values(u).includes(e)},rel:{type:String,default:"noopener noreferrer"}},b={valid:{type:Boolean,default:!1},validLabel:{type:[String,Array],default:void 0}},h={invalid:{type:Boolean,default:!1},invalidLabel:{type:[String,Array],default:void 0}},y={loading:{type:Boolean,default:!1},loadingLabel:{type:String,default:"Loading..."}},S={disabled:{type:Boolean,default:!1}},k={active:{type:Boolean,default:!1}},B={current:{type:Boolean,default:!1}},L={pressed:{type:Boolean,default:!1}},V={label:{type:[String,Number],default:void 0}},$={modifiers:{type:[String,Array],default:void 0}},_={hintLabel:{type:String,default:""}},w={icon:{type:[String,Object],default:void 0},iconPosition:{type:String,default:n.before,validation:e=>Object.values(n).includes(e)}},A={unselectable:{type:Boolean,default:!0}},O={id:[String,Number]};a.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const x={...S,...V,...L,...k,...B,...g,type:{type:String,default:i.button,validator:e=>Object.values(i).includes(e)},ariaLabel:{type:String,default:void 0},defaultTag:{type:String,default:r.button}},C=x;const N=e.defineComponent({name:"VvAction",props:C,emits:["click","mouseover","mouseleave"],setup(t,{expose:l,emit:o}){const a=t,n=f(),i=e.ref(null);l({$el:i});const{reference:u,bus:s,aria:d,expanded:p}=e.inject(v,{});e.watch((()=>i.value),(e=>{u&&(u.value=e)}));const m=e.computed((()=>a.pressed||(null==p?void 0:p.value))),{role:g}=e.inject(c,{}),b=e.computed((()=>{switch(!0){case a.disabled:return r.button;case void 0!==a.to:return(null==n?void 0:n.nuxt)?r.nuxtLink:r.routerLink;case void 0!==a.href:return r.a;default:return a.defaultTag}})),h=e.computed((()=>{const e={...null==d?void 0:d.value,ariaPressed:!!m.value||void 0,ariaLabel:a.ariaLabel,role:null==g?void 0:g.value};switch(b.value){case r.a:return{...e,href:a.href,target:a.target,rel:a.rel};case r.routerLink:case r.nuxtLink:return{...e,to:a.to,target:a.target};case r.button:return{...e,type:a.type,disabled:a.disabled};default:return e}})),y=e=>{a.disabled?e.preventDefault():(null==s||s.emit("click",e),o("click",e))},S=e=>{null==s||s.emit("mouseover",e),o("mouseover",e)},k=e=>{null==s||s.emit("mouseleave",e),o("mouseleave",e)};return(t,l)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(b)),e.mergeProps(e.unref(h),{ref_key:"element",ref:i,class:{active:t.active,pressed:e.unref(m),disabled:t.disabled,current:t.current},onClickPassive:y,onMouseoverPassive:S,onMouseleavePassive:k}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]))])),_:3},16,["class"]))}});function j(e,t,l){return l?I(e,l)===I(t,l):E(e,t)}function E(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){const l=Array.isArray(e),o=Array.isArray(t);let a,n,i;if(l&&o){if(n=e.length,n!=t.length)return!1;for(a=n;0!=a--;)if(!E(e[a],t[a]))return!1;return!0}if(l!=o)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 s=e instanceof RegExp,d=t instanceof RegExp;if(s!=d)return!1;if(s&&d)return e.toString()==t.toString();const v=Object.keys(e);if(n=v.length,n!==Object.keys(t).length)return!1;for(a=n;0!=a--;)if(!Object.prototype.hasOwnProperty.call(t,v[a]))return!1;for(a=n;0!=a--;)if(i=v[a],!E(e[i],t[i]))return!1;return!0}return e!=e&&t!=t}function I(e,t){if(e&&Object.keys(e).length&&t){if(-1===t.indexOf("."))return e[t];{const l=t.split(".");let o=e;for(let t=0,a=l.length;t<a;++t){if(null==e)return null;o=o[l[t]]}return o}}return null}function P(e,t){if(null!=e&&t&&t.length)for(const l of t)if(j(e,l))return!0;return!1}function R(t){const l=e.inject(t,void 0),o=e.computed((()=>{return t=l,!(null==(o=e.unref(t))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length);var t,o}));return{group:l,isInGroup:o,getGroupOrLocalRef:function(t,o,a){if(null==l?void 0:l.value){const o=e.unref(l.value)[t];return e.computed({get:()=>null==o?void 0:o.value,set(e){o.value=e}})}const n=e.toRef(o,t);return e.computed({get:()=>n.value,set(e){a&&a(`update:${t}`,e)}})}}}const D={...x,...O,...$,...A,...y,...w,iconPosition:{type:String,default:a.left,validator:e=>Object.values(a).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 F=t=>e.computed((()=>String((null==t?void 0:t.value)||o.uid())));const M={key:1,class:"vv-button__label"},T={key:1,class:"vv-button__label"},z=e.defineComponent({name:"VvButton",props:D,emits:["update:modelValue"],setup(t,{expose:l,emit:o}){const i=t,r=e.useAttrs(),u=e.useSlots(),{id:s,modifiers:v,iconPosition:c,icon:f,label:g,modelValue:b,disabled:h,toggle:y,unselectable:S}=function(t,l){const{group:o,isInGroup:a,getGroupOrLocalRef:n}=R(d),{id:i,iconPosition:r,icon:u,label:s,pressed:v}=e.toRefs(t),c=n("modelValue",t,l),f=n("toggle",t),p=n("unselectable",t),m=e.computed((()=>(null==o?void 0:o.value.multiple.value)??!1)),g=e.computed((()=>{let e=t.modifiers,l=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)))),l&&(Array.isArray(l)||(l=l.split(" ")),l.forEach((e=>a.add(e)))),Array.from(a)})),b=e.computed((()=>{var e;return Boolean(t.disabled||(null==(e=null==o?void 0:o.value)?void 0:e.disabled.value))}));return{group:o,isInGroup:a,modelValue:c,toggle:f,unselectable:p,multiple:m,modifiers:g,disabled:b,id:i,pressed:v,iconPosition:r,icon:u,label:s}}(i,o),k=F(s),B=e.computed((()=>(null==r?void 0:r.name)||k.value)),L=e.ref(null);l({$el:e.computed((()=>{var e;return null==(e=L.value)?void 0:e.$el}))});const V=e.computed((()=>y.value?Array.isArray(b.value)?P(B.value,b.value):j(B.value,b.value):i.pressed)),$=p("vv-button",v,e.computed((()=>({reverse:[a.right,a.bottom].includes(c.value),column:[a.top,a.bottom].includes(c.value),"icon-only":Boolean((null==f?void 0:f.value)&&!(null==g?void 0:g.value)&&!u.default)})))),{hasIcon:_}=function(t,l){const o=e.computed((()=>"string"==typeof(null==t?void 0:t.value)?{name:null==t?void 0:t.value}:null==t?void 0:t.value)),i=e.computed((()=>(null==l?void 0:l.value)===n.before?o.value:void 0)),r=e.computed((()=>(null==l?void 0:l.value)===n.after?o.value:void 0)),u=e.computed((()=>(null==l?void 0:l.value)===a.left?o.value:void 0)),s=e.computed((()=>(null==l?void 0:l.value)===a.right?o.value:void 0)),d=e.computed((()=>(null==l?void 0:l.value)===a.top?o.value:void 0)),v=e.computed((()=>(null==l?void 0:l.value)===a.bottom?o.value:void 0));return{hasIcon:o,hasIconLeft:u,hasIconRight:s,hasIconTop:d,hasIconBottom:v,hasIconBefore:i,hasIconAfter:r}}(f),w=e.computed((()=>void 0!==i.value?i.value:B.value)),A=()=>{if(y.value){if(Array.isArray(b.value))return P(w.value,b.value)?void(S.value&&(b.value=b.value.filter((e=>e!==w.value)))):void b.value.push(w.value);if(w.value===b.value&&S.value)return void(b.value=i.uncheckedValue);b.value=w.value}};return(t,l)=>(e.openBlock(),e.createBlock(N,e.mergeProps({disabled:e.unref(h),pressed:e.unref(V),active:t.active,type:t.type,to:t.to,href:t.href,target:t.target,rel:t.rel,ariaLabel:t.ariaLabel},{id:e.unref(k),ref_key:"element",ref:L,class:e.unref($),onClick:A}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[t.loading?e.renderSlot(t.$slots,"loading",{key:0},(()=>[t.loadingIcon?(e.openBlock(),e.createBlock(m,{key:0,class:"vv-button__loading-icon",name:t.loadingIcon},null,8,["name"])):e.createCommentVNode("v-if",!0),t.loadingLabel?(e.openBlock(),e.createElementBlock("span",M,e.toDisplayString(t.loadingLabel),1)):e.createCommentVNode("v-if",!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.renderSlot(t.$slots,"before"),e.unref(_)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:0},e.unref(_),{class:"vv-button__icon"}),null,16)):e.createCommentVNode("v-if",!0),e.unref(g)?(e.openBlock(),e.createElementBlock("span",T,[e.renderSlot(t.$slots,"label",{},(()=>[e.createTextVNode(e.toDisplayString(e.unref(g)),1)]))])):e.createCommentVNode("v-if",!0),e.renderSlot(t.$slots,"after")],64))]))])),_:3},16,["id","class"]))}});function q(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const H={...$,...b,...h,..._,...V,...y,name:{type:String},id:{type:String},modelValue:{type:Object,required:!0},max:[Number,String],labelButton:{type:String,default:"Image"},loading:Boolean,accept:String,placeholder:String,multiple:Boolean,iconLeft:String,iconRight:String};const G=["for"],U=["onDragenter","onDragleave","onDrop","onClick"],J={class:"vv-input-file__preview"},K=["src","alt"],Q={class:"vv-input-file__wrapper"},W=["id","placeholder","aria-describedby","aria-invalid","aria-errormessage","multiple","accept","name"],X={class:"vv-input-file__list"},Y={class:"vv-input-file__item-name"},Z={class:"vv-input-file__item-info"},ee=["onClick"];return e.defineComponent({name:"VvInputFile",props:H,emits:["update:modelValue"],setup(l,{emit:o}){const a=l,n=e.useSlots(),i=function(t,l,o){const a=f(),n=e.computed((()=>{var e;if(a&&(null==(e=a.defaults.value)?void 0:e[t]))return a.defaults.value[t]}));return e.computed((()=>{if(void 0===n.value)return o;const e=n.value,t=l,a=o;return Object.keys(t).reduce(((l,o)=>{const n=a[o];if(l[o]=n,o in e){if(Array.isArray(t[o])){const a=t[o];a.length&&a[0]===n&&(l[o]=e[o])}if("function"==typeof t[o]&&(0,t[o])()===n&&(l[o]=e[o]),"object"==typeof t[o]){let a=t[o].default;"function"==typeof a&&(a=a()),"object"==typeof a?JSON.stringify(a)===JSON.stringify(n)&&(l[o]=e[o]):a===n&&(l[o]=e[o])}}return l}),{})}))}("VvInputFile",H,a),{modifiers:r,id:u}=e.toRefs(a),s=F(u),d=e.computed((()=>`${s.value}-hint`)),v=p("vv-input-file",r,e.computed((()=>({dragging:V.value,loading:a.loading,valid:!0===a.valid,invalid:!0===a.invalid,"icon-before":!!a.iconLeft,"icon-after":!!a.iconRight})))),{HintSlot:c,hasHintLabelOrSlot:g,hasInvalidLabelOrSlot:b,hintSlotScope:h}=function(t,l){const o=e.computed((()=>e.isRef(t)?t.value:t)),a=e.computed((()=>q(o.value.invalidLabel))),n=e.computed((()=>q(o.value.validLabel))),i=e.computed((()=>o.value.loadingLabel)),r=e.computed((()=>o.value.hintLabel)),u=e.computed((()=>Boolean(o.value.loading&&(l.loading||i.value)))),s=e.computed((()=>!u.value&&Boolean(o.value.invalid&&(l.invalid||a.value)))),d=e.computed((()=>!u.value&&!s.value&&Boolean(o.value.valid&&(l.valid||n.value)))),v=e.computed((()=>!u.value&&!s.value&&!d.value&&Boolean(l.hint||r.value))),c=e.computed((()=>s.value||d.value||u.value||v.value)),f=e.computed((()=>({modelValue:o.value.modelValue,valid:o.value.valid,invalid:o.value.invalid,loading:o.value.loading}))),p=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:c,invalidLabel:a,validLabel:n,loadingLabel:i,hintLabel:r,hasInvalidLabelOrSlot:s,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:v}),render(){var t,l,o,a,n,i,r,u;if(this.isVisible){let s;return this.hasInvalidLabelOrSlot&&(s="alert"),this.hasValidLabelOrSlot&&(s="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:s},(null==(l=(t=this.$slots).loading)?void 0:l.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:s},(null==(a=(o=this.$slots).invalid)?void 0:a.call(o))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:s},(null==(i=(n=this.$slots).valid)?void 0:i.call(n))??this.validLabel):e.h(this.tag,{role:s},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:s,hasHintLabelOrSlot:v,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:u,hintSlotScope:f,HintSlot:p}}(i,n),y=t.useVModel(a,"modelValue",o),S=e.computed((()=>{var e;return y.value&&(Array.isArray(y.value)||(null==(e=y.value)?void 0:e.name))?Array.isArray(y.value)?y.value:[y.value]:[]})),k=e.computed((()=>"string"==typeof a.max?parseInt(a.max):a.max)),B=e.computed((()=>{var e;return null==(e=null==r?void 0:r.value)?void 0:e.includes("drop-area")})),L=e.computed((()=>!!a.multiple&&(!k.value||k.value-S.value.length>1))),V=e.ref(!1),$=e.ref(),_=()=>{V.value=!0},w=()=>{V.value=!1},A=e=>{var t,l;(null==(t=e.dataTransfer)?void 0:t.files)&&(V.value=!1,x(null==(l=e.dataTransfer)?void 0:l.files))},O=()=>{var e;(null==(e=$.value)?void 0:e.files)&&(x($.value.files),$.value.value="")},x=e=>{if(!a.multiple)return Array.isArray(y.value)?void(y.value=[...e]):void(y.value=e[0]);let t=[];t=!Array.isArray(y.value)&&y.value?[y.value]:y.value&&Array.isArray(y.value)?[...y.value]:t;for(const l of e){if(k.value&&t.length>=k.value)break;t.push(l)}y.value=t},C=()=>{$.value&&$.value.click()},N=e.computed((()=>{if(0!==S.value.length)return S.value[0]instanceof File?URL.createObjectURL(S.value[0]):S.value[0].url}));e.onBeforeUnmount((()=>{N.value&&URL.revokeObjectURL(N.value)}));const j=e=>{if(e)return Math.floor(e/1024)};return(t,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(v))},[t.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(s)},e.toDisplayString(t.label),9,G)):e.createCommentVNode("v-if",!0),B.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vv-input-file__drop-area",onDragenter:e.withModifiers(_,["prevent","stop"]),onDragleave:e.withModifiers(w,["prevent","stop"]),onDrop:e.withModifiers(A,["prevent","stop"]),onDragover:l[0]||(l[0]=e.withModifiers((()=>{}),["prevent","stop"])),onClick:e.withModifiers(C,["stop"])},[e.renderSlot(t.$slots,"drop-area",{},(()=>[e.createVNode(z,{modifiers:"action","aria-label":"upload",label:N.value?void 0:t.labelButton,class:e.normalizeClass([{"absolute top-8 right-8":N.value},"z-1"]),icon:N.value?"edit":"image",onClick:e.withModifiers(C,["stop"])},null,8,["label","class","icon","onClick"]),e.createElementVNode("picture",J,[N.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:N.value,alt:S.value[0].name},null,8,K)):e.createCommentVNode("v-if",!0)])]))],40,U)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",Q,[t.iconLeft?(e.openBlock(),e.createBlock(m,{key:0,name:t.iconLeft},null,8,["name"])):e.createCommentVNode("v-if",!0),e.createElementVNode("input",{id:e.unref(s),ref_key:"inputEl",ref:$,placeholder:t.placeholder,"aria-describedby":e.unref(g)?d.value:void 0,"aria-invalid":t.invalid,"aria-errormessage":e.unref(b)?d.value:void 0,multiple:L.value,accept:t.accept,type:"file",name:t.name,onChange:O},null,40,W),t.iconRight?(e.openBlock(),e.createBlock(m,{key:1,name:t.iconRight},null,8,["name"])):e.createCommentVNode("v-if",!0)]),e.createElementVNode("ul",X,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,((t,l)=>(e.openBlock(),e.createElementBlock("li",{key:l,class:"vv-input-file__item"},[e.createVNode(m,{class:"vv-input-file__item-icon",name:"akar-icons:file"}),e.createElementVNode("div",Y,e.toDisplayString(t.name),1),e.createElementVNode("small",Z,e.toDisplayString(j(t.size))+" KB ",1),e.createElementVNode("button",{type:"button",class:"vv-input-file__item-remove",title:"Remove","aria-label":"remove-file",onClick:e.withModifiers((e=>(e=>{if(!Array.isArray(y.value))return void(y.value=void 0);const t=[...y.value];t.splice(e,1),y.value=t})(l)),["stop"])},null,8,ee)])))),128))]),e.createVNode(e.unref(c),{id:d.value,class:"vv-input-file__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(h))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(h))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(h))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(h))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@vueuse/core"),require("@iconify/vue"),require("uid")):"function"==typeof define&&define.amd?define(["vue","@vueuse/core","@iconify/vue","uid"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvInputFile=t(e.vue,e.core,e.vue$1,e.uid)}(this,(function(e,t,l,o){"use strict";var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),n=(e=>(e.before="before",e.after="after",e))(n||{}),i=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(i||{}),r=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(r||{}),u=(e=>(e._blank="_blank",e._self="_self",e._parent="_parent",e._top="_top",e))(u||{});const d=Symbol.for("volver"),s=Symbol.for("buttonGroup"),c=Symbol.for("dropdownTrigger"),v=Symbol.for("dropdownAction");function f(){return e.inject(d)}function p(t,l,o){return e.computed((()=>{const a={[t]:!0},n="string"==typeof(null==l?void 0:l.value)?l.value.split(" "):null==l?void 0:l.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(a[`${t}--${e}`]=!0)})),o&&Object.keys(o.value).forEach((l=>{a[`${t}--${l}`]=e.unref(o.value[l])})),a}))}const m=e.defineComponent({name:"VvIcon",props: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:{}},{prefix:"normal"}),setup(t){const o=t,a=e.computed((()=>"string"==typeof o.rotate?parseFloat(o.rotate):o.rotate)),n=e.ref(!0),i=f(),{modifiers:r}=e.toRefs(o),u=p("vv-icon",r),d=e.computed((()=>o.provider||(null==i?void 0:i.iconsProvider))),s=e.computed((()=>{const e=o.name??"",t=`@${d.value}:${o.prefix}:${e}`;if(l.iconExists(t))return t;const a=null==i?void 0:i.iconsCollections.find((t=>{const o=`@${d.value}:${t.prefix}:${e}`;return l.iconExists(o)}));return a?`@${d.value}:${a.prefix}:${e}`:e}));function c(e){const t=function(e){let t;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),a=(null==t?void 0:t.innerHTML.trim())||"";t&&a&&l.addIcon(`@${d.value}:${o.prefix}:${o.name}`,{body:a,height:t.viewBox.baseVal.height,width:t.viewBox.baseVal.width})}return i&&o.src&&!l.iconExists(`@${d.value}:${o.prefix}:${o.name}`)&&(n.value=!1,i.fetchIcon(o.src).then((e=>{e&&(c(e),n.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),o.svg&&c(o.svg),(t,o)=>e.unref(n)?(e.openBlock(),e.createBlock(e.unref(l.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:t.inline,width:t.width,height:t.height,horizontalFlip:t.horizontalFlip,verticalFlip:t.verticalFlip,flip:t.flip,rotate:e.unref(a),color:t.color,onLoad:t.onLoad,icon:e.unref(s)}),null,16,["class"])):e.createCommentVNode("v-if",!0)}}),g={to:{type:[String,Object]},href:String,target:{type:String,default:void 0,validator:e=>Object.values(u).includes(e)},rel:{type:String,default:"noopener noreferrer"}},b={valid:{type:Boolean,default:!1},validLabel:{type:[String,Array],default:void 0}},h={invalid:{type:Boolean,default:!1},invalidLabel:{type:[String,Array],default:void 0}},y={loading:{type:Boolean,default:!1},loadingLabel:{type:String,default:"Loading..."}},k={disabled:{type:Boolean,default:!1}},S={active:{type:Boolean,default:!1}},B={current:{type:Boolean,default:!1}},L={pressed:{type:Boolean,default:!1}},V={label:{type:[String,Number],default:void 0}},$={modifiers:{type:[String,Array],default:void 0}},w={hintLabel:{type:String,default:""}},_={icon:{type:[String,Object],default:void 0},iconPosition:{type:String,default:n.before,validation:e=>Object.values(n).includes(e)}},A={unselectable:{type:Boolean,default:!0}},O={id:[String,Number]};a.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const C={...k,...V,...L,...S,...B,...g,type:{type:String,default:i.button,validator:e=>Object.values(i).includes(e)},ariaLabel:{type:String,default:void 0},defaultTag:{type:String,default:r.button}},x=C;const N=e.defineComponent({name:"VvAction",props:x,emits:["click","mouseover","mouseleave"],setup(t,{expose:l,emit:o}){const a=t,n=f(),i=e.ref(null);l({$el:i});const{reference:u,bus:d,aria:s,expanded:p}=e.inject(c,{});e.watch((()=>i.value),(e=>{u&&(u.value=e)}));const m=e.computed((()=>a.pressed||(null==p?void 0:p.value))),{role:g}=e.inject(v,{}),b=e.computed((()=>{switch(!0){case a.disabled:return r.button;case void 0!==a.to:return(null==n?void 0:n.nuxt)?r.nuxtLink:r.routerLink;case void 0!==a.href:return r.a;default:return a.defaultTag}})),h=e.computed((()=>{const e={...null==s?void 0:s.value,ariaPressed:!!m.value||void 0,ariaLabel:a.ariaLabel,role:null==g?void 0:g.value};switch(b.value){case r.a:return{...e,href:a.href,target:a.target,rel:a.rel};case r.routerLink:case r.nuxtLink:return{...e,to:a.to,target:a.target};case r.button:return{...e,type:a.type,disabled:a.disabled};default:return e}})),y=e=>{a.disabled?e.preventDefault():(null==d||d.emit("click",e),o("click",e))},k=e=>{null==d||d.emit("mouseover",e),o("mouseover",e)},S=e=>{null==d||d.emit("mouseleave",e),o("mouseleave",e)};return(t,l)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(b)),e.mergeProps(e.unref(h),{ref_key:"element",ref:i,class:{active:t.active,pressed:e.unref(m),disabled:t.disabled,current:t.current},onClickPassive:y,onMouseoverPassive:k,onMouseleavePassive:S}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]))])),_:3},16,["class"]))}});function E(e,t,l){return l?I(e,l)===I(t,l):j(e,t)}function j(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){const l=Array.isArray(e),o=Array.isArray(t);let a,n,i;if(l&&o){if(n=e.length,n!=t.length)return!1;for(a=n;0!=a--;)if(!j(e[a],t[a]))return!1;return!0}if(l!=o)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 c=Object.keys(e);if(n=c.length,n!==Object.keys(t).length)return!1;for(a=n;0!=a--;)if(!Object.prototype.hasOwnProperty.call(t,c[a]))return!1;for(a=n;0!=a--;)if(i=c[a],!j(e[i],t[i]))return!1;return!0}return e!=e&&t!=t}function I(e,t){if(e&&Object.keys(e).length&&t){if(-1===t.indexOf("."))return e[t];{const l=t.split(".");let o=e;for(let t=0,a=l.length;t<a;++t){if(null==e)return null;o=o[l[t]]}return o}}return null}function P(e,t){if(null!=e&&t&&t.length)for(const l of t)if(E(e,l))return!0;return!1}function R(t){const l=e.inject(t,void 0),o=e.computed((()=>{return t=l,!(null==(o=e.unref(t))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length);var t,o}));return{group:l,isInGroup:o,getGroupOrLocalRef:function(t,o,a){if(null==l?void 0:l.value){const o=e.unref(l.value)[t];return e.computed({get:()=>null==o?void 0:o.value,set(e){o.value=e}})}const n=e.toRef(o,t);return e.computed({get:()=>n.value,set(e){a&&a(`update:${t}`,e)}})}}}const D={...C,...O,...$,...A,...y,..._,iconPosition:{type:String,default:a.left,validator:e=>Object.values(a).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 M=t=>e.computed((()=>String((null==t?void 0:t.value)||o.uid())));const F={key:1,class:"vv-button__label"},T={key:1,class:"vv-button__label"},z=e.defineComponent({name:"VvButton",props:D,emits:["update:modelValue"],setup(t,{expose:l,emit:o}){const i=t,r=e.useAttrs(),u=e.useSlots(),{id:d,modifiers:c,iconPosition:v,icon:f,label:g,modelValue:b,disabled:h,toggle:y,unselectable:k}=function(t,l){const{group:o,isInGroup:a,getGroupOrLocalRef:n}=R(s),{id:i,iconPosition:r,icon:u,label:d,pressed:c}=e.toRefs(t),v=n("modelValue",t,l),f=n("toggle",t),p=n("unselectable",t),m=e.computed((()=>(null==o?void 0:o.value.multiple.value)??!1)),g=e.computed((()=>{let e=t.modifiers,l=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)))),l&&(Array.isArray(l)||(l=l.split(" ")),l.forEach((e=>a.add(e)))),Array.from(a)})),b=e.computed((()=>{var e;return Boolean(t.disabled||(null==(e=null==o?void 0:o.value)?void 0:e.disabled.value))}));return{group:o,isInGroup:a,modelValue:v,toggle:f,unselectable:p,multiple:m,modifiers:g,disabled:b,id:i,pressed:c,iconPosition:r,icon:u,label:d}}(i,o),S=M(d),B=e.computed((()=>(null==r?void 0:r.name)||S.value)),L=e.ref(null);l({$el:e.computed((()=>{var e;return null==(e=L.value)?void 0:e.$el}))});const V=e.computed((()=>y.value?Array.isArray(b.value)?P(B.value,b.value):E(B.value,b.value):i.pressed)),$=p("vv-button",c,e.computed((()=>({reverse:[a.right,a.bottom].includes(v.value),column:[a.top,a.bottom].includes(v.value),"icon-only":Boolean((null==f?void 0:f.value)&&!(null==g?void 0:g.value)&&!u.default)})))),{hasIcon:w}=function(t,l){const o=e.computed((()=>"string"==typeof(null==t?void 0:t.value)?{name:null==t?void 0:t.value}:null==t?void 0:t.value)),i=e.computed((()=>(null==l?void 0:l.value)===n.before?o.value:void 0)),r=e.computed((()=>(null==l?void 0:l.value)===n.after?o.value:void 0)),u=e.computed((()=>(null==l?void 0:l.value)===a.left?o.value:void 0)),d=e.computed((()=>(null==l?void 0:l.value)===a.right?o.value:void 0)),s=e.computed((()=>(null==l?void 0:l.value)===a.top?o.value:void 0)),c=e.computed((()=>(null==l?void 0:l.value)===a.bottom?o.value:void 0));return{hasIcon:o,hasIconLeft:u,hasIconRight:d,hasIconTop:s,hasIconBottom:c,hasIconBefore:i,hasIconAfter:r}}(f),_=e.computed((()=>void 0!==i.value?i.value:B.value)),A=()=>{if(y.value){if(Array.isArray(b.value))return P(_.value,b.value)?void(k.value&&(b.value=b.value.filter((e=>e!==_.value)))):void b.value.push(_.value);if(_.value===b.value&&k.value)return void(b.value=i.uncheckedValue);b.value=_.value}};return(t,l)=>(e.openBlock(),e.createBlock(N,e.mergeProps({disabled:e.unref(h),pressed:e.unref(V),active:t.active,type:t.type,to:t.to,href:t.href,target:t.target,rel:t.rel,ariaLabel:t.ariaLabel},{id:e.unref(S),ref_key:"element",ref:L,class:e.unref($),onClick:A}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[t.loading?e.renderSlot(t.$slots,"loading",{key:0},(()=>[t.loadingIcon?(e.openBlock(),e.createBlock(m,{key:0,class:"vv-button__loading-icon",name:t.loadingIcon},null,8,["name"])):e.createCommentVNode("v-if",!0),t.loadingLabel?(e.openBlock(),e.createElementBlock("span",F,e.toDisplayString(t.loadingLabel),1)):e.createCommentVNode("v-if",!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.renderSlot(t.$slots,"before"),e.unref(w)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:0},e.unref(w),{class:"vv-button__icon"}),null,16)):e.createCommentVNode("v-if",!0),e.unref(g)?(e.openBlock(),e.createElementBlock("span",T,[e.renderSlot(t.$slots,"label",{},(()=>[e.createTextVNode(e.toDisplayString(e.unref(g)),1)]))])):e.createCommentVNode("v-if",!0),e.renderSlot(t.$slots,"after")],64))]))])),_:3},16,["id","class"]))}});function q(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const H={...$,...b,...h,...w,...V,...y,name:{type:String},id:{type:String},modelValue:{type:Object,required:!0},max:[Number,String],labelButton:{type:String,default:"Image"},loading:Boolean,accept:String,placeholder:String,multiple:Boolean,iconLeft:String,iconRight:String};const U=["for"],G=["onDragenter","onDragleave","onDrop","onClick"],J={class:"vv-input-file__preview"},K=["src","alt"],Q={class:"vv-input-file__wrapper"},W=["id","placeholder","aria-describedby","aria-invalid","aria-errormessage","multiple","accept","name"],X={class:"vv-input-file__list"},Y=["onClick"],Z=["onClick"],ee={class:"vv-input-file__item-name cursor-pointer"},te={class:"vv-input-file__item-info"},le=["onClick"];return e.defineComponent({name:"VvInputFile",props:H,emits:["update:modelValue"],setup(l,{emit:o}){const a=l,n=e.useSlots(),i=function(t,l,o){const a=f(),n=e.computed((()=>{var e;if(a&&(null==(e=a.defaults.value)?void 0:e[t]))return a.defaults.value[t]}));return e.computed((()=>{if(void 0===n.value)return o;const e=n.value,t=l,a=o;return Object.keys(t).reduce(((l,o)=>{const n=a[o];if(l[o]=n,o in e){if(Array.isArray(t[o])){const a=t[o];a.length&&a[0]===n&&(l[o]=e[o])}if("function"==typeof t[o]&&(0,t[o])()===n&&(l[o]=e[o]),"object"==typeof t[o]){let a=t[o].default;"function"==typeof a&&(a=a()),"object"==typeof a?JSON.stringify(a)===JSON.stringify(n)&&(l[o]=e[o]):a===n&&(l[o]=e[o])}}return l}),{})}))}("VvInputFile",H,a),{modifiers:r,id:u}=e.toRefs(a),d=M(u),s=e.computed((()=>`${d.value}-hint`)),c=p("vv-input-file",r,e.computed((()=>({dragging:V.value,loading:a.loading,valid:!0===a.valid,invalid:!0===a.invalid,"icon-before":!!a.iconLeft,"icon-after":!!a.iconRight})))),{HintSlot:v,hasHintLabelOrSlot:g,hasInvalidLabelOrSlot:b,hintSlotScope:h}=function(t,l){const o=e.computed((()=>e.isRef(t)?t.value:t)),a=e.computed((()=>q(o.value.invalidLabel))),n=e.computed((()=>q(o.value.validLabel))),i=e.computed((()=>o.value.loadingLabel)),r=e.computed((()=>o.value.hintLabel)),u=e.computed((()=>Boolean(o.value.loading&&(l.loading||i.value)))),d=e.computed((()=>!u.value&&Boolean(o.value.invalid&&(l.invalid||a.value)))),s=e.computed((()=>!u.value&&!d.value&&Boolean(o.value.valid&&(l.valid||n.value)))),c=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(l.hint||r.value))),v=e.computed((()=>d.value||s.value||u.value||c.value)),f=e.computed((()=>({modelValue:o.value.modelValue,valid:o.value.valid,invalid:o.value.invalid,loading:o.value.loading}))),p=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:v,invalidLabel:a,validLabel:n,loadingLabel:i,hintLabel:r,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:c}),render(){var t,l,o,a,n,i,r,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(l=(t=this.$slots).loading)?void 0:l.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:d},(null==(a=(o=this.$slots).invalid)?void 0:a.call(o))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(i=(n=this.$slots).valid)?void 0:i.call(n))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:c,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hintSlotScope:f,HintSlot:p}}(i,n),y=t.useVModel(a,"modelValue",o),k=e.computed((()=>{var e;return y.value&&(Array.isArray(y.value)||(null==(e=y.value)?void 0:e.name))?Array.isArray(y.value)?y.value:[y.value]:[]})),S=e.computed((()=>"string"==typeof a.max?parseInt(a.max):a.max)),B=e.computed((()=>{var e;return null==(e=null==r?void 0:r.value)?void 0:e.includes("drop-area")})),L=e.computed((()=>!!a.multiple&&(!S.value||S.value-k.value.length>1))),V=e.ref(!1),$=e.ref(),w=()=>{V.value=!0},_=()=>{V.value=!1},A=e=>{var t,l;(null==(t=e.dataTransfer)?void 0:t.files)&&(V.value=!1,C(null==(l=e.dataTransfer)?void 0:l.files))},O=()=>{var e;(null==(e=$.value)?void 0:e.files)&&(C($.value.files),$.value.value="")},C=e=>{if(!a.multiple)return Array.isArray(y.value)?void(y.value=[...e]):void(y.value=e[0]);let t=[];t=!Array.isArray(y.value)&&y.value?[y.value]:y.value&&Array.isArray(y.value)?[...y.value]:t;for(const l of e){if(S.value&&t.length>=S.value)break;t.push(l)}y.value=t},x=()=>{$.value&&$.value.click()},N=e.ref(0),E=e.computed((()=>{if(0!==k.value.length)return k.value[N.value]instanceof File?URL.createObjectURL(k.value[N.value]):k.value[N.value].url}));e.onBeforeUnmount((()=>{E.value&&URL.revokeObjectURL(E.value)}));const j=e=>{if(e)return Math.floor(e/1024)};return(t,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(c))},[t.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(d)},e.toDisplayString(t.label),9,U)):e.createCommentVNode("v-if",!0),B.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vv-input-file__drop-area",onDragenter:e.withModifiers(w,["prevent","stop"]),onDragleave:e.withModifiers(_,["prevent","stop"]),onDrop:e.withModifiers(A,["prevent","stop"]),onDragover:l[0]||(l[0]=e.withModifiers((()=>{}),["prevent","stop"])),onClick:e.withModifiers(x,["stop"])},[e.renderSlot(t.$slots,"drop-area",{},(()=>[e.createVNode(z,{modifiers:"action","aria-label":"upload",label:E.value?void 0:t.labelButton,class:e.normalizeClass([{"absolute top-8 right-8":E.value},"z-1"]),icon:E.value?L.value?"add":"edit":"image",onClick:e.withModifiers(x,["stop"])},null,8,["label","class","icon","onClick"]),e.createElementVNode("picture",J,[E.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:E.value,alt:k.value[N.value].name},null,8,K)):e.createCommentVNode("v-if",!0)])]))],40,G)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",Q,[t.iconLeft?(e.openBlock(),e.createBlock(m,{key:0,name:t.iconLeft},null,8,["name"])):e.createCommentVNode("v-if",!0),e.createElementVNode("input",{id:e.unref(d),ref_key:"inputEl",ref:$,placeholder:t.placeholder,"aria-describedby":e.unref(g)?s.value:void 0,"aria-invalid":t.invalid,"aria-errormessage":e.unref(b)?s.value:void 0,multiple:L.value,accept:t.accept,type:"file",name:t.name,onChange:O},null,40,W),t.iconRight?(e.openBlock(),e.createBlock(m,{key:1,name:t.iconRight},null,8,["name"])):e.createCommentVNode("v-if",!0)]),e.createElementVNode("ul",X,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.value,((t,l)=>(e.openBlock(),e.createElementBlock("li",{key:l,class:"vv-input-file__item",onClick:e.withModifiers((e=>N.value=l),["stop"])},[e.createElementVNode("button",{type:"button",class:"vv-input-file__item-icon cursor-pointer",title:"Download","aria-label":"download-file",onClick:e.withModifiers((e=>(e=>{const t=document.createElement("a");e instanceof File?t.href=URL.createObjectURL(e):e.url&&(t.href=e.url),t.setAttribute("download",e.name),document.body.appendChild(t),t.click()})(t)),["stop"])},[e.createVNode(m,{name:"download"})],8,Z),e.createElementVNode("div",ee,e.toDisplayString(t.name),1),e.createElementVNode("small",te,e.toDisplayString(j(t.size))+" KB ",1),e.createElementVNode("button",{type:"button",class:"vv-input-file__item-remove",title:"Remove","aria-label":"remove-file",onClick:e.withModifiers((e=>(e=>{if(!Array.isArray(y.value))return void(y.value=void 0);const t=[...y.value];t.splice(e,1),y.value=t})(l)),["stop"])},null,8,le)],8,Y)))),128))]),e.createVNode(e.unref(v),{id:s.value,class:"vv-input-file__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(h))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(h))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(h))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(h))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
@@ -6946,9 +6946,11 @@ const _hoisted_4 = ["src", "alt"];
6946
6946
  const _hoisted_5 = { class: "vv-input-file__wrapper" };
6947
6947
  const _hoisted_6 = ["id", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "name"];
6948
6948
  const _hoisted_7 = { class: "vv-input-file__list" };
6949
- const _hoisted_8 = { class: "vv-input-file__item-name" };
6950
- const _hoisted_9 = { class: "vv-input-file__item-info" };
6951
- const _hoisted_10 = ["onClick"];
6949
+ const _hoisted_8 = ["onClick"];
6950
+ const _hoisted_9 = ["onClick"];
6951
+ const _hoisted_10 = { class: "vv-input-file__item-name cursor-pointer" };
6952
+ const _hoisted_11 = { class: "vv-input-file__item-info" };
6953
+ const _hoisted_12 = ["onClick"];
6952
6954
  const __default__ = {
6953
6955
  name: "VvInputFile"
6954
6956
  };
@@ -7071,14 +7073,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
7071
7073
  toReturn.splice(index, 1);
7072
7074
  localModelValue.value = toReturn;
7073
7075
  };
7076
+ const currentFileIndex = ref(0);
7074
7077
  const previewSrc = computed(() => {
7075
7078
  if (files.value.length === 0) {
7076
7079
  return;
7077
7080
  }
7078
- if (files.value[0] instanceof File) {
7079
- return URL.createObjectURL(files.value[0]);
7081
+ if (files.value[currentFileIndex.value] instanceof File) {
7082
+ return URL.createObjectURL(
7083
+ files.value[currentFileIndex.value]
7084
+ );
7080
7085
  }
7081
- return files.value[0].url;
7086
+ return files.value[currentFileIndex.value].url;
7082
7087
  });
7083
7088
  onBeforeUnmount(() => {
7084
7089
  if (previewSrc.value) {
@@ -7091,6 +7096,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
7091
7096
  }
7092
7097
  return Math.floor(size2 / 1024);
7093
7098
  };
7099
+ const onClickDownloadFile = (file) => {
7100
+ const link = document.createElement("a");
7101
+ if (file instanceof File) {
7102
+ link.href = URL.createObjectURL(file);
7103
+ } else if (file.url) {
7104
+ link.href = file.url;
7105
+ }
7106
+ link.setAttribute("download", file.name);
7107
+ document.body.appendChild(link);
7108
+ link.click();
7109
+ };
7094
7110
  return (_ctx, _cache) => {
7095
7111
  return openBlock(), createElementBlock(
7096
7112
  "div",
@@ -7120,14 +7136,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
7120
7136
  class: normalizeClass([{
7121
7137
  "absolute top-8 right-8": previewSrc.value
7122
7138
  }, "z-1"]),
7123
- icon: !previewSrc.value ? "image" : "edit",
7139
+ icon: !previewSrc.value ? "image" : isMultiple.value ? "add" : "edit",
7124
7140
  onClick: withModifiers(onClick, ["stop"])
7125
7141
  }, null, 8, ["label", "class", "icon", "onClick"]),
7126
7142
  createElementVNode("picture", _hoisted_3, [
7127
7143
  previewSrc.value ? (openBlock(), createElementBlock("img", {
7128
7144
  key: 0,
7129
7145
  src: previewSrc.value,
7130
- alt: files.value[0].name
7146
+ alt: files.value[currentFileIndex.value].name
7131
7147
  }, null, 8, _hoisted_4)) : createCommentVNode("v-if", true)
7132
7148
  ])
7133
7149
  ])
@@ -7163,22 +7179,28 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
7163
7179
  renderList(files.value, (file, index) => {
7164
7180
  return openBlock(), createElementBlock("li", {
7165
7181
  key: index,
7166
- class: "vv-input-file__item"
7182
+ class: "vv-input-file__item",
7183
+ onClick: withModifiers(($event) => currentFileIndex.value = index, ["stop"])
7167
7184
  }, [
7168
- createVNode(_sfc_main$u, {
7169
- class: "vv-input-file__item-icon",
7170
- name: "akar-icons:file"
7171
- }),
7185
+ createElementVNode("button", {
7186
+ type: "button",
7187
+ class: "vv-input-file__item-icon cursor-pointer",
7188
+ title: "Download",
7189
+ "aria-label": "download-file",
7190
+ onClick: withModifiers(($event) => onClickDownloadFile(file), ["stop"])
7191
+ }, [
7192
+ createVNode(_sfc_main$u, { name: "download" })
7193
+ ], 8, _hoisted_9),
7172
7194
  createElementVNode(
7173
7195
  "div",
7174
- _hoisted_8,
7196
+ _hoisted_10,
7175
7197
  toDisplayString(file.name),
7176
7198
  1
7177
7199
  /* TEXT */
7178
7200
  ),
7179
7201
  createElementVNode(
7180
7202
  "small",
7181
- _hoisted_9,
7203
+ _hoisted_11,
7182
7204
  toDisplayString(sizeInKiB(file.size)) + " KB ",
7183
7205
  1
7184
7206
  /* TEXT */
@@ -7189,8 +7211,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
7189
7211
  title: "Remove",
7190
7212
  "aria-label": "remove-file",
7191
7213
  onClick: withModifiers(($event) => onClickRemoveFile(index), ["stop"])
7192
- }, null, 8, _hoisted_10)
7193
- ]);
7214
+ }, null, 8, _hoisted_12)
7215
+ ], 8, _hoisted_8);
7194
7216
  }),
7195
7217
  128
7196
7218
  /* KEYED_FRAGMENT */