@zeit-ui/vue
Version:
A popular UI framework for Vue
2 lines • 10.3 kB
JavaScript
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["files"]=e():t["files"]=e()})("undefined"!==typeof self?self:this,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="fb15")}({"0617":function(t,e,n){},"6fcf":function(t,e,n){"use strict";var i=n("b894"),r=n.n(i);r.a},"7ce0":function(t,e,n){},"80ea":function(t,e,n){"use strict";var i=n("948a"),r=n.n(i);r.a},"8ef1":function(t,e,n){"use strict";var i=n("0617"),r=n.n(i);r.a},"948a":function(t,e,n){},b894:function(t,e,n){},ba8f:function(t,e,n){"use strict";var i=n("7ce0"),r=n.n(i);r.a},f6fd:function(t,e){(function(t){var e="currentScript",n=t.getElementsByTagName("script");e in t||Object.defineProperty(t,e,{get:function(){try{throw new Error}catch(i){var t,e=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(i.stack)||[!1])[1];for(t in n)if(n[t].src==e||"interactive"==n[t].readyState)return n[t];return null}}})})(document)},fb15:function(t,e,n){"use strict";n.r(e);var i={};n.r(i),n.d(i,"warning",(function(){return c})),n.d(i,"error",(function(){return u}));var r,s={};(n.r(s),n.d(s,"ZiTransitionExpand",(function(){return y})),"undefined"!==typeof window)&&(n("f6fd"),(r=window.document.currentScript)&&(r=r.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(n.p=r[1]));var o=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"files"},[n("zi-files-item",{attrs:{files:t.files,"default-expand":t.defaultExpand},on:{"file-click":t.fileClickHandler}})],1)},l=[],a=function(t){var e=t.getBoundingClientRect(),n=window.getComputedStyle(t),i=n.width,r=n.height,s=function(t,e){if(!t)return 0;var n=t.includes("px")?+t.split("px")[0]:t.includes("%")?+t.split("%")[0]*e*.01:t;return Number.isNaN(+n)?0:+n};return{width:s("".concat(i),e.width),height:s("".concat(r),e.height)}},c=function(t){console.warn(t)},u=function(t){console.error(t)},f=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("transition",{attrs:{name:"expand"},on:{enter:t.enter,"after-enter":t.afterEnter,leave:t.leave}},[t._t("default")],2)},d=[],p={name:"zi-transition-expand",methods:{enter:function(t){var e=a(t),n=e.width;t.style.width="".concat(n,"px"),t.style.position="absolute",t.style.visibility="hidden",t.style.height="auto";var i=a(t),r=i.height;t.style.width=null,t.style.position=null,t.style.visibility=null,t.style.height=0,a(t);var s=setTimeout((function(){t.style.height="".concat(r,"px"),clearTimeout(s)}),0)},afterEnter:function(t){t.style.height="auto"},leave:function(t){var e=a(t),n=e.height;t.style.height="".concat(n,"px"),a(t);var i=setTimeout((function(){t.style.height=0,clearTimeout(i)}),0)},afterLeave:function(t){t.style.height=null}}},h=p;n("ba8f");function m(t,e,n,i,r,s,o,l){var a,c="function"===typeof t?t.options:t;if(e&&(c.render=e,c.staticRenderFns=n,c._compiled=!0),i&&(c.functional=!0),s&&(c._scopeId="data-v-"+s),o?(a=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(o)},c._ssrRegister=a):r&&(a=l?function(){r.call(this,this.$root.$options.shadowRoot)}:r),a)if(c.functional){c._injectStyles=a;var u=c.render;c.render=function(t,e){return a.call(e),u(t,e)}}else{var f=c.beforeCreate;c.beforeCreate=f?[].concat(f,a):[a]}return{exports:t,options:c}}var v=m(h,f,d,!1,null,null,null),y=v.exports,g=(new Map,{name:"zi-files",props:{files:{type:Array,default:function(){return[]},validator:function(t){var e=t.filter((function(t){return!!t.name}));return e.length===t.length||(i.error("[zi-files] prop: Every item in the `files` must contain a `name`"),i.error('e.g. :files=[{ name: "", type: "file", "files": [] }]'),!1)}},defaultExpand:Boolean},methods:{fileClickHandler:function(t){this.$emit("file-click",t)}}}),x=g,b=(n("8ef1"),m(x,o,l,!1,null,"3f835a35",null)),_=b.exports,w=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",t._l(t.files,(function(e,i){return e?n("li",{key:e.name+i,staticClass:"item",class:{"has-children":t.isDir(e.type)&&!t.isTop}},[t.isDir(e.type)?n("FilesStatus",{staticClass:"status",style:t.statusStyle,attrs:{"is-expand":t.isExpand(i)},on:{click:function(e){return t.toggleExpand(i)}}}):t._e(),n("a",{staticClass:"link",on:{click:function(n){t.toggleExpand(i,!t.isDir(e.type),e)}}},[t._l(t.depth,(function(r){return t.isTop?t._e():n("span",{key:"line-"+r,staticClass:"line",class:t.lineClasses(i,e,r)})})),n("FilesIcon",{staticClass:"icon",attrs:{"is-dir":t.isDir(e.type)}}),n("span",[t._v(t._s(e.name))])],2),n("zi-transition-expand",[e.files&&t.isExpand(i)?n("zi-files-item",{attrs:{files:e.files,depth:t.depth+1,"default-expand":t.defaultExpand},on:{"file-click":function(n){return t.childClickHandler(n,e)}}}):t._e()],1)],1):t._e()})),0)},E=[],k=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"icon-box"},[t.isDir?n("DirectoryIcon",{staticClass:"icon"}):n("FileIcon",{staticClass:"icon-file"})],1)},C=[],O=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("svg",t._g(t._b({style:t.styles,attrs:{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5"}},"svg",t.attrs,!1),t.listeners),[n("path",{attrs:{d:"M13 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V9z"}}),n("path",{attrs:{d:"M13 2v7h7"}})])},j=[];const $={size:[String,Number],color:String},S={listeners(){return{...this.$listeners}},styles(){const t=this.size?{height:this.size,width:this.size}:{};return{...t,color:this.color||"currentColor"}},attrs(){return{viewBox:"0 0 24 24","shape-rendering":"geometricPrecision",width:24,height:24,...this.$attrs}}};var T={name:"file-icon",props:$,computed:S},P=T,z=m(P,O,j,!1,null,null,null),D=z.exports,M=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("svg",t._g(t._b({style:t.styles,attrs:{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5"}},"svg",t.attrs,!1),t.listeners),[n("path",{attrs:{d:"M2.707 7.454V5.62c0-.895.762-1.62 1.702-1.62h4.843c.451 0 .884.17 1.204.474l.49.467c.126.12.296.186.473.186h8.399c.94 0 1.55.695 1.55 1.59v.737m-18.661 0h-.354a.344.344 0 00-.353.35l.508 11.587c.015.34.31.609.668.609h17.283c.358 0 .652-.269.667-.61L22 7.805a.344.344 0 00-.353-.35h-.278m-18.662 0h18.662"}})])},B=[],N={name:"folder-icon",props:$,computed:S},F=N,I=m(F,M,B,!1,null,null,null),R=I.exports,H={name:"zi-files-icon",components:{FileIcon:D,DirectoryIcon:R},props:{isDir:Boolean}},V=H,Z=(n("6fcf"),m(V,k,C,!1,null,"148adff2",null)),A=Z.exports,L=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("svg",t._g({attrs:{width:"11px",height:"11px",viewBox:"0 0 11 11"}},t.listeners),[n("g",{attrs:{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"}},[n("rect",{attrs:{x:"0",y:"0",width:"11",height:"11",rx:"1.5"}}),n("rect",{attrs:{stroke:"var(--geist-foreground)","stroke-width":"0.8",x:"1",y:"1",width:"9",height:"9",rx:"1.5"}}),n("path",{attrs:{d:t.isExpand?"M3.5 5.5h4":"M3.5 5.5h4m-2-2v4",stroke:"var(--geist-foreground)","stroke-width":"0.8"}})])])},U=[];function X(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function q(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?X(Object(n),!0).forEach((function(e){G(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function G(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var J={name:"zi-files-status",props:{isExpand:Boolean},computed:{listeners:function(){return q({},this.$listeners)}}},K=J,Q=m(K,L,U,!1,null,null,null),W=Q.exports,Y=s.ZiTransitionExpand,tt={name:"zi-files-item",components:{FilesIcon:A,FilesStatus:W,ZiTransitionExpand:Y},props:{files:{type:Array,default:function(){return[]}},depth:{type:Number,default:0},defaultExpand:Boolean},data:function(){return{expands:{}}},computed:{isTop:function(){return 0===this.depth},statusStyle:function(){if(0===this.depth)return"left: ".concat(-24,"px;");var t=34*this.depth-28;return"left: ".concat(t,"px;")}},methods:{isDir:function(t){return"file"!==t},lineClasses:function(t,e,n){var i=this.depth>0&&n!==this.depth;return 1===this.files.length?{only:!0}:0!==t||i?t!==this.files.length-1||e.files||i?{}:{last:!0}:{first:!0}},toggleExpand:function(t,e,n){if(e)return this.fileClick(n);this.$set(this.expands,t,!this.expands[t])},isExpand:function(t){return void 0===this.expands[t]&&this.$set(this.expands,t,!!this.defaultExpand),!!this.expands[t]},fileClick:function(t){this.$emit("file-click",{name:t.name,trigger:t})},childClickHandler:function(t,e){var n="".concat(e.name,"/").concat(t.name);this.$emit("file-click",{name:n,trigger:t.trigger})}}},et=tt,nt=(n("80ea"),m(et,w,E,!1,null,"5b5ad992",null)),it=nt.exports;_.install=function(t){t.component(_.name,_),t.component(it.name,it)};var rt=_;e["default"]=rt}})["default"]}));
//# sourceMappingURL=files.umd.min.js.map