react-split-pane 0.1.84 → 0.1.89

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/dist/index.esm.js CHANGED
@@ -1,190 +1,31 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import Prefixer from 'inline-style-prefixer';
4
3
  import stylePropType from 'react-style-proptype';
4
+ import { polyfill } from 'react-lifecycles-compat';
5
5
 
6
- /**
7
- * Copyright (c) 2013-present, Facebook, Inc.
8
- *
9
- * This source code is licensed under the MIT license found in the
10
- * LICENSE file in the root directory of this source tree.
11
- */
12
-
13
- function componentWillMount() {
14
- // Call this.constructor.gDSFP to support sub-classes.
15
- var state = this.constructor.getDerivedStateFromProps(this.props, this.state);
16
- if (state !== null && state !== undefined) {
17
- this.setState(state);
18
- }
19
- }
20
-
21
- function componentWillReceiveProps(nextProps) {
22
- // Call this.constructor.gDSFP to support sub-classes.
23
- // Use the setState() updater to ensure state isn't stale in certain edge cases.
24
- function updater(prevState) {
25
- var state = this.constructor.getDerivedStateFromProps(nextProps, prevState);
26
- return state !== null && state !== undefined ? state : null;
6
+ function _classCallCheck(instance, Constructor) {
7
+ if (!(instance instanceof Constructor)) {
8
+ throw new TypeError("Cannot call a class as a function");
27
9
  }
28
- // Binding "this" is important for shallow renderer support.
29
- this.setState(updater.bind(this));
30
10
  }
31
11
 
32
- function componentWillUpdate(nextProps, nextState) {
33
- try {
34
- var prevProps = this.props;
35
- var prevState = this.state;
36
- this.props = nextProps;
37
- this.state = nextState;
38
- this.__reactInternalSnapshotFlag = true;
39
- this.__reactInternalSnapshot = this.getSnapshotBeforeUpdate(
40
- prevProps,
41
- prevState
42
- );
43
- } finally {
44
- this.props = prevProps;
45
- this.state = prevState;
12
+ function _defineProperties(target, props) {
13
+ for (var i = 0; i < props.length; i++) {
14
+ var descriptor = props[i];
15
+ descriptor.enumerable = descriptor.enumerable || false;
16
+ descriptor.configurable = true;
17
+ if ("value" in descriptor) descriptor.writable = true;
18
+ Object.defineProperty(target, descriptor.key, descriptor);
46
19
  }
47
20
  }
48
21
 
49
- // React may warn about cWM/cWRP/cWU methods being deprecated.
50
- // Add a flag to suppress these warnings for this special case.
51
- componentWillMount.__suppressDeprecationWarning = true;
52
- componentWillReceiveProps.__suppressDeprecationWarning = true;
53
- componentWillUpdate.__suppressDeprecationWarning = true;
54
-
55
- function polyfill(Component) {
56
- var prototype = Component.prototype;
57
-
58
- if (!prototype || !prototype.isReactComponent) {
59
- throw new Error('Can only polyfill class components');
60
- }
61
-
62
- if (
63
- typeof Component.getDerivedStateFromProps !== 'function' &&
64
- typeof prototype.getSnapshotBeforeUpdate !== 'function'
65
- ) {
66
- return Component;
67
- }
68
-
69
- // If new component APIs are defined, "unsafe" lifecycles won't be called.
70
- // Error if any of these lifecycles are present,
71
- // Because they would work differently between older and newer (16.3+) versions of React.
72
- var foundWillMountName = null;
73
- var foundWillReceivePropsName = null;
74
- var foundWillUpdateName = null;
75
- if (typeof prototype.componentWillMount === 'function') {
76
- foundWillMountName = 'componentWillMount';
77
- } else if (typeof prototype.UNSAFE_componentWillMount === 'function') {
78
- foundWillMountName = 'UNSAFE_componentWillMount';
79
- }
80
- if (typeof prototype.componentWillReceiveProps === 'function') {
81
- foundWillReceivePropsName = 'componentWillReceiveProps';
82
- } else if (typeof prototype.UNSAFE_componentWillReceiveProps === 'function') {
83
- foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
84
- }
85
- if (typeof prototype.componentWillUpdate === 'function') {
86
- foundWillUpdateName = 'componentWillUpdate';
87
- } else if (typeof prototype.UNSAFE_componentWillUpdate === 'function') {
88
- foundWillUpdateName = 'UNSAFE_componentWillUpdate';
89
- }
90
- if (
91
- foundWillMountName !== null ||
92
- foundWillReceivePropsName !== null ||
93
- foundWillUpdateName !== null
94
- ) {
95
- var componentName = Component.displayName || Component.name;
96
- var newApiName =
97
- typeof Component.getDerivedStateFromProps === 'function'
98
- ? 'getDerivedStateFromProps()'
99
- : 'getSnapshotBeforeUpdate()';
100
-
101
- throw Error(
102
- 'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' +
103
- componentName +
104
- ' uses ' +
105
- newApiName +
106
- ' but also contains the following legacy lifecycles:' +
107
- (foundWillMountName !== null ? '\n ' + foundWillMountName : '') +
108
- (foundWillReceivePropsName !== null
109
- ? '\n ' + foundWillReceivePropsName
110
- : '') +
111
- (foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '') +
112
- '\n\nThe above lifecycles should be removed. Learn more about this warning here:\n' +
113
- 'https://fb.me/react-async-component-lifecycle-hooks'
114
- );
115
- }
116
-
117
- // React <= 16.2 does not support static getDerivedStateFromProps.
118
- // As a workaround, use cWM and cWRP to invoke the new static lifecycle.
119
- // Newer versions of React will ignore these lifecycles if gDSFP exists.
120
- if (typeof Component.getDerivedStateFromProps === 'function') {
121
- prototype.componentWillMount = componentWillMount;
122
- prototype.componentWillReceiveProps = componentWillReceiveProps;
123
- }
124
-
125
- // React <= 16.2 does not support getSnapshotBeforeUpdate.
126
- // As a workaround, use cWU to invoke the new lifecycle.
127
- // Newer versions of React will ignore that lifecycle if gSBU exists.
128
- if (typeof prototype.getSnapshotBeforeUpdate === 'function') {
129
- if (typeof prototype.componentDidUpdate !== 'function') {
130
- throw new Error(
131
- 'Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype'
132
- );
133
- }
134
-
135
- prototype.componentWillUpdate = componentWillUpdate;
136
-
137
- var componentDidUpdate = prototype.componentDidUpdate;
138
-
139
- prototype.componentDidUpdate = function componentDidUpdatePolyfill(
140
- prevProps,
141
- prevState,
142
- maybeSnapshot
143
- ) {
144
- // 16.3+ will not execute our will-update method;
145
- // It will pass a snapshot value to did-update though.
146
- // Older versions will require our polyfilled will-update value.
147
- // We need to handle both cases, but can't just check for the presence of "maybeSnapshot",
148
- // Because for <= 15.x versions this might be a "prevContext" object.
149
- // We also can't just check "__reactInternalSnapshot",
150
- // Because get-snapshot might return a falsy value.
151
- // So check for the explicit __reactInternalSnapshotFlag flag to determine behavior.
152
- var snapshot = this.__reactInternalSnapshotFlag
153
- ? this.__reactInternalSnapshot
154
- : maybeSnapshot;
155
-
156
- componentDidUpdate.call(this, prevProps, prevState, snapshot);
157
- };
158
- }
159
-
160
- return Component;
22
+ function _createClass(Constructor, protoProps, staticProps) {
23
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
24
+ if (staticProps) _defineProperties(Constructor, staticProps);
25
+ return Constructor;
161
26
  }
162
27
 
163
- var classCallCheck = function (instance, Constructor) {
164
- if (!(instance instanceof Constructor)) {
165
- throw new TypeError("Cannot call a class as a function");
166
- }
167
- };
168
-
169
- var createClass = function () {
170
- function defineProperties(target, props) {
171
- for (var i = 0; i < props.length; i++) {
172
- var descriptor = props[i];
173
- descriptor.enumerable = descriptor.enumerable || false;
174
- descriptor.configurable = true;
175
- if ("value" in descriptor) descriptor.writable = true;
176
- Object.defineProperty(target, descriptor.key, descriptor);
177
- }
178
- }
179
-
180
- return function (Constructor, protoProps, staticProps) {
181
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
182
- if (staticProps) defineProperties(Constructor, staticProps);
183
- return Constructor;
184
- };
185
- }();
186
-
187
- var defineProperty = function (obj, key, value) {
28
+ function _defineProperty(obj, key, value) {
188
29
  if (key in obj) {
189
30
  Object.defineProperty(obj, key, {
190
31
  value: value,
@@ -197,63 +38,101 @@ var defineProperty = function (obj, key, value) {
197
38
  }
198
39
 
199
40
  return obj;
200
- };
41
+ }
42
+
43
+ function _objectSpread(target) {
44
+ for (var i = 1; i < arguments.length; i++) {
45
+ var source = arguments[i] != null ? arguments[i] : {};
46
+ var ownKeys = Object.keys(source);
47
+
48
+ if (typeof Object.getOwnPropertySymbols === 'function') {
49
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
50
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
51
+ }));
52
+ }
201
53
 
202
- var inherits = function (subClass, superClass) {
54
+ ownKeys.forEach(function (key) {
55
+ _defineProperty(target, key, source[key]);
56
+ });
57
+ }
58
+
59
+ return target;
60
+ }
61
+
62
+ function _inherits(subClass, superClass) {
203
63
  if (typeof superClass !== "function" && superClass !== null) {
204
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
64
+ throw new TypeError("Super expression must either be null or a function");
205
65
  }
206
66
 
207
67
  subClass.prototype = Object.create(superClass && superClass.prototype, {
208
68
  constructor: {
209
69
  value: subClass,
210
- enumerable: false,
211
70
  writable: true,
212
71
  configurable: true
213
72
  }
214
73
  });
215
- if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
216
- };
74
+ if (superClass) _setPrototypeOf(subClass, superClass);
75
+ }
217
76
 
218
- var possibleConstructorReturn = function (self, call) {
219
- if (!self) {
77
+ function _getPrototypeOf(o) {
78
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
79
+ return o.__proto__ || Object.getPrototypeOf(o);
80
+ };
81
+ return _getPrototypeOf(o);
82
+ }
83
+
84
+ function _setPrototypeOf(o, p) {
85
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
86
+ o.__proto__ = p;
87
+ return o;
88
+ };
89
+
90
+ return _setPrototypeOf(o, p);
91
+ }
92
+
93
+ function _assertThisInitialized(self) {
94
+ if (self === void 0) {
220
95
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
221
96
  }
222
97
 
223
- return call && (typeof call === "object" || typeof call === "function") ? call : self;
224
- };
98
+ return self;
99
+ }
100
+
101
+ function _possibleConstructorReturn(self, call) {
102
+ if (call && (typeof call === "object" || typeof call === "function")) {
103
+ return call;
104
+ }
225
105
 
226
- var DEFAULT_USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Safari/537.2';
227
- var USER_AGENT = typeof navigator !== 'undefined' ? navigator.userAgent : DEFAULT_USER_AGENT;
106
+ return _assertThisInitialized(self);
107
+ }
228
108
 
229
- var Pane = function (_React$PureComponent) {
230
- inherits(Pane, _React$PureComponent);
109
+ var Pane =
110
+ /*#__PURE__*/
111
+ function (_React$PureComponent) {
112
+ _inherits(Pane, _React$PureComponent);
231
113
 
232
114
  function Pane() {
233
- classCallCheck(this, Pane);
234
- return possibleConstructorReturn(this, (Pane.__proto__ || Object.getPrototypeOf(Pane)).apply(this, arguments));
115
+ _classCallCheck(this, Pane);
116
+
117
+ return _possibleConstructorReturn(this, _getPrototypeOf(Pane).apply(this, arguments));
235
118
  }
236
119
 
237
- createClass(Pane, [{
238
- key: 'render',
120
+ _createClass(Pane, [{
121
+ key: "render",
239
122
  value: function render() {
240
- var _props = this.props,
241
- children = _props.children,
242
- className = _props.className,
243
- prefixer = _props.prefixer,
244
- split = _props.split,
245
- styleProps = _props.style,
246
- size = _props.size,
247
- eleRef = _props.eleRef;
248
-
249
-
123
+ var _this$props = this.props,
124
+ children = _this$props.children,
125
+ className = _this$props.className,
126
+ split = _this$props.split,
127
+ styleProps = _this$props.style,
128
+ size = _this$props.size,
129
+ eleRef = _this$props.eleRef;
250
130
  var classes = ['Pane', split, className];
251
-
252
- var style = Object.assign({}, styleProps || {}, {
131
+ var style = {
253
132
  flex: 1,
254
133
  position: 'relative',
255
134
  outline: 'none'
256
- });
135
+ };
257
136
 
258
137
  if (size !== undefined) {
259
138
  if (split === 'vertical') {
@@ -262,95 +141,94 @@ var Pane = function (_React$PureComponent) {
262
141
  style.height = size;
263
142
  style.display = 'flex';
264
143
  }
144
+
265
145
  style.flex = 'none';
266
146
  }
267
147
 
268
- return React.createElement(
269
- 'div',
270
- {
271
- ref: eleRef,
272
- className: classes.join(' '),
273
- style: prefixer.prefix(style)
274
- },
275
- children
276
- );
148
+ style = Object.assign({}, style, styleProps || {});
149
+ return React.createElement("div", {
150
+ ref: eleRef,
151
+ className: classes.join(' '),
152
+ style: style
153
+ }, children);
277
154
  }
278
155
  }]);
156
+
279
157
  return Pane;
280
158
  }(React.PureComponent);
281
159
 
282
160
  Pane.propTypes = {
283
161
  className: PropTypes.string.isRequired,
284
162
  children: PropTypes.node.isRequired,
285
- prefixer: PropTypes.instanceOf(Prefixer).isRequired,
286
163
  size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
287
164
  split: PropTypes.oneOf(['vertical', 'horizontal']),
288
165
  style: stylePropType,
289
166
  eleRef: PropTypes.func
290
167
  };
168
+ Pane.defaultProps = {};
291
169
 
292
- Pane.defaultProps = {
293
- prefixer: new Prefixer({ userAgent: USER_AGENT })
294
- };
295
-
296
- var DEFAULT_USER_AGENT$1 = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Safari/537.2';
297
- var USER_AGENT$1 = typeof navigator !== 'undefined' ? navigator.userAgent : DEFAULT_USER_AGENT$1;
298
170
  var RESIZER_DEFAULT_CLASSNAME = 'Resizer';
299
171
 
300
- var Resizer = function (_React$Component) {
301
- inherits(Resizer, _React$Component);
172
+ var Resizer =
173
+ /*#__PURE__*/
174
+ function (_React$Component) {
175
+ _inherits(Resizer, _React$Component);
302
176
 
303
177
  function Resizer() {
304
- classCallCheck(this, Resizer);
305
- return possibleConstructorReturn(this, (Resizer.__proto__ || Object.getPrototypeOf(Resizer)).apply(this, arguments));
178
+ _classCallCheck(this, Resizer);
179
+
180
+ return _possibleConstructorReturn(this, _getPrototypeOf(Resizer).apply(this, arguments));
306
181
  }
307
182
 
308
- createClass(Resizer, [{
309
- key: 'render',
183
+ _createClass(Resizer, [{
184
+ key: "render",
310
185
  value: function render() {
311
- var _props = this.props,
312
- className = _props.className,
313
- _onClick = _props.onClick,
314
- _onDoubleClick = _props.onDoubleClick,
315
- _onMouseDown = _props.onMouseDown,
316
- _onTouchEnd = _props.onTouchEnd,
317
- _onTouchStart = _props.onTouchStart,
318
- prefixer = _props.prefixer,
319
- resizerClassName = _props.resizerClassName,
320
- split = _props.split,
321
- style = _props.style;
322
-
186
+ var _this$props = this.props,
187
+ className = _this$props.className,
188
+ _onClick = _this$props.onClick,
189
+ _onDoubleClick = _this$props.onDoubleClick,
190
+ _onMouseDown = _this$props.onMouseDown,
191
+ _onTouchEnd = _this$props.onTouchEnd,
192
+ _onTouchStart = _this$props.onTouchStart,
193
+ resizerClassName = _this$props.resizerClassName,
194
+ split = _this$props.split,
195
+ style = _this$props.style;
323
196
  var classes = [resizerClassName, split, className];
324
-
325
- return React.createElement('span', {
197
+ return React.createElement("span", {
198
+ role: "presentation",
326
199
  className: classes.join(' '),
327
- style: prefixer.prefix(style) || {},
200
+ style: style,
328
201
  onMouseDown: function onMouseDown(event) {
329
202
  return _onMouseDown(event);
330
203
  },
331
204
  onTouchStart: function onTouchStart(event) {
332
205
  event.preventDefault();
206
+
333
207
  _onTouchStart(event);
334
208
  },
335
209
  onTouchEnd: function onTouchEnd(event) {
336
210
  event.preventDefault();
211
+
337
212
  _onTouchEnd(event);
338
213
  },
339
214
  onClick: function onClick(event) {
340
215
  if (_onClick) {
341
216
  event.preventDefault();
217
+
342
218
  _onClick(event);
343
219
  }
344
220
  },
345
221
  onDoubleClick: function onDoubleClick(event) {
346
222
  if (_onDoubleClick) {
347
223
  event.preventDefault();
224
+
348
225
  _onDoubleClick(event);
349
226
  }
350
227
  }
351
228
  });
352
229
  }
353
230
  }]);
231
+
354
232
  return Resizer;
355
233
  }(React.Component);
356
234
 
@@ -361,27 +239,20 @@ Resizer.propTypes = {
361
239
  onMouseDown: PropTypes.func.isRequired,
362
240
  onTouchStart: PropTypes.func.isRequired,
363
241
  onTouchEnd: PropTypes.func.isRequired,
364
- prefixer: PropTypes.instanceOf(Prefixer).isRequired,
365
242
  split: PropTypes.oneOf(['vertical', 'horizontal']),
366
243
  style: stylePropType,
367
244
  resizerClassName: PropTypes.string.isRequired
368
245
  };
369
-
370
246
  Resizer.defaultProps = {
371
- prefixer: new Prefixer({ userAgent: USER_AGENT$1 }),
372
247
  resizerClassName: RESIZER_DEFAULT_CLASSNAME
373
248
  };
374
249
 
375
- var DEFAULT_USER_AGENT$2 = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Safari/537.2';
376
- var USER_AGENT$2 = typeof navigator !== 'undefined' ? navigator.userAgent : DEFAULT_USER_AGENT$2;
377
-
378
250
  function unFocus(document, window) {
379
251
  if (document.selection) {
380
252
  document.selection.empty();
381
253
  } else {
382
254
  try {
383
- window.getSelection().removeAllRanges();
384
- // eslint-disable-next-line no-empty
255
+ window.getSelection().removeAllRanges(); // eslint-disable-next-line no-empty
385
256
  } catch (e) {}
386
257
  }
387
258
  }
@@ -392,9 +263,11 @@ function getDefaultSize(defaultSize, minSize, maxSize, draggedSize) {
392
263
  var max = typeof maxSize === 'number' && maxSize >= 0 ? maxSize : Infinity;
393
264
  return Math.max(min, Math.min(max, draggedSize));
394
265
  }
266
+
395
267
  if (defaultSize !== undefined) {
396
268
  return defaultSize;
397
269
  }
270
+
398
271
  return minSize;
399
272
  }
400
273
 
@@ -404,21 +277,22 @@ function removeNullChildren(children) {
404
277
  });
405
278
  }
406
279
 
407
- var SplitPane = function (_React$Component) {
408
- inherits(SplitPane, _React$Component);
280
+ var SplitPane =
281
+ /*#__PURE__*/
282
+ function (_React$Component) {
283
+ _inherits(SplitPane, _React$Component);
409
284
 
410
285
  function SplitPane(props) {
411
- classCallCheck(this, SplitPane);
412
-
413
- var _this = possibleConstructorReturn(this, (SplitPane.__proto__ || Object.getPrototypeOf(SplitPane)).call(this, props));
286
+ var _this;
414
287
 
415
- _this.onMouseDown = _this.onMouseDown.bind(_this);
416
- _this.onTouchStart = _this.onTouchStart.bind(_this);
417
- _this.onMouseMove = _this.onMouseMove.bind(_this);
418
- _this.onTouchMove = _this.onTouchMove.bind(_this);
419
- _this.onMouseUp = _this.onMouseUp.bind(_this);
288
+ _classCallCheck(this, SplitPane);
420
289
 
421
- // order of setting panel sizes.
290
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(SplitPane).call(this, props));
291
+ _this.onMouseDown = _this.onMouseDown.bind(_assertThisInitialized(_assertThisInitialized(_this)));
292
+ _this.onTouchStart = _this.onTouchStart.bind(_assertThisInitialized(_assertThisInitialized(_this)));
293
+ _this.onMouseMove = _this.onMouseMove.bind(_assertThisInitialized(_assertThisInitialized(_this)));
294
+ _this.onTouchMove = _this.onTouchMove.bind(_assertThisInitialized(_assertThisInitialized(_this)));
295
+ _this.onMouseUp = _this.onMouseUp.bind(_assertThisInitialized(_assertThisInitialized(_this))); // order of setting panel sizes.
422
296
  // 1. size
423
297
  // 2. getDefaultSize(defaultSize, minsize, maxSize)
424
298
 
@@ -427,16 +301,12 @@ var SplitPane = function (_React$Component) {
427
301
  minSize = props.minSize,
428
302
  maxSize = props.maxSize,
429
303
  primary = props.primary;
430
-
431
-
432
304
  var initialSize = size !== undefined ? size : getDefaultSize(defaultSize, minSize, maxSize, null);
433
-
434
305
  _this.state = {
435
306
  active: false,
436
307
  resized: false,
437
308
  pane1Size: primary === 'first' ? initialSize : undefined,
438
309
  pane2Size: primary === 'second' ? initialSize : undefined,
439
-
440
310
  // these are props that are needed in static functions. ie: gDSFP
441
311
  instanceProps: {
442
312
  size: size
@@ -445,8 +315,8 @@ var SplitPane = function (_React$Component) {
445
315
  return _this;
446
316
  }
447
317
 
448
- createClass(SplitPane, [{
449
- key: 'componentDidMount',
318
+ _createClass(SplitPane, [{
319
+ key: "componentDidMount",
450
320
  value: function componentDidMount() {
451
321
  document.addEventListener('mouseup', this.onMouseUp);
452
322
  document.addEventListener('mousemove', this.onMouseMove);
@@ -454,27 +324,30 @@ var SplitPane = function (_React$Component) {
454
324
  this.setState(SplitPane.getSizeUpdate(this.props, this.state));
455
325
  }
456
326
  }, {
457
- key: 'componentWillUnmount',
327
+ key: "componentWillUnmount",
458
328
  value: function componentWillUnmount() {
459
329
  document.removeEventListener('mouseup', this.onMouseUp);
460
330
  document.removeEventListener('mousemove', this.onMouseMove);
461
331
  document.removeEventListener('touchmove', this.onTouchMove);
462
332
  }
463
333
  }, {
464
- key: 'onMouseDown',
334
+ key: "onMouseDown",
465
335
  value: function onMouseDown(event) {
466
336
  var eventWithTouches = Object.assign({}, event, {
467
- touches: [{ clientX: event.clientX, clientY: event.clientY }]
337
+ touches: [{
338
+ clientX: event.clientX,
339
+ clientY: event.clientY
340
+ }]
468
341
  });
469
342
  this.onTouchStart(eventWithTouches);
470
343
  }
471
344
  }, {
472
- key: 'onTouchStart',
345
+ key: "onTouchStart",
473
346
  value: function onTouchStart(event) {
474
- var _props = this.props,
475
- allowResize = _props.allowResize,
476
- onDragStarted = _props.onDragStarted,
477
- split = _props.split;
347
+ var _this$props = this.props,
348
+ allowResize = _this$props.allowResize,
349
+ onDragStarted = _this$props.onDragStarted,
350
+ split = _this$props.split;
478
351
 
479
352
  if (allowResize) {
480
353
  unFocus(document, window);
@@ -483,6 +356,7 @@ var SplitPane = function (_React$Component) {
483
356
  if (typeof onDragStarted === 'function') {
484
357
  onDragStarted();
485
358
  }
359
+
486
360
  this.setState({
487
361
  active: true,
488
362
  position: position
@@ -490,33 +364,36 @@ var SplitPane = function (_React$Component) {
490
364
  }
491
365
  }
492
366
  }, {
493
- key: 'onMouseMove',
367
+ key: "onMouseMove",
494
368
  value: function onMouseMove(event) {
495
369
  var eventWithTouches = Object.assign({}, event, {
496
- touches: [{ clientX: event.clientX, clientY: event.clientY }]
370
+ touches: [{
371
+ clientX: event.clientX,
372
+ clientY: event.clientY
373
+ }]
497
374
  });
498
375
  this.onTouchMove(eventWithTouches);
499
376
  }
500
377
  }, {
501
- key: 'onTouchMove',
378
+ key: "onTouchMove",
502
379
  value: function onTouchMove(event) {
503
- var _props2 = this.props,
504
- allowResize = _props2.allowResize,
505
- maxSize = _props2.maxSize,
506
- minSize = _props2.minSize,
507
- onChange = _props2.onChange,
508
- split = _props2.split,
509
- step = _props2.step;
510
- var _state = this.state,
511
- active = _state.active,
512
- position = _state.position;
513
-
380
+ var _this$props2 = this.props,
381
+ allowResize = _this$props2.allowResize,
382
+ maxSize = _this$props2.maxSize,
383
+ minSize = _this$props2.minSize,
384
+ onChange = _this$props2.onChange,
385
+ split = _this$props2.split,
386
+ step = _this$props2.step;
387
+ var _this$state = this.state,
388
+ active = _this$state.active,
389
+ position = _this$state.position;
514
390
 
515
391
  if (allowResize && active) {
516
392
  unFocus(document, window);
517
393
  var isPrimaryFirst = this.props.primary === 'first';
518
394
  var ref = isPrimaryFirst ? this.pane1 : this.pane2;
519
395
  var ref2 = isPrimaryFirst ? this.pane2 : this.pane1;
396
+
520
397
  if (ref) {
521
398
  var node = ref;
522
399
  var node2 = ref2;
@@ -527,25 +404,30 @@ var SplitPane = function (_React$Component) {
527
404
  var current = split === 'vertical' ? event.touches[0].clientX : event.touches[0].clientY;
528
405
  var size = split === 'vertical' ? width : height;
529
406
  var positionDelta = position - current;
407
+
530
408
  if (step) {
531
409
  if (Math.abs(positionDelta) < step) {
532
410
  return;
533
- }
534
- // Integer division
411
+ } // Integer division
535
412
  // eslint-disable-next-line no-bitwise
413
+
414
+
536
415
  positionDelta = ~~(positionDelta / step) * step;
537
416
  }
538
- var sizeDelta = isPrimaryFirst ? positionDelta : -positionDelta;
539
417
 
418
+ var sizeDelta = isPrimaryFirst ? positionDelta : -positionDelta;
540
419
  var pane1Order = parseInt(window.getComputedStyle(node).order);
541
420
  var pane2Order = parseInt(window.getComputedStyle(node2).order);
421
+
542
422
  if (pane1Order > pane2Order) {
543
423
  sizeDelta = -sizeDelta;
544
424
  }
545
425
 
546
426
  var newMaxSize = maxSize;
427
+
547
428
  if (maxSize !== undefined && maxSize <= 0) {
548
429
  var splitPane = this.splitPane;
430
+
549
431
  if (split === 'vertical') {
550
432
  newMaxSize = splitPane.getBoundingClientRect().width + maxSize;
551
433
  } else {
@@ -568,8 +450,7 @@ var SplitPane = function (_React$Component) {
568
450
  }
569
451
 
570
452
  if (onChange) onChange(newSize);
571
-
572
- this.setState(defineProperty({
453
+ this.setState(_defineProperty({
573
454
  draggedSize: newSize
574
455
  }, isPrimaryFirst ? 'pane1Size' : 'pane2Size', newSize));
575
456
  }
@@ -577,58 +458,55 @@ var SplitPane = function (_React$Component) {
577
458
  }
578
459
  }
579
460
  }, {
580
- key: 'onMouseUp',
461
+ key: "onMouseUp",
581
462
  value: function onMouseUp() {
582
- var _props3 = this.props,
583
- allowResize = _props3.allowResize,
584
- onDragFinished = _props3.onDragFinished;
585
- var _state2 = this.state,
586
- active = _state2.active,
587
- draggedSize = _state2.draggedSize;
463
+ var _this$props3 = this.props,
464
+ allowResize = _this$props3.allowResize,
465
+ onDragFinished = _this$props3.onDragFinished;
466
+ var _this$state2 = this.state,
467
+ active = _this$state2.active,
468
+ draggedSize = _this$state2.draggedSize;
588
469
 
589
470
  if (allowResize && active) {
590
471
  if (typeof onDragFinished === 'function') {
591
472
  onDragFinished(draggedSize);
592
473
  }
593
- this.setState({ active: false });
594
- }
595
- }
596
474
 
597
- // we have to check values since gDSFP is called on every render and more in StrictMode
475
+ this.setState({
476
+ active: false
477
+ });
478
+ }
479
+ } // we have to check values since gDSFP is called on every render and more in StrictMode
598
480
 
599
481
  }, {
600
- key: 'render',
482
+ key: "render",
601
483
  value: function render() {
602
484
  var _this2 = this;
603
485
 
604
- var _props4 = this.props,
605
- allowResize = _props4.allowResize,
606
- children = _props4.children,
607
- className = _props4.className,
608
- onResizerClick = _props4.onResizerClick,
609
- onResizerDoubleClick = _props4.onResizerDoubleClick,
610
- paneClassName = _props4.paneClassName,
611
- pane1ClassName = _props4.pane1ClassName,
612
- pane2ClassName = _props4.pane2ClassName,
613
- paneStyle = _props4.paneStyle,
614
- pane1StyleProps = _props4.pane1Style,
615
- pane2StyleProps = _props4.pane2Style,
616
- prefixer = _props4.prefixer,
617
- resizerClassName = _props4.resizerClassName,
618
- resizerStyle = _props4.resizerStyle,
619
- split = _props4.split,
620
- styleProps = _props4.style;
621
- var _state3 = this.state,
622
- pane1Size = _state3.pane1Size,
623
- pane2Size = _state3.pane2Size;
624
-
625
-
486
+ var _this$props4 = this.props,
487
+ allowResize = _this$props4.allowResize,
488
+ children = _this$props4.children,
489
+ className = _this$props4.className,
490
+ onResizerClick = _this$props4.onResizerClick,
491
+ onResizerDoubleClick = _this$props4.onResizerDoubleClick,
492
+ paneClassName = _this$props4.paneClassName,
493
+ pane1ClassName = _this$props4.pane1ClassName,
494
+ pane2ClassName = _this$props4.pane2ClassName,
495
+ paneStyle = _this$props4.paneStyle,
496
+ pane1StyleProps = _this$props4.pane1Style,
497
+ pane2StyleProps = _this$props4.pane2Style,
498
+ resizerClassName = _this$props4.resizerClassName,
499
+ resizerStyle = _this$props4.resizerStyle,
500
+ split = _this$props4.split,
501
+ styleProps = _this$props4.style;
502
+ var _this$state3 = this.state,
503
+ pane1Size = _this$state3.pane1Size,
504
+ pane2Size = _this$state3.pane2Size;
626
505
  var disabledClass = allowResize ? '' : 'disabled';
627
- var resizerClassNamesIncludingDefault = resizerClassName ? resizerClassName + ' ' + RESIZER_DEFAULT_CLASSNAME : resizerClassName;
628
-
506
+ var resizerClassNamesIncludingDefault = resizerClassName ? "".concat(resizerClassName, " ").concat(RESIZER_DEFAULT_CLASSNAME) : resizerClassName;
629
507
  var notNullChildren = removeNullChildren(children);
630
508
 
631
- var style = Object.assign({}, {
509
+ var style = _objectSpread({
632
510
  display: 'flex',
633
511
  flex: 1,
634
512
  height: '100%',
@@ -639,7 +517,7 @@ var SplitPane = function (_React$Component) {
639
517
  WebkitUserSelect: 'text',
640
518
  msUserSelect: 'text',
641
519
  userSelect: 'text'
642
- }, styleProps || {});
520
+ }, styleProps);
643
521
 
644
522
  if (split === 'vertical') {
645
523
  Object.assign(style, {
@@ -658,75 +536,61 @@ var SplitPane = function (_React$Component) {
658
536
  }
659
537
 
660
538
  var classes = ['SplitPane', className, split, disabledClass];
661
- var pane1Style = prefixer.prefix(Object.assign({}, paneStyle || {}, pane1StyleProps || {}));
662
- var pane2Style = prefixer.prefix(Object.assign({}, paneStyle || {}, pane2StyleProps || {}));
539
+
540
+ var pane1Style = _objectSpread({}, paneStyle, pane1StyleProps);
541
+
542
+ var pane2Style = _objectSpread({}, paneStyle, pane2StyleProps);
663
543
 
664
544
  var pane1Classes = ['Pane1', paneClassName, pane1ClassName].join(' ');
665
545
  var pane2Classes = ['Pane2', paneClassName, pane2ClassName].join(' ');
666
-
667
- return React.createElement(
668
- 'div',
669
- {
670
- className: classes.join(' '),
671
- ref: function ref(node) {
672
- _this2.splitPane = node;
673
- },
674
- style: prefixer.prefix(style)
546
+ return React.createElement("div", {
547
+ className: classes.join(' '),
548
+ ref: function ref(node) {
549
+ _this2.splitPane = node;
550
+ },
551
+ style: style
552
+ }, React.createElement(Pane, {
553
+ className: pane1Classes,
554
+ key: "pane1",
555
+ eleRef: function eleRef(node) {
556
+ _this2.pane1 = node;
557
+ },
558
+ size: pane1Size,
559
+ split: split,
560
+ style: pane1Style
561
+ }, notNullChildren[0]), React.createElement(Resizer, {
562
+ className: disabledClass,
563
+ onClick: onResizerClick,
564
+ onDoubleClick: onResizerDoubleClick,
565
+ onMouseDown: this.onMouseDown,
566
+ onTouchStart: this.onTouchStart,
567
+ onTouchEnd: this.onMouseUp,
568
+ key: "resizer",
569
+ resizerClassName: resizerClassNamesIncludingDefault,
570
+ split: split,
571
+ style: resizerStyle || {}
572
+ }), React.createElement(Pane, {
573
+ className: pane2Classes,
574
+ key: "pane2",
575
+ eleRef: function eleRef(node) {
576
+ _this2.pane2 = node;
675
577
  },
676
- React.createElement(
677
- Pane,
678
- {
679
- className: pane1Classes,
680
- key: 'pane1',
681
- eleRef: function eleRef(node) {
682
- _this2.pane1 = node;
683
- },
684
- size: pane1Size,
685
- split: split,
686
- style: pane1Style
687
- },
688
- notNullChildren[0]
689
- ),
690
- React.createElement(Resizer, {
691
- className: disabledClass,
692
- onClick: onResizerClick,
693
- onDoubleClick: onResizerDoubleClick,
694
- onMouseDown: this.onMouseDown,
695
- onTouchStart: this.onTouchStart,
696
- onTouchEnd: this.onMouseUp,
697
- key: 'resizer',
698
- resizerClassName: resizerClassNamesIncludingDefault,
699
- split: split,
700
- style: resizerStyle || {}
701
- }),
702
- React.createElement(
703
- Pane,
704
- {
705
- className: pane2Classes,
706
- key: 'pane2',
707
- eleRef: function eleRef(node) {
708
- _this2.pane2 = node;
709
- },
710
- size: pane2Size,
711
- split: split,
712
- style: pane2Style
713
- },
714
- notNullChildren[1]
715
- )
716
- );
578
+ size: pane2Size,
579
+ split: split,
580
+ style: pane2Style
581
+ }, notNullChildren[1]));
717
582
  }
718
583
  }], [{
719
- key: 'getDerivedStateFromProps',
584
+ key: "getDerivedStateFromProps",
720
585
  value: function getDerivedStateFromProps(nextProps, prevState) {
721
586
  return SplitPane.getSizeUpdate(nextProps, prevState);
722
587
  }
723
588
  }, {
724
- key: 'getSizeUpdate',
589
+ key: "getSizeUpdate",
725
590
  value: function getSizeUpdate(props, state) {
726
591
  var newState = {};
727
592
  var instanceProps = state.instanceProps;
728
593
 
729
-
730
594
  if (instanceProps.size === props.size && props.size !== undefined) {
731
595
  return {};
732
596
  }
@@ -738,15 +602,15 @@ var SplitPane = function (_React$Component) {
738
602
  }
739
603
 
740
604
  var isPanel1Primary = props.primary === 'first';
741
-
742
605
  newState[isPanel1Primary ? 'pane1Size' : 'pane2Size'] = newSize;
743
606
  newState[isPanel1Primary ? 'pane2Size' : 'pane1Size'] = undefined;
744
-
745
- newState.instanceProps = { size: props.size };
746
-
607
+ newState.instanceProps = {
608
+ size: props.size
609
+ };
747
610
  return newState;
748
611
  }
749
612
  }]);
613
+
750
614
  return SplitPane;
751
615
  }(React.Component);
752
616
 
@@ -766,7 +630,6 @@ SplitPane.propTypes = {
766
630
  onChange: PropTypes.func,
767
631
  onResizerClick: PropTypes.func,
768
632
  onResizerDoubleClick: PropTypes.func,
769
- prefixer: PropTypes.instanceOf(Prefixer).isRequired,
770
633
  style: stylePropType,
771
634
  resizerStyle: stylePropType,
772
635
  paneClassName: PropTypes.string,
@@ -778,18 +641,16 @@ SplitPane.propTypes = {
778
641
  resizerClassName: PropTypes.string,
779
642
  step: PropTypes.number
780
643
  };
781
-
782
644
  SplitPane.defaultProps = {
783
645
  allowResize: true,
784
646
  minSize: 50,
785
- prefixer: new Prefixer({ userAgent: USER_AGENT$2 }),
786
647
  primary: 'first',
787
648
  split: 'vertical',
788
649
  paneClassName: '',
789
650
  pane1ClassName: '',
790
651
  pane2ClassName: ''
791
652
  };
792
-
793
653
  polyfill(SplitPane);
794
654
 
795
655
  export default SplitPane;
656
+ export { Pane };