@uiw/react-split
Advanced tools
Comparing version
@@ -233,3 +233,3 @@ "use strict"; | ||
children: [BarCom, /*#__PURE__*/_react.default.cloneElement(element, (0, _objectSpread2.default)({}, props))] | ||
}); | ||
}, idx); | ||
}) | ||
@@ -236,0 +236,0 @@ })); |
@@ -438,3 +438,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
;// CONCATENATED MODULE: ./src/index.tsx | ||
var _excluded=["prefixCls","className","children","mode","visiable","renderBar","lineBar","disable","onDragEnd","onDragging"];var Split=/*#__PURE__*/function(_React$Component){_inherits(Split,_React$Component);var _super=_createSuper(Split);function Split(props){var _this;_classCallCheck(this,Split);_this=_super.call(this,props);_this.state={dragging:false};_this.warpper=void 0;_this.paneNumber=void 0;_this.startX=void 0;_this.startY=void 0;_this.move=void 0;_this.target=void 0;_this.boxWidth=void 0;_this.boxHeight=void 0;_this.preWidth=void 0;_this.nextWidth=void 0;_this.preHeight=void 0;_this.nextHeight=void 0;_this.preSize=void 0;_this.nextSize=void 0;_this.onDragEnd=_this.onDragEnd.bind(_assertThisInitialized(_this));_this.onDragging=_this.onDragging.bind(_assertThisInitialized(_this));return _this;}_createClass(Split,[{key:"componentWillUnmount",value:function componentWillUnmount(){this.removeEvent();}},{key:"removeEvent",value:function removeEvent(){window.removeEventListener('mousemove',this.onDragging,false);window.removeEventListener('mouseup',this.onDragEnd,false);}},{key:"onMouseDown",value:function onMouseDown(paneNumber,env){if(!env.target||!this.warpper){return;}this.paneNumber=paneNumber;this.startX=env.clientX;this.startY=env.clientY;this.move=true;this.target=env.target.parentNode;var prevTarget=this.target.previousElementSibling;var nextTarget=this.target.nextElementSibling;this.boxWidth=this.warpper.clientWidth;this.boxHeight=this.warpper.clientHeight;if(prevTarget){this.preWidth=prevTarget.clientWidth;this.preHeight=prevTarget.clientHeight;}if(nextTarget){this.nextWidth=nextTarget.clientWidth;this.nextHeight=nextTarget.clientHeight;}window.addEventListener('mousemove',this.onDragging);window.addEventListener('mouseup',this.onDragEnd,false);this.setState({dragging:true});}},{key:"onDragging",value:function onDragging(env){if(!this.move){return;}if(!this.state.dragging){this.setState({dragging:true});}var _this$props=this.props,mode=_this$props.mode,onDragging=_this$props.onDragging;var nextTarget=this.target.nextElementSibling;var prevTarget=this.target.previousElementSibling;var x=env.clientX-this.startX;var y=env.clientY-this.startY;this.preSize=0;this.nextSize=0;if(mode==='horizontal'){this.preSize=this.preWidth+x>-1?this.preWidth+x:0;this.nextSize=this.nextWidth-x>-1?this.nextWidth-x:0;if(this.preSize===0||this.nextSize===0){return;}this.preSize=(this.preSize/this.boxWidth>=1?1:this.preSize/this.boxWidth)*100;this.nextSize=(this.nextSize/this.boxWidth>=1?1:this.nextSize/this.boxWidth)*100;if(prevTarget&&nextTarget){prevTarget.style.width="".concat(this.preSize,"%");nextTarget.style.width="".concat(this.nextSize,"%");}}if(mode==='vertical'&&this.preHeight+y>-1&&this.nextHeight-y>-1){this.preSize=this.preHeight+y>-1?this.preHeight+y:0;this.nextSize=this.nextHeight-y>-1?this.nextHeight-y:0;this.preSize=(this.preSize/this.boxHeight>=1?1:this.preSize/this.boxHeight)*100;this.nextSize=(this.nextSize/this.boxHeight>=1?1:this.nextSize/this.boxHeight)*100;if(this.preSize===0||this.nextSize===0){return;}if(prevTarget&&nextTarget){prevTarget.style.height="".concat(this.preSize,"%");nextTarget.style.height="".concat(this.nextSize,"%");}}onDragging&&onDragging(this.preSize,this.nextSize,this.paneNumber);}},{key:"onDragEnd",value:function onDragEnd(){var onDragEnd=this.props.onDragEnd;this.move=false;onDragEnd&&onDragEnd(this.preSize,this.nextSize,this.paneNumber);this.removeEvent();this.setState({dragging:false});}},{key:"render",value:function render(){var _this2=this;var _this$props2=this.props,prefixCls=_this$props2.prefixCls,className=_this$props2.className,children=_this$props2.children,mode=_this$props2.mode,visiable=_this$props2.visiable,renderBar=_this$props2.renderBar,lineBar=_this$props2.lineBar,disable=_this$props2.disable,onDragEnd=_this$props2.onDragEnd,onDragging=_this$props2.onDragging,other=_objectWithoutProperties(_this$props2,_excluded);var dragging=this.state.dragging;var cls=[prefixCls,className,"".concat(prefixCls,"-").concat(mode),dragging?'dragging':null].filter(Boolean).join(' ').trim();var child=external_root_React_commonjs2_react_commonjs_react_amd_react_default().Children.toArray(children);return/*#__PURE__*/(0,jsx_runtime.jsx)("div",_objectSpread2(_objectSpread2({className:cls},other),{},{ref:function ref(node){return _this2.warpper=node;},children:external_root_React_commonjs2_react_commonjs_react_amd_react_default().Children.map(child,function(element,idx){var props=Object.assign({},element.props,{className:["".concat(prefixCls,"-pane"),element.props.className].filter(Boolean).join(' ').trim(),style:_objectSpread2({},element.props.style)});var visiableBar=visiable===true||visiable&&visiable.includes(idx+1)||false;var barProps={className:["".concat(prefixCls,"-bar"),lineBar?"".concat(prefixCls,"-line-bar"):null,!lineBar?"".concat(prefixCls,"-large-bar"):null].filter(Boolean).join(' ').trim()};if(disable===true||disable&&disable.includes(idx+1)){barProps.className=[barProps.className,disable?'disable':null].filter(Boolean).join(' ').trim();}var BarCom=null;if(idx!==0&&visiableBar&&renderBar){BarCom=renderBar(_objectSpread2(_objectSpread2({},barProps),{},{onMouseDown:_this2.onMouseDown.bind(_this2,idx+1)}));}else if(idx!==0&&visiableBar){BarCom=/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement('div',_objectSpread2({},barProps),/*#__PURE__*/(0,jsx_runtime.jsx)("div",{onMouseDown:_this2.onMouseDown.bind(_this2,idx+1)}));}return/*#__PURE__*/(0,jsx_runtime.jsxs)((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment,{children:[BarCom,/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().cloneElement(element,_objectSpread2({},props))]});})}));}}]);return Split;}((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Component);Split.defaultProps={prefixCls:'w-split',visiable:true,mode:'horizontal'}; | ||
var _excluded=["prefixCls","className","children","mode","visiable","renderBar","lineBar","disable","onDragEnd","onDragging"];var Split=/*#__PURE__*/function(_React$Component){_inherits(Split,_React$Component);var _super=_createSuper(Split);function Split(props){var _this;_classCallCheck(this,Split);_this=_super.call(this,props);_this.state={dragging:false};_this.warpper=void 0;_this.paneNumber=void 0;_this.startX=void 0;_this.startY=void 0;_this.move=void 0;_this.target=void 0;_this.boxWidth=void 0;_this.boxHeight=void 0;_this.preWidth=void 0;_this.nextWidth=void 0;_this.preHeight=void 0;_this.nextHeight=void 0;_this.preSize=void 0;_this.nextSize=void 0;_this.onDragEnd=_this.onDragEnd.bind(_assertThisInitialized(_this));_this.onDragging=_this.onDragging.bind(_assertThisInitialized(_this));return _this;}_createClass(Split,[{key:"componentWillUnmount",value:function componentWillUnmount(){this.removeEvent();}},{key:"removeEvent",value:function removeEvent(){window.removeEventListener('mousemove',this.onDragging,false);window.removeEventListener('mouseup',this.onDragEnd,false);}},{key:"onMouseDown",value:function onMouseDown(paneNumber,env){if(!env.target||!this.warpper){return;}this.paneNumber=paneNumber;this.startX=env.clientX;this.startY=env.clientY;this.move=true;this.target=env.target.parentNode;var prevTarget=this.target.previousElementSibling;var nextTarget=this.target.nextElementSibling;this.boxWidth=this.warpper.clientWidth;this.boxHeight=this.warpper.clientHeight;if(prevTarget){this.preWidth=prevTarget.clientWidth;this.preHeight=prevTarget.clientHeight;}if(nextTarget){this.nextWidth=nextTarget.clientWidth;this.nextHeight=nextTarget.clientHeight;}window.addEventListener('mousemove',this.onDragging);window.addEventListener('mouseup',this.onDragEnd,false);this.setState({dragging:true});}},{key:"onDragging",value:function onDragging(env){if(!this.move){return;}if(!this.state.dragging){this.setState({dragging:true});}var _this$props=this.props,mode=_this$props.mode,onDragging=_this$props.onDragging;var nextTarget=this.target.nextElementSibling;var prevTarget=this.target.previousElementSibling;var x=env.clientX-this.startX;var y=env.clientY-this.startY;this.preSize=0;this.nextSize=0;if(mode==='horizontal'){this.preSize=this.preWidth+x>-1?this.preWidth+x:0;this.nextSize=this.nextWidth-x>-1?this.nextWidth-x:0;if(this.preSize===0||this.nextSize===0){return;}this.preSize=(this.preSize/this.boxWidth>=1?1:this.preSize/this.boxWidth)*100;this.nextSize=(this.nextSize/this.boxWidth>=1?1:this.nextSize/this.boxWidth)*100;if(prevTarget&&nextTarget){prevTarget.style.width="".concat(this.preSize,"%");nextTarget.style.width="".concat(this.nextSize,"%");}}if(mode==='vertical'&&this.preHeight+y>-1&&this.nextHeight-y>-1){this.preSize=this.preHeight+y>-1?this.preHeight+y:0;this.nextSize=this.nextHeight-y>-1?this.nextHeight-y:0;this.preSize=(this.preSize/this.boxHeight>=1?1:this.preSize/this.boxHeight)*100;this.nextSize=(this.nextSize/this.boxHeight>=1?1:this.nextSize/this.boxHeight)*100;if(this.preSize===0||this.nextSize===0){return;}if(prevTarget&&nextTarget){prevTarget.style.height="".concat(this.preSize,"%");nextTarget.style.height="".concat(this.nextSize,"%");}}onDragging&&onDragging(this.preSize,this.nextSize,this.paneNumber);}},{key:"onDragEnd",value:function onDragEnd(){var onDragEnd=this.props.onDragEnd;this.move=false;onDragEnd&&onDragEnd(this.preSize,this.nextSize,this.paneNumber);this.removeEvent();this.setState({dragging:false});}},{key:"render",value:function render(){var _this2=this;var _this$props2=this.props,prefixCls=_this$props2.prefixCls,className=_this$props2.className,children=_this$props2.children,mode=_this$props2.mode,visiable=_this$props2.visiable,renderBar=_this$props2.renderBar,lineBar=_this$props2.lineBar,disable=_this$props2.disable,onDragEnd=_this$props2.onDragEnd,onDragging=_this$props2.onDragging,other=_objectWithoutProperties(_this$props2,_excluded);var dragging=this.state.dragging;var cls=[prefixCls,className,"".concat(prefixCls,"-").concat(mode),dragging?'dragging':null].filter(Boolean).join(' ').trim();var child=external_root_React_commonjs2_react_commonjs_react_amd_react_default().Children.toArray(children);return/*#__PURE__*/(0,jsx_runtime.jsx)("div",_objectSpread2(_objectSpread2({className:cls},other),{},{ref:function ref(node){return _this2.warpper=node;},children:external_root_React_commonjs2_react_commonjs_react_amd_react_default().Children.map(child,function(element,idx){var props=Object.assign({},element.props,{className:["".concat(prefixCls,"-pane"),element.props.className].filter(Boolean).join(' ').trim(),style:_objectSpread2({},element.props.style)});var visiableBar=visiable===true||visiable&&visiable.includes(idx+1)||false;var barProps={className:["".concat(prefixCls,"-bar"),lineBar?"".concat(prefixCls,"-line-bar"):null,!lineBar?"".concat(prefixCls,"-large-bar"):null].filter(Boolean).join(' ').trim()};if(disable===true||disable&&disable.includes(idx+1)){barProps.className=[barProps.className,disable?'disable':null].filter(Boolean).join(' ').trim();}var BarCom=null;if(idx!==0&&visiableBar&&renderBar){BarCom=renderBar(_objectSpread2(_objectSpread2({},barProps),{},{onMouseDown:_this2.onMouseDown.bind(_this2,idx+1)}));}else if(idx!==0&&visiableBar){BarCom=/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement('div',_objectSpread2({},barProps),/*#__PURE__*/(0,jsx_runtime.jsx)("div",{onMouseDown:_this2.onMouseDown.bind(_this2,idx+1)}));}return/*#__PURE__*/(0,jsx_runtime.jsxs)((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment,{children:[BarCom,/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().cloneElement(element,_objectSpread2({},props))]},idx);})}));}}]);return Split;}((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Component);Split.defaultProps={prefixCls:'w-split',visiable:true,mode:'horizontal'}; | ||
})(); | ||
@@ -441,0 +441,0 @@ |
/*! For license information please see split.min.js.LICENSE.txt */ | ||
!function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("react")):"function"===typeof define&&define.amd?define(["react"],t):"object"===typeof exports?exports["@uiw/react-split"]=t(require("react")):e["@uiw/react-split"]=t(e.React)}(self,(function(e){return(()=>{"use strict";var t={323:e=>{var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(i){return!1}}()?Object.assign:function(e,o){for(var s,a,c=i(e),l=1;l<arguments.length;l++){for(var u in s=Object(arguments[l]))r.call(s,u)&&(c[u]=s[u]);if(t){a=t(s);for(var p=0;p<a.length;p++)n.call(s,a[p])&&(c[a[p]]=s[a[p]])}}return c}},638:(e,t,r)=>{r(323);var n=r(787),i=60103;if(60107,"function"===typeof Symbol&&Symbol.for){var o=Symbol.for;i=o("react.element"),o("react.fragment")}var s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a=Object.prototype.hasOwnProperty,c={key:!0,ref:!0,__self:!0,__source:!0};function l(e,t,r){var n,o={},l=null,u=null;for(n in void 0!==r&&(l=""+r),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,n)&&!c.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===o[n]&&(o[n]=t[n]);return{$$typeof:i,type:e,key:l,ref:u,props:o,_owner:s.current}}t.jsx=l,t.jsxs=l},724:(e,t,r)=>{e.exports=r(638)},787:t=>{t.exports=e}},r={};function n(e){var i=r[e];if(void 0!==i)return i.exports;var o=r[e]={exports:{}};return t[e](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function r(r){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?t(Object(i),!0).forEach((function(t){e(r,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))}))}return r}function o(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},c(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function p(e,t){if(t&&("object"===u(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return a(e)}function h(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=l(e);if(t){var i=l(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return p(this,r)}}n.r(i),n.d(i,{default:()=>y});var f=n(787),d=n.n(f),g=n(724),b=["prefixCls","className","children","mode","visiable","renderBar","lineBar","disable","onDragEnd","onDragging"],y=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}(u,e);var t,n,i,l=h(u);function u(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(t=l.call(this,e)).state={dragging:!1},t.warpper=void 0,t.paneNumber=void 0,t.startX=void 0,t.startY=void 0,t.move=void 0,t.target=void 0,t.boxWidth=void 0,t.boxHeight=void 0,t.preWidth=void 0,t.nextWidth=void 0,t.preHeight=void 0,t.nextHeight=void 0,t.preSize=void 0,t.nextSize=void 0,t.onDragEnd=t.onDragEnd.bind(a(t)),t.onDragging=t.onDragging.bind(a(t)),t}return t=u,(n=[{key:"componentWillUnmount",value:function(){this.removeEvent()}},{key:"removeEvent",value:function(){window.removeEventListener("mousemove",this.onDragging,!1),window.removeEventListener("mouseup",this.onDragEnd,!1)}},{key:"onMouseDown",value:function(e,t){if(t.target&&this.warpper){this.paneNumber=e,this.startX=t.clientX,this.startY=t.clientY,this.move=!0,this.target=t.target.parentNode;var r=this.target.previousElementSibling,n=this.target.nextElementSibling;this.boxWidth=this.warpper.clientWidth,this.boxHeight=this.warpper.clientHeight,r&&(this.preWidth=r.clientWidth,this.preHeight=r.clientHeight),n&&(this.nextWidth=n.clientWidth,this.nextHeight=n.clientHeight),window.addEventListener("mousemove",this.onDragging),window.addEventListener("mouseup",this.onDragEnd,!1),this.setState({dragging:!0})}}},{key:"onDragging",value:function(e){if(this.move){this.state.dragging||this.setState({dragging:!0});var t=this.props,r=t.mode,n=t.onDragging,i=this.target.nextElementSibling,o=this.target.previousElementSibling,s=e.clientX-this.startX,a=e.clientY-this.startY;if(this.preSize=0,this.nextSize=0,"horizontal"===r){if(this.preSize=this.preWidth+s>-1?this.preWidth+s:0,this.nextSize=this.nextWidth-s>-1?this.nextWidth-s:0,0===this.preSize||0===this.nextSize)return;this.preSize=100*(this.preSize/this.boxWidth>=1?1:this.preSize/this.boxWidth),this.nextSize=100*(this.nextSize/this.boxWidth>=1?1:this.nextSize/this.boxWidth),o&&i&&(o.style.width="".concat(this.preSize,"%"),i.style.width="".concat(this.nextSize,"%"))}if("vertical"===r&&this.preHeight+a>-1&&this.nextHeight-a>-1){if(this.preSize=this.preHeight+a>-1?this.preHeight+a:0,this.nextSize=this.nextHeight-a>-1?this.nextHeight-a:0,this.preSize=100*(this.preSize/this.boxHeight>=1?1:this.preSize/this.boxHeight),this.nextSize=100*(this.nextSize/this.boxHeight>=1?1:this.nextSize/this.boxHeight),0===this.preSize||0===this.nextSize)return;o&&i&&(o.style.height="".concat(this.preSize,"%"),i.style.height="".concat(this.nextSize,"%"))}n&&n(this.preSize,this.nextSize,this.paneNumber)}}},{key:"onDragEnd",value:function(){var e=this.props.onDragEnd;this.move=!1,e&&e(this.preSize,this.nextSize,this.paneNumber),this.removeEvent(),this.setState({dragging:!1})}},{key:"render",value:function(){var e=this,t=this.props,n=t.prefixCls,i=t.className,s=t.children,a=t.mode,c=t.visiable,l=t.renderBar,u=t.lineBar,p=t.disable,h=(t.onDragEnd,t.onDragging,o(t,b)),f=this.state.dragging,y=[n,i,"".concat(n,"-").concat(a),f?"dragging":null].filter(Boolean).join(" ").trim(),v=d().Children.toArray(s);return(0,g.jsx)("div",r(r({className:y},h),{},{ref:function(t){return e.warpper=t},children:d().Children.map(v,(function(t,i){var o=Object.assign({},t.props,{className:["".concat(n,"-pane"),t.props.className].filter(Boolean).join(" ").trim(),style:r({},t.props.style)}),s=!0===c||c&&c.includes(i+1)||!1,a={className:["".concat(n,"-bar"),u?"".concat(n,"-line-bar"):null,u?null:"".concat(n,"-large-bar")].filter(Boolean).join(" ").trim()};(!0===p||p&&p.includes(i+1))&&(a.className=[a.className,p?"disable":null].filter(Boolean).join(" ").trim());var h=null;return 0!==i&&s&&l?h=l(r(r({},a),{},{onMouseDown:e.onMouseDown.bind(e,i+1)})):0!==i&&s&&(h=d().createElement("div",r({},a),(0,g.jsx)("div",{onMouseDown:e.onMouseDown.bind(e,i+1)}))),(0,g.jsxs)(d().Fragment,{children:[h,d().cloneElement(t,r({},o))]})}))}))}}])&&s(t.prototype,n),i&&s(t,i),Object.defineProperty(t,"prototype",{writable:!1}),u}(d().Component);y.defaultProps={prefixCls:"w-split",visiable:!0,mode:"horizontal"}})(),i})()})); | ||
!function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("react")):"function"===typeof define&&define.amd?define(["react"],t):"object"===typeof exports?exports["@uiw/react-split"]=t(require("react")):e["@uiw/react-split"]=t(e.React)}(self,(function(e){return(()=>{"use strict";var t={323:e=>{var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(i){return!1}}()?Object.assign:function(e,o){for(var s,a,c=i(e),l=1;l<arguments.length;l++){for(var u in s=Object(arguments[l]))r.call(s,u)&&(c[u]=s[u]);if(t){a=t(s);for(var p=0;p<a.length;p++)n.call(s,a[p])&&(c[a[p]]=s[a[p]])}}return c}},638:(e,t,r)=>{r(323);var n=r(787),i=60103;if(60107,"function"===typeof Symbol&&Symbol.for){var o=Symbol.for;i=o("react.element"),o("react.fragment")}var s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a=Object.prototype.hasOwnProperty,c={key:!0,ref:!0,__self:!0,__source:!0};function l(e,t,r){var n,o={},l=null,u=null;for(n in void 0!==r&&(l=""+r),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,n)&&!c.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===o[n]&&(o[n]=t[n]);return{$$typeof:i,type:e,key:l,ref:u,props:o,_owner:s.current}}t.jsx=l,t.jsxs=l},724:(e,t,r)=>{e.exports=r(638)},787:t=>{t.exports=e}},r={};function n(e){var i=r[e];if(void 0!==i)return i.exports;var o=r[e]={exports:{}};return t[e](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function r(r){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?t(Object(i),!0).forEach((function(t){e(r,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))}))}return r}function o(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},c(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function p(e,t){if(t&&("object"===u(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return a(e)}function h(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=l(e);if(t){var i=l(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return p(this,r)}}n.r(i),n.d(i,{default:()=>y});var f=n(787),d=n.n(f),g=n(724),b=["prefixCls","className","children","mode","visiable","renderBar","lineBar","disable","onDragEnd","onDragging"],y=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}(u,e);var t,n,i,l=h(u);function u(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(t=l.call(this,e)).state={dragging:!1},t.warpper=void 0,t.paneNumber=void 0,t.startX=void 0,t.startY=void 0,t.move=void 0,t.target=void 0,t.boxWidth=void 0,t.boxHeight=void 0,t.preWidth=void 0,t.nextWidth=void 0,t.preHeight=void 0,t.nextHeight=void 0,t.preSize=void 0,t.nextSize=void 0,t.onDragEnd=t.onDragEnd.bind(a(t)),t.onDragging=t.onDragging.bind(a(t)),t}return t=u,(n=[{key:"componentWillUnmount",value:function(){this.removeEvent()}},{key:"removeEvent",value:function(){window.removeEventListener("mousemove",this.onDragging,!1),window.removeEventListener("mouseup",this.onDragEnd,!1)}},{key:"onMouseDown",value:function(e,t){if(t.target&&this.warpper){this.paneNumber=e,this.startX=t.clientX,this.startY=t.clientY,this.move=!0,this.target=t.target.parentNode;var r=this.target.previousElementSibling,n=this.target.nextElementSibling;this.boxWidth=this.warpper.clientWidth,this.boxHeight=this.warpper.clientHeight,r&&(this.preWidth=r.clientWidth,this.preHeight=r.clientHeight),n&&(this.nextWidth=n.clientWidth,this.nextHeight=n.clientHeight),window.addEventListener("mousemove",this.onDragging),window.addEventListener("mouseup",this.onDragEnd,!1),this.setState({dragging:!0})}}},{key:"onDragging",value:function(e){if(this.move){this.state.dragging||this.setState({dragging:!0});var t=this.props,r=t.mode,n=t.onDragging,i=this.target.nextElementSibling,o=this.target.previousElementSibling,s=e.clientX-this.startX,a=e.clientY-this.startY;if(this.preSize=0,this.nextSize=0,"horizontal"===r){if(this.preSize=this.preWidth+s>-1?this.preWidth+s:0,this.nextSize=this.nextWidth-s>-1?this.nextWidth-s:0,0===this.preSize||0===this.nextSize)return;this.preSize=100*(this.preSize/this.boxWidth>=1?1:this.preSize/this.boxWidth),this.nextSize=100*(this.nextSize/this.boxWidth>=1?1:this.nextSize/this.boxWidth),o&&i&&(o.style.width="".concat(this.preSize,"%"),i.style.width="".concat(this.nextSize,"%"))}if("vertical"===r&&this.preHeight+a>-1&&this.nextHeight-a>-1){if(this.preSize=this.preHeight+a>-1?this.preHeight+a:0,this.nextSize=this.nextHeight-a>-1?this.nextHeight-a:0,this.preSize=100*(this.preSize/this.boxHeight>=1?1:this.preSize/this.boxHeight),this.nextSize=100*(this.nextSize/this.boxHeight>=1?1:this.nextSize/this.boxHeight),0===this.preSize||0===this.nextSize)return;o&&i&&(o.style.height="".concat(this.preSize,"%"),i.style.height="".concat(this.nextSize,"%"))}n&&n(this.preSize,this.nextSize,this.paneNumber)}}},{key:"onDragEnd",value:function(){var e=this.props.onDragEnd;this.move=!1,e&&e(this.preSize,this.nextSize,this.paneNumber),this.removeEvent(),this.setState({dragging:!1})}},{key:"render",value:function(){var e=this,t=this.props,n=t.prefixCls,i=t.className,s=t.children,a=t.mode,c=t.visiable,l=t.renderBar,u=t.lineBar,p=t.disable,h=(t.onDragEnd,t.onDragging,o(t,b)),f=this.state.dragging,y=[n,i,"".concat(n,"-").concat(a),f?"dragging":null].filter(Boolean).join(" ").trim(),v=d().Children.toArray(s);return(0,g.jsx)("div",r(r({className:y},h),{},{ref:function(t){return e.warpper=t},children:d().Children.map(v,(function(t,i){var o=Object.assign({},t.props,{className:["".concat(n,"-pane"),t.props.className].filter(Boolean).join(" ").trim(),style:r({},t.props.style)}),s=!0===c||c&&c.includes(i+1)||!1,a={className:["".concat(n,"-bar"),u?"".concat(n,"-line-bar"):null,u?null:"".concat(n,"-large-bar")].filter(Boolean).join(" ").trim()};(!0===p||p&&p.includes(i+1))&&(a.className=[a.className,p?"disable":null].filter(Boolean).join(" ").trim());var h=null;return 0!==i&&s&&l?h=l(r(r({},a),{},{onMouseDown:e.onMouseDown.bind(e,i+1)})):0!==i&&s&&(h=d().createElement("div",r({},a),(0,g.jsx)("div",{onMouseDown:e.onMouseDown.bind(e,i+1)}))),(0,g.jsxs)(d().Fragment,{children:[h,d().cloneElement(t,r({},o))]},i)}))}))}}])&&s(t.prototype,n),i&&s(t,i),Object.defineProperty(t,"prototype",{writable:!1}),u}(d().Component);y.defaultProps={prefixCls:"w-split",visiable:!0,mode:"horizontal"}})(),i})()})); |
@@ -194,3 +194,3 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
children: [BarCom, /*#__PURE__*/React.cloneElement(element, _extends({}, props))] | ||
}); | ||
}, idx); | ||
}) | ||
@@ -197,0 +197,0 @@ })); |
{ | ||
"name": "@uiw/react-split", | ||
"version": "5.8.6", | ||
"version": "5.8.7", | ||
"description": "A piece of view can be divided into areas where the width or height can be adjusted by dragging.", | ||
@@ -5,0 +5,0 @@ "main": "cjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
130588
0.06%