react-window 1.8.11 → 2.0.0-alpha.0
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/README.md +9 -161
- package/dist/react-window.cjs +22 -0
- package/dist/react-window.d.ts +217 -0
- package/dist/react-window.js +812 -0
- package/docs/assets/index-DlGpNu0r.css +1 -0
- package/docs/assets/index-fVOw1dKb.js +67 -0
- package/docs/data/addresses.json +7954 -0
- package/docs/data/contacts.json +4202 -0
- package/docs/data/names.json +1002 -0
- package/docs/favicon.svg +16 -0
- package/docs/generated/README.md +1 -0
- package/docs/generated/code-snippets/CellComponent.json +4 -0
- package/docs/generated/code-snippets/FixedHeightList.json +4 -0
- package/docs/generated/code-snippets/FixedHeightRowComponent.json +4 -0
- package/docs/generated/code-snippets/FlexboxLayout.json +4 -0
- package/docs/generated/code-snippets/Grid.json +4 -0
- package/docs/generated/code-snippets/ListVariableRowHeights.json +4 -0
- package/docs/generated/code-snippets/columnWidth.json +4 -0
- package/docs/generated/code-snippets/gridRefClickEventHandler.json +3 -0
- package/docs/generated/code-snippets/listRefClickEventHandler.json +3 -0
- package/docs/generated/code-snippets/rowHeight.json +4 -0
- package/docs/generated/code-snippets/useGridRef.json +4 -0
- package/docs/generated/code-snippets/useGridRefImport.json +3 -0
- package/docs/generated/code-snippets/useListRef.json +4 -0
- package/docs/generated/code-snippets/useListRefImport.json +3 -0
- package/docs/generated/js-docs/Grid.json +314 -0
- package/docs/generated/js-docs/List.json +266 -0
- package/docs/index.html +30 -0
- package/docs/og.html +42 -0
- package/docs/og.png +0 -0
- package/docs/stats.html +4949 -0
- package/docs/svgs/checkbox-checked.svg +1 -0
- package/docs/svgs/checkbox-indeterminate.svg +1 -0
- package/docs/svgs/checkbox-unchecked.svg +1 -0
- package/docs/svgs/github.svg +3 -0
- package/docs/svgs/npm.svg +1 -0
- package/docs/svgs/radio-checked.svg +1 -0
- package/docs/svgs/radio-unchecked.svg +1 -0
- package/package.json +70 -90
- package/LICENSE.md +0 -21
- package/dist/index-dev.umd.js +0 -2
- package/dist/index-dev.umd.js.map +0 -1
- package/dist/index-prod.umd.js +0 -2
- package/dist/index-prod.umd.js.map +0 -1
- package/dist/index.cjs.js +0 -2087
- package/dist/index.cjs.js.flow +0 -3
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -2076
- package/dist/index.esm.js.flow +0 -3
- package/dist/index.esm.js.map +0 -1
- package/src/FixedSizeGrid.js +0 -244
- package/src/FixedSizeList.js +0 -137
- package/src/VariableSizeGrid.js +0 -507
- package/src/VariableSizeList.js +0 -317
- package/src/areEqual.js +0 -18
- package/src/createGridComponent.js +0 -919
- package/src/createListComponent.js +0 -745
- package/src/domHelpers.js +0 -72
- package/src/index.js +0 -9
- package/src/shallowDiffers.js +0 -17
- package/src/shouldComponentUpdate.js +0 -16
- package/src/timer.js +0 -37
package/src/domHelpers.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
let size: number = -1;
|
|
4
|
-
|
|
5
|
-
// This utility copied from "dom-helpers" package.
|
|
6
|
-
export function getScrollbarSize(recalculate?: boolean = false): number {
|
|
7
|
-
if (size === -1 || recalculate) {
|
|
8
|
-
const div = document.createElement('div');
|
|
9
|
-
const style = div.style;
|
|
10
|
-
style.width = '50px';
|
|
11
|
-
style.height = '50px';
|
|
12
|
-
style.overflow = 'scroll';
|
|
13
|
-
|
|
14
|
-
((document.body: any): HTMLBodyElement).appendChild(div);
|
|
15
|
-
|
|
16
|
-
size = div.offsetWidth - div.clientWidth;
|
|
17
|
-
|
|
18
|
-
((document.body: any): HTMLBodyElement).removeChild(div);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return size;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type RTLOffsetType =
|
|
25
|
-
| 'negative'
|
|
26
|
-
| 'positive-descending'
|
|
27
|
-
| 'positive-ascending';
|
|
28
|
-
|
|
29
|
-
let cachedRTLResult: RTLOffsetType | null = null;
|
|
30
|
-
|
|
31
|
-
// TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
|
|
32
|
-
// Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).
|
|
33
|
-
// Safari's elastic bounce makes detecting this even more complicated wrt potential false positives.
|
|
34
|
-
// The safest way to check this is to intentionally set a negative offset,
|
|
35
|
-
// and then verify that the subsequent "scroll" event matches the negative offset.
|
|
36
|
-
// If it does not match, then we can assume a non-standard RTL scroll implementation.
|
|
37
|
-
export function getRTLOffsetType(recalculate?: boolean = false): RTLOffsetType {
|
|
38
|
-
if (cachedRTLResult === null || recalculate) {
|
|
39
|
-
const outerDiv = document.createElement('div');
|
|
40
|
-
const outerStyle = outerDiv.style;
|
|
41
|
-
outerStyle.width = '50px';
|
|
42
|
-
outerStyle.height = '50px';
|
|
43
|
-
outerStyle.overflow = 'scroll';
|
|
44
|
-
outerStyle.direction = 'rtl';
|
|
45
|
-
|
|
46
|
-
const innerDiv = document.createElement('div');
|
|
47
|
-
const innerStyle = innerDiv.style;
|
|
48
|
-
innerStyle.width = '100px';
|
|
49
|
-
innerStyle.height = '100px';
|
|
50
|
-
|
|
51
|
-
outerDiv.appendChild(innerDiv);
|
|
52
|
-
|
|
53
|
-
((document.body: any): HTMLBodyElement).appendChild(outerDiv);
|
|
54
|
-
|
|
55
|
-
if (outerDiv.scrollLeft > 0) {
|
|
56
|
-
cachedRTLResult = 'positive-descending';
|
|
57
|
-
} else {
|
|
58
|
-
outerDiv.scrollLeft = 1;
|
|
59
|
-
if (outerDiv.scrollLeft === 0) {
|
|
60
|
-
cachedRTLResult = 'negative';
|
|
61
|
-
} else {
|
|
62
|
-
cachedRTLResult = 'positive-ascending';
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
((document.body: any): HTMLBodyElement).removeChild(outerDiv);
|
|
67
|
-
|
|
68
|
-
return cachedRTLResult;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return cachedRTLResult;
|
|
72
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
export { default as VariableSizeGrid } from './VariableSizeGrid';
|
|
4
|
-
export { default as VariableSizeList } from './VariableSizeList';
|
|
5
|
-
export { default as FixedSizeGrid } from './FixedSizeGrid';
|
|
6
|
-
export { default as FixedSizeList } from './FixedSizeList';
|
|
7
|
-
|
|
8
|
-
export { default as areEqual } from './areEqual';
|
|
9
|
-
export { default as shouldComponentUpdate } from './shouldComponentUpdate';
|
package/src/shallowDiffers.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
// Pulled from react-compat
|
|
4
|
-
// https://github.com/developit/preact-compat/blob/7c5de00e7c85e2ffd011bf3af02899b63f699d3a/src/index.js#L349
|
|
5
|
-
export default function shallowDiffers(prev: Object, next: Object): boolean {
|
|
6
|
-
for (let attribute in prev) {
|
|
7
|
-
if (!(attribute in next)) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
for (let attribute in next) {
|
|
12
|
-
if (prev[attribute] !== next[attribute]) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import areEqual from './areEqual';
|
|
4
|
-
import shallowDiffers from './shallowDiffers';
|
|
5
|
-
|
|
6
|
-
// Custom shouldComponentUpdate for class components.
|
|
7
|
-
// It knows to compare individual style props and ignore the wrapper object.
|
|
8
|
-
// See https://reactjs.org/docs/react-component.html#shouldcomponentupdate
|
|
9
|
-
export default function shouldComponentUpdate(
|
|
10
|
-
nextProps: Object,
|
|
11
|
-
nextState: Object
|
|
12
|
-
): boolean {
|
|
13
|
-
return (
|
|
14
|
-
!areEqual(this.props, nextProps) || shallowDiffers(this.state, nextState)
|
|
15
|
-
);
|
|
16
|
-
}
|
package/src/timer.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
// Animation frame based implementation of setTimeout.
|
|
4
|
-
// Inspired by Joe Lambert, https://gist.github.com/joelambert/1002116#file-requesttimeout-js
|
|
5
|
-
|
|
6
|
-
const hasNativePerformanceNow =
|
|
7
|
-
typeof performance === 'object' && typeof performance.now === 'function';
|
|
8
|
-
|
|
9
|
-
const now = hasNativePerformanceNow
|
|
10
|
-
? () => performance.now()
|
|
11
|
-
: () => Date.now();
|
|
12
|
-
|
|
13
|
-
export type TimeoutID = {|
|
|
14
|
-
id: AnimationFrameID,
|
|
15
|
-
|};
|
|
16
|
-
|
|
17
|
-
export function cancelTimeout(timeoutID: TimeoutID) {
|
|
18
|
-
cancelAnimationFrame(timeoutID.id);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function requestTimeout(callback: Function, delay: number): TimeoutID {
|
|
22
|
-
const start = now();
|
|
23
|
-
|
|
24
|
-
function tick() {
|
|
25
|
-
if (now() - start >= delay) {
|
|
26
|
-
callback.call(null);
|
|
27
|
-
} else {
|
|
28
|
-
timeoutID.id = requestAnimationFrame(tick);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const timeoutID: TimeoutID = {
|
|
33
|
-
id: requestAnimationFrame(tick),
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
return timeoutID;
|
|
37
|
-
}
|