@elliemae/ds-shared 1.57.1-rc.0 → 2.0.0-alpha.11

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