@volverjs/ui-vue 0.0.10-beta.43 → 0.0.10-beta.44
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/VvInputFile/VvInputFile.es.js +11 -6
- package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
- package/dist/components/VvInputFile/VvInputFile.vue.d.ts +9 -0
- package/dist/components/VvInputFile/index.d.ts +4 -0
- package/dist/components/index.es.js +11 -6
- package/dist/components/index.umd.js +1 -1
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/stories/InputFile/InputFile.stories.d.ts +1 -0
- package/package.json +1 -1
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvInputFile/VvInputFile.vue +8 -3
- package/src/components/VvInputFile/index.ts +2 -0
- package/src/stories/InputFile/InputFile.stories.ts +8 -0
|
@@ -1200,6 +1200,7 @@ const VvInputFileProps = {
|
|
|
1200
1200
|
...LabelProps,
|
|
1201
1201
|
...LoadingProps,
|
|
1202
1202
|
...ReadonlyProps,
|
|
1203
|
+
...DisabledProps,
|
|
1203
1204
|
...IconProps,
|
|
1204
1205
|
/**
|
|
1205
1206
|
* Input value
|
|
@@ -1363,13 +1364,13 @@ const _hoisted_1 = ["for"];
|
|
|
1363
1364
|
const _hoisted_2 = { class: "vv-input-file__preview" };
|
|
1364
1365
|
const _hoisted_3 = ["src", "alt"];
|
|
1365
1366
|
const _hoisted_4 = { class: "vv-input-file__wrapper" };
|
|
1366
|
-
const _hoisted_5 = ["id", "readonly", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "capture", "name"];
|
|
1367
|
+
const _hoisted_5 = ["id", "readonly", "disabled", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "capture", "name"];
|
|
1367
1368
|
const _hoisted_6 = ["value"];
|
|
1368
1369
|
const _hoisted_7 = ["onClick"];
|
|
1369
1370
|
const _hoisted_8 = ["title", "onClick"];
|
|
1370
1371
|
const _hoisted_9 = { class: "vv-input-file__item-name" };
|
|
1371
1372
|
const _hoisted_10 = { class: "vv-input-file__item-info" };
|
|
1372
|
-
const _hoisted_11 = ["title", "onClick"];
|
|
1373
|
+
const _hoisted_11 = ["title", "disabled", "onClick"];
|
|
1373
1374
|
const __default__ = {
|
|
1374
1375
|
name: "VvInputFile"
|
|
1375
1376
|
};
|
|
@@ -1386,7 +1387,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1386
1387
|
VvInputFileProps,
|
|
1387
1388
|
props
|
|
1388
1389
|
);
|
|
1389
|
-
const { modifiers, id, readonly, icon, iconPosition, iconDownload } = toRefs(props);
|
|
1390
|
+
const { modifiers, id, readonly, disabled, icon, iconPosition, iconDownload } = toRefs(props);
|
|
1390
1391
|
const hasId = useUniqueId(id);
|
|
1391
1392
|
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
1392
1393
|
const hasProgress = computed(() => {
|
|
@@ -1434,11 +1435,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1434
1435
|
localModelValue.value = value == null ? void 0 : value[0];
|
|
1435
1436
|
}
|
|
1436
1437
|
});
|
|
1438
|
+
const isDisabledOrReadonly = computed(() => props.disabled || props.readonly);
|
|
1437
1439
|
const hasMax = computed(() => {
|
|
1438
1440
|
return typeof props.max === "string" ? Number.parseInt(props.max) : props.max;
|
|
1439
1441
|
});
|
|
1440
1442
|
const hasDropArea = computed(() => {
|
|
1441
|
-
return props.dropArea && !
|
|
1443
|
+
return props.dropArea && !isDisabledOrReadonly.value;
|
|
1442
1444
|
});
|
|
1443
1445
|
const isMultiple = computed(() => {
|
|
1444
1446
|
if (!props.multiple) {
|
|
@@ -1501,7 +1503,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1501
1503
|
if (!inputEl.value) {
|
|
1502
1504
|
return;
|
|
1503
1505
|
}
|
|
1504
|
-
if (!
|
|
1506
|
+
if (!isDisabledOrReadonly.value) {
|
|
1505
1507
|
inputEl.value.click();
|
|
1506
1508
|
}
|
|
1507
1509
|
}
|
|
@@ -1634,12 +1636,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1634
1636
|
modifiers: "action",
|
|
1635
1637
|
label: !previewSrc.value ? dropdAreaActionLabel.value : void 0,
|
|
1636
1638
|
title: previewSrc.value ? dropdAreaActionLabel.value : void 0,
|
|
1639
|
+
disabled: unref(disabled),
|
|
1637
1640
|
class: normalizeClass({
|
|
1638
1641
|
"vv-input-file__drop-area-action": previewSrc.value
|
|
1639
1642
|
}),
|
|
1640
1643
|
icon: dropAreaActionIcon.value,
|
|
1641
1644
|
onClick: withModifiers(onClickDropArea, ["stop"])
|
|
1642
|
-
}, null, 8, ["label", "title", "class", "icon"])) : createCommentVNode("v-if", true)
|
|
1645
|
+
}, null, 8, ["label", "title", "disabled", "class", "icon"])) : createCommentVNode("v-if", true)
|
|
1643
1646
|
])
|
|
1644
1647
|
],
|
|
1645
1648
|
32
|
|
@@ -1659,6 +1662,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1659
1662
|
ref: inputEl,
|
|
1660
1663
|
type: "file",
|
|
1661
1664
|
readonly: unref(readonly),
|
|
1665
|
+
disabled: unref(disabled),
|
|
1662
1666
|
placeholder: _ctx.placeholder,
|
|
1663
1667
|
"aria-describedby": unref(hasHintLabelOrSlot) ? hasHintId.value : void 0,
|
|
1664
1668
|
"aria-invalid": _ctx.invalid,
|
|
@@ -1734,6 +1738,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1734
1738
|
type: "button",
|
|
1735
1739
|
class: "vv-input-file__item-remove",
|
|
1736
1740
|
title: _ctx.labelRemove,
|
|
1741
|
+
disabled: unref(disabled),
|
|
1737
1742
|
onClick: withModifiers(($event) => onClickRemoveFile(index), ["stop"])
|
|
1738
1743
|
}, null, 8, _hoisted_11)) : createCommentVNode("v-if", true)
|
|
1739
1744
|
], 10, _hoisted_7)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@vueuse/core"),require("vuedraggable"),require("@iconify/vue"),require("uid")):"function"==typeof define&&define.amd?define(["vue","@vueuse/core","vuedraggable","@iconify/vue","uid"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvInputFile=t(e.vue,e.core,e.Sortable,e.vue$1,e.uid)}(this,(function(e,t,l,o,a){"use strict";const n="add",i="edit",r="download",u={prefix:"normal"};var d=(e=>(e.local="local",e.session="session",e))(d||{}),s=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(s||{}),v=(e=>(e.before="before",e.after="after",e))(v||{}),c=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(c||{}),f=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(f||{});const p=Symbol.for("volver"),m=Symbol.for("buttonGroup"),g=Symbol.for("dropdownTrigger"),b=Symbol.for("dropdownAction");function y(){return e.inject(p)}function h(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 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(t){const l=t,a=e.computed((()=>"string"==typeof l.rotate?Number.parseFloat(l.rotate):l.rotate)),n=e.ref(!0),i=y(),{modifiers:r}=e.toRefs(l),u=h("vv-icon",r),d=e.computed((()=>l.provider||(null==i?void 0:i.iconsProvider))),s=e.computed((()=>{const e=l.name??"",t=`@${d.value}:${l.prefix}:${e}`;if(o.iconExists(t))return t;const a=null==i?void 0:i.iconsCollections.find((t=>{const l=`@${d.value}:${t.prefix}:${e}`;return o.iconExists(l)}));return a?`@${d.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&&o.addIcon(`@${d.value}:${l.prefix}:${l.name}`,{body:a,height:t.viewBox.baseVal.height,width:t.viewBox.baseVal.width})}return i&&l.src&&!o.iconExists(`@${d.value}:${l.prefix}:${l.name}`)&&(n.value=!1,i.fetchIcon(l.src).then((e=>{e&&(v(e),n.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),l.svg&&v(l.svg),(t,l)=>e.unref(n)?(e.openBlock(),e.createBlock(e.unref(o.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:t.inline,width:t.width,height:t.height,horizontalFlip:t.horizontalFlip,verticalFlip:t.verticalFlip,flip:t.flip,rotate:e.unref(a),color:t.color,onLoad:t.onLoad,icon:e.unref(s)}),null,16,["class"])):e.createCommentVNode("v-if",!0)}}),S={to:{type:[String,Object]},href:String,target:String,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}},C={pressed:{type:Boolean,default:!1}},N={label:{type:[String,Number],default:void 0}},O={readonly:{type:Boolean,default:!1}},x={modifiers:{type:[String,Array],default:void 0}},_={hintLabel:{type:String,default:""}},I={icon:{type:[String,Object],default:void 0},iconPosition:{type:String,default:v.before,validation:e=>Object.values(v).includes(e)}},R={unselectable:{type:Boolean,default:!0}},j={id:[String,Number]};s.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const P={...j,name:{type:String,required:!0}},E={...w,...N,...C,...A,...$,...S,type:{type:String,default:c.button,validator:e=>Object.values(c).includes(e)},ariaLabel:{type:String,default:void 0},defaultTag:{type:String,default:f.button}};d.local;const D=E;const M=e.defineComponent({name:"VvAction",props:D,emits:["click","mouseover","mouseleave"],setup(t,{expose:l,emit:o}){const a=t,n=o,i=e.getCurrentInstance(),r=y(),u=e.ref(null);l({$el:u});const{reference:d,bus:s,aria:v,expanded:c}=e.inject(g,{});e.watch((()=>u.value),(e=>{d&&(d.value=e)}));const p=e.computed((()=>a.pressed||(null==c?void 0:c.value))),{role:m}=e.inject(b,{}),h=e.computed((()=>{switch(!0){case a.disabled:return f.button;case void 0!==a.to:return(null==r?void 0:r.nuxt)?f.nuxtLink:f.routerLink;case void 0!==a.href:return f.a;default:return a.defaultTag}})),k=e.computed((()=>{const e={...null==v?void 0:v.value,ariaPressed:!!p.value||void 0,ariaLabel:a.ariaLabel,role:null==m?void 0:m.value};switch(h.value){case f.a:return{...e,href:a.href,target:a.target,rel:a.rel};case f.routerLink:case f.nuxtLink:return{...e,to:a.to,target:a.target};case f.button:return{...e,type:a.type,disabled:a.disabled};default:return e}}));function S(e){var t;a.disabled?e.preventDefault():(null==(t=null==i?void 0:i.vnode.props)?void 0:t.onClick)?n("click",e):null==s||s.emit("click",e)}function B(e){var t;(null==(t=null==i?void 0:i.vnode.props)?void 0:t.onMouseover)?n("mouseover",e):null==s||s.emit("mouseover",e)}function L(e){var t;(null==(t=null==i?void 0:i.vnode.props)?void 0:t.onMouseleave)?n("mouseleave",e):null==s||s.emit("mouseleave",e)}return(t,l)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(h)),e.mergeProps(e.unref(k),{ref_key:"element",ref:u,class:{active:t.active,pressed:e.unref(p),disabled:t.disabled,current:t.current},onClickPassive:S,onMouseoverPassive:B,onMouseleavePassive:L}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]))])),_:3},16,["class"]))}});const F={...E,...j,...x,...R,...V,...I,iconPosition:{type:String,default:s.left,validator:e=>Object.values(s).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(t,l){const{group:o,isInGroup:a,getGroupOrLocalRef:n}=function(t){const l=e.inject(t,void 0),o=e.computed((()=>void 0!==l));return{group:l,isInGroup:o,getGroupOrLocalRef:function(t,o,a){const n=null==l?void 0:l[t];if(n)return e.computed({get:()=>n.value,set(e){n.value=e}});const i=e.toRef(o,t);return e.computed({get:()=>i.value,set(e){a&&a(`update:${t}`,e)}})}}}(m),{id:i,iconPosition:r,icon:u,label:d,pressed:s}=e.toRefs(t),v=n("modelValue",t,l),c=n("toggle",t),f=n("unselectable",t),p=e.computed((()=>(null==o?void 0:o.multiple.value)??!1)),g=e.computed((()=>{let e=t.modifiers,l=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)))),l&&(Array.isArray(l)||(l=l.split(" ")),l.forEach((e=>a.add(e)))),Array.from(a)})),b=e.computed((()=>Boolean(t.disabled||(null==o?void 0:o.disabled.value))));return{group:o,isInGroup:a,modelValue:v,toggle:c,unselectable:f,multiple:p,modifiers:g,disabled:b,id:i,pressed:s,iconPosition:r,icon:u,label:d}}function U(t){return e.computed((()=>String((null==t?void 0:t.value)||a.uid())))}function T(e,t,l){return l?H(e,l)===H(t,l):q(e,t)}function q(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(!q(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 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],!q(e[i],t[i]))return!1;return!0}return Number.isNaN(e)&&Number.isNaN(t)}function H(e,t){if(e&&Object.keys(e).length&&t){if(t.includes(".")){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 e[t]}return null}function G(e,t){if(null!=e&&t&&t.length)for(const l of t)if(T(e,l))return!0;return!1}function J(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)),a=e.computed((()=>(null==l?void 0:l.value)===v.before?o.value:void 0)),n=e.computed((()=>(null==l?void 0:l.value)===v.after?o.value:void 0)),i=e.computed((()=>(null==l?void 0:l.value)===s.left?o.value:void 0)),r=e.computed((()=>(null==l?void 0:l.value)===s.right?o.value:void 0)),u=e.computed((()=>(null==l?void 0:l.value)===s.top?o.value:void 0)),d=e.computed((()=>(null==l?void 0:l.value)===s.bottom?o.value:void 0));return{hasIcon:o,hasIconLeft:i,hasIconRight:r,hasIconTop:u,hasIconBottom:d,hasIconBefore:a,hasIconAfter:n}}const K={key:1,class:"vv-button__label"},Q={key:1,class:"vv-button__label"},W=e.defineComponent({name:"VvButton",inheritAttrs:!1,props:F,emits:["update:modelValue"],setup(t,{expose:l,emit:o}){const a=t,n=o,i=e.useAttrs(),r=e.useSlots(),{id:u,modifiers:d,iconPosition:v,icon:c,label:f,modelValue:p,disabled:m,toggle:g,unselectable:b}=z(a,n),y=U(u),S=e.computed((()=>(null==i?void 0:i.name)||y.value)),B=e.ref(null);l({$el:e.computed((()=>{var e;return null==(e=B.value)?void 0:e.$el}))});const L=e.computed((()=>g.value?Array.isArray(p.value)?G(S.value,p.value):T(S.value,p.value):a.pressed)),V=h("vv-button",d,e.computed((()=>({reverse:[s.right,s.bottom].includes(v.value),column:[s.top,s.bottom].includes(v.value),"icon-only":Boolean((null==c?void 0:c.value)&&!(null==f?void 0:f.value)&&!r.default)})))),{hasIcon:w}=J(c),A=e.computed((()=>void 0!==a.value?a.value:S.value)),$=e.computed((()=>{if(g.value)return{onClick:C}}));function C(){if(g.value){if(Array.isArray(p.value))return G(A.value,p.value)?void(b.value&&(p.value=p.value.filter((e=>e!==A.value)))):void p.value.push(A.value);if(A.value===p.value&&b.value)return void(p.value=a.uncheckedValue);p.value=A.value}}return(t,l)=>(e.openBlock(),e.createBlock(M,e.mergeProps({...e.unref(i),...e.unref($),disabled:e.unref(m),pressed:e.unref(L),active:t.active,type:t.type,to:t.to,href:t.href,target:t.target,rel:t.rel,ariaLabel:t.ariaLabel},{id:e.unref(y),ref_key:"element",ref:B,class:e.unref(V)}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[t.loading?e.renderSlot(t.$slots,"loading",{key:0},(()=>[t.loadingIcon?(e.openBlock(),e.createBlock(k,{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",K,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(k,e.mergeProps({key:0},e.unref(w),{class:"vv-button__icon"}),null,16)):e.createCommentVNode("v-if",!0),e.unref(f)?(e.openBlock(),e.createElementBlock("span",Q,[e.renderSlot(t.$slots,"label",{},(()=>[e.createTextVNode(e.toDisplayString(e.unref(f)),1)]))])):e.createCommentVNode("v-if",!0),e.renderSlot(t.$slots,"after")],64))]))])),_:3},16,["id","class"]))}});function X(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const Y={...P,...x,...B,...L,..._,...N,...V,...O,...I,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:i},labelDownload:{type:String,default:"Downlaod file"},iconDownload:{type:[String,Object],default:r},labelRemove:{type:String,default:"Remove file"}};const Z=["for"],ee={class:"vv-input-file__preview"},te=["src","alt"],le={class:"vv-input-file__wrapper"},oe=["id","readonly","placeholder","aria-describedby","aria-invalid","aria-errormessage","multiple","accept","capture","name"],ae=["value"],ne=["onClick"],ie=["title","onClick"],re={class:"vv-input-file__item-name"},ue={class:"vv-input-file__item-info"},de=["title","onClick"];return e.defineComponent({name:"VvInputFile",props:Y,emits:["remove","download","update:modelValue"],setup(o,{emit:a}){const n=o,i=a,r=e.useSlots(),u=function(t,l,o){const a=y(),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",Y,n),{modifiers:d,id:s,readonly:v,icon:c,iconPosition:f,iconDownload:p}=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?Number.parseInt(n.progress):n.progress;return e>0&&e<100})),{hasIconBefore:S,hasIconAfter:B}=J(c,f),{hasIcon:L}=J(p),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":_.value})))),{HintSlot:w,hasHintLabelOrSlot:A,hasInvalidLabelOrSlot:$,hintSlotScope:C}=function(t,l){const o=e.computed((()=>e.isRef(t)?t.value:t)),a=e.computed((()=>X(o.value.invalidLabel))),n=e.computed((()=>X(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)))),v=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(l.hint||r.value))),c=e.computed((()=>d.value||s.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:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:v}),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:v,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hintSlotScope:f,HintSlot:p}}(u,r),N=t.useVModel(n,"modelValue",i),O=e.computed({get:()=>{var e;return N.value&&(Array.isArray(N.value)||(null==(e=N.value)?void 0:e.name))?Array.isArray(N.value)?N.value:[N.value]:[]},set:e=>{I.value?N.value=e:N.value=null==e?void 0:e[0]}}),x=e.computed((()=>"string"==typeof n.max?Number.parseInt(n.max):n.max)),_=e.computed((()=>n.dropArea&&!v.value)),I=e.computed((()=>!!n.multiple&&(!x.value||x.value-O.value.length>1))),R=e.ref(!1),j=e.ref();function P(){R.value=!0}function E(){R.value=!1}function D(e){var t,l;(null==(t=e.dataTransfer)?void 0:t.files)&&(R.value=!1,F(null==(l=e.dataTransfer)?void 0:l.files))}function M(){var e;(null==(e=j.value)?void 0:e.files)&&(F(j.value.files),j.value.value="")}function F(e){if(!n.multiple)return Array.isArray(N.value)?void(N.value=[...e]):void(N.value=e[0]);let t=[];t=!Array.isArray(N.value)&&N.value?[N.value]:N.value&&Array.isArray(N.value)?[...N.value]:t;for(const l of e){if(x.value&&t.length>=x.value)break;t.push(l)}N.value=t,T.value=t.length-1}function z(){j.value&&(v.value||j.value.click())}const T=e.ref(0),q=["image/jpeg","image/png"],H=e.computed((()=>{if(0===O.value.length)return;if(!O.value[T.value])return;if(O.value[T.value]instanceof File){const e=O.value[T.value];if(!q.includes(e.type))return;return URL.createObjectURL(e)}const e=O.value[T.value];return e.thumbnailUrl?e.thumbnailUrl:q.includes(e.type)?e.url:void 0}));function G(e){if(e)return Math.floor(e/1024)}e.watch(H,((e,t)=>{t&&URL.revokeObjectURL(t)})),e.onBeforeUnmount((()=>{H.value&&URL.revokeObjectURL(H.value)}));const K=e.computed((()=>0===O.value.length||I.value?n.labelAdd:n.labelReplace)),Q=e.computed((()=>0===O.value.length||I.value?n.iconAdd:n.iconReplace));function se({newIndex:e}){null!==e&&(T.value=e)}return(t,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(V))},[t.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(m)},e.toDisplayString(t.label),9,Z)):e.createCommentVNode("v-if",!0),_.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:o[0]||(o[0]=e.withModifiers((()=>{}),["prevent","stop"])),onClick:e.withModifiers(z,["stop"])},[e.renderSlot(t.$slots,"drop-area",{},(()=>[e.createElementVNode("picture",ee,[H.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:H.value,alt:O.value[T.value].name},null,8,te)):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",le,[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:j,type:"file",readonly:e.unref(v),placeholder:t.placeholder,"aria-describedby":e.unref(A)?g.value:void 0,"aria-invalid":t.invalid,"aria-errormessage":e.unref($)?g.value:void 0,multiple:I.value,accept:t.accept,capture:t.capture,name:t.name,onChange:M},null,40,oe),b.value?(e.openBlock(),e.createElementBlock("progress",{key:1,class:"vv-input-file__progress",value:t.progress,max:"100"},e.toDisplayString(t.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(l),{modelValue:O.value,"onUpdate:modelValue":o[1]||(o[1]=e=>O.value=e),tag:"ul",class:"vv-input-file__list","item-key":"name",move:()=>t.sortable,onEnd:se},{item:e.withCtx((({element:l,index:o})=>[e.createElementVNode("li",{class:e.normalizeClass(["vv-input-file__item",{active:o===T.value&&_.value&&O.value.length>1,"cursor-move":t.sortable}]),onClick:e.withModifiers((e=>function(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:t.labelDownload,onClick:e.withModifiers((e=>function(e){i("download",e);const t=e instanceof File?URL.createObjectURL(e):e.url;if(!t)return;const l=document.createElement("a");l.href=t,l.setAttribute("download",e.name),document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(l.href)}(l)),["stop"])},[e.createVNode(k,e.normalizeProps(e.guardReactiveProps(e.unref(L))),null,16)],8,ie)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",re,e.toDisplayString(l.name),1),e.createElementVNode("small",ue,e.toDisplayString(G(l.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:t.labelRemove,onClick:e.withModifiers((e=>function(e){const t=Array.isArray(N.value)?N.value[e]:N.value;if(!t)return;if(i("remove",t),!Array.isArray(N.value))return void(N.value=void 0);T.value===e&&(T.value=0);const l=[...N.value];l.splice(e,1),N.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},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(C))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(C))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(C))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(C))))])),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("vuedraggable"),require("@iconify/vue"),require("uid")):"function"==typeof define&&define.amd?define(["vue","@vueuse/core","vuedraggable","@iconify/vue","uid"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvInputFile=l(e.vue,e.core,e.Sortable,e.vue$1,e.uid)}(this,(function(e,l,t,o,a){"use strict";const n="add",i="edit",r="download",u={prefix:"normal"};var d=(e=>(e.local="local",e.session="session",e))(d||{}),s=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(s||{}),v=(e=>(e.before="before",e.after="after",e))(v||{}),c=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(c||{}),f=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(f||{});const p=Symbol.for("volver"),m=Symbol.for("buttonGroup"),g=Symbol.for("dropdownTrigger"),b=Symbol.for("dropdownAction");function y(){return e.inject(p)}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 t=l,a=e.computed((()=>"string"==typeof t.rotate?Number.parseFloat(t.rotate):t.rotate)),n=e.ref(!0),i=y(),{modifiers:r}=e.toRefs(t),u=h("vv-icon",r),d=e.computed((()=>t.provider||(null==i?void 0:i.iconsProvider))),s=e.computed((()=>{const e=t.name??"",l=`@${d.value}:${t.prefix}:${e}`;if(o.iconExists(l))return l;const a=null==i?void 0:i.iconsCollections.find((l=>{const t=`@${d.value}:${l.prefix}:${e}`;return o.iconExists(t)}));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&&o.addIcon(`@${d.value}:${t.prefix}:${t.name}`,{body:a,height:l.viewBox.baseVal.height,width:l.viewBox.baseVal.width})}return i&&t.src&&!o.iconExists(`@${d.value}:${t.prefix}:${t.name}`)&&(n.value=!1,i.fetchIcon(t.src).then((e=>{e&&(v(e),n.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),t.svg&&v(t.svg),(l,t)=>e.unref(n)?(e.openBlock(),e.createBlock(e.unref(o.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:String,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}},C={pressed:{type:Boolean,default:!1}},N={label:{type:[String,Number],default:void 0}},O={readonly:{type:Boolean,default:!1}},x={modifiers:{type:[String,Array],default:void 0}},_={hintLabel:{type:String,default:""}},I={icon:{type:[String,Object],default:void 0},iconPosition:{type:String,default:v.before,validation:e=>Object.values(v).includes(e)}},R={unselectable:{type:Boolean,default:!0}},j={id:[String,Number]};s.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const P={...j,name:{type:String,required:!0}},E={...w,...N,...C,...A,...$,...S,type:{type:String,default:c.button,validator:e=>Object.values(c).includes(e)},ariaLabel:{type:String,default:void 0},defaultTag:{type:String,default:f.button}};d.local;const 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,i=e.getCurrentInstance(),r=y(),u=e.ref(null);t({$el:u});const{reference:d,bus:s,aria:v,expanded:c}=e.inject(g,{});e.watch((()=>u.value),(e=>{d&&(d.value=e)}));const p=e.computed((()=>a.pressed||(null==c?void 0:c.value))),{role:m}=e.inject(b,{}),h=e.computed((()=>{switch(!0){case a.disabled:return f.button;case void 0!==a.to:return(null==r?void 0:r.nuxt)?f.nuxtLink:f.routerLink;case void 0!==a.href:return f.a;default:return a.defaultTag}})),k=e.computed((()=>{const e={...null==v?void 0:v.value,ariaPressed:!!p.value||void 0,ariaLabel:a.ariaLabel,role:null==m?void 0:m.value};switch(h.value){case f.a:return{...e,href:a.href,target:a.target,rel:a.rel};case f.routerLink:case f.nuxtLink:return{...e,to:a.to,target:a.target};case f.button:return{...e,type:a.type,disabled:a.disabled};default:return e}}));function S(e){var l;a.disabled?e.preventDefault():(null==(l=null==i?void 0:i.vnode.props)?void 0:l.onClick)?n("click",e):null==s||s.emit("click",e)}function B(e){var l;(null==(l=null==i?void 0:i.vnode.props)?void 0:l.onMouseover)?n("mouseover",e):null==s||s.emit("mouseover",e)}function L(e){var l;(null==(l=null==i?void 0:i.vnode.props)?void 0:l.onMouseleave)?n("mouseleave",e):null==s||s.emit("mouseleave",e)}return(l,t)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(h)),e.mergeProps(e.unref(k),{ref_key:"element",ref:u,class:{active:l.active,pressed:e.unref(p),disabled:l.disabled,current:l.current},onClickPassive:S,onMouseoverPassive:B,onMouseleavePassive:L}),{default:e.withCtx((()=>[e.renderSlot(l.$slots,"default",{},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)]))])),_:3},16,["class"]))}});const F={...E,...j,...x,...R,...V,...I,iconPosition:{type:String,default:s.left,validator:e=>Object.values(s).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 i=e.toRef(o,l);return e.computed({get:()=>i.value,set(e){a&&a(`update:${l}`,e)}})}}}(m),{id:i,iconPosition:r,icon:u,label:d,pressed:s}=e.toRefs(l),v=n("modelValue",l,t),c=n("toggle",l),f=n("unselectable",l),p=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:f,multiple:p,modifiers:g,disabled:b,id:i,pressed:s,iconPosition:r,icon:u,label:d}}function U(l){return e.computed((()=>String((null==l?void 0:l.value)||a.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,i;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 r=e instanceof Date,u=l instanceof Date;if(r!==u)return!1;if(r&&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(i=v[a],!q(e[i],l[i]))return!1;return!0}return Number.isNaN(e)&&Number.isNaN(l)}function H(e,l){if(e&&Object.keys(e).length&&l){if(l.includes(".")){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 e[l]}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)===v.before?o.value:void 0)),n=e.computed((()=>(null==t?void 0:t.value)===v.after?o.value:void 0)),i=e.computed((()=>(null==t?void 0:t.value)===s.left?o.value:void 0)),r=e.computed((()=>(null==t?void 0:t.value)===s.right?o.value:void 0)),u=e.computed((()=>(null==t?void 0:t.value)===s.top?o.value:void 0)),d=e.computed((()=>(null==t?void 0:t.value)===s.bottom?o.value:void 0));return{hasIcon:o,hasIconLeft:i,hasIconRight:r,hasIconTop:u,hasIconBottom:d,hasIconBefore:a,hasIconAfter:n}}const K={key:1,class:"vv-button__label"},Q={key:1,class:"vv-button__label"},W=e.defineComponent({name:"VvButton",inheritAttrs:!1,props:F,emits:["update:modelValue"],setup(l,{expose:t,emit:o}){const a=l,n=o,i=e.useAttrs(),r=e.useSlots(),{id:u,modifiers:d,iconPosition:v,icon:c,label:f,modelValue:p,disabled:m,toggle:g,unselectable:b}=z(a,n),y=U(u),S=e.computed((()=>(null==i?void 0:i.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(p.value)?G(S.value,p.value):T(S.value,p.value):a.pressed)),V=h("vv-button",d,e.computed((()=>({reverse:[s.right,s.bottom].includes(v.value),column:[s.top,s.bottom].includes(v.value),"icon-only":Boolean((null==c?void 0:c.value)&&!(null==f?void 0:f.value)&&!r.default)})))),{hasIcon:w}=J(c),A=e.computed((()=>void 0!==a.value?a.value:S.value)),$=e.computed((()=>{if(g.value)return{onClick:C}}));function C(){if(g.value){if(Array.isArray(p.value))return G(A.value,p.value)?void(b.value&&(p.value=p.value.filter((e=>e!==A.value)))):void p.value.push(A.value);if(A.value===p.value&&b.value)return void(p.value=a.uncheckedValue);p.value=A.value}}return(l,t)=>(e.openBlock(),e.createBlock(M,e.mergeProps({...e.unref(i),...e.unref($),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)}),{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(f)?(e.openBlock(),e.createElementBlock("span",Q,[e.renderSlot(l.$slots,"label",{},(()=>[e.createTextVNode(e.toDisplayString(e.unref(f)),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,...V,...O,...w,...I,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:i},labelDownload:{type:String,default:"Downlaod file"},iconDownload:{type:[String,Object],default:r},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","disabled","placeholder","aria-describedby","aria-invalid","aria-errormessage","multiple","accept","capture","name"],ae=["value"],ne=["onClick"],ie=["title","onClick"],re={class:"vv-input-file__item-name"},ue={class:"vv-input-file__item-info"},de=["title","disabled","onClick"];return e.defineComponent({name:"VvInputFile",props:Y,emits:["remove","download","update:modelValue"],setup(o,{emit:a}){const n=o,i=a,r=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,disabled:c,icon:f,iconPosition:p,iconDownload:m}=e.toRefs(n),g=U(s),b=e.computed((()=>`${g.value}-hint`)),S=e.computed((()=>{if(!n.progress)return!1;const e="string"==typeof n.progress?Number.parseInt(n.progress):n.progress;return e>0&&e<100})),{hasIconBefore:B,hasIconAfter:L}=J(f,p),{hasIcon:V}=J(m),w=h("vv-input-file",d,e.computed((()=>({dragging:P.value,loading:n.loading&&!S.value,valid:!0===n.valid,invalid:!0===n.invalid,"icon-before":!!B.value,"icon-after":!!L.value,"drop-area":R.value})))),{HintSlot:A,hasHintLabelOrSlot:$,hasInvalidLabelOrSlot:C,hintSlotScope:N}=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))),i=e.computed((()=>o.value.loadingLabel)),r=e.computed((()=>o.value.hintLabel)),u=e.computed((()=>Boolean(o.value.loading&&(t.loading||i.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||r.value))),c=e.computed((()=>d.value||s.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:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:v}),render(){var l,t,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==(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==(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:v,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hintSlotScope:f,HintSlot:p}}(u,r),O=l.useVModel(n,"modelValue",i),x=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]}}),_=e.computed((()=>n.disabled||n.readonly)),I=e.computed((()=>"string"==typeof n.max?Number.parseInt(n.max):n.max)),R=e.computed((()=>n.dropArea&&!_.value)),j=e.computed((()=>!!n.multiple&&(!I.value||I.value-x.value.length>1))),P=e.ref(!1),E=e.ref();function D(){P.value=!0}function M(){P.value=!1}function F(e){var l,t;(null==(l=e.dataTransfer)?void 0:l.files)&&(P.value=!1,T(null==(t=e.dataTransfer)?void 0:t.files))}function z(){var e;(null==(e=E.value)?void 0:e.files)&&(T(E.value.files),E.value.value="")}function T(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(I.value&&l.length>=I.value)break;l.push(t)}O.value=l,H.value=l.length-1}function q(){E.value&&(_.value||E.value.click())}const H=e.ref(0),G=["image/jpeg","image/png"],K=e.computed((()=>{if(0===x.value.length)return;if(!x.value[H.value])return;if(x.value[H.value]instanceof File){const e=x.value[H.value];if(!G.includes(e.type))return;return URL.createObjectURL(e)}const e=x.value[H.value];return e.thumbnailUrl?e.thumbnailUrl:G.includes(e.type)?e.url:void 0}));function Q(e){if(e)return Math.floor(e/1024)}e.watch(K,((e,l)=>{l&&URL.revokeObjectURL(l)})),e.onBeforeUnmount((()=>{K.value&&URL.revokeObjectURL(K.value)}));const se=e.computed((()=>0===x.value.length||j.value?n.labelAdd:n.labelReplace)),ve=e.computed((()=>0===x.value.length||j.value?n.iconAdd:n.iconReplace));function ce({newIndex:e}){null!==e&&(H.value=e)}return(l,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(w))},[l.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(g)},e.toDisplayString(l.label),9,Z)):e.createCommentVNode("v-if",!0),R.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vv-input-file__drop-area",onDragenter:e.withModifiers(D,["prevent","stop"]),onDragleave:e.withModifiers(M,["prevent","stop"]),onDrop:e.withModifiers(F,["prevent","stop"]),onDragover:o[0]||(o[0]=e.withModifiers((()=>{}),["prevent","stop"])),onClick:e.withModifiers(q,["stop"])},[e.renderSlot(l.$slots,"drop-area",{},(()=>[e.createElementVNode("picture",ee,[K.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:K.value,alt:x.value[H.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:K.value?void 0:se.value,title:K.value?se.value:void 0,disabled:e.unref(c),class:e.normalizeClass({"vv-input-file__drop-area-action":K.value}),icon:ve.value,onClick:e.withModifiers(q,["stop"])},null,8,["label","title","disabled","class","icon"]))]))],32)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",te,[e.unref(B)?(e.openBlock(),e.createBlock(k,e.normalizeProps(e.mergeProps({key:0},e.unref(B))),null,16)):e.createCommentVNode("v-if",!0),e.createElementVNode("input",{id:e.unref(g),ref_key:"inputEl",ref:E,type:"file",readonly:e.unref(v),disabled:e.unref(c),placeholder:l.placeholder,"aria-describedby":e.unref($)?b.value:void 0,"aria-invalid":l.invalid,"aria-errormessage":e.unref(C)?b.value:void 0,multiple:j.value,accept:l.accept,capture:l.capture,name:l.name,onChange:z},null,40,oe),S.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(L)?(e.openBlock(),e.createBlock(k,e.normalizeProps(e.mergeProps({key:2},e.unref(L))),null,16)):e.createCommentVNode("v-if",!0)]),e.createVNode(e.unref(t),{modelValue:x.value,"onUpdate:modelValue":o[1]||(o[1]=e=>x.value=e),tag:"ul",class:"vv-input-file__list","item-key":"name",move:()=>l.sortable,onEnd:ce},{item:e.withCtx((({element:t,index:o})=>[e.createElementVNode("li",{class:e.normalizeClass(["vv-input-file__item",{active:o===H.value&&R.value&&x.value.length>1,"cursor-move":l.sortable}]),onClick:e.withModifiers((e=>function(e){H.value=e}(o)),["stop"])},[e.unref(V)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"vv-input-file__item-action",title:l.labelDownload,onClick:e.withModifiers((e=>function(e){i("download",e);const l=e instanceof File?URL.createObjectURL(e):e.url;if(!l)return;const t=document.createElement("a");t.href=l,t.setAttribute("download",e.name),document.body.appendChild(t),t.click(),document.body.removeChild(t),URL.revokeObjectURL(t.href)}(t)),["stop"])},[e.createVNode(k,e.normalizeProps(e.guardReactiveProps(e.unref(V))),null,16)],8,ie)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",re,e.toDisplayString(t.name),1),e.createElementVNode("small",ue,e.toDisplayString(Q(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,disabled:e.unref(c),onClick:e.withModifiers((e=>function(e){const l=Array.isArray(O.value)?O.value[e]:O.value;if(!l)return;if(i("remove",l),!Array.isArray(O.value))return void(O.value=void 0);H.value===e&&(H.value=0);const t=[...O.value];t.splice(e,1),O.value=t}(o)),["stop"])},null,8,de))],10,ne)])),_:1},8,["modelValue","move"]),e.createVNode(e.unref(A),{id:b.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(N))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(N))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(N))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(N))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|
|
@@ -73,6 +73,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
73
73
|
default: import("../../constants").Position;
|
|
74
74
|
validation: (value: import("../../constants").Position) => boolean;
|
|
75
75
|
};
|
|
76
|
+
disabled: {
|
|
77
|
+
type: BooleanConstructor;
|
|
78
|
+
default: boolean;
|
|
79
|
+
};
|
|
76
80
|
readonly: {
|
|
77
81
|
type: BooleanConstructor;
|
|
78
82
|
default: boolean;
|
|
@@ -196,6 +200,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
196
200
|
default: import("../../constants").Position;
|
|
197
201
|
validation: (value: import("../../constants").Position) => boolean;
|
|
198
202
|
};
|
|
203
|
+
disabled: {
|
|
204
|
+
type: BooleanConstructor;
|
|
205
|
+
default: boolean;
|
|
206
|
+
};
|
|
199
207
|
readonly: {
|
|
200
208
|
type: BooleanConstructor;
|
|
201
209
|
default: boolean;
|
|
@@ -247,6 +255,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
247
255
|
onRemove?: ((args_0: File | UploadedFile) => any) | undefined;
|
|
248
256
|
}, {
|
|
249
257
|
label: string | number;
|
|
258
|
+
disabled: boolean;
|
|
250
259
|
modifiers: string | string[];
|
|
251
260
|
readonly: boolean;
|
|
252
261
|
progress: string | number;
|
|
@@ -141,6 +141,10 @@ export declare const VvInputFileProps: {
|
|
|
141
141
|
default: import("../../constants").Position;
|
|
142
142
|
validation: (value: import("../../constants").Position) => boolean;
|
|
143
143
|
};
|
|
144
|
+
disabled: {
|
|
145
|
+
type: BooleanConstructor;
|
|
146
|
+
default: boolean;
|
|
147
|
+
};
|
|
144
148
|
readonly: {
|
|
145
149
|
type: BooleanConstructor;
|
|
146
150
|
default: boolean;
|
|
@@ -7524,6 +7524,7 @@ const VvInputFileProps = {
|
|
|
7524
7524
|
...LabelProps,
|
|
7525
7525
|
...LoadingProps,
|
|
7526
7526
|
...ReadonlyProps,
|
|
7527
|
+
...DisabledProps,
|
|
7527
7528
|
...IconProps,
|
|
7528
7529
|
/**
|
|
7529
7530
|
* Input value
|
|
@@ -7634,13 +7635,13 @@ const _hoisted_1 = ["for"];
|
|
|
7634
7635
|
const _hoisted_2 = { class: "vv-input-file__preview" };
|
|
7635
7636
|
const _hoisted_3 = ["src", "alt"];
|
|
7636
7637
|
const _hoisted_4 = { class: "vv-input-file__wrapper" };
|
|
7637
|
-
const _hoisted_5 = ["id", "readonly", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "capture", "name"];
|
|
7638
|
+
const _hoisted_5 = ["id", "readonly", "disabled", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "capture", "name"];
|
|
7638
7639
|
const _hoisted_6 = ["value"];
|
|
7639
7640
|
const _hoisted_7 = ["onClick"];
|
|
7640
7641
|
const _hoisted_8 = ["title", "onClick"];
|
|
7641
7642
|
const _hoisted_9 = { class: "vv-input-file__item-name" };
|
|
7642
7643
|
const _hoisted_10 = { class: "vv-input-file__item-info" };
|
|
7643
|
-
const _hoisted_11 = ["title", "onClick"];
|
|
7644
|
+
const _hoisted_11 = ["title", "disabled", "onClick"];
|
|
7644
7645
|
const __default__ = {
|
|
7645
7646
|
name: "VvInputFile"
|
|
7646
7647
|
};
|
|
@@ -7657,7 +7658,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7657
7658
|
VvInputFileProps,
|
|
7658
7659
|
props
|
|
7659
7660
|
);
|
|
7660
|
-
const { modifiers, id, readonly, icon, iconPosition, iconDownload } = toRefs(props);
|
|
7661
|
+
const { modifiers, id, readonly, disabled, icon, iconPosition, iconDownload } = toRefs(props);
|
|
7661
7662
|
const hasId = useUniqueId(id);
|
|
7662
7663
|
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
7663
7664
|
const hasProgress = computed(() => {
|
|
@@ -7705,11 +7706,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7705
7706
|
localModelValue.value = value == null ? void 0 : value[0];
|
|
7706
7707
|
}
|
|
7707
7708
|
});
|
|
7709
|
+
const isDisabledOrReadonly = computed(() => props.disabled || props.readonly);
|
|
7708
7710
|
const hasMax = computed(() => {
|
|
7709
7711
|
return typeof props.max === "string" ? Number.parseInt(props.max) : props.max;
|
|
7710
7712
|
});
|
|
7711
7713
|
const hasDropArea = computed(() => {
|
|
7712
|
-
return props.dropArea && !
|
|
7714
|
+
return props.dropArea && !isDisabledOrReadonly.value;
|
|
7713
7715
|
});
|
|
7714
7716
|
const isMultiple = computed(() => {
|
|
7715
7717
|
if (!props.multiple) {
|
|
@@ -7772,7 +7774,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7772
7774
|
if (!inputEl.value) {
|
|
7773
7775
|
return;
|
|
7774
7776
|
}
|
|
7775
|
-
if (!
|
|
7777
|
+
if (!isDisabledOrReadonly.value) {
|
|
7776
7778
|
inputEl.value.click();
|
|
7777
7779
|
}
|
|
7778
7780
|
}
|
|
@@ -7905,12 +7907,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7905
7907
|
modifiers: "action",
|
|
7906
7908
|
label: !previewSrc.value ? dropdAreaActionLabel.value : void 0,
|
|
7907
7909
|
title: previewSrc.value ? dropdAreaActionLabel.value : void 0,
|
|
7910
|
+
disabled: unref(disabled),
|
|
7908
7911
|
class: normalizeClass({
|
|
7909
7912
|
"vv-input-file__drop-area-action": previewSrc.value
|
|
7910
7913
|
}),
|
|
7911
7914
|
icon: dropAreaActionIcon.value,
|
|
7912
7915
|
onClick: withModifiers(onClickDropArea, ["stop"])
|
|
7913
|
-
}, null, 8, ["label", "title", "class", "icon"])) : createCommentVNode("v-if", true)
|
|
7916
|
+
}, null, 8, ["label", "title", "disabled", "class", "icon"])) : createCommentVNode("v-if", true)
|
|
7914
7917
|
])
|
|
7915
7918
|
],
|
|
7916
7919
|
32
|
|
@@ -7930,6 +7933,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7930
7933
|
ref: inputEl,
|
|
7931
7934
|
type: "file",
|
|
7932
7935
|
readonly: unref(readonly),
|
|
7936
|
+
disabled: unref(disabled),
|
|
7933
7937
|
placeholder: _ctx.placeholder,
|
|
7934
7938
|
"aria-describedby": unref(hasHintLabelOrSlot) ? hasHintId.value : void 0,
|
|
7935
7939
|
"aria-invalid": _ctx.invalid,
|
|
@@ -8005,6 +8009,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
8005
8009
|
type: "button",
|
|
8006
8010
|
class: "vv-input-file__item-remove",
|
|
8007
8011
|
title: _ctx.labelRemove,
|
|
8012
|
+
disabled: unref(disabled),
|
|
8008
8013
|
onClick: withModifiers(($event) => onClickRemoveFile(index), ["stop"])
|
|
8009
8014
|
}, null, 8, _hoisted_11)) : createCommentVNode("v-if", true)
|
|
8010
8015
|
], 10, _hoisted_7)
|