@elliemae/ds-shared 1.60.0 → 2.0.0-alpha.12

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 (264) hide show
  1. package/cjs/Animations/BaseAnimation.js +19 -27
  2. package/cjs/Animations/Grow.js +17 -22
  3. package/cjs/Animations/GrowRight.js +17 -23
  4. package/cjs/Animations/GrowVertical.js +3 -2
  5. package/cjs/CheckableGroup.js +40 -46
  6. package/cjs/DeferRenderAfterComputation.js +12 -21
  7. package/cjs/FocusGroup/FocusGrid.js +91 -92
  8. package/cjs/FocusGroup/FocusGroup.js +225 -262
  9. package/cjs/FocusGroup/FocusGroupContext.js +1 -2
  10. package/cjs/FocusGroup/FocusGroupManager.js +88 -126
  11. package/cjs/FocusGroup/focusGroupManagerHoc.js +28 -27
  12. package/cjs/FocusGroup/index.js +14 -28
  13. package/cjs/FocusGroup/useFocusGroupItem.js +27 -24
  14. package/cjs/FocusGroup/utils/getNextCellPosition.js +14 -15
  15. package/cjs/GroupContext/Group.js +81 -103
  16. package/cjs/GroupContext/GroupContext.js +1 -2
  17. package/cjs/GroupContext/GroupItem.js +12 -10
  18. package/cjs/GroupContext/index.js +6 -15
  19. package/cjs/ScrollSync/ScrollSync.js +90 -112
  20. package/cjs/ScrollSync/ScrollSyncPane.js +58 -90
  21. package/cjs/ScrollSync/ScrollSyncProvider.js +36 -26
  22. package/cjs/ScrollSync/index.js +4 -13
  23. package/cjs/ScrollSync/useScrollSync.js +0 -1
  24. package/cjs/constants.js +43 -4
  25. package/cjs/createDataInstance/createInstancePlugin.js +11 -10
  26. package/cjs/createDataInstance/createInstanceRef.js +41 -42
  27. package/cjs/createDataInstance/utils.js +56 -58
  28. package/cjs/defer-render-hoc/index.js +26 -61
  29. package/cjs/dimsum.config.js +7 -0
  30. package/cjs/index.js +10 -20
  31. package/cjs/prop-types.js +59 -0
  32. package/cjs/react-spring/index.js +3 -6
  33. package/cjs/react-spring/renderprops.js +3 -6
  34. package/cjs/toolbar/ToolbarProvider.js +65 -77
  35. package/cjs/useDataGrid/VolatileRowsListener.js +13 -27
  36. package/cjs/useDataGrid/index.js +2 -17
  37. package/cjs/useDataGrid/initColumnDefinition.js +46 -47
  38. package/cjs/useDataGrid/useDataGrid.js +104 -144
  39. package/cjs/useDataList/index.js +2 -15
  40. package/cjs/useDataList/recordIterator.js +9 -10
  41. package/cjs/useDataList/useDataList.js +51 -59
  42. package/cjs/utils.js +46 -59
  43. package/cjs/virtualization/AutoHeightList.js +31 -22
  44. package/cjs/virtualization/FluidHeightList.js +26 -12
  45. package/cjs/virtualization/index.js +12 -17
  46. package/esm/Animations/BaseAnimation.js +18 -26
  47. package/esm/Animations/Grow.js +15 -20
  48. package/esm/Animations/GrowRight.js +15 -21
  49. package/esm/Animations/GrowVertical.js +3 -2
  50. package/esm/CheckableGroup.js +38 -42
  51. package/esm/DeferRenderAfterComputation.js +12 -20
  52. package/esm/FocusGroup/FocusGrid.js +87 -89
  53. package/esm/FocusGroup/FocusGroup.js +222 -257
  54. package/esm/FocusGroup/FocusGroupContext.js +0 -1
  55. package/esm/FocusGroup/FocusGroupManager.js +82 -114
  56. package/esm/FocusGroup/focusGroupManagerHoc.js +24 -22
  57. package/esm/FocusGroup/index.js +0 -14
  58. package/esm/FocusGroup/useFocusGroupItem.js +25 -22
  59. package/esm/FocusGroup/utils/getNextCellPosition.js +14 -15
  60. package/esm/GroupContext/Group.js +80 -95
  61. package/esm/GroupContext/GroupContext.js +1 -2
  62. package/esm/GroupContext/GroupItem.js +10 -8
  63. package/esm/GroupContext/index.js +0 -9
  64. package/esm/ScrollSync/ScrollSync.js +88 -105
  65. package/esm/ScrollSync/ScrollSyncPane.js +56 -83
  66. package/esm/ScrollSync/ScrollSyncProvider.js +35 -26
  67. package/esm/ScrollSync/index.js +0 -9
  68. package/esm/ScrollSync/useScrollSync.js +0 -1
  69. package/esm/constants.js +31 -5
  70. package/esm/createDataInstance/createInstancePlugin.js +10 -8
  71. package/esm/createDataInstance/createInstanceRef.js +36 -36
  72. package/esm/createDataInstance/utils.js +55 -57
  73. package/esm/defer-render-hoc/index.js +25 -55
  74. package/esm/dimsum.config.js +5 -0
  75. package/esm/index.js +0 -10
  76. package/esm/prop-types.js +43 -0
  77. package/esm/react-spring/index.js +1 -2
  78. package/esm/react-spring/renderprops.js +1 -2
  79. package/esm/toolbar/ToolbarProvider.js +60 -71
  80. package/esm/useDataGrid/VolatileRowsListener.js +14 -23
  81. package/esm/useDataGrid/index.js +0 -15
  82. package/esm/useDataGrid/initColumnDefinition.js +43 -43
  83. package/esm/useDataGrid/useDataGrid.js +90 -127
  84. package/esm/useDataList/index.js +0 -13
  85. package/esm/useDataList/recordIterator.js +9 -10
  86. package/esm/useDataList/useDataList.js +39 -46
  87. package/esm/utils.js +44 -57
  88. package/esm/virtualization/AutoHeightList.js +28 -18
  89. package/esm/virtualization/FluidHeightList.js +24 -10
  90. package/esm/virtualization/index.js +6 -11
  91. package/package.json +201 -8
  92. package/types/Animations/BaseAnimation.d.ts +12 -0
  93. package/types/Animations/Grow.d.ts +11 -0
  94. package/types/Animations/GrowRight.d.ts +11 -0
  95. package/types/Animations/GrowVertical.d.ts +1 -0
  96. package/types/CheckableGroup.d.ts +20 -0
  97. package/types/DeferRenderAfterComputation.d.ts +6 -0
  98. package/types/FocusGroup/FocusGrid.d.ts +10 -0
  99. package/types/FocusGroup/FocusGroup.d.ts +36 -0
  100. package/types/FocusGroup/FocusGroupContext.d.ts +3 -0
  101. package/types/FocusGroup/FocusGroupManager.d.ts +24 -0
  102. package/types/FocusGroup/focusGroupManagerHoc.d.ts +7 -0
  103. package/types/FocusGroup/index.d.ts +6 -0
  104. package/types/FocusGroup/useFocusGroupItem.d.ts +2 -0
  105. package/types/FocusGroup/utils/getNextCellPosition.d.ts +12 -0
  106. package/types/GroupContext/Group.d.ts +14 -0
  107. package/types/GroupContext/GroupContext.d.ts +2 -0
  108. package/types/GroupContext/GroupItem.d.ts +5 -0
  109. package/types/GroupContext/index.d.ts +3 -0
  110. package/types/ScrollSync/ScrollSync.d.ts +21 -0
  111. package/types/ScrollSync/ScrollSyncPane.d.ts +3 -0
  112. package/types/ScrollSync/ScrollSyncProvider.d.ts +12 -0
  113. package/types/ScrollSync/index.d.ts +2 -0
  114. package/types/ScrollSync/useScrollSync.d.ts +6 -0
  115. package/types/constants.d.ts +30 -0
  116. package/types/createDataInstance/createInstancePlugin.d.ts +1 -0
  117. package/types/createDataInstance/createInstanceRef.d.ts +12 -0
  118. package/types/createDataInstance/tests/createInstanceRef.test.d.ts +0 -0
  119. package/types/createDataInstance/utils.d.ts +9 -0
  120. package/types/dimsum.config.d.ts +4 -0
  121. package/types/index.d.ts +2 -0
  122. package/types/prop-types.d.ts +41 -0
  123. package/types/react-spring/index.d.ts +1 -0
  124. package/types/react-spring/renderprops.d.ts +1 -0
  125. package/types/toolbar/ToolbarProvider.d.ts +10 -0
  126. package/types/useDataGrid/VolatileRowsListener.d.ts +5 -0
  127. package/types/useDataGrid/index.d.ts +1 -0
  128. package/types/useDataGrid/initColumnDefinition.d.ts +5 -0
  129. package/types/useDataGrid/useDataGrid.d.ts +8 -0
  130. package/types/useDataList/index.d.ts +1 -0
  131. package/types/useDataList/recordIterator.d.ts +1 -0
  132. package/types/useDataList/useDataList.d.ts +13 -0
  133. package/types/utils.d.ts +22 -0
  134. package/types/virtualization/AutoHeightList.d.ts +2 -0
  135. package/types/virtualization/FluidHeightList.d.ts +2 -0
  136. package/types/virtualization/index.d.ts +9 -0
  137. package/Animations/BaseAnimation/package.json +0 -10
  138. package/Animations/Grow/package.json +0 -10
  139. package/Animations/GrowRight/package.json +0 -10
  140. package/Animations/GrowVertical/package.json +0 -10
  141. package/CheckableGroup/package.json +0 -10
  142. package/DeferRenderAfterComputation/package.json +0 -10
  143. package/FocusGroup/FocusGrid/package.json +0 -10
  144. package/FocusGroup/FocusGroup/package.json +0 -10
  145. package/FocusGroup/FocusGroupContext/package.json +0 -10
  146. package/FocusGroup/FocusGroupManager/package.json +0 -10
  147. package/FocusGroup/focusGroupManagerHoc/package.json +0 -10
  148. package/FocusGroup/package.json +0 -10
  149. package/FocusGroup/useFocusGroupItem/package.json +0 -10
  150. package/FocusGroup/utils/getNextCellPosition/package.json +0 -10
  151. package/GroupContext/Group/package.json +0 -10
  152. package/GroupContext/GroupContext/package.json +0 -10
  153. package/GroupContext/GroupItem/package.json +0 -10
  154. package/GroupContext/package.json +0 -10
  155. package/ScrollSync/ScrollSync/package.json +0 -10
  156. package/ScrollSync/ScrollSyncPane/package.json +0 -10
  157. package/ScrollSync/ScrollSyncProvider/package.json +0 -10
  158. package/ScrollSync/package.json +0 -10
  159. package/ScrollSync/useScrollSync/package.json +0 -10
  160. package/cjs/Animations/BaseAnimation.js.map +0 -1
  161. package/cjs/Animations/Grow.js.map +0 -1
  162. package/cjs/Animations/GrowRight.js.map +0 -1
  163. package/cjs/Animations/GrowVertical.js.map +0 -1
  164. package/cjs/CheckableGroup.js.map +0 -1
  165. package/cjs/DeferRenderAfterComputation.js.map +0 -1
  166. package/cjs/FocusGroup/FocusGrid.js.map +0 -1
  167. package/cjs/FocusGroup/FocusGroup.js.map +0 -1
  168. package/cjs/FocusGroup/FocusGroupContext.js.map +0 -1
  169. package/cjs/FocusGroup/FocusGroupManager.js.map +0 -1
  170. package/cjs/FocusGroup/focusGroupManagerHoc.js.map +0 -1
  171. package/cjs/FocusGroup/index.js.map +0 -1
  172. package/cjs/FocusGroup/useFocusGroupItem.js.map +0 -1
  173. package/cjs/FocusGroup/utils/getNextCellPosition.js.map +0 -1
  174. package/cjs/GroupContext/Group.js.map +0 -1
  175. package/cjs/GroupContext/GroupContext.js.map +0 -1
  176. package/cjs/GroupContext/GroupItem.js.map +0 -1
  177. package/cjs/GroupContext/index.js.map +0 -1
  178. package/cjs/ScrollSync/ScrollSync.js.map +0 -1
  179. package/cjs/ScrollSync/ScrollSyncPane.js.map +0 -1
  180. package/cjs/ScrollSync/ScrollSyncProvider.js.map +0 -1
  181. package/cjs/ScrollSync/index.js.map +0 -1
  182. package/cjs/ScrollSync/useScrollSync.js.map +0 -1
  183. package/cjs/constants.js.map +0 -1
  184. package/cjs/createDataInstance/createInstancePlugin.js.map +0 -1
  185. package/cjs/createDataInstance/createInstanceRef.js.map +0 -1
  186. package/cjs/createDataInstance/utils.js.map +0 -1
  187. package/cjs/defer-render-hoc/index.js.map +0 -1
  188. package/cjs/index.js.map +0 -1
  189. package/cjs/react-spring/index.js.map +0 -1
  190. package/cjs/react-spring/renderprops.js.map +0 -1
  191. package/cjs/toolbar/ToolbarProvider.js.map +0 -1
  192. package/cjs/useDataGrid/VolatileRowsListener.js.map +0 -1
  193. package/cjs/useDataGrid/index.js.map +0 -1
  194. package/cjs/useDataGrid/initColumnDefinition.js.map +0 -1
  195. package/cjs/useDataGrid/useDataGrid.js.map +0 -1
  196. package/cjs/useDataList/index.js.map +0 -1
  197. package/cjs/useDataList/recordIterator.js.map +0 -1
  198. package/cjs/useDataList/useDataList.js.map +0 -1
  199. package/cjs/utils.js.map +0 -1
  200. package/cjs/virtualization/AutoHeightList.js.map +0 -1
  201. package/cjs/virtualization/FluidHeightList.js.map +0 -1
  202. package/cjs/virtualization/index.js.map +0 -1
  203. package/constants/package.json +0 -10
  204. package/createDataInstance/createInstancePlugin/package.json +0 -10
  205. package/createDataInstance/createInstanceRef/package.json +0 -10
  206. package/createDataInstance/utils/package.json +0 -10
  207. package/defer-render-hoc/package.json +0 -10
  208. package/esm/Animations/BaseAnimation.js.map +0 -1
  209. package/esm/Animations/Grow.js.map +0 -1
  210. package/esm/Animations/GrowRight.js.map +0 -1
  211. package/esm/Animations/GrowVertical.js.map +0 -1
  212. package/esm/CheckableGroup.js.map +0 -1
  213. package/esm/DeferRenderAfterComputation.js.map +0 -1
  214. package/esm/FocusGroup/FocusGrid.js.map +0 -1
  215. package/esm/FocusGroup/FocusGroup.js.map +0 -1
  216. package/esm/FocusGroup/FocusGroupContext.js.map +0 -1
  217. package/esm/FocusGroup/FocusGroupManager.js.map +0 -1
  218. package/esm/FocusGroup/focusGroupManagerHoc.js.map +0 -1
  219. package/esm/FocusGroup/index.js.map +0 -1
  220. package/esm/FocusGroup/useFocusGroupItem.js.map +0 -1
  221. package/esm/FocusGroup/utils/getNextCellPosition.js.map +0 -1
  222. package/esm/GroupContext/Group.js.map +0 -1
  223. package/esm/GroupContext/GroupContext.js.map +0 -1
  224. package/esm/GroupContext/GroupItem.js.map +0 -1
  225. package/esm/GroupContext/index.js.map +0 -1
  226. package/esm/ScrollSync/ScrollSync.js.map +0 -1
  227. package/esm/ScrollSync/ScrollSyncPane.js.map +0 -1
  228. package/esm/ScrollSync/ScrollSyncProvider.js.map +0 -1
  229. package/esm/ScrollSync/index.js.map +0 -1
  230. package/esm/ScrollSync/useScrollSync.js.map +0 -1
  231. package/esm/constants.js.map +0 -1
  232. package/esm/createDataInstance/createInstancePlugin.js.map +0 -1
  233. package/esm/createDataInstance/createInstanceRef.js.map +0 -1
  234. package/esm/createDataInstance/utils.js.map +0 -1
  235. package/esm/defer-render-hoc/index.js.map +0 -1
  236. package/esm/index.js.map +0 -1
  237. package/esm/react-spring/index.js.map +0 -1
  238. package/esm/react-spring/renderprops.js.map +0 -1
  239. package/esm/toolbar/ToolbarProvider.js.map +0 -1
  240. package/esm/useDataGrid/VolatileRowsListener.js.map +0 -1
  241. package/esm/useDataGrid/index.js.map +0 -1
  242. package/esm/useDataGrid/initColumnDefinition.js.map +0 -1
  243. package/esm/useDataGrid/useDataGrid.js.map +0 -1
  244. package/esm/useDataList/index.js.map +0 -1
  245. package/esm/useDataList/recordIterator.js.map +0 -1
  246. package/esm/useDataList/useDataList.js.map +0 -1
  247. package/esm/utils.js.map +0 -1
  248. package/esm/virtualization/AutoHeightList.js.map +0 -1
  249. package/esm/virtualization/FluidHeightList.js.map +0 -1
  250. package/esm/virtualization/index.js.map +0 -1
  251. package/react-spring/package.json +0 -10
  252. package/react-spring/renderprops/package.json +0 -10
  253. package/toolbar/ToolbarProvider/package.json +0 -10
  254. package/useDataGrid/VolatileRowsListener/package.json +0 -10
  255. package/useDataGrid/initColumnDefinition/package.json +0 -10
  256. package/useDataGrid/package.json +0 -10
  257. package/useDataGrid/useDataGrid/package.json +0 -10
  258. package/useDataList/package.json +0 -10
  259. package/useDataList/recordIterator/package.json +0 -10
  260. package/useDataList/useDataList/package.json +0 -10
  261. package/utils/package.json +0 -10
  262. package/virtualization/AutoHeightList/package.json +0 -10
  263. package/virtualization/FluidHeightList/package.json +0 -10
  264. package/virtualization/package.json +0 -10
@@ -1,17 +1,23 @@
1
- import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';
2
- import _createClass from '@babel/runtime/helpers/esm/createClass';
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.filter.js';
3
3
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
4
+ import 'core-js/modules/web.dom-collections.iterator.js';
5
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
6
+ import 'core-js/modules/esnext.iterator.constructor.js';
7
+ import 'core-js/modules/esnext.iterator.for-each.js';
8
+ import 'core-js/modules/esnext.async-iterator.map.js';
9
+ import 'core-js/modules/esnext.iterator.map.js';
4
10
  import { get, isFunction } from '@elliemae/ds-utilities';
5
11
  import hotkeys from 'hotkeys-js';
6
12
 
7
13
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
8
14
 
9
15
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
10
- var defaultOptions = {
16
+ const defaultOptions = {
11
17
  orientation: 'vertical'
12
18
  };
13
19
 
14
- var safeCallAction = function safeCallAction(e, fun) {
20
+ const safeCallAction = function (e, fun) {
15
21
  if (isFunction(fun)) {
16
22
  e.preventDefault();
17
23
 
@@ -19,25 +25,23 @@ var safeCallAction = function safeCallAction(e, fun) {
19
25
  args[_key - 2] = arguments[_key];
20
26
  }
21
27
 
22
- fun.apply(void 0, args);
28
+ fun(...args);
23
29
  }
24
30
  };
25
31
 
26
- var registerHotkeys = function registerHotkeys() {
27
- var hotKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
28
- var params = arguments.length > 1 ? arguments[1] : undefined;
29
- var getContainer = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
30
- return document;
31
- };
32
- Object.keys(hotKeys).forEach(function (hotkey) {
33
- var _hotKeys$hotkey = hotKeys[hotkey],
34
- options = _hotKeys$hotkey.options,
35
- handler = _hotKeys$hotkey.handler,
36
- _hotKeys$hotkey$allow = _hotKeys$hotkey.allowDocumentHandler,
37
- allowDocumentHandler = _hotKeys$hotkey$allow === void 0 ? false : _hotKeys$hotkey$allow;
38
-
39
- var parameterizedHandler = function parameterizedHandler(e) {
40
- var handlerParams = isFunction(params) ? params() : params;
32
+ const registerHotkeys = function () {
33
+ let hotKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
34
+ let params = arguments.length > 1 ? arguments[1] : undefined;
35
+ let getContainer = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => document;
36
+ Object.keys(hotKeys).forEach(hotkey => {
37
+ const {
38
+ options,
39
+ handler,
40
+ allowDocumentHandler = false
41
+ } = hotKeys[hotkey];
42
+
43
+ const parameterizedHandler = e => {
44
+ const handlerParams = isFunction(params) ? params() : params;
41
45
  if (!allowDocumentHandler && handlerParams.item !== document.activeElement) return;
42
46
  e.preventDefault();
43
47
  handler(handlerParams);
@@ -49,26 +53,23 @@ var registerHotkeys = function registerHotkeys() {
49
53
  });
50
54
  };
51
55
 
52
- var unregisterHotKeys = function unregisterHotKeys() {
53
- var hotKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
54
- Object.keys(hotKeys).forEach(function (hotkey) {
56
+ const unregisterHotKeys = function () {
57
+ let hotKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
58
+ Object.keys(hotKeys).forEach(hotkey => {
55
59
  hotkeys.unbind(hotkey);
56
60
  });
57
61
  };
58
62
 
59
- var noop = function noop() {
60
- return null;
61
- };
62
-
63
- var FocusGroup = /*#__PURE__*/function () {
64
- function FocusGroup() {
65
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
66
-
67
- _classCallCheck(this, FocusGroup);
63
+ const noop = () => null;
68
64
 
65
+ class FocusGroup {
66
+ constructor() {
67
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
69
68
  this.items = [];
70
69
  this.options = _objectSpread(_objectSpread({}, defaultOptions), options);
71
- var orientation = this.options.orientation;
70
+ const {
71
+ orientation
72
+ } = this.options;
72
73
  this.keyBindings = _objectSpread({
73
74
  ArrowUp: orientation !== 'horizontal' && 'previous',
74
75
  ArrowRight: orientation !== 'vertical' && 'next',
@@ -88,9 +89,7 @@ var FocusGroup = /*#__PURE__*/function () {
88
89
  first: this.focusFirst.bind(this),
89
90
  last: this.focusLast.bind(this),
90
91
  exit: this.exit.bind(this),
91
- enter: function enter() {
92
- return null;
93
- }
92
+ enter: () => null
94
93
  };
95
94
  this.handleKeyDown = this.handleKeyDown.bind(this);
96
95
  this.register = this.register.bind(this);
@@ -104,233 +103,199 @@ var FocusGroup = /*#__PURE__*/function () {
104
103
  this.getHotKeysParams = this.getHotKeysParams.bind(this);
105
104
  }
106
105
 
107
- _createClass(FocusGroup, [{
108
- key: "getHotKeysParams",
109
- value: function getHotKeysParams() {
110
- var item = this.currentFocusedItem;
106
+ getHotKeysParams() {
107
+ const item = this.currentFocusedItem;
108
+ const {
109
+ index
110
+ } = get(item, ['dataset'], {});
111
+ return {
112
+ item,
113
+ index
114
+ };
115
+ }
111
116
 
112
- var _get = get(item, ['dataset'], {}),
113
- index = _get.index;
117
+ activate() {
118
+ const {
119
+ getContainer
120
+ } = this.options;
121
+ document.addEventListener('keydown', this.handleKeyDown, true);
122
+ registerHotkeys(this.options.hotKeys, this.getHotKeysParams, getContainer);
123
+ }
114
124
 
115
- return {
116
- item: item,
117
- index: index
118
- };
119
- }
120
- }, {
121
- key: "activate",
122
- value: function activate() {
123
- var getContainer = this.options.getContainer;
124
- document.addEventListener('keydown', this.handleKeyDown, true);
125
- registerHotkeys(this.options.hotKeys, this.getHotKeysParams, getContainer);
126
- }
127
- }, {
128
- key: "deactivate",
129
- value: function deactivate() {
130
- document.removeEventListener('keydown', this.handleKeyDown, true);
131
- unregisterHotKeys(this.options.hotKeys);
132
- }
133
- }, {
134
- key: "handleKeyDown",
135
- value: function handleKeyDown(e) {
136
- if (!this.isGroupActive()) return;
137
- this.executeActionByEvent(e);
138
- }
139
- }, {
140
- key: "executeActionByEvent",
141
- value: function executeActionByEvent(e) {
142
- var _this = this;
143
-
144
- var actions = Array.isArray(this.keyBindings[e.key]) ? this.keyBindings[e.key] : [this.keyBindings[e.key]];
145
- return actions.map(function (action) {
146
- return typeof action === 'string' ? safeCallAction(e, _this.mapActions[action]) : safeCallAction(e, action);
147
- });
148
- }
149
- }, {
150
- key: "register",
151
- value: function register(node) {
152
- var _this2 = this;
153
-
154
- var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
155
- var afterIndex = this.items.findIndex(function (item) {
156
- return item.compareDocumentPosition(node) === Node.DOCUMENT_POSITION_PRECEDING;
157
- });
158
- node.specialOnFocus = props.onFocus || noop;
159
- node.specialOnBlur = props.onBlur || noop;
160
-
161
- node.onclick = function () {
162
- return _this2.focusItem(node);
163
- };
164
-
165
- node.onfocus = function () {
166
- _this2.focusItem(node);
167
- };
168
-
169
- if (afterIndex === -1) {
170
- this.items.push(node);
171
- } else {
172
- this.items.splice(afterIndex, 0, node);
173
- }
174
- }
175
- }, {
176
- key: "unregister",
177
- value: function unregister(node) {
178
- var index = this.getItemIndexByNode(node);
179
- if (index > -1) this.items.splice(index, 1);
180
- }
181
- }, {
182
- key: "exit",
183
- value: function exit() {
184
- var onExitFocusGroup = this.options.onExitFocusGroup;
185
- onExitFocusGroup();
186
- }
187
- }, {
188
- key: "focusItem",
189
- value: function focusItem(node) {
190
- if (this.currentFocusedItem && this.currentFocusedItem !== node) {
191
- this.currentFocusedItem.specialOnBlur();
192
- this.currentFocusedItem.setAttribute('tabindex', -1);
193
- }
194
-
195
- if (!node) return;
196
- this.currentFocusedItem = node;
197
- node.setAttribute('tabindex', 0);
198
- node.focus();
199
- node.specialOnFocus();
200
- }
201
- }, {
202
- key: "focusNext",
203
- value: function focusNext() {
204
- var item = this.getNextItem();
205
- this.focusItem(item);
206
- }
207
- }, {
208
- key: "focusByNode",
209
- value: function focusByNode(node) {
210
- var index = this.getItemIndexByNode(node);
211
- this.focusByIndex(index);
212
- }
213
- }, {
214
- key: "focusByIndex",
215
- value: function focusByIndex(index) {
216
- var item = this.getItemByIndex(index);
217
- this.focusItem(item);
218
- }
219
- }, {
220
- key: "focusPrevious",
221
- value: function focusPrevious() {
222
- var prevItem = this.getPreviousItem();
223
- this.focusItem(prevItem);
224
- }
225
- }, {
226
- key: "focusFirst",
227
- value: function focusFirst() {
228
- var item = this.getFirstItem();
229
- this.focusItem(item);
230
- }
231
- }, {
232
- key: "focusLast",
233
- value: function focusLast() {
234
- var item = this.getLastItem();
235
- this.focusItem(item);
236
- }
237
- }, {
238
- key: "focusCurrent",
239
- value: function focusCurrent() {
240
- this.focusItem(this.currentFocusedItem);
241
- }
242
- }, {
243
- key: "focusNextGroup",
244
- value: function focusNextGroup() {
245
- var onFocusNextGroup = this.options.onFocusNextGroup;
246
- this.exit();
247
- onFocusNextGroup();
248
- }
249
- }, {
250
- key: "focusPreviousGroup",
251
- value: function focusPreviousGroup() {
252
- var onFocusPreviousGroup = this.options.onFocusPreviousGroup;
253
- this.exit();
254
- onFocusPreviousGroup();
255
- }
256
- }, {
257
- key: "getNextItem",
258
- value: function getNextItem() {
259
- var loop = this.options.loop;
260
- var currentIndex = this.getFocusedIndex();
261
- var supposedNextIndex = currentIndex + 1;
262
-
263
- if (!this.checkCanFocusNext(supposedNextIndex)) {
264
- return loop ? this.getFirstItem() : this.focusNextGroup();
265
- }
266
-
267
- return this.getItemByIndex(supposedNextIndex);
268
- }
269
- }, {
270
- key: "getPreviousItem",
271
- value: function getPreviousItem() {
272
- var loop = this.options.loop;
273
- var currentIndex = this.getFocusedIndex();
274
- var supposedPrevIndex = currentIndex - 1;
275
-
276
- if (!this.checkCanFocusPrev(supposedPrevIndex)) {
277
- return loop ? this.getLastItem() : this.focusPreviousGroup();
278
- }
279
-
280
- return this.getItemByIndex(supposedPrevIndex);
281
- }
282
- }, {
283
- key: "checkCanFocusNext",
284
- value: function checkCanFocusNext(index) {
285
- return this.items.length > index;
286
- }
287
- }, {
288
- key: "checkCanFocusPrev",
289
- value: function checkCanFocusPrev(index) {
290
- return index >= 0;
291
- }
292
- }, {
293
- key: "getItemByIndex",
294
- value: function getItemByIndex(index) {
295
- return this.items[index];
296
- }
297
- }, {
298
- key: "getItemIndexByNode",
299
- value: function getItemIndexByNode(node) {
300
- return this.items.findIndex(function (item) {
301
- return item === node;
302
- });
303
- }
304
- }, {
305
- key: "getFocusedIndex",
306
- value: function getFocusedIndex() {
307
- return this.getItemIndexByNode(document.activeElement);
308
- }
309
- }, {
310
- key: "getFocusedItem",
311
- value: function getFocusedItem() {
312
- var index = this.getFocusedIndex();
313
- return index > -1 && this.items[index];
125
+ deactivate() {
126
+ document.removeEventListener('keydown', this.handleKeyDown, true);
127
+ unregisterHotKeys(this.options.hotKeys);
128
+ }
129
+
130
+ handleKeyDown(e) {
131
+ if (!this.isGroupActive()) return;
132
+ this.executeActionByEvent(e);
133
+ }
134
+
135
+ executeActionByEvent(e) {
136
+ const actions = Array.isArray(this.keyBindings[e.key]) ? this.keyBindings[e.key] : [this.keyBindings[e.key]];
137
+ return actions.map(action => typeof action === 'string' ? safeCallAction(e, this.mapActions[action]) : safeCallAction(e, action));
138
+ }
139
+
140
+ register(node) {
141
+ let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
142
+ const afterIndex = this.items.findIndex(item => item.compareDocumentPosition(node) === Node.DOCUMENT_POSITION_PRECEDING);
143
+ node.specialOnFocus = props.onFocus || noop;
144
+ node.specialOnBlur = props.onBlur || noop;
145
+
146
+ node.onclick = () => this.focusItem(node);
147
+
148
+ node.onfocus = () => {
149
+ this.focusItem(node);
150
+ };
151
+
152
+ if (afterIndex === -1) {
153
+ this.items.push(node);
154
+ } else {
155
+ this.items.splice(afterIndex, 0, node);
314
156
  }
315
- }, {
316
- key: "isGroupActive",
317
- value: function isGroupActive() {
318
- return this.getFocusedIndex() !== -1;
157
+ }
158
+
159
+ unregister(node) {
160
+ const index = this.getItemIndexByNode(node);
161
+ if (index > -1) this.items.splice(index, 1);
162
+ }
163
+
164
+ exit() {
165
+ const {
166
+ onExitFocusGroup
167
+ } = this.options;
168
+ onExitFocusGroup();
169
+ }
170
+
171
+ focusItem(node) {
172
+ if (this.currentFocusedItem && this.currentFocusedItem !== node) {
173
+ this.currentFocusedItem.specialOnBlur();
174
+ this.currentFocusedItem.setAttribute('tabindex', -1);
319
175
  }
320
- }, {
321
- key: "getFirstItem",
322
- value: function getFirstItem() {
323
- return !!this.items.length && this.items[0];
176
+
177
+ if (!node) return;
178
+ this.currentFocusedItem = node;
179
+ node.setAttribute('tabindex', 0);
180
+ node.focus();
181
+ node.specialOnFocus();
182
+ }
183
+
184
+ focusNext() {
185
+ const item = this.getNextItem();
186
+ this.focusItem(item);
187
+ }
188
+
189
+ focusByNode(node) {
190
+ const index = this.getItemIndexByNode(node);
191
+ this.focusByIndex(index);
192
+ }
193
+
194
+ focusByIndex(index) {
195
+ const item = this.getItemByIndex(index);
196
+ this.focusItem(item);
197
+ }
198
+
199
+ focusPrevious() {
200
+ const prevItem = this.getPreviousItem();
201
+ this.focusItem(prevItem);
202
+ }
203
+
204
+ focusFirst() {
205
+ const item = this.getFirstItem();
206
+ this.focusItem(item);
207
+ }
208
+
209
+ focusLast() {
210
+ const item = this.getLastItem();
211
+ this.focusItem(item);
212
+ }
213
+
214
+ focusCurrent() {
215
+ this.focusItem(this.currentFocusedItem);
216
+ }
217
+
218
+ focusNextGroup() {
219
+ const {
220
+ onFocusNextGroup
221
+ } = this.options;
222
+ this.exit();
223
+ onFocusNextGroup();
224
+ }
225
+
226
+ focusPreviousGroup() {
227
+ const {
228
+ onFocusPreviousGroup
229
+ } = this.options;
230
+ this.exit();
231
+ onFocusPreviousGroup();
232
+ }
233
+
234
+ getNextItem() {
235
+ const {
236
+ loop
237
+ } = this.options;
238
+ const currentIndex = this.getFocusedIndex();
239
+ const supposedNextIndex = currentIndex + 1;
240
+
241
+ if (!this.checkCanFocusNext(supposedNextIndex)) {
242
+ return loop ? this.getFirstItem() : this.focusNextGroup();
324
243
  }
325
- }, {
326
- key: "getLastItem",
327
- value: function getLastItem() {
328
- return !!this.items.length && this.items[this.items.length - 1];
244
+
245
+ return this.getItemByIndex(supposedNextIndex);
246
+ }
247
+
248
+ getPreviousItem() {
249
+ const {
250
+ loop
251
+ } = this.options;
252
+ const currentIndex = this.getFocusedIndex();
253
+ const supposedPrevIndex = currentIndex - 1;
254
+
255
+ if (!this.checkCanFocusPrev(supposedPrevIndex)) {
256
+ return loop ? this.getLastItem() : this.focusPreviousGroup();
329
257
  }
330
- }]);
331
258
 
332
- return FocusGroup;
333
- }();
259
+ return this.getItemByIndex(supposedPrevIndex);
260
+ }
261
+
262
+ checkCanFocusNext(index) {
263
+ return this.items.length > index;
264
+ }
265
+
266
+ checkCanFocusPrev(index) {
267
+ return index >= 0;
268
+ }
269
+
270
+ getItemByIndex(index) {
271
+ return this.items[index];
272
+ }
273
+
274
+ getItemIndexByNode(node) {
275
+ return this.items.findIndex(item => item === node);
276
+ }
277
+
278
+ getFocusedIndex() {
279
+ return this.getItemIndexByNode(document.activeElement);
280
+ }
281
+
282
+ getFocusedItem() {
283
+ const index = this.getFocusedIndex();
284
+ return index > -1 && this.items[index];
285
+ }
286
+
287
+ isGroupActive() {
288
+ return this.getFocusedIndex() !== -1;
289
+ }
290
+
291
+ getFirstItem() {
292
+ return !!this.items.length && this.items[0];
293
+ }
294
+
295
+ getLastItem() {
296
+ return !!this.items.length && this.items[this.items.length - 1];
297
+ }
298
+
299
+ }
334
300
 
335
301
  export { FocusGroup as default };
336
- //# sourceMappingURL=FocusGroup.js.map
@@ -3,4 +3,3 @@ import React from 'react';
3
3
  var FocusGroupContext = /*#__PURE__*/React.createContext();
4
4
 
5
5
  export { FocusGroupContext as default };
6
- //# sourceMappingURL=FocusGroupContext.js.map