@zeit-ui/vue
Version:
A popular UI framework for Vue
2 lines • 7.65 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["collapse"]=e():t["collapse"]=e()})("undefined"!==typeof self?self:this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},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 r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},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")}({2310:function(t,e,n){"use strict";var r=n("2f80"),i=n.n(r);i.a},"2f80":function(t,e,n){},"7ce0":function(t,e,n){},ba8f:function(t,e,n){"use strict";var r=n("7ce0"),i=n.n(r);i.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(r){var t,e=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(r.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 r={};n.r(r),n.d(r,"warning",(function(){return u})),n.d(r,"error",(function(){return c}));var i,o={};(n.r(o),n.d(o,"ZiTransitionExpand",(function(){return y})),"undefined"!==typeof window)&&(n("f6fd"),(i=window.document.currentScript)&&(i=i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(n.p=i[1]));var a=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"zi-collapse-group"},[t._t("default")],2)},s=[],l=function(t){var e=t.getBoundingClientRect(),n=window.getComputedStyle(t),r=n.width,i=n.height,o=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:o("".concat(r),e.width),height:o("".concat(i),e.height)}},u=function(t){console.warn(t)},c=function(t){console.error(t)},d=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)},f=[],p={name:"zi-transition-expand",methods:{enter:function(t){var e=l(t),n=e.width;t.style.width="".concat(n,"px"),t.style.position="absolute",t.style.visibility="hidden",t.style.height="auto";var r=l(t),i=r.height;t.style.width=null,t.style.position=null,t.style.visibility=null,t.style.height=0,l(t);var o=setTimeout((function(){t.style.height="".concat(i,"px"),clearTimeout(o)}),0)},afterEnter:function(t){t.style.height="auto"},leave:function(t){var e=l(t),n=e.height;t.style.height="".concat(n,"px"),l(t);var r=setTimeout((function(){t.style.height=0,clearTimeout(r)}),0)},afterLeave:function(t){t.style.height=null}}},h=p;n("ba8f");function m(t,e,n,r,i,o,a,s){var l,u="function"===typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),r&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),a?(l=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__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},u._ssrRegister=l):i&&(l=s?function(){i.call(this,this.$root.$options.shadowRoot)}:i),l)if(u.functional){u._injectStyles=l;var c=u.render;u.render=function(t,e){return l.call(e),c(t,e)}}else{var d=u.beforeCreate;u.beforeCreate=d?[].concat(d,l):[l]}return{exports:t,options:u}}var v=m(h,d,f,!1,null,null,null),y=v.exports;new Map;function g(t){return x(t)||w(t)||_(t)||b()}function b(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _(t,e){if(t){if("string"===typeof t)return A(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?A(t,e):void 0}}function w(t){if("undefined"!==typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}function x(t){if(Array.isArray(t))return A(t)}function A(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var S={name:"zi-collapse",data:function(){return{privateModel:"",privateModelArr:[]}},props:{value:[Array,String,Number],accordion:Boolean},computed:{model:{get:function(){return void 0!==this.value?this.value:this.modelAlias},set:function(t){this.modelAlias=t,this.$emit("input",t)}}},mounted:function(){if(this.modelAlias=this.accordion?this.privateModel:this.privateModelArr,void 0!==this.value){var t=Array.isArray(this.value);return this.accordion&&t?r.error("[value/v-model] cannot be an Array in [accordion] mode."):this.accordion||t?void 0:r.error("[value/v-model] must be an Array.")}},methods:{setValue:function(t,e){Array.isArray(this.modelAlias)?this.model=e?g(new Set(this.modelAlias.concat([t]))):this.modelAlias.filter((function(e){return e!==t})):this.model=e?t:null}}},j=S,C=(n("2310"),m(j,a,s,!1,null,null,null)),$=C.exports,E=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"zi-collapse",class:{shadow:t.shadow}},[n("div",[n("div",{staticClass:"zi-collapse-title",on:{click:t.clickHandler}},[n("h3",[t._v(t._s(t.title))]),n("downIcon",{staticClass:"icon",class:{reverse:t.model}})],1),n("div",{staticClass:"zi-collapse-subtitle",domProps:{innerHTML:t._s(t.subtitle)}})]),n("zi-transition-expand",[t.model?n("div",{staticClass:"zi-collapse-content"},[n("div",{staticClass:"content"},[t._t("default")],2)]):t._e()])],1)},T=[],M=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("svg",{attrs:{viewBox:"0 0 22 12",fill:"none"}},[n("path",{attrs:{d:"M1 1L11 11L21 1",stroke:"var(--geist-foreground)","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}})])},O=[],z={name:"zi-down-icon"},N=z,k=m(N,M,O,!1,null,null,null),P=k.exports,I=o.ZiTransitionExpand,R={name:"zi-collapse-item",components:{downIcon:P,ZiTransitionExpand:I},data:function(){return{privateModel:!1}},props:{title:{type:[String,Number],required:!0},name:{type:[String,Number],default:function(){return this.title}},shadow:Boolean,subtitle:String},mounted:function(){if(!this.inGroup)return r.error("".concat(this.$options.name," required parent component: [zi-collapse]"))},computed:{model:{get:function(){var t=this;return!!this.inGroup&&(Array.isArray(this._group.model)?!!this._group.model.find((function(e){return e===t.name})):this._group.model===this.name)},set:function(t){this._group.setValue(this.name,t)}},inGroup:function(){var t=this.$parent;while(t){if("zi-collapse"===t.$options.name)return this._group=t,!0;t=t.$parent}return!1}},methods:{clickHandler:function(){this.model=!this.model}}},B=R,L=m(B,E,T,!1,null,null,null),V=L.exports;$.install=function(t){t.component($.name,$),t.component(V.name,V)};var G=$;e["default"]=G}})["default"]}));
//# sourceMappingURL=collapse.umd.min.js.map