@volverjs/ui-vue 0.0.10-beta.18 → 0.0.10-beta.20
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/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/components/VvInputFile/VvInputFile.es.js +23 -8
- 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 +13 -7
- 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 +20 -23
- 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 +7 -2
- package/src/components/VvInputFile/index.ts +2 -0
- package/src/stories/InputFile/InputFile.stories.ts +8 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inject, computed, unref, defineComponent, mergeDefaults, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, watch, resolveDynamicComponent, withCtx, renderSlot, createTextVNode, toDisplayString, toRef, useAttrs, useSlots, createElementBlock, Fragment, isRef, h, onBeforeUnmount, normalizeClass, withModifiers,
|
|
1
|
+
import { inject, computed, unref, defineComponent, mergeDefaults, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, watch, resolveDynamicComponent, withCtx, renderSlot, createTextVNode, toDisplayString, toRef, useAttrs, useSlots, createElementBlock, Fragment, isRef, h, onBeforeUnmount, normalizeClass, withModifiers, createElementVNode, renderList, createVNode, createSlots, normalizeProps, guardReactiveProps } from "vue";
|
|
2
2
|
import { useVModel } from "@vueuse/core";
|
|
3
3
|
import { iconExists, Icon, addIcon } from "@iconify/vue";
|
|
4
4
|
import { uid } from "uid";
|
|
@@ -313,6 +313,15 @@ const LabelProps = {
|
|
|
313
313
|
default: void 0
|
|
314
314
|
}
|
|
315
315
|
};
|
|
316
|
+
const ReadonlyProps = {
|
|
317
|
+
/**
|
|
318
|
+
* The value is not editable
|
|
319
|
+
*/
|
|
320
|
+
readonly: {
|
|
321
|
+
type: Boolean,
|
|
322
|
+
default: false
|
|
323
|
+
}
|
|
324
|
+
};
|
|
316
325
|
const ModifiersProps = {
|
|
317
326
|
/**
|
|
318
327
|
* Component BEM modifiers
|
|
@@ -1142,6 +1151,7 @@ const VvInputFileProps = {
|
|
|
1142
1151
|
...HintProps,
|
|
1143
1152
|
...LabelProps,
|
|
1144
1153
|
...LoadingProps,
|
|
1154
|
+
...ReadonlyProps,
|
|
1145
1155
|
name: { type: String },
|
|
1146
1156
|
id: { type: String },
|
|
1147
1157
|
modelValue: {
|
|
@@ -1214,7 +1224,7 @@ const _hoisted_1 = ["for"];
|
|
|
1214
1224
|
const _hoisted_2 = { class: "vv-input-file__preview" };
|
|
1215
1225
|
const _hoisted_3 = ["src", "alt"];
|
|
1216
1226
|
const _hoisted_4 = { class: "vv-input-file__wrapper" };
|
|
1217
|
-
const _hoisted_5 = ["id", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "name"];
|
|
1227
|
+
const _hoisted_5 = ["id", "readonly", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "name"];
|
|
1218
1228
|
const _hoisted_6 = { class: "vv-input-file__list" };
|
|
1219
1229
|
const _hoisted_7 = ["onClick"];
|
|
1220
1230
|
const _hoisted_8 = ["onClick"];
|
|
@@ -1237,7 +1247,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1237
1247
|
VvInputFileProps,
|
|
1238
1248
|
props
|
|
1239
1249
|
);
|
|
1240
|
-
const { modifiers, id } = toRefs(props);
|
|
1250
|
+
const { modifiers, id, readonly } = toRefs(props);
|
|
1241
1251
|
const hasId = useUniqueId(id);
|
|
1242
1252
|
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
1243
1253
|
const bemCssClasses = useModifiers(
|
|
@@ -1333,7 +1343,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1333
1343
|
if (!inputEl.value) {
|
|
1334
1344
|
return;
|
|
1335
1345
|
}
|
|
1336
|
-
|
|
1346
|
+
if (!readonly.value) {
|
|
1347
|
+
inputEl.value.click();
|
|
1348
|
+
}
|
|
1337
1349
|
};
|
|
1338
1350
|
const onClickRemoveFile = (index) => {
|
|
1339
1351
|
if (!Array.isArray(localModelValue.value)) {
|
|
@@ -1403,7 +1415,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1403
1415
|
},
|
|
1404
1416
|
[
|
|
1405
1417
|
renderSlot(_ctx.$slots, "drop-area", {}, () => [
|
|
1406
|
-
|
|
1418
|
+
!unref(readonly) ? (openBlock(), createBlock(_sfc_main$1, {
|
|
1419
|
+
key: 0,
|
|
1407
1420
|
modifiers: "action",
|
|
1408
1421
|
"aria-label": "upload",
|
|
1409
1422
|
label: !previewSrc.value ? _ctx.labelButton : void 0,
|
|
@@ -1412,7 +1425,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1412
1425
|
}, "z-1"]),
|
|
1413
1426
|
icon: !previewSrc.value ? "image" : isMultiple.value ? "add" : "edit",
|
|
1414
1427
|
onClick: withModifiers(onClick, ["stop"])
|
|
1415
|
-
}, null, 8, ["label", "class", "icon"]),
|
|
1428
|
+
}, null, 8, ["label", "class", "icon"])) : createCommentVNode("v-if", true),
|
|
1416
1429
|
createElementVNode("picture", _hoisted_2, [
|
|
1417
1430
|
previewSrc.value ? (openBlock(), createElementBlock("img", {
|
|
1418
1431
|
key: 0,
|
|
@@ -1434,6 +1447,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1434
1447
|
id: unref(hasId),
|
|
1435
1448
|
ref_key: "inputEl",
|
|
1436
1449
|
ref: inputEl,
|
|
1450
|
+
readonly: unref(readonly),
|
|
1437
1451
|
placeholder: _ctx.placeholder,
|
|
1438
1452
|
"aria-describedby": unref(hasHintLabelOrSlot) ? hasHintId.value : void 0,
|
|
1439
1453
|
"aria-invalid": _ctx.invalid,
|
|
@@ -1482,13 +1496,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1482
1496
|
1
|
|
1483
1497
|
/* TEXT */
|
|
1484
1498
|
),
|
|
1485
|
-
|
|
1499
|
+
!unref(readonly) ? (openBlock(), createElementBlock("button", {
|
|
1500
|
+
key: 0,
|
|
1486
1501
|
type: "button",
|
|
1487
1502
|
class: "vv-input-file__item-remove",
|
|
1488
1503
|
title: "Remove",
|
|
1489
1504
|
"aria-label": "remove-file",
|
|
1490
1505
|
onClick: withModifiers(($event) => onClickRemoveFile(index), ["stop"])
|
|
1491
|
-
}, null, 8, _hoisted_11)
|
|
1506
|
+
}, null, 8, _hoisted_11)) : createCommentVNode("v-if", true)
|
|
1492
1507
|
], 8, _hoisted_7);
|
|
1493
1508
|
}),
|
|
1494
1509
|
128
|
|
@@ -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";const a={prefix:"normal"};var n=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(n||{}),i=(e=>(e.before="before",e.after="after",e))(i||{}),r=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(r||{}),u=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(u||{}),d=(e=>(e._blank="_blank",e._self="_self",e._parent="_parent",e._top="_top",e))(d||{});const s=Symbol.for("volver"),c=Symbol.for("buttonGroup"),v=Symbol.for("dropdownTrigger"),f=Symbol.for("dropdownAction");function p(){return e.inject(s)}function m(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 g=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:{}},a),setup(t){const o=t,a=e.computed((()=>"string"==typeof o.rotate?parseFloat(o.rotate):o.rotate)),n=e.ref(!0),i=p(),{modifiers:r}=e.toRefs(o),u=m("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)}}),b={to:{type:[String,Object]},href:String,target:{type:String,default:void 0,validator:e=>Object.values(d).includes(e)},rel:{type:String,default:"noopener noreferrer"}},h={valid:{type:Boolean,default:!1},validLabel:{type:[String,Array],default:void 0}},y={invalid:{type:Boolean,default:!1},invalidLabel:{type:[String,Array],default:void 0}},k={loading:{type:Boolean,default:!1},loadingLabel:{type:String,default:"Loading..."}},S={disabled:{type:Boolean,default:!1}},B={active:{type:Boolean,default:!1}},L={current:{type:Boolean,default:!1}},V={pressed:{type:Boolean,default:!1}},$={label:{type:[String,Number],default:void 0}},w={modifiers:{type:[String,Array],default:void 0}},_={hintLabel:{type:String,default:""}},A={icon:{type:[String,Object],default:void 0},iconPosition:{type:String,default:i.before,validation:e=>Object.values(i).includes(e)}},O={unselectable:{type:Boolean,default:!0}},x={id:[String,Number]};n.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const C={...S,...$,...V,...B,...L,...b,type:{type:String,default:r.button,validator:e=>Object.values(r).includes(e)},ariaLabel:{type:String,default:void 0},defaultTag:{type:String,default:u.button}},N=C;const E=e.defineComponent({name:"VvAction",props:N,emits:["click","mouseover","mouseleave"],setup(t,{expose:l,emit:o}){const a=t,n=o,i=p(),r=e.ref(null);l({$el:r});const{reference:d,bus:s,aria:c,expanded:m}=e.inject(v,{});e.watch((()=>r.value),(e=>{d&&(d.value=e)}));const g=e.computed((()=>a.pressed||(null==m?void 0:m.value))),{role:b}=e.inject(f,{}),h=e.computed((()=>{switch(!0){case a.disabled:return u.button;case void 0!==a.to:return(null==i?void 0:i.nuxt)?u.nuxtLink:u.routerLink;case void 0!==a.href:return u.a;default:return a.defaultTag}})),y=e.computed((()=>{const e={...null==c?void 0:c.value,ariaPressed:!!g.value||void 0,ariaLabel:a.ariaLabel,role:null==b?void 0:b.value};switch(h.value){case u.a:return{...e,href:a.href,target:a.target,rel:a.rel};case u.routerLink:case u.nuxtLink:return{...e,to:a.to,target:a.target};case u.button:return{...e,type:a.type,disabled:a.disabled};default:return e}})),k=e=>{a.disabled?e.preventDefault():(null==s||s.emit("click",e),n("click",e))},S=e=>{null==s||s.emit("mouseover",e),n("mouseover",e)},B=e=>{null==s||s.emit("mouseleave",e),n("mouseleave",e)};return(t,l)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(h)),e.mergeProps(e.unref(y),{ref_key:"element",ref:r,class:{active:t.active,pressed:e.unref(g),disabled:t.disabled,current:t.current},onClickPassive:k,onMouseoverPassive:S,onMouseleavePassive:B}),{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?P(e,l)===P(t,l):I(e,t)}function I(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(!I(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],!I(e[i],t[i]))return!1;return!0}return e!=e&&t!=t}function P(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 R(e,t){if(null!=e&&t&&t.length)for(const l of t)if(j(e,l))return!0;return!1}function D(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 M={...C,...x,...w,...O,...k,...A,iconPosition:{type:String,default:n.left,validator:e=>Object.values(n).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 T={key:1,class:"vv-button__label"},z={key:1,class:"vv-button__label"},q=e.defineComponent({name:"VvButton",props:M,emits:["update:modelValue"],setup(t,{expose:l,emit:o}){const a=t,r=e.useAttrs(),u=e.useSlots(),d=o,{id:s,modifiers:v,iconPosition:f,icon:p,label:b,modelValue:h,disabled:y,toggle:k,unselectable:S}=function(t,l){const{group:o,isInGroup:a,getGroupOrLocalRef:n}=D(c),{id:i,iconPosition:r,icon:u,label:d,pressed:s}=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:s,iconPosition:r,icon:u,label:d}}(a,d),B=F(s),L=e.computed((()=>(null==r?void 0:r.name)||B.value)),V=e.ref(null);l({$el:e.computed((()=>{var e;return null==(e=V.value)?void 0:e.$el}))});const $=e.computed((()=>k.value?Array.isArray(h.value)?R(L.value,h.value):j(L.value,h.value):a.pressed)),w=m("vv-button",v,e.computed((()=>({reverse:[n.right,n.bottom].includes(f.value),column:[n.top,n.bottom].includes(f.value),"icon-only":Boolean((null==p?void 0:p.value)&&!(null==b?void 0:b.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)),a=e.computed((()=>(null==l?void 0:l.value)===i.before?o.value:void 0)),r=e.computed((()=>(null==l?void 0:l.value)===i.after?o.value:void 0)),u=e.computed((()=>(null==l?void 0:l.value)===n.left?o.value:void 0)),d=e.computed((()=>(null==l?void 0:l.value)===n.right?o.value:void 0)),s=e.computed((()=>(null==l?void 0:l.value)===n.top?o.value:void 0)),c=e.computed((()=>(null==l?void 0:l.value)===n.bottom?o.value:void 0));return{hasIcon:o,hasIconLeft:u,hasIconRight:d,hasIconTop:s,hasIconBottom:c,hasIconBefore:a,hasIconAfter:r}}(p),A=e.computed((()=>void 0!==a.value?a.value:L.value)),O=()=>{if(k.value){if(Array.isArray(h.value))return R(A.value,h.value)?void(S.value&&(h.value=h.value.filter((e=>e!==A.value)))):void h.value.push(A.value);if(A.value===h.value&&S.value)return void(h.value=a.uncheckedValue);h.value=A.value}};return(t,l)=>(e.openBlock(),e.createBlock(E,e.mergeProps({disabled:e.unref(y),pressed:e.unref($),active:t.active,type:t.type,to:t.to,href:t.href,target:t.target,rel:t.rel,ariaLabel:t.ariaLabel},{id:e.unref(B),ref_key:"element",ref:V,class:e.unref(w),onClick:O}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[t.loading?e.renderSlot(t.$slots,"loading",{key:0},(()=>[t.loadingIcon?(e.openBlock(),e.createBlock(g,{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",T,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(g,e.mergeProps({key:0},e.unref(_),{class:"vv-button__icon"}),null,16)):e.createCommentVNode("v-if",!0),e.unref(b)?(e.openBlock(),e.createElementBlock("span",z,[e.renderSlot(t.$slots,"label",{},(()=>[e.createTextVNode(e.toDisplayString(e.unref(b)),1)]))])):e.createCommentVNode("v-if",!0),e.renderSlot(t.$slots,"after")],64))]))])),_:3},16,["id","class"]))}});function H(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const U={...w,...h,...y,..._,...$,...k,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"],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:U,emits:["update:modelValue"],setup(l,{emit:o}){const a=l,n=o,i=e.useSlots(),r=function(t,l,o){const a=p(),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",U,a),{modifiers:u,id:d}=e.toRefs(a),s=F(d),c=e.computed((()=>`${s.value}-hint`)),v=m("vv-input-file",u,e.computed((()=>({dragging:$.value,loading:a.loading,valid:!0===a.valid,invalid:!0===a.invalid,"icon-before":!!a.iconLeft,"icon-after":!!a.iconRight})))),{HintSlot:f,hasHintLabelOrSlot:b,hasInvalidLabelOrSlot:h,hintSlotScope:y}=function(t,l){const o=e.computed((()=>e.isRef(t)?t.value:t)),a=e.computed((()=>H(o.value.invalidLabel))),n=e.computed((()=>H(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}}(r,i),k=t.useVModel(a,"modelValue",n),S=e.computed((()=>{var e;return k.value&&(Array.isArray(k.value)||(null==(e=k.value)?void 0:e.name))?Array.isArray(k.value)?k.value:[k.value]:[]})),B=e.computed((()=>"string"==typeof a.max?parseInt(a.max):a.max)),L=e.computed((()=>{var e;return null==(e=null==u?void 0:u.value)?void 0:e.includes("drop-area")})),V=e.computed((()=>!!a.multiple&&(!B.value||B.value-S.value.length>1))),$=e.ref(!1),w=e.ref(),_=()=>{$.value=!0},A=()=>{$.value=!1},O=e=>{var t,l;(null==(t=e.dataTransfer)?void 0:t.files)&&($.value=!1,C(null==(l=e.dataTransfer)?void 0:l.files))},x=()=>{var e;(null==(e=w.value)?void 0:e.files)&&(C(w.value.files),w.value.value="")},C=e=>{if(!a.multiple)return Array.isArray(k.value)?void(k.value=[...e]):void(k.value=e[0]);let t=[];t=!Array.isArray(k.value)&&k.value?[k.value]:k.value&&Array.isArray(k.value)?[...k.value]:t;for(const l of e){if(B.value&&t.length>=B.value)break;t.push(l)}k.value=t},N=()=>{w.value&&w.value.click()},E=e.ref(0),j=e.computed((()=>{if(0!==S.value.length)return S.value[E.value]instanceof File?URL.createObjectURL(S.value[E.value]):S.value[E.value].url}));e.onBeforeUnmount((()=>{j.value&&URL.revokeObjectURL(j.value)}));const I=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),L.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vv-input-file__drop-area",onDragenter:e.withModifiers(_,["prevent","stop"]),onDragleave:e.withModifiers(A,["prevent","stop"]),onDrop:e.withModifiers(O,["prevent","stop"]),onDragover:l[0]||(l[0]=e.withModifiers((()=>{}),["prevent","stop"])),onClick:e.withModifiers(N,["stop"])},[e.renderSlot(t.$slots,"drop-area",{},(()=>[e.createVNode(q,{modifiers:"action","aria-label":"upload",label:j.value?void 0:t.labelButton,class:e.normalizeClass([{"absolute top-8 right-8":j.value},"z-1"]),icon:j.value?V.value?"add":"edit":"image",onClick:e.withModifiers(N,["stop"])},null,8,["label","class","icon"]),e.createElementVNode("picture",J,[j.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:j.value,alt:S.value[E.value].name},null,8,K)):e.createCommentVNode("v-if",!0)])]))],32)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",Q,[t.iconLeft?(e.openBlock(),e.createBlock(g,{key:0,name:t.iconLeft},null,8,["name"])):e.createCommentVNode("v-if",!0),e.createElementVNode("input",{id:e.unref(s),ref_key:"inputEl",ref:w,placeholder:t.placeholder,"aria-describedby":e.unref(b)?c.value:void 0,"aria-invalid":t.invalid,"aria-errormessage":e.unref(h)?c.value:void 0,multiple:V.value,accept:t.accept,type:"file",name:t.name,onChange:x},null,40,W),t.iconRight?(e.openBlock(),e.createBlock(g,{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",onClick:e.withModifiers((e=>E.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(g,{name:"download"})],8,Z),e.createElementVNode("div",ee,e.toDisplayString(t.name),1),e.createElementVNode("small",te,e.toDisplayString(I(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(k.value))return void(k.value=void 0);const t=[...k.value];t.splice(e,1),k.value=t})(l)),["stop"])},null,8,le)],8,Y)))),128))]),e.createVNode(e.unref(f),{id:c.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(y))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),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";const a={prefix:"normal"};var n=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(n||{}),i=(e=>(e.before="before",e.after="after",e))(i||{}),r=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(r||{}),u=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(u||{}),d=(e=>(e._blank="_blank",e._self="_self",e._parent="_parent",e._top="_top",e))(d||{});const s=Symbol.for("volver"),c=Symbol.for("buttonGroup"),v=Symbol.for("dropdownTrigger"),f=Symbol.for("dropdownAction");function p(){return e.inject(s)}function m(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 g=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:{}},a),setup(t){const o=t,a=e.computed((()=>"string"==typeof o.rotate?parseFloat(o.rotate):o.rotate)),n=e.ref(!0),i=p(),{modifiers:r}=e.toRefs(o),u=m("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)}}),b={to:{type:[String,Object]},href:String,target:{type:String,default:void 0,validator:e=>Object.values(d).includes(e)},rel:{type:String,default:"noopener noreferrer"}},y={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}},k={loading:{type:Boolean,default:!1},loadingLabel:{type:String,default:"Loading..."}},S={disabled:{type:Boolean,default:!1}},B={active:{type:Boolean,default:!1}},L={current:{type:Boolean,default:!1}},V={pressed:{type:Boolean,default:!1}},$={label:{type:[String,Number],default:void 0}},w={readonly:{type:Boolean,default:!1}},_={modifiers:{type:[String,Array],default:void 0}},A={hintLabel:{type:String,default:""}},O={icon:{type:[String,Object],default:void 0},iconPosition:{type:String,default:i.before,validation:e=>Object.values(i).includes(e)}},C={unselectable:{type:Boolean,default:!0}},x={id:[String,Number]};n.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const N={...S,...$,...V,...B,...L,...b,type:{type:String,default:r.button,validator:e=>Object.values(r).includes(e)},ariaLabel:{type:String,default:void 0},defaultTag:{type:String,default:u.button}},E=N;const j=e.defineComponent({name:"VvAction",props:E,emits:["click","mouseover","mouseleave"],setup(t,{expose:l,emit:o}){const a=t,n=o,i=p(),r=e.ref(null);l({$el:r});const{reference:d,bus:s,aria:c,expanded:m}=e.inject(v,{});e.watch((()=>r.value),(e=>{d&&(d.value=e)}));const g=e.computed((()=>a.pressed||(null==m?void 0:m.value))),{role:b}=e.inject(f,{}),y=e.computed((()=>{switch(!0){case a.disabled:return u.button;case void 0!==a.to:return(null==i?void 0:i.nuxt)?u.nuxtLink:u.routerLink;case void 0!==a.href:return u.a;default:return a.defaultTag}})),h=e.computed((()=>{const e={...null==c?void 0:c.value,ariaPressed:!!g.value||void 0,ariaLabel:a.ariaLabel,role:null==b?void 0:b.value};switch(y.value){case u.a:return{...e,href:a.href,target:a.target,rel:a.rel};case u.routerLink:case u.nuxtLink:return{...e,to:a.to,target:a.target};case u.button:return{...e,type:a.type,disabled:a.disabled};default:return e}})),k=e=>{a.disabled?e.preventDefault():(null==s||s.emit("click",e),n("click",e))},S=e=>{null==s||s.emit("mouseover",e),n("mouseover",e)},B=e=>{null==s||s.emit("mouseleave",e),n("mouseleave",e)};return(t,l)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(y)),e.mergeProps(e.unref(h),{ref_key:"element",ref:r,class:{active:t.active,pressed:e.unref(g),disabled:t.disabled,current:t.current},onClickPassive:k,onMouseoverPassive:S,onMouseleavePassive:B}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]))])),_:3},16,["class"]))}});function I(e,t,l){return l?R(e,l)===R(t,l):P(e,t)}function P(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(!P(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],!P(e[i],t[i]))return!1;return!0}return e!=e&&t!=t}function R(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 D(e,t){if(null!=e&&t&&t.length)for(const l of t)if(I(e,l))return!0;return!1}function M(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 F={...N,...x,..._,...C,...k,...O,iconPosition:{type:String,default:n.left,validator:e=>Object.values(n).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 T=t=>e.computed((()=>String((null==t?void 0:t.value)||o.uid())));const z={key:1,class:"vv-button__label"},q={key:1,class:"vv-button__label"},H=e.defineComponent({name:"VvButton",props:F,emits:["update:modelValue"],setup(t,{expose:l,emit:o}){const a=t,r=e.useAttrs(),u=e.useSlots(),d=o,{id:s,modifiers:v,iconPosition:f,icon:p,label:b,modelValue:y,disabled:h,toggle:k,unselectable:S}=function(t,l){const{group:o,isInGroup:a,getGroupOrLocalRef:n}=M(c),{id:i,iconPosition:r,icon:u,label:d,pressed:s}=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:s,iconPosition:r,icon:u,label:d}}(a,d),B=T(s),L=e.computed((()=>(null==r?void 0:r.name)||B.value)),V=e.ref(null);l({$el:e.computed((()=>{var e;return null==(e=V.value)?void 0:e.$el}))});const $=e.computed((()=>k.value?Array.isArray(y.value)?D(L.value,y.value):I(L.value,y.value):a.pressed)),w=m("vv-button",v,e.computed((()=>({reverse:[n.right,n.bottom].includes(f.value),column:[n.top,n.bottom].includes(f.value),"icon-only":Boolean((null==p?void 0:p.value)&&!(null==b?void 0:b.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)),a=e.computed((()=>(null==l?void 0:l.value)===i.before?o.value:void 0)),r=e.computed((()=>(null==l?void 0:l.value)===i.after?o.value:void 0)),u=e.computed((()=>(null==l?void 0:l.value)===n.left?o.value:void 0)),d=e.computed((()=>(null==l?void 0:l.value)===n.right?o.value:void 0)),s=e.computed((()=>(null==l?void 0:l.value)===n.top?o.value:void 0)),c=e.computed((()=>(null==l?void 0:l.value)===n.bottom?o.value:void 0));return{hasIcon:o,hasIconLeft:u,hasIconRight:d,hasIconTop:s,hasIconBottom:c,hasIconBefore:a,hasIconAfter:r}}(p),A=e.computed((()=>void 0!==a.value?a.value:L.value)),O=()=>{if(k.value){if(Array.isArray(y.value))return D(A.value,y.value)?void(S.value&&(y.value=y.value.filter((e=>e!==A.value)))):void y.value.push(A.value);if(A.value===y.value&&S.value)return void(y.value=a.uncheckedValue);y.value=A.value}};return(t,l)=>(e.openBlock(),e.createBlock(j,e.mergeProps({disabled:e.unref(h),pressed:e.unref($),active:t.active,type:t.type,to:t.to,href:t.href,target:t.target,rel:t.rel,ariaLabel:t.ariaLabel},{id:e.unref(B),ref_key:"element",ref:V,class:e.unref(w),onClick:O}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[t.loading?e.renderSlot(t.$slots,"loading",{key:0},(()=>[t.loadingIcon?(e.openBlock(),e.createBlock(g,{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",z,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(g,e.mergeProps({key:0},e.unref(_),{class:"vv-button__icon"}),null,16)):e.createCommentVNode("v-if",!0),e.unref(b)?(e.openBlock(),e.createElementBlock("span",q,[e.renderSlot(t.$slots,"label",{},(()=>[e.createTextVNode(e.toDisplayString(e.unref(b)),1)]))])):e.createCommentVNode("v-if",!0),e.renderSlot(t.$slots,"after")],64))]))])),_:3},16,["id","class"]))}});function U(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const G={..._,...y,...h,...A,...$,...k,...w,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 J=["for"],K={class:"vv-input-file__preview"},Q=["src","alt"],W={class:"vv-input-file__wrapper"},X=["id","readonly","placeholder","aria-describedby","aria-invalid","aria-errormessage","multiple","accept","name"],Y={class:"vv-input-file__list"},Z=["onClick"],ee=["onClick"],te={class:"vv-input-file__item-name cursor-pointer"},le={class:"vv-input-file__item-info"},oe=["onClick"];return e.defineComponent({name:"VvInputFile",props:G,emits:["update:modelValue"],setup(l,{emit:o}){const a=l,n=o,i=e.useSlots(),r=function(t,l,o){const a=p(),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",G,a),{modifiers:u,id:d,readonly:s}=e.toRefs(a),c=T(d),v=e.computed((()=>`${c.value}-hint`)),f=m("vv-input-file",u,e.computed((()=>({dragging:w.value,loading:a.loading,valid:!0===a.valid,invalid:!0===a.invalid,"icon-before":!!a.iconLeft,"icon-after":!!a.iconRight})))),{HintSlot:b,hasHintLabelOrSlot:y,hasInvalidLabelOrSlot:h,hintSlotScope:k}=function(t,l){const o=e.computed((()=>e.isRef(t)?t.value:t)),a=e.computed((()=>U(o.value.invalidLabel))),n=e.computed((()=>U(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}}(r,i),S=t.useVModel(a,"modelValue",n),B=e.computed((()=>{var e;return S.value&&(Array.isArray(S.value)||(null==(e=S.value)?void 0:e.name))?Array.isArray(S.value)?S.value:[S.value]:[]})),L=e.computed((()=>"string"==typeof a.max?parseInt(a.max):a.max)),V=e.computed((()=>{var e;return null==(e=null==u?void 0:u.value)?void 0:e.includes("drop-area")})),$=e.computed((()=>!!a.multiple&&(!L.value||L.value-B.value.length>1))),w=e.ref(!1),_=e.ref(),A=()=>{w.value=!0},O=()=>{w.value=!1},C=e=>{var t,l;(null==(t=e.dataTransfer)?void 0:t.files)&&(w.value=!1,N(null==(l=e.dataTransfer)?void 0:l.files))},x=()=>{var e;(null==(e=_.value)?void 0:e.files)&&(N(_.value.files),_.value.value="")},N=e=>{if(!a.multiple)return Array.isArray(S.value)?void(S.value=[...e]):void(S.value=e[0]);let t=[];t=!Array.isArray(S.value)&&S.value?[S.value]:S.value&&Array.isArray(S.value)?[...S.value]:t;for(const l of e){if(L.value&&t.length>=L.value)break;t.push(l)}S.value=t},E=()=>{_.value&&(s.value||_.value.click())},j=e.ref(0),I=e.computed((()=>{if(0!==B.value.length)return B.value[j.value]instanceof File?URL.createObjectURL(B.value[j.value]):B.value[j.value].url}));e.onBeforeUnmount((()=>{I.value&&URL.revokeObjectURL(I.value)}));const P=e=>{if(e)return Math.floor(e/1024)};return(t,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(f))},[t.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(c)},e.toDisplayString(t.label),9,J)):e.createCommentVNode("v-if",!0),V.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vv-input-file__drop-area",onDragenter:e.withModifiers(A,["prevent","stop"]),onDragleave:e.withModifiers(O,["prevent","stop"]),onDrop:e.withModifiers(C,["prevent","stop"]),onDragover:l[0]||(l[0]=e.withModifiers((()=>{}),["prevent","stop"])),onClick:e.withModifiers(E,["stop"])},[e.renderSlot(t.$slots,"drop-area",{},(()=>[e.unref(s)?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createBlock(H,{key:0,modifiers:"action","aria-label":"upload",label:I.value?void 0:t.labelButton,class:e.normalizeClass([{"absolute top-8 right-8":I.value},"z-1"]),icon:I.value?$.value?"add":"edit":"image",onClick:e.withModifiers(E,["stop"])},null,8,["label","class","icon"])),e.createElementVNode("picture",K,[I.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:I.value,alt:B.value[j.value].name},null,8,Q)):e.createCommentVNode("v-if",!0)])]))],32)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",W,[t.iconLeft?(e.openBlock(),e.createBlock(g,{key:0,name:t.iconLeft},null,8,["name"])):e.createCommentVNode("v-if",!0),e.createElementVNode("input",{id:e.unref(c),ref_key:"inputEl",ref:_,readonly:e.unref(s),placeholder:t.placeholder,"aria-describedby":e.unref(y)?v.value:void 0,"aria-invalid":t.invalid,"aria-errormessage":e.unref(h)?v.value:void 0,multiple:$.value,accept:t.accept,type:"file",name:t.name,onChange:x},null,40,X),t.iconRight?(e.openBlock(),e.createBlock(g,{key:1,name:t.iconRight},null,8,["name"])):e.createCommentVNode("v-if",!0)]),e.createElementVNode("ul",Y,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.value,((t,l)=>(e.openBlock(),e.createElementBlock("li",{key:l,class:"vv-input-file__item",onClick:e.withModifiers((e=>j.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(g,{name:"download"})],8,ee),e.createElementVNode("div",te,e.toDisplayString(t.name),1),e.createElementVNode("small",le,e.toDisplayString(P(t.size))+" KB ",1),e.unref(s)?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"vv-input-file__item-remove",title:"Remove","aria-label":"remove-file",onClick:e.withModifiers((e=>(e=>{if(!Array.isArray(S.value))return void(S.value=void 0);const t=[...S.value];t.splice(e,1),S.value=t})(l)),["stop"])},null,8,oe))],8,Z)))),128))]),e.createVNode(e.unref(b),{id:v.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(k))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|
|
@@ -32,6 +32,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
32
32
|
multiple: BooleanConstructor;
|
|
33
33
|
iconLeft: StringConstructor;
|
|
34
34
|
iconRight: StringConstructor;
|
|
35
|
+
readonly: {
|
|
36
|
+
type: BooleanConstructor;
|
|
37
|
+
default: boolean;
|
|
38
|
+
};
|
|
35
39
|
loadingLabel: {
|
|
36
40
|
type: StringConstructor;
|
|
37
41
|
default: string;
|
|
@@ -100,6 +104,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
100
104
|
multiple: BooleanConstructor;
|
|
101
105
|
iconLeft: StringConstructor;
|
|
102
106
|
iconRight: StringConstructor;
|
|
107
|
+
readonly: {
|
|
108
|
+
type: BooleanConstructor;
|
|
109
|
+
default: boolean;
|
|
110
|
+
};
|
|
103
111
|
loadingLabel: {
|
|
104
112
|
type: StringConstructor;
|
|
105
113
|
default: string;
|
|
@@ -135,6 +143,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
135
143
|
}>> & {
|
|
136
144
|
"onUpdate:modelValue"?: ((args_0: File | undefined) => any) | undefined;
|
|
137
145
|
}, {
|
|
146
|
+
readonly: boolean;
|
|
138
147
|
valid: boolean;
|
|
139
148
|
invalid: boolean;
|
|
140
149
|
multiple: boolean;
|
|
@@ -35,6 +35,10 @@ export declare const VvInputFileProps: {
|
|
|
35
35
|
multiple: BooleanConstructor;
|
|
36
36
|
iconLeft: StringConstructor;
|
|
37
37
|
iconRight: StringConstructor;
|
|
38
|
+
readonly: {
|
|
39
|
+
type: BooleanConstructor;
|
|
40
|
+
default: boolean;
|
|
41
|
+
};
|
|
38
42
|
loadingLabel: {
|
|
39
43
|
type: StringConstructor;
|
|
40
44
|
default: string;
|
|
@@ -6952,6 +6952,7 @@ const VvInputFileProps = {
|
|
|
6952
6952
|
...HintProps,
|
|
6953
6953
|
...LabelProps,
|
|
6954
6954
|
...LoadingProps,
|
|
6955
|
+
...ReadonlyProps,
|
|
6955
6956
|
name: { type: String },
|
|
6956
6957
|
id: { type: String },
|
|
6957
6958
|
modelValue: {
|
|
@@ -6971,7 +6972,7 @@ const _hoisted_1 = ["for"];
|
|
|
6971
6972
|
const _hoisted_2 = { class: "vv-input-file__preview" };
|
|
6972
6973
|
const _hoisted_3 = ["src", "alt"];
|
|
6973
6974
|
const _hoisted_4 = { class: "vv-input-file__wrapper" };
|
|
6974
|
-
const _hoisted_5 = ["id", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "name"];
|
|
6975
|
+
const _hoisted_5 = ["id", "readonly", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "name"];
|
|
6975
6976
|
const _hoisted_6 = { class: "vv-input-file__list" };
|
|
6976
6977
|
const _hoisted_7 = ["onClick"];
|
|
6977
6978
|
const _hoisted_8 = ["onClick"];
|
|
@@ -6994,7 +6995,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
6994
6995
|
VvInputFileProps,
|
|
6995
6996
|
props
|
|
6996
6997
|
);
|
|
6997
|
-
const { modifiers, id } = toRefs(props);
|
|
6998
|
+
const { modifiers, id, readonly } = toRefs(props);
|
|
6998
6999
|
const hasId = useUniqueId(id);
|
|
6999
7000
|
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
7000
7001
|
const bemCssClasses = useModifiers(
|
|
@@ -7090,7 +7091,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7090
7091
|
if (!inputEl.value) {
|
|
7091
7092
|
return;
|
|
7092
7093
|
}
|
|
7093
|
-
|
|
7094
|
+
if (!readonly.value) {
|
|
7095
|
+
inputEl.value.click();
|
|
7096
|
+
}
|
|
7094
7097
|
};
|
|
7095
7098
|
const onClickRemoveFile = (index) => {
|
|
7096
7099
|
if (!Array.isArray(localModelValue.value)) {
|
|
@@ -7160,7 +7163,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7160
7163
|
},
|
|
7161
7164
|
[
|
|
7162
7165
|
renderSlot(_ctx.$slots, "drop-area", {}, () => [
|
|
7163
|
-
|
|
7166
|
+
!unref(readonly) ? (openBlock(), createBlock(_sfc_main$n, {
|
|
7167
|
+
key: 0,
|
|
7164
7168
|
modifiers: "action",
|
|
7165
7169
|
"aria-label": "upload",
|
|
7166
7170
|
label: !previewSrc.value ? _ctx.labelButton : void 0,
|
|
@@ -7169,7 +7173,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7169
7173
|
}, "z-1"]),
|
|
7170
7174
|
icon: !previewSrc.value ? "image" : isMultiple.value ? "add" : "edit",
|
|
7171
7175
|
onClick: withModifiers(onClick, ["stop"])
|
|
7172
|
-
}, null, 8, ["label", "class", "icon"]),
|
|
7176
|
+
}, null, 8, ["label", "class", "icon"])) : createCommentVNode("v-if", true),
|
|
7173
7177
|
createElementVNode("picture", _hoisted_2, [
|
|
7174
7178
|
previewSrc.value ? (openBlock(), createElementBlock("img", {
|
|
7175
7179
|
key: 0,
|
|
@@ -7191,6 +7195,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7191
7195
|
id: unref(hasId),
|
|
7192
7196
|
ref_key: "inputEl",
|
|
7193
7197
|
ref: inputEl,
|
|
7198
|
+
readonly: unref(readonly),
|
|
7194
7199
|
placeholder: _ctx.placeholder,
|
|
7195
7200
|
"aria-describedby": unref(hasHintLabelOrSlot) ? hasHintId.value : void 0,
|
|
7196
7201
|
"aria-invalid": _ctx.invalid,
|
|
@@ -7239,13 +7244,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7239
7244
|
1
|
|
7240
7245
|
/* TEXT */
|
|
7241
7246
|
),
|
|
7242
|
-
|
|
7247
|
+
!unref(readonly) ? (openBlock(), createElementBlock("button", {
|
|
7248
|
+
key: 0,
|
|
7243
7249
|
type: "button",
|
|
7244
7250
|
class: "vv-input-file__item-remove",
|
|
7245
7251
|
title: "Remove",
|
|
7246
7252
|
"aria-label": "remove-file",
|
|
7247
7253
|
onClick: withModifiers(($event) => onClickRemoveFile(index), ["stop"])
|
|
7248
|
-
}, null, 8, _hoisted_11)
|
|
7254
|
+
}, null, 8, _hoisted_11)) : createCommentVNode("v-if", true)
|
|
7249
7255
|
], 8, _hoisted_7);
|
|
7250
7256
|
}),
|
|
7251
7257
|
128
|