@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.
Files changed (212) hide show
  1. package/cjs/Animations/BaseAnimation.js +35 -55
  2. package/cjs/Animations/Grow.js +41 -54
  3. package/cjs/Animations/GrowRight.js +41 -63
  4. package/cjs/Animations/GrowVertical.js +7 -47
  5. package/cjs/CheckableGroup.js +65 -67
  6. package/cjs/DeferRenderAfterComputation.js +24 -48
  7. package/cjs/FocusGroup/FocusGrid.js +143 -108
  8. package/cjs/FocusGroup/FocusGroup.js +147 -88
  9. package/cjs/FocusGroup/FocusGroupContext.js +11 -38
  10. package/cjs/FocusGroup/FocusGroupManager.js +47 -56
  11. package/cjs/FocusGroup/focusGroupManagerHoc.js +42 -52
  12. package/cjs/FocusGroup/index.js +21 -47
  13. package/cjs/FocusGroup/useFocusGroupItem.js +51 -59
  14. package/cjs/FocusGroup/utils/getNextCellPosition.js +27 -47
  15. package/cjs/GroupContext/Group.js +73 -64
  16. package/cjs/GroupContext/GroupContext.js +13 -36
  17. package/cjs/GroupContext/GroupItem.js +21 -39
  18. package/cjs/GroupContext/index.js +13 -39
  19. package/cjs/ScrollSync/ScrollSync.js +75 -60
  20. package/cjs/ScrollSync/ScrollSyncPane.js +60 -52
  21. package/cjs/ScrollSync/ScrollSyncProvider.js +50 -103
  22. package/cjs/ScrollSync/index.js +11 -37
  23. package/cjs/ScrollSync/useScrollSync.js +7 -38
  24. package/cjs/constants.js +46 -65
  25. package/cjs/createDataInstance/createInstancePlugin.js +29 -41
  26. package/cjs/createDataInstance/createInstanceRef.js +71 -66
  27. package/cjs/createDataInstance/utils.js +100 -76
  28. package/cjs/defer-render-hoc/index.js +41 -48
  29. package/cjs/dimsum.config.js +6 -38
  30. package/cjs/index.js +17 -40
  31. package/cjs/prop-types.js +49 -106
  32. package/cjs/react-spring/index.js +14 -28
  33. package/cjs/react-spring/renderprops.js +14 -28
  34. package/cjs/toolbar/ToolbarProvider.js +94 -82
  35. package/cjs/useDataGrid/VolatileRowsListener.js +13 -38
  36. package/cjs/useDataGrid/index.js +7 -36
  37. package/cjs/useDataGrid/initColumnDefinition.js +110 -105
  38. package/cjs/useDataGrid/useDataGrid.js +148 -122
  39. package/cjs/useDataList/index.js +7 -36
  40. package/cjs/useDataList/recordIterator.js +18 -42
  41. package/cjs/useDataList/useDataList.js +83 -74
  42. package/cjs/utils.js +80 -71
  43. package/cjs/virtualization/AutoHeightList.js +54 -62
  44. package/cjs/virtualization/FluidHeightList.js +48 -42
  45. package/cjs/virtualization/index.js +20 -48
  46. package/esm/Animations/BaseAnimation.js +29 -26
  47. package/esm/Animations/Grow.js +35 -25
  48. package/esm/Animations/GrowRight.js +35 -34
  49. package/esm/Animations/GrowVertical.js +4 -29
  50. package/esm/CheckableGroup.js +52 -35
  51. package/esm/DeferRenderAfterComputation.js +15 -16
  52. package/esm/FocusGroup/FocusGrid.js +117 -64
  53. package/esm/FocusGroup/FocusGroup.js +137 -56
  54. package/esm/FocusGroup/FocusGroupContext.js +5 -9
  55. package/esm/FocusGroup/FocusGroupManager.js +38 -24
  56. package/esm/FocusGroup/focusGroupManagerHoc.js +36 -24
  57. package/esm/FocusGroup/index.js +6 -18
  58. package/esm/FocusGroup/useFocusGroupItem.js +40 -28
  59. package/esm/FocusGroup/utils/getNextCellPosition.js +25 -18
  60. package/esm/GroupContext/Group.js +66 -34
  61. package/esm/GroupContext/GroupContext.js +5 -7
  62. package/esm/GroupContext/GroupItem.js +15 -10
  63. package/esm/GroupContext/index.js +3 -10
  64. package/esm/ScrollSync/ScrollSync.js +64 -30
  65. package/esm/ScrollSync/ScrollSyncPane.js +52 -22
  66. package/esm/ScrollSync/ScrollSyncProvider.js +42 -74
  67. package/esm/ScrollSync/index.js +2 -8
  68. package/esm/ScrollSync/useScrollSync.js +5 -9
  69. package/esm/constants.js +28 -37
  70. package/esm/createDataInstance/createInstancePlugin.js +23 -12
  71. package/esm/createDataInstance/createInstanceRef.js +59 -36
  72. package/esm/createDataInstance/utils.js +85 -48
  73. package/esm/defer-render-hoc/index.js +31 -17
  74. package/esm/dimsum.config.js +4 -9
  75. package/esm/index.js +5 -11
  76. package/esm/prop-types.js +31 -75
  77. package/esm/react-spring/index.js +1 -3
  78. package/esm/react-spring/renderprops.js +1 -3
  79. package/esm/toolbar/ToolbarProvider.js +74 -45
  80. package/esm/useDataGrid/VolatileRowsListener.js +11 -9
  81. package/esm/useDataGrid/index.js +1 -7
  82. package/esm/useDataGrid/initColumnDefinition.js +94 -78
  83. package/esm/useDataGrid/useDataGrid.js +99 -82
  84. package/esm/useDataList/index.js +1 -7
  85. package/esm/useDataList/recordIterator.js +14 -13
  86. package/esm/useDataList/useDataList.js +67 -44
  87. package/esm/utils.js +59 -42
  88. package/esm/virtualization/AutoHeightList.js +40 -28
  89. package/esm/virtualization/FluidHeightList.js +38 -14
  90. package/esm/virtualization/index.js +16 -19
  91. package/package.json +3 -3
  92. package/types/Animations/BaseAnimation.d.ts +0 -1
  93. package/types/Animations/Grow.d.ts +0 -1
  94. package/types/Animations/GrowRight.d.ts +0 -1
  95. package/types/CheckableGroup.d.ts +0 -1
  96. package/types/DeferRenderAfterComputation.d.ts +2 -3
  97. package/types/FocusGroup/FocusGrid.d.ts +3 -5
  98. package/types/FocusGroup/FocusGroup.d.ts +1 -3
  99. package/types/FocusGroup/FocusGroupContext.d.ts +2 -3
  100. package/types/FocusGroup/FocusGroupManager.d.ts +1 -3
  101. package/types/FocusGroup/focusGroupManagerHoc.d.ts +1 -3
  102. package/types/FocusGroup/index.d.ts +6 -6
  103. package/types/FocusGroup/useFocusGroupItem.d.ts +1 -3
  104. package/types/FocusGroup/utils/getNextCellPosition.d.ts +1 -3
  105. package/types/GroupContext/Group.d.ts +0 -1
  106. package/types/GroupContext/GroupItem.d.ts +0 -1
  107. package/types/GroupContext/index.d.ts +3 -3
  108. package/types/ScrollSync/ScrollSync.d.ts +2 -4
  109. package/types/ScrollSync/ScrollSyncPane.d.ts +2 -2
  110. package/types/ScrollSync/index.d.ts +2 -2
  111. package/types/ScrollSync/useScrollSync.d.ts +5 -6
  112. package/types/createDataInstance/createInstancePlugin.d.ts +1 -2
  113. package/types/createDataInstance/createInstanceRef.d.ts +1 -3
  114. package/types/dimsum.config.d.ts +2 -3
  115. package/types/index.d.ts +2 -2
  116. package/types/toolbar/ToolbarProvider.d.ts +8 -3
  117. package/types/useDataGrid/VolatileRowsListener.d.ts +1 -3
  118. package/types/useDataGrid/index.d.ts +1 -1
  119. package/types/useDataGrid/initColumnDefinition.d.ts +1 -2
  120. package/types/useDataGrid/useDataGrid.d.ts +2 -3
  121. package/types/useDataList/index.d.ts +1 -1
  122. package/types/useDataList/useDataList.d.ts +2 -3
  123. package/cjs/Animations/BaseAnimation.js.map +0 -7
  124. package/cjs/Animations/Grow.js.map +0 -7
  125. package/cjs/Animations/GrowRight.js.map +0 -7
  126. package/cjs/Animations/GrowVertical.js.map +0 -7
  127. package/cjs/CheckableGroup.js.map +0 -7
  128. package/cjs/DeferRenderAfterComputation.js.map +0 -7
  129. package/cjs/FocusGroup/FocusGrid.js.map +0 -7
  130. package/cjs/FocusGroup/FocusGroup.js.map +0 -7
  131. package/cjs/FocusGroup/FocusGroupContext.js.map +0 -7
  132. package/cjs/FocusGroup/FocusGroupManager.js.map +0 -7
  133. package/cjs/FocusGroup/focusGroupManagerHoc.js.map +0 -7
  134. package/cjs/FocusGroup/index.js.map +0 -7
  135. package/cjs/FocusGroup/useFocusGroupItem.js.map +0 -7
  136. package/cjs/FocusGroup/utils/getNextCellPosition.js.map +0 -7
  137. package/cjs/GroupContext/Group.js.map +0 -7
  138. package/cjs/GroupContext/GroupContext.js.map +0 -7
  139. package/cjs/GroupContext/GroupItem.js.map +0 -7
  140. package/cjs/GroupContext/index.js.map +0 -7
  141. package/cjs/ScrollSync/ScrollSync.js.map +0 -7
  142. package/cjs/ScrollSync/ScrollSyncPane.js.map +0 -7
  143. package/cjs/ScrollSync/ScrollSyncProvider.js.map +0 -7
  144. package/cjs/ScrollSync/index.js.map +0 -7
  145. package/cjs/ScrollSync/useScrollSync.js.map +0 -7
  146. package/cjs/constants.js.map +0 -7
  147. package/cjs/createDataInstance/createInstancePlugin.js.map +0 -7
  148. package/cjs/createDataInstance/createInstanceRef.js.map +0 -7
  149. package/cjs/createDataInstance/utils.js.map +0 -7
  150. package/cjs/defer-render-hoc/index.js.map +0 -7
  151. package/cjs/dimsum.config.js.map +0 -7
  152. package/cjs/index.js.map +0 -7
  153. package/cjs/prop-types.js.map +0 -7
  154. package/cjs/react-spring/index.js.map +0 -7
  155. package/cjs/react-spring/renderprops.js.map +0 -7
  156. package/cjs/toolbar/ToolbarProvider.js.map +0 -7
  157. package/cjs/useDataGrid/VolatileRowsListener.js.map +0 -7
  158. package/cjs/useDataGrid/index.js.map +0 -7
  159. package/cjs/useDataGrid/initColumnDefinition.js.map +0 -7
  160. package/cjs/useDataGrid/useDataGrid.js.map +0 -7
  161. package/cjs/useDataList/index.js.map +0 -7
  162. package/cjs/useDataList/recordIterator.js.map +0 -7
  163. package/cjs/useDataList/useDataList.js.map +0 -7
  164. package/cjs/utils.js.map +0 -7
  165. package/cjs/virtualization/AutoHeightList.js.map +0 -7
  166. package/cjs/virtualization/FluidHeightList.js.map +0 -7
  167. package/cjs/virtualization/index.js.map +0 -7
  168. package/esm/Animations/BaseAnimation.js.map +0 -7
  169. package/esm/Animations/Grow.js.map +0 -7
  170. package/esm/Animations/GrowRight.js.map +0 -7
  171. package/esm/Animations/GrowVertical.js.map +0 -7
  172. package/esm/CheckableGroup.js.map +0 -7
  173. package/esm/DeferRenderAfterComputation.js.map +0 -7
  174. package/esm/FocusGroup/FocusGrid.js.map +0 -7
  175. package/esm/FocusGroup/FocusGroup.js.map +0 -7
  176. package/esm/FocusGroup/FocusGroupContext.js.map +0 -7
  177. package/esm/FocusGroup/FocusGroupManager.js.map +0 -7
  178. package/esm/FocusGroup/focusGroupManagerHoc.js.map +0 -7
  179. package/esm/FocusGroup/index.js.map +0 -7
  180. package/esm/FocusGroup/useFocusGroupItem.js.map +0 -7
  181. package/esm/FocusGroup/utils/getNextCellPosition.js.map +0 -7
  182. package/esm/GroupContext/Group.js.map +0 -7
  183. package/esm/GroupContext/GroupContext.js.map +0 -7
  184. package/esm/GroupContext/GroupItem.js.map +0 -7
  185. package/esm/GroupContext/index.js.map +0 -7
  186. package/esm/ScrollSync/ScrollSync.js.map +0 -7
  187. package/esm/ScrollSync/ScrollSyncPane.js.map +0 -7
  188. package/esm/ScrollSync/ScrollSyncProvider.js.map +0 -7
  189. package/esm/ScrollSync/index.js.map +0 -7
  190. package/esm/ScrollSync/useScrollSync.js.map +0 -7
  191. package/esm/constants.js.map +0 -7
  192. package/esm/createDataInstance/createInstancePlugin.js.map +0 -7
  193. package/esm/createDataInstance/createInstanceRef.js.map +0 -7
  194. package/esm/createDataInstance/utils.js.map +0 -7
  195. package/esm/defer-render-hoc/index.js.map +0 -7
  196. package/esm/dimsum.config.js.map +0 -7
  197. package/esm/index.js.map +0 -7
  198. package/esm/prop-types.js.map +0 -7
  199. package/esm/react-spring/index.js.map +0 -7
  200. package/esm/react-spring/renderprops.js.map +0 -7
  201. package/esm/toolbar/ToolbarProvider.js.map +0 -7
  202. package/esm/useDataGrid/VolatileRowsListener.js.map +0 -7
  203. package/esm/useDataGrid/index.js.map +0 -7
  204. package/esm/useDataGrid/initColumnDefinition.js.map +0 -7
  205. package/esm/useDataGrid/useDataGrid.js.map +0 -7
  206. package/esm/useDataList/index.js.map +0 -7
  207. package/esm/useDataList/recordIterator.js.map +0 -7
  208. package/esm/useDataList/useDataList.js.map +0 -7
  209. package/esm/utils.js.map +0 -7
  210. package/esm/virtualization/AutoHeightList.js.map +0 -7
  211. package/esm/virtualization/FluidHeightList.js.map +0 -7
  212. package/esm/virtualization/index.js.map +0 -7
@@ -1,35 +1,45 @@
1
- import * as React from "react";
2
- function getNextCellPosition({
3
- grid,
4
- currentRow = 0,
5
- currentCell = 0,
6
- directionY,
7
- directionX,
8
- shouldWrapCells,
9
- shouldWrapRows
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
- const cellsLength = grid[0].length;
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
- var getNextCellPosition_default = getNextCellPosition;
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 * as React from "react";
2
- import React2, { Component } from "react";
3
- import PropTypes from "prop-types";
4
- import { GroupContext } from "./GroupContext";
5
- const getValueItem = (e) => {
6
- const { target, currentTarget } = e;
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 { value } = target;
13
+ const {
14
+ value
15
+ } = target;
9
16
  return value;
10
17
  }
18
+
11
19
  if (currentTarget) {
12
- const { value } = currentTarget;
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
- const { Provider } = GroupContext;
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 { activeValue, disabled } = props;
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
- static getDerivedStateFromProps(nextProps, { prevValue }) {
41
- if (nextProps.activeValue === prevValue)
42
- return null;
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
- handleChange(e, ...rest) {
49
- const { multiple, onChange } = this.props;
50
- const { activeValue } = this.state;
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
- if (onChange)
62
- onChange(newValue, ...rest);
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 { children } = this.props;
66
- return /* @__PURE__ */ React2.createElement(Provider, {
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
- Group.propTypes = {
75
- children: PropTypes.array,
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 * as React from "react";
2
- import React2 from "react";
3
- const GroupContext = React2.createContext();
4
- export {
5
- GroupContext
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 * as React from "react";
2
- import React2 from "react";
3
- import { GroupContext } from "./GroupContext";
4
- const { Consumer } = GroupContext;
5
- const GroupItem = ({ render }) => /* @__PURE__ */ React2.createElement(Consumer, null, (context) => render(context));
6
- var GroupItem_default = GroupItem;
7
- export {
8
- GroupItem,
9
- GroupItem_default as default
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
- //# sourceMappingURL=GroupItem.js.map
15
+
16
+ export { GroupItem as default };
@@ -1,10 +1,3 @@
1
- import * as React from "react";
2
- import { Group } from "./Group";
3
- import { GroupContext } from "./GroupContext";
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 * as React from "react";
2
- import React2, { Component } from "react";
3
- const ScrollSyncContext = React2.createContext();
4
- const { Provider } = ScrollSyncContext;
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((group) => {
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((group) => {
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
- node.onscroll = this.handlePaneScroll.bind(this, node, groups);
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
- this.removeEvents = (node) => {
33
- node.onscroll = null;
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
- return this.panes[group].find((pane) => pane === node);
56
+
57
+ return this.panes[group].find(pane => pane === node);
40
58
  };
59
+
41
60
  this.handlePaneScroll = (node, groups, e) => {
42
- const { enabled } = this.props;
43
- if (this.props.onScroll)
44
- this.props.onScroll(e);
45
- if (!enabled)
46
- return;
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((group) => {
53
- this.panes[group].forEach((pane) => {
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 { proportional, vertical, horizontal } = this.props;
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 { children } = this.props;
92
- return /* @__PURE__ */ React2.createElement(Provider, {
127
+ const {
128
+ children
129
+ } = this.props;
130
+ return /*#__PURE__*/_jsx(Provider, {
93
131
  value: this.syncContext
94
- }, React2.Children.only(children));
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
- var ScrollSync_default = ScrollSync;
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 * as React from "react";
2
- import React2, { Component } from "react";
3
- import { ScrollSyncContext } from "./ScrollSync";
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
- this.toArray = (groups) => [].concat(groups);
23
+
24
+ this.toArray = groups => [].concat(groups);
8
25
  }
26
+
9
27
  componentWillUnmount() {
10
- const { enabled, group, syncContext } = this.props;
11
- const { unregisterPane } = syncContext;
12
- if (enabled)
13
- unregisterPane(this.node, this.toArray(group));
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 { children, group, syncContext, notPaginated } = this.props;
17
- const { registerPane } = syncContext;
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: (node) => {
50
+ registerPane: node => {
20
51
  if (notPaginated) {
21
- const virtualizedBody = node.querySelector(".virtualized-body-wrapper");
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: "default",
67
+ group: 'default',
33
68
  enabled: true
34
69
  };
35
- const ScrollSyncPaneHOC = (props) => /* @__PURE__ */ React2.createElement(ScrollSyncContext.Consumer, null, (context) => /* @__PURE__ */ React2.createElement(ScrollSyncPane, {
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
- var ScrollSyncPane_default = ScrollSyncPaneHOC;
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 * as React from "react";
2
- import React2 from "react";
3
- import raf from "raf";
4
- const ScrollSyncContext = React2.createContext();
5
- const { Provider } = ScrollSyncContext;
6
- function ScrollSyncProvider({ enabled, horizontal, vertical, children }) {
7
- const panes = useRef();
8
- const registerPane = (node, groups) => {
9
- groups.forEach((group) => {
10
- if (!this.panes[group]) {
11
- this.panes[group] = [];
12
- }
13
- if (!this.findPane(node, group)) {
14
- if (this.panes[group].length > 0) {
15
- this.syncScrollPosition(this.panes[group][0], node);
16
- }
17
- this.panes[group].push(node);
18
- }
19
- });
20
- this.addEvents(node, groups);
21
- };
22
- const unregisterPane = (node, groups) => {
23
- groups.forEach((group) => {
24
- if (this.findPane(node, group)) {
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 { proportional, vertical: vertical2, horizontal: horizontal2 } = this.props;
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
- if (vertical2 && scrollTopOffset > 0) {
77
- pane.scrollTop = proportional ? paneHeight * scrollTop / scrollTopOffset : scrollTop;
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
- if (horizontal2 && scrollLeftOffset > 0) {
80
- pane.scrollLeft = proportional ? paneWidth * scrollLeft / scrollLeftOffset : scrollLeft;
49
+
50
+ if (horizontal && scrollLeftOffset > 0) {
51
+ pane.scrollLeft = proportional ? paneWidth * scrollLeft / scrollLeftOffset : scrollLeft; // eslint-disable-line
81
52
  }
82
53
  });
83
- return /* @__PURE__ */ React2.createElement(Provider, null, children);
54
+ return /*#__PURE__*/_jsx(Provider, {}, void 0, children);
84
55
  }
85
- ScrollSyncProvider.propTypes = {};
56
+
86
57
  ScrollSyncProvider.defaultProps = {};
87
- var ScrollSyncProvider_default = ScrollSyncProvider;
88
- export {
89
- ScrollSyncProvider_default as default
90
- };
91
- //# sourceMappingURL=ScrollSyncProvider.js.map
58
+
59
+ export { ScrollSyncProvider as default };