@elliemae/ds-shared 2.2.0-alpha.4 → 3.0.0-next.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/cjs/Animations/BaseAnimation.js +35 -55
- package/cjs/Animations/Grow.js +41 -54
- package/cjs/Animations/GrowRight.js +41 -63
- package/cjs/Animations/GrowVertical.js +7 -47
- package/cjs/CheckableGroup.js +65 -67
- package/cjs/DeferRenderAfterComputation.js +24 -48
- package/cjs/FocusGroup/FocusGrid.js +143 -108
- package/cjs/FocusGroup/FocusGroup.js +147 -88
- package/cjs/FocusGroup/FocusGroupContext.js +11 -38
- package/cjs/FocusGroup/FocusGroupManager.js +47 -56
- package/cjs/FocusGroup/focusGroupManagerHoc.js +42 -52
- package/cjs/FocusGroup/index.js +21 -47
- package/cjs/FocusGroup/useFocusGroupItem.js +51 -59
- package/cjs/FocusGroup/utils/getNextCellPosition.js +27 -47
- package/cjs/GroupContext/Group.js +73 -64
- package/cjs/GroupContext/GroupContext.js +13 -36
- package/cjs/GroupContext/GroupItem.js +21 -39
- package/cjs/GroupContext/index.js +13 -39
- package/cjs/ScrollSync/ScrollSync.js +75 -60
- package/cjs/ScrollSync/ScrollSyncPane.js +60 -52
- package/cjs/ScrollSync/ScrollSyncProvider.js +50 -103
- package/cjs/ScrollSync/index.js +11 -37
- package/cjs/ScrollSync/useScrollSync.js +7 -38
- package/cjs/constants.js +46 -65
- package/cjs/createDataInstance/createInstancePlugin.js +29 -41
- package/cjs/createDataInstance/createInstanceRef.js +71 -66
- package/cjs/createDataInstance/utils.js +100 -76
- package/cjs/defer-render-hoc/index.js +41 -48
- package/cjs/dimsum.config.js +6 -38
- package/cjs/index.js +17 -40
- package/cjs/prop-types.js +49 -106
- package/cjs/react-spring/index.js +14 -28
- package/cjs/react-spring/renderprops.js +14 -28
- package/cjs/toolbar/ToolbarProvider.js +94 -82
- package/cjs/useDataGrid/VolatileRowsListener.js +13 -38
- package/cjs/useDataGrid/index.js +7 -36
- package/cjs/useDataGrid/initColumnDefinition.js +110 -105
- package/cjs/useDataGrid/useDataGrid.js +148 -122
- package/cjs/useDataList/index.js +7 -36
- package/cjs/useDataList/recordIterator.js +18 -42
- package/cjs/useDataList/useDataList.js +83 -74
- package/cjs/utils.js +80 -71
- package/cjs/virtualization/AutoHeightList.js +54 -62
- package/cjs/virtualization/FluidHeightList.js +48 -42
- package/cjs/virtualization/index.js +20 -48
- package/esm/Animations/BaseAnimation.js +29 -26
- package/esm/Animations/Grow.js +35 -25
- package/esm/Animations/GrowRight.js +35 -34
- package/esm/Animations/GrowVertical.js +4 -29
- package/esm/CheckableGroup.js +52 -35
- package/esm/DeferRenderAfterComputation.js +15 -16
- package/esm/FocusGroup/FocusGrid.js +117 -64
- package/esm/FocusGroup/FocusGroup.js +137 -56
- package/esm/FocusGroup/FocusGroupContext.js +5 -9
- package/esm/FocusGroup/FocusGroupManager.js +38 -24
- package/esm/FocusGroup/focusGroupManagerHoc.js +36 -24
- package/esm/FocusGroup/index.js +6 -18
- package/esm/FocusGroup/useFocusGroupItem.js +40 -28
- package/esm/FocusGroup/utils/getNextCellPosition.js +25 -18
- package/esm/GroupContext/Group.js +66 -34
- package/esm/GroupContext/GroupContext.js +5 -7
- package/esm/GroupContext/GroupItem.js +15 -10
- package/esm/GroupContext/index.js +3 -10
- package/esm/ScrollSync/ScrollSync.js +64 -30
- package/esm/ScrollSync/ScrollSyncPane.js +52 -22
- package/esm/ScrollSync/ScrollSyncProvider.js +42 -74
- package/esm/ScrollSync/index.js +2 -8
- package/esm/ScrollSync/useScrollSync.js +5 -9
- package/esm/constants.js +28 -37
- package/esm/createDataInstance/createInstancePlugin.js +23 -12
- package/esm/createDataInstance/createInstanceRef.js +59 -36
- package/esm/createDataInstance/utils.js +85 -48
- package/esm/defer-render-hoc/index.js +31 -17
- package/esm/dimsum.config.js +4 -9
- package/esm/index.js +5 -11
- package/esm/prop-types.js +31 -75
- package/esm/react-spring/index.js +1 -3
- package/esm/react-spring/renderprops.js +1 -3
- package/esm/toolbar/ToolbarProvider.js +74 -45
- package/esm/useDataGrid/VolatileRowsListener.js +11 -9
- package/esm/useDataGrid/index.js +1 -7
- package/esm/useDataGrid/initColumnDefinition.js +94 -78
- package/esm/useDataGrid/useDataGrid.js +99 -82
- package/esm/useDataList/index.js +1 -7
- package/esm/useDataList/recordIterator.js +14 -13
- package/esm/useDataList/useDataList.js +67 -44
- package/esm/utils.js +59 -42
- package/esm/virtualization/AutoHeightList.js +40 -28
- package/esm/virtualization/FluidHeightList.js +38 -14
- package/esm/virtualization/index.js +16 -19
- package/package.json +3 -3
- package/types/Animations/BaseAnimation.d.ts +0 -1
- package/types/Animations/Grow.d.ts +0 -1
- package/types/Animations/GrowRight.d.ts +0 -1
- package/types/CheckableGroup.d.ts +0 -1
- package/types/DeferRenderAfterComputation.d.ts +2 -3
- package/types/FocusGroup/FocusGrid.d.ts +3 -5
- package/types/FocusGroup/FocusGroup.d.ts +1 -3
- package/types/FocusGroup/FocusGroupContext.d.ts +2 -3
- package/types/FocusGroup/FocusGroupManager.d.ts +1 -3
- package/types/FocusGroup/focusGroupManagerHoc.d.ts +1 -3
- package/types/FocusGroup/index.d.ts +6 -6
- package/types/FocusGroup/useFocusGroupItem.d.ts +1 -3
- package/types/FocusGroup/utils/getNextCellPosition.d.ts +1 -3
- package/types/GroupContext/Group.d.ts +0 -1
- package/types/GroupContext/GroupItem.d.ts +0 -1
- package/types/GroupContext/index.d.ts +3 -3
- package/types/ScrollSync/ScrollSync.d.ts +2 -4
- package/types/ScrollSync/ScrollSyncPane.d.ts +2 -2
- package/types/ScrollSync/index.d.ts +2 -2
- package/types/ScrollSync/useScrollSync.d.ts +5 -6
- package/types/createDataInstance/createInstancePlugin.d.ts +1 -2
- package/types/createDataInstance/createInstanceRef.d.ts +1 -3
- package/types/dimsum.config.d.ts +2 -3
- package/types/index.d.ts +2 -2
- package/types/toolbar/ToolbarProvider.d.ts +8 -3
- package/types/useDataGrid/VolatileRowsListener.d.ts +1 -3
- package/types/useDataGrid/index.d.ts +1 -1
- package/types/useDataGrid/initColumnDefinition.d.ts +1 -2
- package/types/useDataGrid/useDataGrid.d.ts +2 -3
- package/types/useDataList/index.d.ts +1 -1
- package/types/useDataList/useDataList.d.ts +2 -3
- package/cjs/Animations/BaseAnimation.js.map +0 -7
- package/cjs/Animations/Grow.js.map +0 -7
- package/cjs/Animations/GrowRight.js.map +0 -7
- package/cjs/Animations/GrowVertical.js.map +0 -7
- package/cjs/CheckableGroup.js.map +0 -7
- package/cjs/DeferRenderAfterComputation.js.map +0 -7
- package/cjs/FocusGroup/FocusGrid.js.map +0 -7
- package/cjs/FocusGroup/FocusGroup.js.map +0 -7
- package/cjs/FocusGroup/FocusGroupContext.js.map +0 -7
- package/cjs/FocusGroup/FocusGroupManager.js.map +0 -7
- package/cjs/FocusGroup/focusGroupManagerHoc.js.map +0 -7
- package/cjs/FocusGroup/index.js.map +0 -7
- package/cjs/FocusGroup/useFocusGroupItem.js.map +0 -7
- package/cjs/FocusGroup/utils/getNextCellPosition.js.map +0 -7
- package/cjs/GroupContext/Group.js.map +0 -7
- package/cjs/GroupContext/GroupContext.js.map +0 -7
- package/cjs/GroupContext/GroupItem.js.map +0 -7
- package/cjs/GroupContext/index.js.map +0 -7
- package/cjs/ScrollSync/ScrollSync.js.map +0 -7
- package/cjs/ScrollSync/ScrollSyncPane.js.map +0 -7
- package/cjs/ScrollSync/ScrollSyncProvider.js.map +0 -7
- package/cjs/ScrollSync/index.js.map +0 -7
- package/cjs/ScrollSync/useScrollSync.js.map +0 -7
- package/cjs/constants.js.map +0 -7
- package/cjs/createDataInstance/createInstancePlugin.js.map +0 -7
- package/cjs/createDataInstance/createInstanceRef.js.map +0 -7
- package/cjs/createDataInstance/utils.js.map +0 -7
- package/cjs/defer-render-hoc/index.js.map +0 -7
- package/cjs/dimsum.config.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/prop-types.js.map +0 -7
- package/cjs/react-spring/index.js.map +0 -7
- package/cjs/react-spring/renderprops.js.map +0 -7
- package/cjs/toolbar/ToolbarProvider.js.map +0 -7
- package/cjs/useDataGrid/VolatileRowsListener.js.map +0 -7
- package/cjs/useDataGrid/index.js.map +0 -7
- package/cjs/useDataGrid/initColumnDefinition.js.map +0 -7
- package/cjs/useDataGrid/useDataGrid.js.map +0 -7
- package/cjs/useDataList/index.js.map +0 -7
- package/cjs/useDataList/recordIterator.js.map +0 -7
- package/cjs/useDataList/useDataList.js.map +0 -7
- package/cjs/utils.js.map +0 -7
- package/cjs/virtualization/AutoHeightList.js.map +0 -7
- package/cjs/virtualization/FluidHeightList.js.map +0 -7
- package/cjs/virtualization/index.js.map +0 -7
- package/esm/Animations/BaseAnimation.js.map +0 -7
- package/esm/Animations/Grow.js.map +0 -7
- package/esm/Animations/GrowRight.js.map +0 -7
- package/esm/Animations/GrowVertical.js.map +0 -7
- package/esm/CheckableGroup.js.map +0 -7
- package/esm/DeferRenderAfterComputation.js.map +0 -7
- package/esm/FocusGroup/FocusGrid.js.map +0 -7
- package/esm/FocusGroup/FocusGroup.js.map +0 -7
- package/esm/FocusGroup/FocusGroupContext.js.map +0 -7
- package/esm/FocusGroup/FocusGroupManager.js.map +0 -7
- package/esm/FocusGroup/focusGroupManagerHoc.js.map +0 -7
- package/esm/FocusGroup/index.js.map +0 -7
- package/esm/FocusGroup/useFocusGroupItem.js.map +0 -7
- package/esm/FocusGroup/utils/getNextCellPosition.js.map +0 -7
- package/esm/GroupContext/Group.js.map +0 -7
- package/esm/GroupContext/GroupContext.js.map +0 -7
- package/esm/GroupContext/GroupItem.js.map +0 -7
- package/esm/GroupContext/index.js.map +0 -7
- package/esm/ScrollSync/ScrollSync.js.map +0 -7
- package/esm/ScrollSync/ScrollSyncPane.js.map +0 -7
- package/esm/ScrollSync/ScrollSyncProvider.js.map +0 -7
- package/esm/ScrollSync/index.js.map +0 -7
- package/esm/ScrollSync/useScrollSync.js.map +0 -7
- package/esm/constants.js.map +0 -7
- package/esm/createDataInstance/createInstancePlugin.js.map +0 -7
- package/esm/createDataInstance/createInstanceRef.js.map +0 -7
- package/esm/createDataInstance/utils.js.map +0 -7
- package/esm/defer-render-hoc/index.js.map +0 -7
- package/esm/dimsum.config.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/prop-types.js.map +0 -7
- package/esm/react-spring/index.js.map +0 -7
- package/esm/react-spring/renderprops.js.map +0 -7
- package/esm/toolbar/ToolbarProvider.js.map +0 -7
- package/esm/useDataGrid/VolatileRowsListener.js.map +0 -7
- package/esm/useDataGrid/index.js.map +0 -7
- package/esm/useDataGrid/initColumnDefinition.js.map +0 -7
- package/esm/useDataGrid/useDataGrid.js.map +0 -7
- package/esm/useDataList/index.js.map +0 -7
- package/esm/useDataList/recordIterator.js.map +0 -7
- package/esm/useDataList/useDataList.js.map +0 -7
- package/esm/utils.js.map +0 -7
- package/esm/virtualization/AutoHeightList.js.map +0 -7
- package/esm/virtualization/FluidHeightList.js.map +0 -7
- package/esm/virtualization/index.js.map +0 -7
|
@@ -1,35 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
function getNextCellPosition({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
// eslint-disable-next-line max-statements
|
|
2
|
+
function getNextCellPosition(_ref) {
|
|
3
|
+
let {
|
|
4
|
+
grid,
|
|
5
|
+
currentRow = 0,
|
|
6
|
+
currentCell = 0,
|
|
7
|
+
directionY,
|
|
8
|
+
directionX,
|
|
9
|
+
shouldWrapCells,
|
|
10
|
+
shouldWrapRows
|
|
11
|
+
} = _ref;
|
|
11
12
|
let nextRow = currentRow + directionY;
|
|
12
13
|
let nextCell = currentCell + directionX;
|
|
13
14
|
const rowCount = grid.length;
|
|
14
15
|
const isLeftRight = directionX !== 0;
|
|
16
|
+
|
|
15
17
|
if (!rowCount) {
|
|
16
18
|
return false;
|
|
17
19
|
}
|
|
18
|
-
|
|
20
|
+
|
|
21
|
+
const cellsLength = grid[0].length; // moving horizontally
|
|
22
|
+
|
|
19
23
|
if (shouldWrapCells && isLeftRight) {
|
|
24
|
+
// to left
|
|
20
25
|
if (nextCell < 0) {
|
|
21
26
|
nextCell = cellsLength - 1;
|
|
22
27
|
nextRow -= 1;
|
|
23
28
|
}
|
|
29
|
+
|
|
24
30
|
if (nextCell >= cellsLength) {
|
|
25
31
|
nextCell = 0;
|
|
26
32
|
nextRow += 1;
|
|
27
33
|
}
|
|
28
|
-
}
|
|
34
|
+
} // moving vertically
|
|
35
|
+
|
|
36
|
+
|
|
29
37
|
if (shouldWrapRows && !isLeftRight) {
|
|
38
|
+
// to top
|
|
30
39
|
if (nextRow < 0) {
|
|
31
40
|
nextCell -= 1;
|
|
32
41
|
nextRow = rowCount - 1;
|
|
42
|
+
|
|
33
43
|
if (grid[nextRow] && nextCell >= 0 && !grid[nextRow][nextCell]) {
|
|
34
44
|
nextRow -= 1;
|
|
35
45
|
}
|
|
@@ -38,14 +48,11 @@ function getNextCellPosition({
|
|
|
38
48
|
nextCell += 1;
|
|
39
49
|
}
|
|
40
50
|
}
|
|
51
|
+
|
|
41
52
|
return {
|
|
42
53
|
cellIndex: nextCell,
|
|
43
54
|
rowIndex: nextRow
|
|
44
55
|
};
|
|
45
56
|
}
|
|
46
|
-
|
|
47
|
-
export {
|
|
48
|
-
getNextCellPosition_default as default,
|
|
49
|
-
getNextCellPosition
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=getNextCellPosition.js.map
|
|
57
|
+
|
|
58
|
+
export { getNextCellPosition as default };
|
|
@@ -1,35 +1,57 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { GroupContext } from
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
+
import { Component } from 'react';
|
|
4
|
+
import { GroupContext } from './GroupContext.js';
|
|
5
|
+
|
|
6
|
+
const getValueItem = e => {
|
|
7
|
+
const {
|
|
8
|
+
target,
|
|
9
|
+
currentTarget
|
|
10
|
+
} = e;
|
|
11
|
+
|
|
7
12
|
if (target) {
|
|
8
|
-
const {
|
|
13
|
+
const {
|
|
14
|
+
value
|
|
15
|
+
} = target;
|
|
9
16
|
return value;
|
|
10
17
|
}
|
|
18
|
+
|
|
11
19
|
if (currentTarget) {
|
|
12
|
-
const {
|
|
20
|
+
const {
|
|
21
|
+
value
|
|
22
|
+
} = currentTarget;
|
|
13
23
|
return value;
|
|
14
24
|
}
|
|
25
|
+
|
|
15
26
|
return e;
|
|
16
27
|
};
|
|
28
|
+
|
|
17
29
|
const toggleItemValue = (array, e) => {
|
|
18
30
|
const newvalue = getValueItem(e);
|
|
19
31
|
const res = array;
|
|
20
32
|
const index = array.indexOf(newvalue);
|
|
33
|
+
|
|
21
34
|
if (index === -1) {
|
|
22
35
|
res.push(newvalue);
|
|
23
36
|
} else {
|
|
24
37
|
res.splice(index, 1);
|
|
25
38
|
}
|
|
39
|
+
|
|
26
40
|
return res;
|
|
27
41
|
};
|
|
28
|
-
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
Provider
|
|
45
|
+
} = GroupContext;
|
|
46
|
+
/** deprecated use CheckableGroup instead */
|
|
47
|
+
|
|
29
48
|
class Group extends Component {
|
|
30
49
|
constructor(props) {
|
|
31
50
|
super(props);
|
|
32
|
-
const {
|
|
51
|
+
const {
|
|
52
|
+
activeValue,
|
|
53
|
+
disabled
|
|
54
|
+
} = props;
|
|
33
55
|
this.state = {
|
|
34
56
|
activeValue,
|
|
35
57
|
disabled,
|
|
@@ -37,50 +59,60 @@ class Group extends Component {
|
|
|
37
59
|
onChange: this.handleChange.bind(this)
|
|
38
60
|
};
|
|
39
61
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
62
|
+
|
|
63
|
+
static getDerivedStateFromProps(nextProps, _ref) {
|
|
64
|
+
let {
|
|
65
|
+
prevValue
|
|
66
|
+
} = _ref;
|
|
67
|
+
if (nextProps.activeValue === prevValue) return null;
|
|
43
68
|
return {
|
|
44
69
|
activeValue: nextProps.activeValue,
|
|
45
70
|
prevValue: nextProps.activeValue
|
|
46
71
|
};
|
|
47
72
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const {
|
|
73
|
+
|
|
74
|
+
handleChange(e) {
|
|
75
|
+
const {
|
|
76
|
+
multiple,
|
|
77
|
+
onChange
|
|
78
|
+
} = this.props;
|
|
79
|
+
const {
|
|
80
|
+
activeValue
|
|
81
|
+
} = this.state;
|
|
51
82
|
const value = getValueItem(e);
|
|
52
83
|
let newValue;
|
|
84
|
+
|
|
53
85
|
if (multiple) {
|
|
54
86
|
newValue = toggleItemValue(activeValue || [], value);
|
|
55
87
|
} else if (activeValue !== value) {
|
|
88
|
+
// default behaviour it will be toggle the active value
|
|
56
89
|
newValue = value;
|
|
57
90
|
}
|
|
91
|
+
|
|
58
92
|
this.setState({
|
|
59
93
|
activeValue: newValue
|
|
60
94
|
});
|
|
61
|
-
|
|
62
|
-
|
|
95
|
+
|
|
96
|
+
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
97
|
+
rest[_key - 1] = arguments[_key];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (onChange) onChange(newValue, ...rest);
|
|
63
101
|
}
|
|
102
|
+
|
|
64
103
|
render() {
|
|
65
|
-
const {
|
|
66
|
-
|
|
104
|
+
const {
|
|
105
|
+
children
|
|
106
|
+
} = this.props;
|
|
107
|
+
return /*#__PURE__*/_jsx(Provider, {
|
|
67
108
|
value: this.state
|
|
68
|
-
}, children);
|
|
109
|
+
}, void 0, children);
|
|
69
110
|
}
|
|
111
|
+
|
|
70
112
|
}
|
|
113
|
+
|
|
71
114
|
Group.defaultProps = {
|
|
72
115
|
multiple: false
|
|
73
116
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
multiple: PropTypes.bool,
|
|
77
|
-
onChange: PropTypes.func,
|
|
78
|
-
activeValue: PropTypes.oneOfType([PropTypes.array, PropTypes.number]),
|
|
79
|
-
disabled: PropTypes.bool
|
|
80
|
-
};
|
|
81
|
-
var Group_default = Group;
|
|
82
|
-
export {
|
|
83
|
-
Group,
|
|
84
|
-
Group_default as default
|
|
85
|
-
};
|
|
86
|
-
//# sourceMappingURL=Group.js.map
|
|
117
|
+
|
|
118
|
+
export { Group as default };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const GroupContext =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=GroupContext.js.map
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const GroupContext = /*#__PURE__*/React.createContext();
|
|
4
|
+
|
|
5
|
+
export { GroupContext };
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { GroupContext } from
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { GroupContext } from './GroupContext.js';
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
Consumer
|
|
7
|
+
} = GroupContext;
|
|
8
|
+
|
|
9
|
+
const GroupItem = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
render
|
|
12
|
+
} = _ref;
|
|
13
|
+
return /*#__PURE__*/_jsx(Consumer, {}, void 0, context => render(context));
|
|
10
14
|
};
|
|
11
|
-
|
|
15
|
+
|
|
16
|
+
export { GroupItem as default };
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { GroupItem } from "./GroupItem";
|
|
5
|
-
export {
|
|
6
|
-
Group,
|
|
7
|
-
GroupContext,
|
|
8
|
-
GroupItem
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { default as Group } from './Group.js';
|
|
2
|
+
export { GroupContext } from './GroupContext.js';
|
|
3
|
+
export { default as GroupItem } from './GroupItem.js';
|
|
@@ -1,59 +1,83 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
7
|
+
import React, { Component } from 'react';
|
|
8
|
+
|
|
9
|
+
const ScrollSyncContext = /*#__PURE__*/React.createContext();
|
|
10
|
+
const {
|
|
11
|
+
Provider
|
|
12
|
+
} = ScrollSyncContext;
|
|
5
13
|
class ScrollSync extends Component {
|
|
6
14
|
constructor(props) {
|
|
7
15
|
super(props);
|
|
8
16
|
this.panes = {};
|
|
17
|
+
|
|
9
18
|
this.registerPane = (node, groups) => {
|
|
10
|
-
groups.forEach(
|
|
19
|
+
groups.forEach(group => {
|
|
11
20
|
if (!this.panes[group]) {
|
|
12
21
|
this.panes[group] = [];
|
|
13
22
|
}
|
|
23
|
+
|
|
14
24
|
if (this.panes[group].length > 0) {
|
|
15
25
|
this.syncScrollPosition(this.panes[group][0], node);
|
|
16
26
|
}
|
|
27
|
+
|
|
17
28
|
this.panes[group].push(node);
|
|
18
29
|
});
|
|
19
30
|
this.addEvents(node, groups);
|
|
20
31
|
};
|
|
32
|
+
|
|
21
33
|
this.unregisterPane = (node, groups) => {
|
|
22
|
-
groups.forEach(
|
|
34
|
+
groups.forEach(group => {
|
|
23
35
|
if (this.findPane(node, group)) {
|
|
24
36
|
this.removeEvents(node);
|
|
25
37
|
this.panes[group].splice(this.panes[group].indexOf(node), 1);
|
|
26
38
|
}
|
|
27
39
|
});
|
|
28
40
|
};
|
|
41
|
+
|
|
29
42
|
this.addEvents = (node, groups) => {
|
|
30
|
-
|
|
43
|
+
/* For some reason element.addEventListener doesnt work with document.body */
|
|
44
|
+
node.onscroll = this.handlePaneScroll.bind(this, node, groups); // eslint-disable-line
|
|
31
45
|
};
|
|
32
|
-
|
|
33
|
-
|
|
46
|
+
|
|
47
|
+
this.removeEvents = node => {
|
|
48
|
+
/* For some reason element.removeEventListener doesnt work with document.body */
|
|
49
|
+
node.onscroll = null; // eslint-disable-line
|
|
34
50
|
};
|
|
51
|
+
|
|
35
52
|
this.findPane = (node, group) => {
|
|
36
53
|
if (!this.panes[group]) {
|
|
37
54
|
return false;
|
|
38
55
|
}
|
|
39
|
-
|
|
56
|
+
|
|
57
|
+
return this.panes[group].find(pane => pane === node);
|
|
40
58
|
};
|
|
59
|
+
|
|
41
60
|
this.handlePaneScroll = (node, groups, e) => {
|
|
42
|
-
const {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
|
|
61
|
+
const {
|
|
62
|
+
enabled
|
|
63
|
+
} = this.props;
|
|
64
|
+
if (this.props.onScroll) this.props.onScroll(e);
|
|
65
|
+
if (!enabled) return;
|
|
47
66
|
window.requestAnimationFrame(() => {
|
|
48
67
|
this.syncScrollPositions(node, groups);
|
|
49
68
|
});
|
|
50
69
|
};
|
|
70
|
+
|
|
51
71
|
this.syncScrollPositions = (scrolledPane, groups) => {
|
|
52
|
-
groups.forEach(
|
|
53
|
-
this.panes[group].forEach(
|
|
72
|
+
groups.forEach(group => {
|
|
73
|
+
this.panes[group].forEach(pane => {
|
|
74
|
+
/* For all panes beside the currently scrolling one */
|
|
54
75
|
if (scrolledPane !== pane) {
|
|
76
|
+
/* Remove event listeners from the node that we'll manipulate */
|
|
55
77
|
this.removeEvents(pane, group);
|
|
56
78
|
this.syncScrollPosition(scrolledPane, pane);
|
|
79
|
+
/* Re-attach event listeners after we're done scrolling */
|
|
80
|
+
|
|
57
81
|
window.requestAnimationFrame(() => {
|
|
58
82
|
this.addEvents(pane, groups);
|
|
59
83
|
});
|
|
@@ -61,11 +85,13 @@ class ScrollSync extends Component {
|
|
|
61
85
|
});
|
|
62
86
|
});
|
|
63
87
|
};
|
|
88
|
+
|
|
64
89
|
this.syncContext = {
|
|
65
90
|
registerPane: this.registerPane,
|
|
66
91
|
unregisterPane: this.unregisterPane
|
|
67
92
|
};
|
|
68
93
|
}
|
|
94
|
+
|
|
69
95
|
syncScrollPosition(scrolledPane, pane) {
|
|
70
96
|
const {
|
|
71
97
|
scrollTop,
|
|
@@ -77,22 +103,35 @@ class ScrollSync extends Component {
|
|
|
77
103
|
} = scrolledPane;
|
|
78
104
|
const scrollTopOffset = scrollHeight - clientHeight;
|
|
79
105
|
const scrollLeftOffset = scrollWidth - clientWidth;
|
|
80
|
-
const {
|
|
106
|
+
const {
|
|
107
|
+
proportional,
|
|
108
|
+
vertical,
|
|
109
|
+
horizontal
|
|
110
|
+
} = this.props;
|
|
111
|
+
/* Calculate the actual pane height */
|
|
112
|
+
|
|
81
113
|
const paneHeight = pane.scrollHeight - clientHeight;
|
|
82
114
|
const paneWidth = pane.scrollWidth - clientWidth;
|
|
115
|
+
/* Adjust the scrollTop position of it accordingly */
|
|
116
|
+
|
|
83
117
|
if (vertical && scrollTopOffset > 0) {
|
|
84
|
-
pane.scrollTop = proportional ? paneHeight * scrollTop / scrollTopOffset : scrollTop;
|
|
118
|
+
pane.scrollTop = proportional ? paneHeight * scrollTop / scrollTopOffset : scrollTop; // eslint-disable-line
|
|
85
119
|
}
|
|
120
|
+
|
|
86
121
|
if (horizontal && scrollLeftOffset > 0) {
|
|
87
|
-
pane.scrollLeft = proportional ? paneWidth * scrollLeft / scrollLeftOffset : scrollLeft;
|
|
122
|
+
pane.scrollLeft = proportional ? paneWidth * scrollLeft / scrollLeftOffset : scrollLeft; // eslint-disable-line
|
|
88
123
|
}
|
|
89
124
|
}
|
|
125
|
+
|
|
90
126
|
render() {
|
|
91
|
-
const {
|
|
92
|
-
|
|
127
|
+
const {
|
|
128
|
+
children
|
|
129
|
+
} = this.props;
|
|
130
|
+
return /*#__PURE__*/_jsx(Provider, {
|
|
93
131
|
value: this.syncContext
|
|
94
|
-
},
|
|
132
|
+
}, void 0, React.Children.only(children));
|
|
95
133
|
}
|
|
134
|
+
|
|
96
135
|
}
|
|
97
136
|
ScrollSync.defaultProps = {
|
|
98
137
|
proportional: true,
|
|
@@ -100,10 +139,5 @@ ScrollSync.defaultProps = {
|
|
|
100
139
|
horizontal: true,
|
|
101
140
|
enabled: true
|
|
102
141
|
};
|
|
103
|
-
|
|
104
|
-
export {
|
|
105
|
-
ScrollSync,
|
|
106
|
-
ScrollSyncContext,
|
|
107
|
-
ScrollSync_default as default
|
|
108
|
-
};
|
|
109
|
-
//# sourceMappingURL=ScrollSync.js.map
|
|
142
|
+
|
|
143
|
+
export { ScrollSyncContext, ScrollSync as default };
|
|
@@ -1,44 +1,74 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.constructor.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.to-array.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.to-array.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
10
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
11
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
12
|
+
import { Component } from 'react';
|
|
13
|
+
import { ScrollSyncContext } from './ScrollSync.js';
|
|
14
|
+
import { jsx } from 'react/jsx-runtime';
|
|
15
|
+
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
|
|
4
20
|
class ScrollSyncPane extends Component {
|
|
5
21
|
constructor() {
|
|
6
22
|
super(...arguments);
|
|
7
|
-
|
|
23
|
+
|
|
24
|
+
this.toArray = groups => [].concat(groups);
|
|
8
25
|
}
|
|
26
|
+
|
|
9
27
|
componentWillUnmount() {
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
28
|
+
const {
|
|
29
|
+
enabled,
|
|
30
|
+
group,
|
|
31
|
+
syncContext
|
|
32
|
+
} = this.props;
|
|
33
|
+
const {
|
|
34
|
+
unregisterPane
|
|
35
|
+
} = syncContext;
|
|
36
|
+
if (enabled) unregisterPane(this.node, this.toArray(group));
|
|
14
37
|
}
|
|
38
|
+
|
|
15
39
|
render() {
|
|
16
|
-
const {
|
|
17
|
-
|
|
40
|
+
const {
|
|
41
|
+
children,
|
|
42
|
+
group,
|
|
43
|
+
syncContext,
|
|
44
|
+
notPaginated
|
|
45
|
+
} = this.props;
|
|
46
|
+
const {
|
|
47
|
+
registerPane
|
|
48
|
+
} = syncContext;
|
|
18
49
|
return children({
|
|
19
|
-
registerPane:
|
|
50
|
+
registerPane: node => {
|
|
20
51
|
if (notPaginated) {
|
|
21
|
-
const virtualizedBody = node.querySelector(
|
|
52
|
+
const virtualizedBody = node.querySelector('.virtualized-body-wrapper');
|
|
53
|
+
|
|
22
54
|
if (virtualizedBody) {
|
|
23
55
|
registerPane(virtualizedBody, this.toArray(group));
|
|
24
56
|
}
|
|
25
57
|
}
|
|
58
|
+
|
|
26
59
|
return registerPane(node, this.toArray(group));
|
|
27
60
|
}
|
|
28
61
|
});
|
|
29
62
|
}
|
|
63
|
+
|
|
30
64
|
}
|
|
65
|
+
|
|
31
66
|
ScrollSyncPane.defaultProps = {
|
|
32
|
-
group:
|
|
67
|
+
group: 'default',
|
|
33
68
|
enabled: true
|
|
34
69
|
};
|
|
35
|
-
|
|
36
|
-
...props,
|
|
70
|
+
var ScrollSyncPane$1 = (props => /*#__PURE__*/_jsx(ScrollSyncContext.Consumer, {}, void 0, context => /*#__PURE__*/jsx(ScrollSyncPane, _objectSpread(_objectSpread({}, props), {}, {
|
|
37
71
|
syncContext: context
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
export {
|
|
41
|
-
ScrollSyncPaneHOC,
|
|
42
|
-
ScrollSyncPane_default as default
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=ScrollSyncPane.js.map
|
|
72
|
+
}))));
|
|
73
|
+
|
|
74
|
+
export { ScrollSyncPane$1 as default };
|
|
@@ -1,65 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.removeEvents(node);
|
|
26
|
-
this.panes[group].splice(this.panes[group].indexOf(node), 1);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
const addEvents = (node, groups) => {
|
|
31
|
-
node.onscroll = this.handlePaneScroll.bind(this, node, groups);
|
|
32
|
-
};
|
|
33
|
-
const removeEvents = (node) => {
|
|
34
|
-
node.onscroll = null;
|
|
35
|
-
};
|
|
36
|
-
const findPane = (node, group) => {
|
|
37
|
-
if (!this.panes[group]) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
return this.panes[group].find((pane) => pane === node);
|
|
41
|
-
};
|
|
42
|
-
const handlePaneScroll = (node, groups) => {
|
|
43
|
-
if (!enabled)
|
|
44
|
-
return;
|
|
45
|
-
window.requestAnimationFrame(() => {
|
|
46
|
-
this.syncScrollPositions(node, groups);
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
const syncScrollPositions = (scrolledPane, groups) => {
|
|
50
|
-
groups.forEach((group) => {
|
|
51
|
-
this.panes[group].forEach((pane) => {
|
|
52
|
-
if (scrolledPane !== pane) {
|
|
53
|
-
this.removeEvents(pane, group);
|
|
54
|
-
this.syncScrollPosition(scrolledPane, pane);
|
|
55
|
-
window.requestAnimationFrame(() => {
|
|
56
|
-
this.addEvents(pane, groups);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
const syncScrollPosition = raf((scrolledPane, pane) => {
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import raf from 'raf';
|
|
9
|
+
|
|
10
|
+
const ScrollSyncContext = /*#__PURE__*/React.createContext();
|
|
11
|
+
const {
|
|
12
|
+
Provider
|
|
13
|
+
} = ScrollSyncContext;
|
|
14
|
+
|
|
15
|
+
function ScrollSyncProvider(_ref) {
|
|
16
|
+
let {
|
|
17
|
+
enabled,
|
|
18
|
+
horizontal,
|
|
19
|
+
vertical,
|
|
20
|
+
children
|
|
21
|
+
} = _ref;
|
|
22
|
+
useRef();
|
|
23
|
+
|
|
24
|
+
raf((scrolledPane, pane) => {
|
|
63
25
|
const {
|
|
64
26
|
scrollTop,
|
|
65
27
|
scrollHeight,
|
|
@@ -70,22 +32,28 @@ function ScrollSyncProvider({ enabled, horizontal, vertical, children }) {
|
|
|
70
32
|
} = scrolledPane;
|
|
71
33
|
const scrollTopOffset = scrollHeight - clientHeight;
|
|
72
34
|
const scrollLeftOffset = scrollWidth - clientWidth;
|
|
73
|
-
const {
|
|
35
|
+
const {
|
|
36
|
+
proportional,
|
|
37
|
+
vertical,
|
|
38
|
+
horizontal
|
|
39
|
+
} = this.props;
|
|
40
|
+
/* Calculate the actual pane height */
|
|
41
|
+
|
|
74
42
|
const paneHeight = pane.scrollHeight - clientHeight;
|
|
75
43
|
const paneWidth = pane.scrollWidth - clientWidth;
|
|
76
|
-
|
|
77
|
-
|
|
44
|
+
/* Adjust the scrollTop position of it accordingly */
|
|
45
|
+
|
|
46
|
+
if (vertical && scrollTopOffset > 0) {
|
|
47
|
+
pane.scrollTop = proportional ? paneHeight * scrollTop / scrollTopOffset : scrollTop; // eslint-disable-line
|
|
78
48
|
}
|
|
79
|
-
|
|
80
|
-
|
|
49
|
+
|
|
50
|
+
if (horizontal && scrollLeftOffset > 0) {
|
|
51
|
+
pane.scrollLeft = proportional ? paneWidth * scrollLeft / scrollLeftOffset : scrollLeft; // eslint-disable-line
|
|
81
52
|
}
|
|
82
53
|
});
|
|
83
|
-
return
|
|
54
|
+
return /*#__PURE__*/_jsx(Provider, {}, void 0, children);
|
|
84
55
|
}
|
|
85
|
-
|
|
56
|
+
|
|
86
57
|
ScrollSyncProvider.defaultProps = {};
|
|
87
|
-
|
|
88
|
-
export {
|
|
89
|
-
ScrollSyncProvider_default as default
|
|
90
|
-
};
|
|
91
|
-
//# sourceMappingURL=ScrollSyncProvider.js.map
|
|
58
|
+
|
|
59
|
+
export { ScrollSyncProvider as default };
|