UNPKG

vue-splitjs

Version:

tiny unopinionated utility for resizeable split views, based on split.js

3 lines 12.6 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("VueSplitjs",[],t):"object"==typeof exports?exports.VueSplitjs=t():e.VueSplitjs=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/dist/",t(t.s=1)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9),i=function(e){return e&&e.__esModule?e:{default:e}}(r);t.default={props:{elements:{type:Array,required:!0,validator:function(e){var t=e.every(function(e){return"string"==typeof e});return t||console.error('VueSplitJs: Invalid elements - "'+e+'". Must be array of strings'),t}},direction:{type:String,default:"horizontal",validator:function(e){var t=["horizontal","vertical"],n=t.includes(e);return n||console.error('VueSplitJs: Invalid direction - "'+e+'". Possible values are "horizontal" or "vertical"'),n}},sizes:{type:Array,default:null,validator:function(e){var t=e.every(function(e){return"number"==typeof e});return t||console.error('VueSplitJs: Invalid sizes - "'+e+'". Must be array of numbers'),t}},minSize:{type:[Number,Array],default:100},gutterSize:{type:Number,default:10},snapOffset:{type:Number,default:30},cursor:{type:String,default:"grabbing"}},mounted:function(){(0,i.default)(this.elements,{direction:this.direction,sizes:this.sizes,minSize:this.minSize,gutterSize:this.gutterSize,snapOffset:this.snapOffset,cursor:this.cursor,onDrag:this.onDrag,onDragStart:this.onDragStart,onDragEnd:this.onDragEnd})},methods:{onDrag:function(){this.$emit("onDrag")},onDragEnd:function(){this.$emit("onDragEnd")},onDragStart:function(){this.$emit("onDragStart")}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),i=function(e){return e&&e.__esModule?e:{default:e}}(r);t.default=i.default},function(e,t,n){"use strict";function r(e){n(3)}Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),o=n.n(i);for(var s in i)"default"!==s&&function(e){n.d(t,e,function(){return i[e]})}(s);var a=n(10),u=n(8),l=r,c=u(o.a,a.a,!1,l,null,null);t.default=c.exports},function(e,t,n){var r=n(4);"string"==typeof r&&(r=[[e.i,r,""]]),r.locals&&(e.exports=r.locals);n(6)("3a0827fc",r,!0,{})},function(e,t,n){t=e.exports=n(5)(!1),t.push([e.i,'.split-container{height:100%}.split-container>*{position:relative;overflow-y:hidden}.split-container--horizontal{display:flex}.gutter{background-color:#eee;background-repeat:no-repeat;background-position:50%}.gutter.gutter-vertical{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAFAQMAAABo7865AAAABlBMVEVHcEzMzMzyAv2sAAAAAXRSTlMAQObYZgAAABBJREFUeF5jOAMEEAIEEFwAn3kMwcB6I2AAAAAASUVORK5CYII=");cursor:ns-resize}.gutter.gutter-horizontal{float:left;cursor:ew-resize;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==")}.split{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;overflow-y:auto;overflow-x:hidden}',""])},function(e,t){function n(e,t){var n=e[1]||"",i=e[3];if(!i)return n;if(t&&"function"==typeof btoa){var o=r(i);return[n].concat(i.sources.map(function(e){return"/*# sourceURL="+i.sourceRoot+e+" */"})).concat([o]).join("\n")}return[n].join("\n")}function r(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var r=n(t,e);return t[2]?"@media "+t[2]+"{"+r+"}":r}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},i=0;i<this.length;i++){var o=this[i][0];"number"==typeof o&&(r[o]=!0)}for(i=0;i<e.length;i++){var s=e[i];"number"==typeof s[0]&&r[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="("+s[2]+") and ("+n+")"),t.push(s))}},t}},function(e,t,n){function r(e){for(var t=0;t<e.length;t++){var n=e[t],r=c[n.id];if(r){r.refs++;for(var i=0;i<r.parts.length;i++)r.parts[i](n.parts[i]);for(;i<n.parts.length;i++)r.parts.push(o(n.parts[i]));r.parts.length>n.parts.length&&(r.parts.length=n.parts.length)}else{for(var s=[],i=0;i<n.parts.length;i++)s.push(o(n.parts[i]));c[n.id]={id:n.id,refs:1,parts:s}}}}function i(){var e=document.createElement("style");return e.type="text/css",f.appendChild(e),e}function o(e){var t,n,r=document.querySelector("style["+m+'~="'+e.id+'"]');if(r){if(g)return h;r.parentNode.removeChild(r)}if(y){var o=p++;r=d||(d=i()),t=s.bind(null,r,o,!1),n=s.bind(null,r,o,!0)}else r=i(),t=a.bind(null,r),n=function(){r.parentNode.removeChild(r)};return t(e),function(r){if(r){if(r.css===e.css&&r.media===e.media&&r.sourceMap===e.sourceMap)return;t(e=r)}else n()}}function s(e,t,n,r){var i=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=b(t,i);else{var o=document.createTextNode(i),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(o,s[t]):e.appendChild(o)}}function a(e,t){var n=t.css,r=t.media,i=t.sourceMap;if(r&&e.setAttribute("media",r),v.ssrId&&e.setAttribute(m,t.id),i&&(n+="\n/*# sourceURL="+i.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */"),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var u="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!u)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var l=n(7),c={},f=u&&(document.head||document.getElementsByTagName("head")[0]),d=null,p=0,g=!1,h=function(){},v=null,m="data-vue-ssr-id",y="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());e.exports=function(e,t,n,i){g=n,v=i||{};var o=l(e,t);return r(o),function(t){for(var n=[],i=0;i<o.length;i++){var s=o[i],a=c[s.id];a.refs--,n.push(a)}t?(o=l(e,t),r(o)):o=[];for(var i=0;i<n.length;i++){var a=n[i];if(0===a.refs){for(var u=0;u<a.parts.length;u++)a.parts[u]();delete c[a.id]}}}};var b=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}()},function(e,t){e.exports=function(e,t){for(var n=[],r={},i=0;i<t.length;i++){var o=t[i],s=o[0],a=o[1],u=o[2],l=o[3],c={id:e+":"+i,css:a,media:u,sourceMap:l};r[s]?r[s].parts.push(c):n.push(r[s]={id:s,parts:[c]})}return n}},function(e,t){e.exports=function(e,t,n,r,i,o){var s,a=e=e||{},u=typeof e.default;"object"!==u&&"function"!==u||(s=e,a=e.default);var l="function"==typeof a?a.options:a;t&&(l.render=t.render,l.staticRenderFns=t.staticRenderFns,l._compiled=!0),n&&(l.functional=!0),i&&(l._scopeId=i);var c;if(o?(c=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(o)},l._ssrRegister=c):r&&(c=r),c){var f=l.functional,d=f?l.render:l.beforeCreate;f?(l._injectStyles=c,l.render=function(e,t){return c.call(t),d(e,t)}):l.beforeCreate=d?[].concat(d,c):[c]}return{esModule:s,exports:a,options:l}}},function(e,t,n){/*! Split.js - v1.3.5 */ !function(t,n){e.exports=n()}(0,function(){"use strict";var e=window,t=e.document,n="addEventListener",r="removeEventListener",i="getBoundingClientRect",o=function(){return!1},s=e.attachEvent&&!e[n],a=["","-webkit-","-moz-","-o-"].filter(function(e){var n=t.createElement("div");return n.style.cssText="width:"+e+"calc(9px)",!!n.style.length}).shift()+"calc",u=function(e){return"string"==typeof e||e instanceof String?t.querySelector(e):e};return function(l,c){function f(e,t,n){var r=R(z,t,n);Object.keys(r).forEach(function(t){return e.style[t]=r[t]})}function d(e,t){var n=k(z,t);Object.keys(n).forEach(function(t){return e.style[t]=n[t]})}function p(e){var t=E[this.a],n=E[this.b],r=t.size+n.size;t.size=e/this.size*r,n.size=r-e/this.size*r,f(t.element,t.size,this.aGutterSize),f(n.element,n.size,this.bGutterSize)}function g(e){var t;this.dragging&&(t="touches"in e?e.touches[0][S]-this.start:e[S]-this.start,t<=E[this.a].minSize+j+this.aGutterSize?t=E[this.a].minSize+this.aGutterSize:t>=this.size-(E[this.b].minSize+j+this.bGutterSize)&&(t=this.size-(E[this.b].minSize+this.bGutterSize)),p.call(this,t),c.onDrag&&c.onDrag())}function h(){var e=E[this.a].element,t=E[this.b].element;this.size=e[i]()[z]+t[i]()[z]+this.aGutterSize+this.bGutterSize,this.start=e[i]()[A]}function v(){var t=this,n=E[t.a].element,i=E[t.b].element;t.dragging&&c.onDragEnd&&c.onDragEnd(),t.dragging=!1,e[r]("mouseup",t.stop),e[r]("touchend",t.stop),e[r]("touchcancel",t.stop),t.parent[r]("mousemove",t.move),t.parent[r]("touchmove",t.move),delete t.stop,delete t.move,n[r]("selectstart",o),n[r]("dragstart",o),i[r]("selectstart",o),i[r]("dragstart",o),n.style.userSelect="",n.style.webkitUserSelect="",n.style.MozUserSelect="",n.style.pointerEvents="",i.style.userSelect="",i.style.webkitUserSelect="",i.style.MozUserSelect="",i.style.pointerEvents="",t.gutter.style.cursor="",t.parent.style.cursor=""}function m(t){var r=this,i=E[r.a].element,s=E[r.b].element;!r.dragging&&c.onDragStart&&c.onDragStart(),t.preventDefault(),r.dragging=!0,r.move=g.bind(r),r.stop=v.bind(r),e[n]("mouseup",r.stop),e[n]("touchend",r.stop),e[n]("touchcancel",r.stop),r.parent[n]("mousemove",r.move),r.parent[n]("touchmove",r.move),i[n]("selectstart",o),i[n]("dragstart",o),s[n]("selectstart",o),s[n]("dragstart",o),i.style.userSelect="none",i.style.webkitUserSelect="none",i.style.MozUserSelect="none",i.style.pointerEvents="none",s.style.userSelect="none",s.style.webkitUserSelect="none",s.style.MozUserSelect="none",s.style.pointerEvents="none",r.gutter.style.cursor=O,r.parent.style.cursor=O,h.call(r)}function y(e){e.forEach(function(t,n){if(n>0){var r=N[n-1],i=E[r.a],o=E[r.b];i.size=e[n-1],o.size=t,f(i.element,i.size,r.aGutterSize),f(o.element,o.size,r.bGutterSize)}})}function b(){N.forEach(function(e){e.parent.removeChild(e.gutter),E[e.a].element.style[z]="",E[e.b].element.style[z]=""})}void 0===c&&(c={});var z,S,A,E,x=u(l[0]).parentNode,_=e.getComputedStyle(x).flexDirection,M=c.sizes||l.map(function(){return 100/l.length}),w=void 0!==c.minSize?c.minSize:100,U=Array.isArray(w)?w:l.map(function(){return w}),C=void 0!==c.gutterSize?c.gutterSize:10,j=void 0!==c.snapOffset?c.snapOffset:30,D=c.direction||"horizontal",O=c.cursor||("horizontal"===D?"ew-resize":"ns-resize"),G=c.gutter||function(e,n){var r=t.createElement("div");return r.className="gutter gutter-"+n,r},R=c.elementStyle||function(e,t,n){var r={};return"string"==typeof t||t instanceof String?r[e]=t:r[e]=s?t+"%":a+"("+t+"% - "+n+"px)",r},k=c.gutterStyle||function(e,t){return n={},n[e]=t+"px",n;var n};"horizontal"===D?(z="width","clientWidth",S="clientX",A="left","paddingLeft"):"vertical"===D&&(z="height","clientHeight",S="clientY",A="top","paddingTop");var N=[];return E=l.map(function(e,t){var r,o={element:u(e),size:M[t],minSize:U[t]};if(t>0&&(r={a:t-1,b:t,dragging:!1,isFirst:1===t,isLast:t===l.length-1,direction:D,parent:x},r.aGutterSize=C,r.bGutterSize=C,r.isFirst&&(r.aGutterSize=C/2),r.isLast&&(r.bGutterSize=C/2),"row-reverse"===_||"column-reverse"===_)){var a=r.a;r.a=r.b,r.b=a}if(!s&&t>0){var c=G(t,D);d(c,C),c[n]("mousedown",m.bind(r)),c[n]("touchstart",m.bind(r)),x.insertBefore(c,o.element),r.gutter=c}0===t||t===l.length-1?f(o.element,o.size,C/2):f(o.element,o.size,C);var p=o.element[i]()[z];return p<o.minSize&&(o.minSize=p),t>0&&N.push(r),o}),s?{setSizes:y,destroy:b}:{setSizes:y,getSizes:function(){return E.map(function(e){return e.size})},collapse:function(e){if(e===N.length){var t=N[e-1];h.call(t),s||p.call(t,t.size-t.bGutterSize)}else{var n=N[e];h.call(n),s||p.call(n,n.aGutterSize)}},destroy:b}}})},function(e,t,n){"use strict";var r=function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{staticClass:"split-container",class:{"split-container--horizontal":"horizontal"===e.direction}},[e._t("default")],2)},i=[],o={render:r,staticRenderFns:i};t.a=o}])}); //# sourceMappingURL=vue-splitjs.min.js.map