baseui 0.0.0-alpha-47b62ee → 0.0.0-alpha-cb60490
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/data-table/data-table.js +1 -1
- package/data-table/data-table.js.flow +1 -1
- package/es/data-table/data-table.js +1 -1
- package/esm/data-table/data-table.js +1 -1
- package/package.json +1 -1
- package/data-table/react-virtualized-auto-sizer.js +0 -200
- package/data-table/react-virtualized-auto-sizer.js.flow +0 -201
- package/data-table/react-virtualized-detect-element-resize.js +0 -267
- package/data-table/react-virtualized-detect-element-resize.js.flow +0 -287
- package/es/data-table/react-virtualized-auto-sizer.js +0 -145
- package/es/data-table/react-virtualized-detect-element-resize.js +0 -244
- package/esm/data-table/react-virtualized-auto-sizer.js +0 -188
- package/esm/data-table/react-virtualized-detect-element-resize.js +0 -260
package/data-table/data-table.js
CHANGED
|
@@ -11,7 +11,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _reactWindow = require("react-window");
|
|
13
13
|
|
|
14
|
-
var _reactVirtualizedAutoSizer = _interopRequireDefault(require("
|
|
14
|
+
var _reactVirtualizedAutoSizer = _interopRequireDefault(require("react-virtualized-auto-sizer"));
|
|
15
15
|
|
|
16
16
|
var _index = require("../button/index.js");
|
|
17
17
|
|
|
@@ -8,7 +8,7 @@ LICENSE file in the root directory of this source tree.
|
|
|
8
8
|
|
|
9
9
|
import * as React from 'react';
|
|
10
10
|
import {VariableSizeGrid} from 'react-window';
|
|
11
|
-
import AutoSizer from '
|
|
11
|
+
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
14
|
Button,
|
|
@@ -6,7 +6,7 @@ LICENSE file in the root directory of this source tree.
|
|
|
6
6
|
*/
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import { VariableSizeGrid } from 'react-window';
|
|
9
|
-
import AutoSizer from '
|
|
9
|
+
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
10
10
|
import { Button, SHAPE as BUTTON_SHAPES, SIZE as BUTTON_SIZES, KIND as BUTTON_KINDS } from '../button/index.js';
|
|
11
11
|
import { useStyletron } from '../styles/index.js';
|
|
12
12
|
import { Tooltip, PLACEMENT } from '../tooltip/index.js';
|
|
@@ -32,7 +32,7 @@ LICENSE file in the root directory of this source tree.
|
|
|
32
32
|
*/
|
|
33
33
|
import * as React from 'react';
|
|
34
34
|
import { VariableSizeGrid } from 'react-window';
|
|
35
|
-
import AutoSizer from '
|
|
35
|
+
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
36
36
|
import { Button, SHAPE as BUTTON_SHAPES, SIZE as BUTTON_SIZES, KIND as BUTTON_KINDS } from '../button/index.js';
|
|
37
37
|
import { useStyletron } from '../styles/index.js';
|
|
38
38
|
import { Tooltip, PLACEMENT } from '../tooltip/index.js';
|
package/package.json
CHANGED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _reactVirtualizedDetectElementResize = _interopRequireDefault(require("./react-virtualized-detect-element-resize.js"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
23
|
-
|
|
24
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
25
|
-
|
|
26
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
27
|
-
|
|
28
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
29
|
-
|
|
30
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
31
|
-
|
|
32
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
33
|
-
|
|
34
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
35
|
-
|
|
36
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
37
|
-
|
|
38
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
39
|
-
|
|
40
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
41
|
-
|
|
42
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
43
|
-
|
|
44
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
45
|
-
|
|
46
|
-
var AutoSizer = /*#__PURE__*/function (_React$PureComponent) {
|
|
47
|
-
_inherits(AutoSizer, _React$PureComponent);
|
|
48
|
-
|
|
49
|
-
var _super = _createSuper(AutoSizer);
|
|
50
|
-
|
|
51
|
-
function AutoSizer() {
|
|
52
|
-
var _this;
|
|
53
|
-
|
|
54
|
-
_classCallCheck(this, AutoSizer);
|
|
55
|
-
|
|
56
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
57
|
-
args[_key] = arguments[_key];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
61
|
-
|
|
62
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
63
|
-
height: _this.props.defaultHeight || 0,
|
|
64
|
-
width: _this.props.defaultWidth || 0
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
_defineProperty(_assertThisInitialized(_this), "_parentNode", void 0);
|
|
68
|
-
|
|
69
|
-
_defineProperty(_assertThisInitialized(_this), "_autoSizer", void 0);
|
|
70
|
-
|
|
71
|
-
_defineProperty(_assertThisInitialized(_this), "_detectElementResize", void 0);
|
|
72
|
-
|
|
73
|
-
_defineProperty(_assertThisInitialized(_this), "_onResize", function () {
|
|
74
|
-
var _this$props = _this.props,
|
|
75
|
-
disableHeight = _this$props.disableHeight,
|
|
76
|
-
disableWidth = _this$props.disableWidth,
|
|
77
|
-
onResize = _this$props.onResize;
|
|
78
|
-
|
|
79
|
-
if (_this._parentNode) {
|
|
80
|
-
// Guard against AutoSizer component being removed from the DOM immediately after being added.
|
|
81
|
-
// This can result in invalid style values which can result in NaN values if we don't handle them.
|
|
82
|
-
// See issue #150 for more context.
|
|
83
|
-
console.log(_this._parentNode.offsetWidth, _this._parentNode.offsetHeight);
|
|
84
|
-
var height = _this._parentNode.offsetHeight || 0;
|
|
85
|
-
var width = _this._parentNode.offsetWidth || 0;
|
|
86
|
-
var style = window.getComputedStyle(_this._parentNode) || {};
|
|
87
|
-
var paddingLeft = parseInt(style.paddingLeft, 10) || 0;
|
|
88
|
-
var paddingRight = parseInt(style.paddingRight, 10) || 0;
|
|
89
|
-
var paddingTop = parseInt(style.paddingTop, 10) || 0;
|
|
90
|
-
var paddingBottom = parseInt(style.paddingBottom, 10) || 0;
|
|
91
|
-
var newHeight = height - paddingTop - paddingBottom;
|
|
92
|
-
var newWidth = width - paddingLeft - paddingRight;
|
|
93
|
-
|
|
94
|
-
if (!disableHeight && _this.state.height !== newHeight || !disableWidth && _this.state.width !== newWidth) {
|
|
95
|
-
_this.setState({
|
|
96
|
-
height: height - paddingTop - paddingBottom,
|
|
97
|
-
width: width - paddingLeft - paddingRight
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
onResize({
|
|
101
|
-
height: height,
|
|
102
|
-
width: width
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
_defineProperty(_assertThisInitialized(_this), "_setRef", function (autoSizer) {
|
|
109
|
-
_this._autoSizer = autoSizer;
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
return _this;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
_createClass(AutoSizer, [{
|
|
116
|
-
key: "componentDidMount",
|
|
117
|
-
value: function componentDidMount() {
|
|
118
|
-
var nonce = this.props.nonce;
|
|
119
|
-
|
|
120
|
-
if (this._autoSizer && this._autoSizer.parentNode && this._autoSizer.parentNode.ownerDocument && this._autoSizer.parentNode.ownerDocument.defaultView && this._autoSizer.parentNode instanceof this._autoSizer.parentNode.ownerDocument.defaultView.HTMLElement) {
|
|
121
|
-
// Delay access of parentNode until mount.
|
|
122
|
-
// This handles edge-cases where the component has already been unmounted before its ref has been set,
|
|
123
|
-
// As well as libraries like react-lite which have a slightly different lifecycle.
|
|
124
|
-
this._parentNode = this._autoSizer.parentNode; // Defer requiring resize handler in order to support server-side rendering.
|
|
125
|
-
// See issue #41
|
|
126
|
-
|
|
127
|
-
this._detectElementResize = (0, _reactVirtualizedDetectElementResize.default)(nonce);
|
|
128
|
-
|
|
129
|
-
this._detectElementResize.addResizeListener(this._parentNode, this._onResize);
|
|
130
|
-
|
|
131
|
-
this._onResize();
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}, {
|
|
135
|
-
key: "componentWillUnmount",
|
|
136
|
-
value: function componentWillUnmount() {
|
|
137
|
-
if (this._detectElementResize && this._parentNode) {
|
|
138
|
-
this._detectElementResize.removeResizeListener(this._parentNode, this._onResize);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}, {
|
|
142
|
-
key: "render",
|
|
143
|
-
value: function render() {
|
|
144
|
-
var _this$props2 = this.props,
|
|
145
|
-
children = _this$props2.children,
|
|
146
|
-
className = _this$props2.className,
|
|
147
|
-
disableHeight = _this$props2.disableHeight,
|
|
148
|
-
disableWidth = _this$props2.disableWidth,
|
|
149
|
-
style = _this$props2.style;
|
|
150
|
-
var _this$state = this.state,
|
|
151
|
-
height = _this$state.height,
|
|
152
|
-
width = _this$state.width; // Outer div should not force width/height since that may prevent containers from shrinking.
|
|
153
|
-
// Inner component should overflow and use calculated width/height.
|
|
154
|
-
// See issue #68 for more information.
|
|
155
|
-
|
|
156
|
-
var outerStyle = {
|
|
157
|
-
overflow: 'visible'
|
|
158
|
-
};
|
|
159
|
-
var childParams = {}; // Avoid rendering children before the initial measurements have been collected.
|
|
160
|
-
// At best this would just be wasting cycles.
|
|
161
|
-
|
|
162
|
-
var bailoutOnChildren = false;
|
|
163
|
-
|
|
164
|
-
if (!disableHeight) {
|
|
165
|
-
if (height === 0) {
|
|
166
|
-
bailoutOnChildren = true;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
outerStyle.height = 0;
|
|
170
|
-
childParams.height = height;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (!disableWidth) {
|
|
174
|
-
if (width === 0) {
|
|
175
|
-
bailoutOnChildren = true;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
outerStyle.width = 0;
|
|
179
|
-
childParams.width = width;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
183
|
-
className: className,
|
|
184
|
-
ref: this._setRef,
|
|
185
|
-
style: _objectSpread(_objectSpread({}, outerStyle), style)
|
|
186
|
-
}, children(childParams));
|
|
187
|
-
}
|
|
188
|
-
}]);
|
|
189
|
-
|
|
190
|
-
return AutoSizer;
|
|
191
|
-
}(React.PureComponent);
|
|
192
|
-
|
|
193
|
-
exports.default = AutoSizer;
|
|
194
|
-
|
|
195
|
-
_defineProperty(AutoSizer, "defaultProps", {
|
|
196
|
-
onResize: function onResize() {},
|
|
197
|
-
disableHeight: false,
|
|
198
|
-
disableWidth: false,
|
|
199
|
-
style: {}
|
|
200
|
-
});
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
// https://github.com/bvaughn/react-virtualized-auto-sizer
|
|
2
|
-
// MIT license https://github.com/bvaughn/react-virtualized-auto-sizer/blob/1275e69264dd960d15aca42fea8bd73194672778/package.json#L11
|
|
3
|
-
// @flow
|
|
4
|
-
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
import createDetectElementResize from './react-virtualized-detect-element-resize.js';
|
|
7
|
-
|
|
8
|
-
type Size = {
|
|
9
|
-
height: number,
|
|
10
|
-
width: number,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
/** Function responsible for rendering children.*/
|
|
15
|
-
children: Size => React.Element<*>,
|
|
16
|
-
|
|
17
|
-
/** Optional custom CSS class name to attach to root AutoSizer element. */
|
|
18
|
-
className?: string,
|
|
19
|
-
|
|
20
|
-
/** Default height to use for initial render; useful for SSR */
|
|
21
|
-
defaultHeight?: number,
|
|
22
|
-
|
|
23
|
-
/** Default width to use for initial render; useful for SSR */
|
|
24
|
-
defaultWidth?: number,
|
|
25
|
-
|
|
26
|
-
/** Disable dynamic :height property */
|
|
27
|
-
disableHeight: boolean,
|
|
28
|
-
|
|
29
|
-
/** Disable dynamic :width property */
|
|
30
|
-
disableWidth: boolean,
|
|
31
|
-
|
|
32
|
-
/** Nonce of the inlined stylesheet for Content Security Policy */
|
|
33
|
-
nonce?: string,
|
|
34
|
-
|
|
35
|
-
/** Callback to be invoked on-resize */
|
|
36
|
-
onResize: Size => void,
|
|
37
|
-
|
|
38
|
-
/** Optional inline style */
|
|
39
|
-
style: ?Object,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
type State = {
|
|
43
|
-
height: number,
|
|
44
|
-
width: number,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
type ResizeHandler = (element: HTMLElement, onResize: () => void) => void;
|
|
48
|
-
|
|
49
|
-
type DetectElementResize = {
|
|
50
|
-
addResizeListener: ResizeHandler,
|
|
51
|
-
removeResizeListener: ResizeHandler,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export default class AutoSizer extends React.PureComponent<Props, State> {
|
|
55
|
-
static defaultProps = {
|
|
56
|
-
onResize: () => {},
|
|
57
|
-
disableHeight: false,
|
|
58
|
-
disableWidth: false,
|
|
59
|
-
style: {},
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
state = {
|
|
63
|
-
height: this.props.defaultHeight || 0,
|
|
64
|
-
width: this.props.defaultWidth || 0,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
_parentNode: ?HTMLElement;
|
|
68
|
-
_autoSizer: ?HTMLElement;
|
|
69
|
-
_detectElementResize: DetectElementResize;
|
|
70
|
-
|
|
71
|
-
componentDidMount() {
|
|
72
|
-
const {nonce} = this.props;
|
|
73
|
-
if (
|
|
74
|
-
this._autoSizer &&
|
|
75
|
-
this._autoSizer.parentNode &&
|
|
76
|
-
this._autoSizer.parentNode.ownerDocument &&
|
|
77
|
-
this._autoSizer.parentNode.ownerDocument.defaultView &&
|
|
78
|
-
this._autoSizer.parentNode instanceof
|
|
79
|
-
this._autoSizer.parentNode.ownerDocument.defaultView.HTMLElement
|
|
80
|
-
) {
|
|
81
|
-
// Delay access of parentNode until mount.
|
|
82
|
-
// This handles edge-cases where the component has already been unmounted before its ref has been set,
|
|
83
|
-
// As well as libraries like react-lite which have a slightly different lifecycle.
|
|
84
|
-
this._parentNode = this._autoSizer.parentNode;
|
|
85
|
-
|
|
86
|
-
// Defer requiring resize handler in order to support server-side rendering.
|
|
87
|
-
// See issue #41
|
|
88
|
-
this._detectElementResize = createDetectElementResize(nonce);
|
|
89
|
-
this._detectElementResize.addResizeListener(
|
|
90
|
-
this._parentNode,
|
|
91
|
-
this._onResize,
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
this._onResize();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
componentWillUnmount() {
|
|
99
|
-
if (this._detectElementResize && this._parentNode) {
|
|
100
|
-
this._detectElementResize.removeResizeListener(
|
|
101
|
-
this._parentNode,
|
|
102
|
-
this._onResize,
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
render() {
|
|
108
|
-
const {
|
|
109
|
-
children,
|
|
110
|
-
className,
|
|
111
|
-
disableHeight,
|
|
112
|
-
disableWidth,
|
|
113
|
-
style,
|
|
114
|
-
} = this.props;
|
|
115
|
-
const {height, width} = this.state;
|
|
116
|
-
|
|
117
|
-
// Outer div should not force width/height since that may prevent containers from shrinking.
|
|
118
|
-
// Inner component should overflow and use calculated width/height.
|
|
119
|
-
// See issue #68 for more information.
|
|
120
|
-
const outerStyle: Object = {overflow: 'visible'};
|
|
121
|
-
const childParams: Object = {};
|
|
122
|
-
|
|
123
|
-
// Avoid rendering children before the initial measurements have been collected.
|
|
124
|
-
// At best this would just be wasting cycles.
|
|
125
|
-
let bailoutOnChildren = false;
|
|
126
|
-
|
|
127
|
-
if (!disableHeight) {
|
|
128
|
-
if (height === 0) {
|
|
129
|
-
bailoutOnChildren = true;
|
|
130
|
-
}
|
|
131
|
-
outerStyle.height = 0;
|
|
132
|
-
childParams.height = height;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (!disableWidth) {
|
|
136
|
-
if (width === 0) {
|
|
137
|
-
bailoutOnChildren = true;
|
|
138
|
-
}
|
|
139
|
-
outerStyle.width = 0;
|
|
140
|
-
childParams.width = width;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return (
|
|
144
|
-
<div
|
|
145
|
-
className={className}
|
|
146
|
-
ref={this._setRef}
|
|
147
|
-
style={{
|
|
148
|
-
...outerStyle,
|
|
149
|
-
...style,
|
|
150
|
-
}}
|
|
151
|
-
>
|
|
152
|
-
{children(childParams)}
|
|
153
|
-
{/* {!bailoutOnChildren && children(childParams)} */}
|
|
154
|
-
</div>
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
_onResize = () => {
|
|
159
|
-
const {disableHeight, disableWidth, onResize} = this.props;
|
|
160
|
-
|
|
161
|
-
if (this._parentNode) {
|
|
162
|
-
// Guard against AutoSizer component being removed from the DOM immediately after being added.
|
|
163
|
-
// This can result in invalid style values which can result in NaN values if we don't handle them.
|
|
164
|
-
// See issue #150 for more context.
|
|
165
|
-
|
|
166
|
-
console.log(this._parentNode.offsetWidth, this._parentNode.offsetHeight);
|
|
167
|
-
|
|
168
|
-
const height = this._parentNode.offsetHeight || 0;
|
|
169
|
-
const width = this._parentNode.offsetWidth || 0;
|
|
170
|
-
|
|
171
|
-
const style = window.getComputedStyle(this._parentNode) || {};
|
|
172
|
-
const paddingLeft = parseInt(style.paddingLeft, 10) || 0;
|
|
173
|
-
const paddingRight = parseInt(style.paddingRight, 10) || 0;
|
|
174
|
-
const paddingTop = parseInt(style.paddingTop, 10) || 0;
|
|
175
|
-
const paddingBottom = parseInt(style.paddingBottom, 10) || 0;
|
|
176
|
-
|
|
177
|
-
const newHeight = height - paddingTop - paddingBottom;
|
|
178
|
-
const newWidth = width - paddingLeft - paddingRight;
|
|
179
|
-
|
|
180
|
-
if (
|
|
181
|
-
(!disableHeight && this.state.height !== newHeight) ||
|
|
182
|
-
(!disableWidth && this.state.width !== newWidth)
|
|
183
|
-
) {
|
|
184
|
-
this.setState({
|
|
185
|
-
height: height - paddingTop - paddingBottom,
|
|
186
|
-
width: width - paddingLeft - paddingRight,
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
onResize({height, width});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
_setRef = (autoSizer: ?HTMLElement) => {
|
|
195
|
-
this._autoSizer = autoSizer;
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
declare var __DEV__: boolean;
|
|
200
|
-
declare var __NODE__: boolean;
|
|
201
|
-
declare var __BROWSER__: boolean;
|