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