@difizen/libro-virtualized 0.1.2
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/LICENSE +21 -0
- package/README.md +0 -0
- package/es/auto-sizer/auto-sizer.d.ts +56 -0
- package/es/auto-sizer/auto-sizer.d.ts.map +1 -0
- package/es/auto-sizer/auto-sizer.js +157 -0
- package/es/auto-sizer/index.d.ts +3 -0
- package/es/auto-sizer/index.d.ts.map +1 -0
- package/es/auto-sizer/index.js +2 -0
- package/es/cell-measurer/cell-measurer-cache.d.ts +52 -0
- package/es/cell-measurer/cell-measurer-cache.d.ts.map +1 -0
- package/es/cell-measurer/cell-measurer-cache.js +176 -0
- package/es/cell-measurer/cell-measurer.d.ts +39 -0
- package/es/cell-measurer/cell-measurer.d.ts.map +1 -0
- package/es/cell-measurer/cell-measurer.js +154 -0
- package/es/cell-measurer/index.d.ts +5 -0
- package/es/cell-measurer/index.d.ts.map +1 -0
- package/es/cell-measurer/index.js +4 -0
- package/es/cell-measurer/types.d.ts +9 -0
- package/es/cell-measurer/types.d.ts.map +1 -0
- package/es/cell-measurer/types.js +0 -0
- package/es/grid/accessibility-overscanIndices-getter.d.ts +11 -0
- package/es/grid/accessibility-overscanIndices-getter.d.ts.map +1 -0
- package/es/grid/accessibility-overscanIndices-getter.js +33 -0
- package/es/grid/default-cell-range-renderer.d.ts +10 -0
- package/es/grid/default-cell-range-renderer.d.ts.map +1 -0
- package/es/grid/default-cell-range-renderer.js +135 -0
- package/es/grid/default-overscanIndices-getter.d.ts +11 -0
- package/es/grid/default-overscanIndices-getter.d.ts.map +1 -0
- package/es/grid/default-overscanIndices-getter.js +28 -0
- package/es/grid/grid.d.ts +359 -0
- package/es/grid/grid.d.ts.map +1 -0
- package/es/grid/grid.js +1287 -0
- package/es/grid/index.d.ts +6 -0
- package/es/grid/index.d.ts.map +1 -0
- package/es/grid/index.js +4 -0
- package/es/grid/types.d.ts +87 -0
- package/es/grid/types.d.ts.map +1 -0
- package/es/grid/types.js +1 -0
- package/es/grid/utils/calculate-size-and-position-data-and-update-scroll-offset.d.ts +17 -0
- package/es/grid/utils/calculate-size-and-position-data-and-update-scroll-offset.d.ts.map +1 -0
- package/es/grid/utils/calculate-size-and-position-data-and-update-scroll-offset.js +25 -0
- package/es/grid/utils/cell-size-and-position-manager-row.d.ts +97 -0
- package/es/grid/utils/cell-size-and-position-manager-row.d.ts.map +1 -0
- package/es/grid/utils/cell-size-and-position-manager-row.js +297 -0
- package/es/grid/utils/cell-size-and-position-manager.d.ts +85 -0
- package/es/grid/utils/cell-size-and-position-manager.d.ts.map +1 -0
- package/es/grid/utils/cell-size-and-position-manager.js +268 -0
- package/es/grid/utils/max-element-size.d.ts +2 -0
- package/es/grid/utils/max-element-size.d.ts.map +1 -0
- package/es/grid/utils/max-element-size.js +17 -0
- package/es/grid/utils/scaling-cell-size-and-position-manager-row.d.ts +78 -0
- package/es/grid/utils/scaling-cell-size-and-position-manager-row.d.ts.map +1 -0
- package/es/grid/utils/scaling-cell-size-and-position-manager-row.js +187 -0
- package/es/grid/utils/scaling-cell-size-and-position-manager.d.ts +70 -0
- package/es/grid/utils/scaling-cell-size-and-position-manager.d.ts.map +1 -0
- package/es/grid/utils/scaling-cell-size-and-position-manager.js +187 -0
- package/es/grid/utils/update-scroll-index-helper.d.ts +24 -0
- package/es/grid/utils/update-scroll-index-helper.d.ts.map +1 -0
- package/es/grid/utils/update-scroll-index-helper.js +40 -0
- package/es/index.d.ts +5 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +4 -0
- package/es/list/index.d.ts +3 -0
- package/es/list/index.d.ts.map +1 -0
- package/es/list/index.js +1 -0
- package/es/list/list.d.ts +109 -0
- package/es/list/list.d.ts.map +1 -0
- package/es/list/list.js +261 -0
- package/es/list/types.d.ts +22 -0
- package/es/list/types.d.ts.map +1 -0
- package/es/list/types.js +1 -0
- package/es/utils/animation-frame.d.ts +7 -0
- package/es/utils/animation-frame.d.ts.map +1 -0
- package/es/utils/animation-frame.js +20 -0
- package/es/utils/create-callback-memoizer.d.ts +5 -0
- package/es/utils/create-callback-memoizer.d.ts.map +1 -0
- package/es/utils/create-callback-memoizer.js +25 -0
- package/es/utils/get-updated-offset-for-index.d.ts +14 -0
- package/es/utils/get-updated-offset-for-index.d.ts.map +1 -0
- package/es/utils/get-updated-offset-for-index.js +32 -0
- package/es/utils/init-cell-metadata.d.ts +13 -0
- package/es/utils/init-cell-metadata.d.ts.map +1 -0
- package/es/utils/init-cell-metadata.js +32 -0
- package/es/utils/request-animation-timeout.d.ts +12 -0
- package/es/utils/request-animation-timeout.d.ts.map +1 -0
- package/es/utils/request-animation-timeout.js +33 -0
- package/es/utils/test-helper.d.ts +5 -0
- package/es/utils/test-helper.d.ts.map +1 -0
- package/es/utils/test-helper.js +31 -0
- package/es/vendor/binary-search-bounds.d.ts +22 -0
- package/es/vendor/binary-search-bounds.d.ts.map +1 -0
- package/es/vendor/binary-search-bounds.js +198 -0
- package/es/vendor/detect-element-resize.d.ts +16 -0
- package/es/vendor/detect-element-resize.d.ts.map +1 -0
- package/es/vendor/detect-element-resize.js +184 -0
- package/es/vendor/interval-tree.d.ts +10 -0
- package/es/vendor/interval-tree.d.ts.map +1 -0
- package/es/vendor/interval-tree.js +359 -0
- package/package.json +59 -0
- package/src/auto-sizer/auto-sizer.tsx +187 -0
- package/src/auto-sizer/index.ts +4 -0
- package/src/cell-measurer/cell-measurer-cache.ts +220 -0
- package/src/cell-measurer/cell-measurer.ts +151 -0
- package/src/cell-measurer/index.ts +5 -0
- package/src/cell-measurer/types.ts +8 -0
- package/src/grid/accessibility-overscanIndices-getter.ts +38 -0
- package/src/grid/default-cell-range-renderer.ts +166 -0
- package/src/grid/default-overscanIndices-getter.ts +32 -0
- package/src/grid/grid.tsx +1672 -0
- package/src/grid/index.ts +14 -0
- package/src/grid/types.ts +112 -0
- package/src/grid/utils/calculate-size-and-position-data-and-update-scroll-offset.ts +62 -0
- package/src/grid/utils/cell-size-and-position-manager-row.ts +365 -0
- package/src/grid/utils/cell-size-and-position-manager.ts +309 -0
- package/src/grid/utils/max-element-size.ts +18 -0
- package/src/grid/utils/scaling-cell-size-and-position-manager-row.ts +206 -0
- package/src/grid/utils/scaling-cell-size-and-position-manager.ts +198 -0
- package/src/grid/utils/update-scroll-index-helper.ts +96 -0
- package/src/index.spec.ts +10 -0
- package/src/index.ts +4 -0
- package/src/list/index.ts +2 -0
- package/src/list/list.tsx +292 -0
- package/src/list/types.ts +25 -0
- package/src/utils/animation-frame.ts +38 -0
- package/src/utils/create-callback-memoizer.ts +32 -0
- package/src/utils/get-updated-offset-for-index.ts +33 -0
- package/src/utils/init-cell-metadata.ts +32 -0
- package/src/utils/request-animation-timeout.ts +44 -0
- package/src/utils/test-helper.ts +20 -0
- package/src/vendor/binary-search-bounds.ts +203 -0
- package/src/vendor/detect-element-resize.ts +241 -0
- package/src/vendor/interval-tree.ts +406 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
8
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
9
|
+
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); }; }
|
|
10
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
11
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
12
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
14
|
+
import * as React from 'react';
|
|
15
|
+
import { findDOMNode } from 'react-dom';
|
|
16
|
+
/**
|
|
17
|
+
* Wraps a cell and measures its rendered content.
|
|
18
|
+
* Measurements are stored in a per-cell cache.
|
|
19
|
+
* Cached-content is not be re-measured.
|
|
20
|
+
*/
|
|
21
|
+
var CellMeasurer = /*#__PURE__*/function (_React$PureComponent) {
|
|
22
|
+
_inherits(CellMeasurer, _React$PureComponent);
|
|
23
|
+
var _super = _createSuper(CellMeasurer);
|
|
24
|
+
function CellMeasurer() {
|
|
25
|
+
var _this;
|
|
26
|
+
_classCallCheck(this, CellMeasurer);
|
|
27
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
28
|
+
args[_key] = arguments[_key];
|
|
29
|
+
}
|
|
30
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
31
|
+
_this._measure = function () {
|
|
32
|
+
var _this$props = _this.props,
|
|
33
|
+
cache = _this$props.cache,
|
|
34
|
+
_this$props$columnInd = _this$props.columnIndex,
|
|
35
|
+
columnIndex = _this$props$columnInd === void 0 ? 0 : _this$props$columnInd,
|
|
36
|
+
parent = _this$props.parent,
|
|
37
|
+
_this$props$rowIndex = _this$props.rowIndex,
|
|
38
|
+
rowIndex = _this$props$rowIndex === void 0 ? _this.props.index || 0 : _this$props$rowIndex;
|
|
39
|
+
var _this$_getCellMeasure = _this._getCellMeasurements(),
|
|
40
|
+
height = _this$_getCellMeasure.height,
|
|
41
|
+
width = _this$_getCellMeasure.width;
|
|
42
|
+
if (height !== cache.getHeight(rowIndex, columnIndex) || width !== cache.getWidth(rowIndex, columnIndex)) {
|
|
43
|
+
cache.set(rowIndex, columnIndex, width, height);
|
|
44
|
+
if (parent && typeof parent.recomputeGridSize === 'function') {
|
|
45
|
+
parent.recomputeGridSize({
|
|
46
|
+
columnIndex: columnIndex,
|
|
47
|
+
rowIndex: rowIndex
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return _this;
|
|
53
|
+
}
|
|
54
|
+
_createClass(CellMeasurer, [{
|
|
55
|
+
key: "componentDidMount",
|
|
56
|
+
value: function componentDidMount() {
|
|
57
|
+
this._maybeMeasureCell();
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
key: "componentDidUpdate",
|
|
61
|
+
value: function componentDidUpdate() {
|
|
62
|
+
this._maybeMeasureCell();
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "render",
|
|
66
|
+
value: function render() {
|
|
67
|
+
var children = this.props.children;
|
|
68
|
+
return typeof children === 'function' ? children({
|
|
69
|
+
measure: this._measure
|
|
70
|
+
}) : children;
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
key: "_getCellMeasurements",
|
|
74
|
+
value: function _getCellMeasurements() {
|
|
75
|
+
var cache = this.props.cache;
|
|
76
|
+
|
|
77
|
+
// eslint-disable-next-line react/no-find-dom-node
|
|
78
|
+
var node = findDOMNode(this);
|
|
79
|
+
|
|
80
|
+
// TODO Check for a bad combination of fixedWidth and missing numeric width or vice versa with height
|
|
81
|
+
|
|
82
|
+
if (node && node.ownerDocument && node.ownerDocument.defaultView && node instanceof node.ownerDocument.defaultView.HTMLElement) {
|
|
83
|
+
var styleWidth = node.style.width;
|
|
84
|
+
var styleHeight = node.style.height;
|
|
85
|
+
|
|
86
|
+
// If we are re-measuring a cell that has already been measured,
|
|
87
|
+
// It will have a hard-coded width/height from the previous measurement.
|
|
88
|
+
// The fact that we are measuring indicates this measurement is probably stale,
|
|
89
|
+
// So explicitly clear it out (eg set to "auto") so we can recalculate.
|
|
90
|
+
// See issue #593 for more info.
|
|
91
|
+
// Even if we are measuring initially- if we're inside of a MultiGrid component,
|
|
92
|
+
// Explicitly clear width/height before measuring to avoid being tainted by another Grid.
|
|
93
|
+
// eg top/left Grid renders before bottom/right Grid
|
|
94
|
+
// Since the CellMeasurerCache is shared between them this taints derived cell size values.
|
|
95
|
+
if (!cache.hasFixedWidth()) {
|
|
96
|
+
node.style.width = 'auto';
|
|
97
|
+
}
|
|
98
|
+
if (!cache.hasFixedHeight()) {
|
|
99
|
+
node.style.height = 'auto';
|
|
100
|
+
}
|
|
101
|
+
var height = Math.ceil(node.offsetHeight);
|
|
102
|
+
var width = Math.ceil(node.offsetWidth);
|
|
103
|
+
|
|
104
|
+
// Reset after measuring to avoid breaking styles; see #660
|
|
105
|
+
if (styleWidth) {
|
|
106
|
+
node.style.width = styleWidth;
|
|
107
|
+
}
|
|
108
|
+
if (styleHeight) {
|
|
109
|
+
node.style.height = styleHeight;
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
height: height,
|
|
113
|
+
width: width
|
|
114
|
+
};
|
|
115
|
+
} else {
|
|
116
|
+
return {
|
|
117
|
+
height: 0,
|
|
118
|
+
width: 0
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "_maybeMeasureCell",
|
|
124
|
+
value: function _maybeMeasureCell() {
|
|
125
|
+
var _this$props2 = this.props,
|
|
126
|
+
cache = _this$props2.cache,
|
|
127
|
+
_this$props2$columnIn = _this$props2.columnIndex,
|
|
128
|
+
columnIndex = _this$props2$columnIn === void 0 ? 0 : _this$props2$columnIn,
|
|
129
|
+
parent = _this$props2.parent,
|
|
130
|
+
_this$props2$rowIndex = _this$props2.rowIndex,
|
|
131
|
+
rowIndex = _this$props2$rowIndex === void 0 ? this.props.index || 0 : _this$props2$rowIndex;
|
|
132
|
+
if (!cache.has(rowIndex, columnIndex)) {
|
|
133
|
+
var _this$_getCellMeasure2 = this._getCellMeasurements(),
|
|
134
|
+
height = _this$_getCellMeasure2.height,
|
|
135
|
+
width = _this$_getCellMeasure2.width;
|
|
136
|
+
cache.set(rowIndex, columnIndex, width, height);
|
|
137
|
+
|
|
138
|
+
// If size has changed, let Grid know to re-render.
|
|
139
|
+
if (parent && typeof parent.invalidateCellSizeAfterRender === 'function') {
|
|
140
|
+
parent.invalidateCellSizeAfterRender({
|
|
141
|
+
columnIndex: columnIndex,
|
|
142
|
+
rowIndex: rowIndex
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}]);
|
|
148
|
+
return CellMeasurer;
|
|
149
|
+
}(React.PureComponent); // Used for DEV mode warning check
|
|
150
|
+
CellMeasurer.__internalCellMeasurerFlag = false;
|
|
151
|
+
export { CellMeasurer as default };
|
|
152
|
+
if (process.env['NODE_ENV'] !== 'production') {
|
|
153
|
+
CellMeasurer.__internalCellMeasurerFlag = true;
|
|
154
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cell-measurer/index.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,0BAA0B,CAAC;AACzD,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAE9C,eAAe,YAAY,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface CellMeasureCache {
|
|
2
|
+
hasFixedWidth(): boolean;
|
|
3
|
+
hasFixedHeight(): boolean;
|
|
4
|
+
has(rowIndex: number, columnIndex: number): boolean;
|
|
5
|
+
set(rowIndex: number, columnIndex: number, width: number, height: number): void;
|
|
6
|
+
getHeight(rowIndex: number, columnIndex?: number): number;
|
|
7
|
+
getWidth(rowIndex: number, columnIndex?: number): number;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cell-measurer/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,aAAa,IAAI,OAAO,CAAC;IACzB,cAAc,IAAI,OAAO,CAAC;IAC1B,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IACpD,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAChF,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1D,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1D"}
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OverscanIndices, OverscanIndicesGetterParams } from './types.js';
|
|
2
|
+
export declare const SCROLL_DIRECTION_BACKWARD = -1;
|
|
3
|
+
export declare const SCROLL_DIRECTION_FORWARD = 1;
|
|
4
|
+
export declare const SCROLL_DIRECTION_HORIZONTAL = "horizontal";
|
|
5
|
+
export declare const SCROLL_DIRECTION_VERTICAL = "vertical";
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the number of cells to overscan before and after a specified range.
|
|
8
|
+
* This function ensures that overscanning doesn't exceed the available cells.
|
|
9
|
+
*/
|
|
10
|
+
export default function defaultOverscanIndicesGetter({ cellCount, overscanCellsCount, scrollDirection, startIndex, stopIndex, }: OverscanIndicesGetterParams): OverscanIndices;
|
|
11
|
+
//# sourceMappingURL=accessibility-overscanIndices-getter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessibility-overscanIndices-getter.d.ts","sourceRoot":"","sources":["../../src/grid/accessibility-overscanIndices-getter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAE/E,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAC5C,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,eAAO,MAAM,2BAA2B,eAAe,CAAC;AACxD,eAAO,MAAM,yBAAyB,aAAa,CAAC;AAEpD;;;GAGG;AAEH,MAAM,CAAC,OAAO,UAAU,4BAA4B,CAAC,EACnD,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,SAAS,GACV,EAAE,2BAA2B,GAAG,eAAe,CAkB/C"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export var SCROLL_DIRECTION_BACKWARD = -1;
|
|
2
|
+
export var SCROLL_DIRECTION_FORWARD = 1;
|
|
3
|
+
export var SCROLL_DIRECTION_HORIZONTAL = 'horizontal';
|
|
4
|
+
export var SCROLL_DIRECTION_VERTICAL = 'vertical';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the number of cells to overscan before and after a specified range.
|
|
8
|
+
* This function ensures that overscanning doesn't exceed the available cells.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export default function defaultOverscanIndicesGetter(_ref) {
|
|
12
|
+
var cellCount = _ref.cellCount,
|
|
13
|
+
overscanCellsCount = _ref.overscanCellsCount,
|
|
14
|
+
scrollDirection = _ref.scrollDirection,
|
|
15
|
+
startIndex = _ref.startIndex,
|
|
16
|
+
stopIndex = _ref.stopIndex;
|
|
17
|
+
// Make sure we render at least 1 cell extra before and after (except near boundaries)
|
|
18
|
+
// This is necessary in order to support keyboard navigation (TAB/SHIFT+TAB) in some cases
|
|
19
|
+
// For more info see issues #625
|
|
20
|
+
// eslint-disable-next-line no-param-reassign
|
|
21
|
+
overscanCellsCount = Math.max(1, overscanCellsCount);
|
|
22
|
+
if (scrollDirection === SCROLL_DIRECTION_FORWARD) {
|
|
23
|
+
return {
|
|
24
|
+
overscanStartIndex: Math.max(0, startIndex - 1),
|
|
25
|
+
overscanStopIndex: Math.min(cellCount - 1, stopIndex + overscanCellsCount)
|
|
26
|
+
};
|
|
27
|
+
} else {
|
|
28
|
+
return {
|
|
29
|
+
overscanStartIndex: Math.max(0, startIndex - overscanCellsCount),
|
|
30
|
+
overscanStopIndex: Math.min(cellCount - 1, stopIndex + 1)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @flow */
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
import type { CellRangeRendererParams } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Default implementation of cellRangeRenderer used by Grid.
|
|
6
|
+
* This renderer supports cell-caching while the user is scrolling.
|
|
7
|
+
*/
|
|
8
|
+
export default function defaultCellRangeRenderer({ cellCache, cellRenderer, columnSizeAndPositionManager, columnStartIndex, columnStopIndex, deferredMeasurementCache, horizontalOffsetAdjustment, isScrolling, isScrollingOptOut, parent, // Grid (or List or Table)
|
|
9
|
+
rowSizeAndPositionManager, rowStartIndex, rowStopIndex, styleCache, verticalOffsetAdjustment, visibleColumnIndices, visibleRowIndices, }: CellRangeRendererParams): (string | number | boolean | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | undefined)[];
|
|
10
|
+
//# sourceMappingURL=default-cell-range-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-cell-range-renderer.d.ts","sourceRoot":"","sources":["../../src/grid/default-cell-range-renderer.ts"],"names":[],"mappings":"AACA,YAAY;;AAEZ,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;;GAGG;AAEH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC/C,SAAS,EACT,YAAY,EACZ,4BAA4B,EAC5B,gBAAgB,EAChB,eAAe,EACf,wBAAwB,EACxB,0BAA0B,EAC1B,WAAW,EACX,iBAAiB,EACjB,MAAM,EAAE,0BAA0B;AAClC,yBAAyB,EACzB,aAAa,EACb,YAAY,EACZ,UAAU,EACV,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,GAClB,EAAE,uBAAuB,4KAiHzB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/**
|
|
3
|
+
* Default implementation of cellRangeRenderer used by Grid.
|
|
4
|
+
* This renderer supports cell-caching while the user is scrolling.
|
|
5
|
+
*/
|
|
6
|
+
export default function defaultCellRangeRenderer(_ref) {
|
|
7
|
+
var cellCache = _ref.cellCache,
|
|
8
|
+
cellRenderer = _ref.cellRenderer,
|
|
9
|
+
columnSizeAndPositionManager = _ref.columnSizeAndPositionManager,
|
|
10
|
+
columnStartIndex = _ref.columnStartIndex,
|
|
11
|
+
columnStopIndex = _ref.columnStopIndex,
|
|
12
|
+
deferredMeasurementCache = _ref.deferredMeasurementCache,
|
|
13
|
+
horizontalOffsetAdjustment = _ref.horizontalOffsetAdjustment,
|
|
14
|
+
isScrolling = _ref.isScrolling,
|
|
15
|
+
isScrollingOptOut = _ref.isScrollingOptOut,
|
|
16
|
+
parent = _ref.parent,
|
|
17
|
+
rowSizeAndPositionManager = _ref.rowSizeAndPositionManager,
|
|
18
|
+
rowStartIndex = _ref.rowStartIndex,
|
|
19
|
+
rowStopIndex = _ref.rowStopIndex,
|
|
20
|
+
styleCache = _ref.styleCache,
|
|
21
|
+
verticalOffsetAdjustment = _ref.verticalOffsetAdjustment,
|
|
22
|
+
visibleColumnIndices = _ref.visibleColumnIndices,
|
|
23
|
+
visibleRowIndices = _ref.visibleRowIndices;
|
|
24
|
+
var renderedCells = [];
|
|
25
|
+
|
|
26
|
+
// Browsers have native size limits for elements (eg Chrome 33M pixels, IE 1.5M pixes).
|
|
27
|
+
// User cannot scroll beyond these size limitations.
|
|
28
|
+
// In order to work around this, ScalingCellSizeAndPositionManager compresses offsets.
|
|
29
|
+
// We should never cache styles for compressed offsets though as this can lead to bugs.
|
|
30
|
+
// See issue #576 for more.
|
|
31
|
+
// const areOffsetsAdjusted =
|
|
32
|
+
// columnSizeAndPositionManager.areOffsetsAdjusted() ||
|
|
33
|
+
// rowSizeAndPositionManager.areOffsetsAdjusted();
|
|
34
|
+
|
|
35
|
+
// const canCacheStyle = !isScrolling && !areOffsetsAdjusted;
|
|
36
|
+
|
|
37
|
+
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
|
|
38
|
+
var rowDatum = rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
|
|
39
|
+
// 计算无偏差
|
|
40
|
+
|
|
41
|
+
for (var columnIndex = columnStartIndex; columnIndex <= columnStopIndex; columnIndex++) {
|
|
42
|
+
// const columnDatum = columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex);
|
|
43
|
+
var isVisible = columnIndex >= visibleColumnIndices['start'] && columnIndex <= visibleColumnIndices['stop'] && rowIndex >= visibleRowIndices['start'] && rowIndex <= visibleRowIndices['stop'];
|
|
44
|
+
var key = "".concat(rowIndex, "-").concat(columnIndex);
|
|
45
|
+
|
|
46
|
+
// Cache style objects so shallow-compare doesn't re-render unnecessarily.
|
|
47
|
+
// if (canCacheStyle && styleCache[key]) {
|
|
48
|
+
// style = styleCache[key];
|
|
49
|
+
// } else {
|
|
50
|
+
// In deferred mode, cells will be initially rendered before we know their size.
|
|
51
|
+
// Don't interfere with CellMeasurer's measurements by setting an invalid size.
|
|
52
|
+
// if (deferredMeasurementCache && !deferredMeasurementCache.has(rowIndex, columnIndex)) {
|
|
53
|
+
// // Position not-yet-measured cells at top/left 0,0,
|
|
54
|
+
// // And give them width/height of 'auto' so they can grow larger than the parent Grid if necessary.
|
|
55
|
+
// // Positioning them further to the right/bottom influences their measured size.
|
|
56
|
+
// style = {
|
|
57
|
+
// height: 'auto',
|
|
58
|
+
// left: 0,
|
|
59
|
+
// position: 'absolute',
|
|
60
|
+
// top: 0,
|
|
61
|
+
// width: 'auto',
|
|
62
|
+
// };
|
|
63
|
+
// } else {
|
|
64
|
+
var style = {
|
|
65
|
+
height: rowDatum.size,
|
|
66
|
+
left: '73px',
|
|
67
|
+
// columnDatum.offset + horizontalOffsetAdjustment,
|
|
68
|
+
position: 'absolute',
|
|
69
|
+
top: rowDatum.offset + verticalOffsetAdjustment,
|
|
70
|
+
width: 'calc(100% - 135px)' // columnDatum.size,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// styleCache[key] = style;
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
76
|
+
|
|
77
|
+
var cellRendererParams = {
|
|
78
|
+
columnIndex: columnIndex,
|
|
79
|
+
isScrolling: isScrolling,
|
|
80
|
+
isVisible: isVisible,
|
|
81
|
+
key: key,
|
|
82
|
+
parent: parent,
|
|
83
|
+
rowIndex: rowIndex,
|
|
84
|
+
style: style
|
|
85
|
+
};
|
|
86
|
+
var renderedCell = void 0;
|
|
87
|
+
|
|
88
|
+
// Avoid re-creating cells while scrolling.
|
|
89
|
+
// This can lead to the same cell being created many times and can cause performance issues for "heavy" cells.
|
|
90
|
+
// If a scroll is in progress- cache and reuse cells.
|
|
91
|
+
// This cache will be thrown away once scrolling completes.
|
|
92
|
+
// However if we are scaling scroll positions and sizes, we should also avoid caching.
|
|
93
|
+
// This is because the offset changes slightly as scroll position changes and caching leads to stale values.
|
|
94
|
+
// For more info refer to issue #395
|
|
95
|
+
//
|
|
96
|
+
// If isScrollingOptOut is specified, we always cache cells.
|
|
97
|
+
// For more info refer to issue #1028
|
|
98
|
+
if ((isScrollingOptOut || isScrolling) && !horizontalOffsetAdjustment && !verticalOffsetAdjustment) {
|
|
99
|
+
if (!cellCache[key]) {
|
|
100
|
+
cellCache[key] = cellRenderer(cellRendererParams);
|
|
101
|
+
}
|
|
102
|
+
renderedCell = cellCache[key];
|
|
103
|
+
|
|
104
|
+
// If the user is no longer scrolling, don't cache cells.
|
|
105
|
+
// This makes dynamic cell content difficult for users and would also lead to a heavier memory footprint.
|
|
106
|
+
} else {
|
|
107
|
+
renderedCell = cellRenderer(cellRendererParams);
|
|
108
|
+
}
|
|
109
|
+
if (renderedCell === null || renderedCell === false) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (process.env['NODE_ENV'] !== 'production') {
|
|
113
|
+
warnAboutMissingStyle(parent, renderedCell);
|
|
114
|
+
}
|
|
115
|
+
renderedCells.push(renderedCell);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return renderedCells;
|
|
119
|
+
}
|
|
120
|
+
function warnAboutMissingStyle(parent, renderedCell) {
|
|
121
|
+
if (process.env['NODE_ENV'] !== 'production') {
|
|
122
|
+
if (renderedCell) {
|
|
123
|
+
// If the direct child is a CellMeasurer, then we should check its child
|
|
124
|
+
// See issue #611
|
|
125
|
+
if (renderedCell.type && renderedCell.type.__internalCellMeasurerFlag) {
|
|
126
|
+
// eslint-disable-next-line no-param-reassign
|
|
127
|
+
renderedCell = renderedCell.props.children;
|
|
128
|
+
}
|
|
129
|
+
if (renderedCell && renderedCell.props && renderedCell.props.style === undefined && parent.__warnedAboutMissingStyle !== true) {
|
|
130
|
+
parent.__warnedAboutMissingStyle = true;
|
|
131
|
+
console.warn('Rendered cell should include style property for positioning.');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OverscanIndices, OverscanIndicesGetterParams } from './types.js';
|
|
2
|
+
export declare const SCROLL_DIRECTION_BACKWARD = -1;
|
|
3
|
+
export declare const SCROLL_DIRECTION_FORWARD = 1;
|
|
4
|
+
export declare const SCROLL_DIRECTION_HORIZONTAL = "horizontal";
|
|
5
|
+
export declare const SCROLL_DIRECTION_VERTICAL = "vertical";
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the number of cells to overscan before and after a specified range.
|
|
8
|
+
* This function ensures that overscanning doesn't exceed the available cells.
|
|
9
|
+
*/
|
|
10
|
+
export default function defaultOverscanIndicesGetter({ cellCount, overscanCellsCount, scrollDirection, startIndex, stopIndex, }: OverscanIndicesGetterParams): OverscanIndices;
|
|
11
|
+
//# sourceMappingURL=default-overscanIndices-getter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-overscanIndices-getter.d.ts","sourceRoot":"","sources":["../../src/grid/default-overscanIndices-getter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAE/E,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAC5C,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,eAAO,MAAM,2BAA2B,eAAe,CAAC;AACxD,eAAO,MAAM,yBAAyB,aAAa,CAAC;AAEpD;;;GAGG;AAEH,MAAM,CAAC,OAAO,UAAU,4BAA4B,CAAC,EACnD,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,SAAS,GACV,EAAE,2BAA2B,GAAG,eAAe,CAY/C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export var SCROLL_DIRECTION_BACKWARD = -1;
|
|
2
|
+
export var SCROLL_DIRECTION_FORWARD = 1;
|
|
3
|
+
export var SCROLL_DIRECTION_HORIZONTAL = 'horizontal';
|
|
4
|
+
export var SCROLL_DIRECTION_VERTICAL = 'vertical';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the number of cells to overscan before and after a specified range.
|
|
8
|
+
* This function ensures that overscanning doesn't exceed the available cells.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export default function defaultOverscanIndicesGetter(_ref) {
|
|
12
|
+
var cellCount = _ref.cellCount,
|
|
13
|
+
overscanCellsCount = _ref.overscanCellsCount,
|
|
14
|
+
scrollDirection = _ref.scrollDirection,
|
|
15
|
+
startIndex = _ref.startIndex,
|
|
16
|
+
stopIndex = _ref.stopIndex;
|
|
17
|
+
if (scrollDirection === SCROLL_DIRECTION_FORWARD) {
|
|
18
|
+
return {
|
|
19
|
+
overscanStartIndex: Math.max(0, startIndex),
|
|
20
|
+
overscanStopIndex: Math.min(cellCount - 1, stopIndex + overscanCellsCount)
|
|
21
|
+
};
|
|
22
|
+
} else {
|
|
23
|
+
return {
|
|
24
|
+
overscanStartIndex: Math.max(0, startIndex - overscanCellsCount),
|
|
25
|
+
overscanStopIndex: Math.min(cellCount - 1, stopIndex)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|