@elliemae/ds-shared 2.2.0-alpha.4 → 3.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/cjs/Animations/BaseAnimation.js +35 -55
  2. package/cjs/Animations/Grow.js +41 -54
  3. package/cjs/Animations/GrowRight.js +41 -63
  4. package/cjs/Animations/GrowVertical.js +7 -47
  5. package/cjs/CheckableGroup.js +65 -67
  6. package/cjs/DeferRenderAfterComputation.js +24 -48
  7. package/cjs/FocusGroup/FocusGrid.js +143 -108
  8. package/cjs/FocusGroup/FocusGroup.js +147 -88
  9. package/cjs/FocusGroup/FocusGroupContext.js +11 -38
  10. package/cjs/FocusGroup/FocusGroupManager.js +47 -56
  11. package/cjs/FocusGroup/focusGroupManagerHoc.js +42 -52
  12. package/cjs/FocusGroup/index.js +21 -47
  13. package/cjs/FocusGroup/useFocusGroupItem.js +51 -59
  14. package/cjs/FocusGroup/utils/getNextCellPosition.js +27 -47
  15. package/cjs/GroupContext/Group.js +73 -64
  16. package/cjs/GroupContext/GroupContext.js +13 -36
  17. package/cjs/GroupContext/GroupItem.js +21 -39
  18. package/cjs/GroupContext/index.js +13 -39
  19. package/cjs/ScrollSync/ScrollSync.js +75 -60
  20. package/cjs/ScrollSync/ScrollSyncPane.js +60 -52
  21. package/cjs/ScrollSync/ScrollSyncProvider.js +50 -103
  22. package/cjs/ScrollSync/index.js +11 -37
  23. package/cjs/ScrollSync/useScrollSync.js +7 -38
  24. package/cjs/constants.js +46 -65
  25. package/cjs/createDataInstance/createInstancePlugin.js +29 -41
  26. package/cjs/createDataInstance/createInstanceRef.js +71 -66
  27. package/cjs/createDataInstance/utils.js +100 -76
  28. package/cjs/defer-render-hoc/index.js +41 -48
  29. package/cjs/dimsum.config.js +6 -38
  30. package/cjs/index.js +17 -40
  31. package/cjs/prop-types.js +49 -106
  32. package/cjs/react-spring/index.js +14 -28
  33. package/cjs/react-spring/renderprops.js +14 -28
  34. package/cjs/toolbar/ToolbarProvider.js +94 -82
  35. package/cjs/useDataGrid/VolatileRowsListener.js +13 -38
  36. package/cjs/useDataGrid/index.js +7 -36
  37. package/cjs/useDataGrid/initColumnDefinition.js +110 -105
  38. package/cjs/useDataGrid/useDataGrid.js +148 -122
  39. package/cjs/useDataList/index.js +7 -36
  40. package/cjs/useDataList/recordIterator.js +18 -42
  41. package/cjs/useDataList/useDataList.js +83 -74
  42. package/cjs/utils.js +80 -71
  43. package/cjs/virtualization/AutoHeightList.js +54 -62
  44. package/cjs/virtualization/FluidHeightList.js +48 -42
  45. package/cjs/virtualization/index.js +20 -48
  46. package/esm/Animations/BaseAnimation.js +29 -26
  47. package/esm/Animations/Grow.js +35 -25
  48. package/esm/Animations/GrowRight.js +35 -34
  49. package/esm/Animations/GrowVertical.js +4 -29
  50. package/esm/CheckableGroup.js +52 -35
  51. package/esm/DeferRenderAfterComputation.js +15 -16
  52. package/esm/FocusGroup/FocusGrid.js +117 -64
  53. package/esm/FocusGroup/FocusGroup.js +137 -56
  54. package/esm/FocusGroup/FocusGroupContext.js +5 -9
  55. package/esm/FocusGroup/FocusGroupManager.js +38 -24
  56. package/esm/FocusGroup/focusGroupManagerHoc.js +36 -24
  57. package/esm/FocusGroup/index.js +6 -18
  58. package/esm/FocusGroup/useFocusGroupItem.js +40 -28
  59. package/esm/FocusGroup/utils/getNextCellPosition.js +25 -18
  60. package/esm/GroupContext/Group.js +66 -34
  61. package/esm/GroupContext/GroupContext.js +5 -7
  62. package/esm/GroupContext/GroupItem.js +15 -10
  63. package/esm/GroupContext/index.js +3 -10
  64. package/esm/ScrollSync/ScrollSync.js +64 -30
  65. package/esm/ScrollSync/ScrollSyncPane.js +52 -22
  66. package/esm/ScrollSync/ScrollSyncProvider.js +42 -74
  67. package/esm/ScrollSync/index.js +2 -8
  68. package/esm/ScrollSync/useScrollSync.js +5 -9
  69. package/esm/constants.js +28 -37
  70. package/esm/createDataInstance/createInstancePlugin.js +23 -12
  71. package/esm/createDataInstance/createInstanceRef.js +59 -36
  72. package/esm/createDataInstance/utils.js +85 -48
  73. package/esm/defer-render-hoc/index.js +31 -17
  74. package/esm/dimsum.config.js +4 -9
  75. package/esm/index.js +5 -11
  76. package/esm/prop-types.js +31 -75
  77. package/esm/react-spring/index.js +1 -3
  78. package/esm/react-spring/renderprops.js +1 -3
  79. package/esm/toolbar/ToolbarProvider.js +74 -45
  80. package/esm/useDataGrid/VolatileRowsListener.js +11 -9
  81. package/esm/useDataGrid/index.js +1 -7
  82. package/esm/useDataGrid/initColumnDefinition.js +94 -78
  83. package/esm/useDataGrid/useDataGrid.js +99 -82
  84. package/esm/useDataList/index.js +1 -7
  85. package/esm/useDataList/recordIterator.js +14 -13
  86. package/esm/useDataList/useDataList.js +67 -44
  87. package/esm/utils.js +59 -42
  88. package/esm/virtualization/AutoHeightList.js +40 -28
  89. package/esm/virtualization/FluidHeightList.js +38 -14
  90. package/esm/virtualization/index.js +16 -19
  91. package/package.json +3 -3
  92. package/types/Animations/BaseAnimation.d.ts +0 -1
  93. package/types/Animations/Grow.d.ts +0 -1
  94. package/types/Animations/GrowRight.d.ts +0 -1
  95. package/types/CheckableGroup.d.ts +0 -1
  96. package/types/DeferRenderAfterComputation.d.ts +2 -3
  97. package/types/FocusGroup/FocusGrid.d.ts +3 -5
  98. package/types/FocusGroup/FocusGroup.d.ts +1 -3
  99. package/types/FocusGroup/FocusGroupContext.d.ts +2 -3
  100. package/types/FocusGroup/FocusGroupManager.d.ts +1 -3
  101. package/types/FocusGroup/focusGroupManagerHoc.d.ts +1 -3
  102. package/types/FocusGroup/index.d.ts +6 -6
  103. package/types/FocusGroup/useFocusGroupItem.d.ts +1 -3
  104. package/types/FocusGroup/utils/getNextCellPosition.d.ts +1 -3
  105. package/types/GroupContext/Group.d.ts +0 -1
  106. package/types/GroupContext/GroupItem.d.ts +0 -1
  107. package/types/GroupContext/index.d.ts +3 -3
  108. package/types/ScrollSync/ScrollSync.d.ts +2 -4
  109. package/types/ScrollSync/ScrollSyncPane.d.ts +2 -2
  110. package/types/ScrollSync/index.d.ts +2 -2
  111. package/types/ScrollSync/useScrollSync.d.ts +5 -6
  112. package/types/createDataInstance/createInstancePlugin.d.ts +1 -2
  113. package/types/createDataInstance/createInstanceRef.d.ts +1 -3
  114. package/types/dimsum.config.d.ts +2 -3
  115. package/types/index.d.ts +2 -2
  116. package/types/toolbar/ToolbarProvider.d.ts +8 -3
  117. package/types/useDataGrid/VolatileRowsListener.d.ts +1 -3
  118. package/types/useDataGrid/index.d.ts +1 -1
  119. package/types/useDataGrid/initColumnDefinition.d.ts +1 -2
  120. package/types/useDataGrid/useDataGrid.d.ts +2 -3
  121. package/types/useDataList/index.d.ts +1 -1
  122. package/types/useDataList/useDataList.d.ts +2 -3
  123. package/cjs/Animations/BaseAnimation.js.map +0 -7
  124. package/cjs/Animations/Grow.js.map +0 -7
  125. package/cjs/Animations/GrowRight.js.map +0 -7
  126. package/cjs/Animations/GrowVertical.js.map +0 -7
  127. package/cjs/CheckableGroup.js.map +0 -7
  128. package/cjs/DeferRenderAfterComputation.js.map +0 -7
  129. package/cjs/FocusGroup/FocusGrid.js.map +0 -7
  130. package/cjs/FocusGroup/FocusGroup.js.map +0 -7
  131. package/cjs/FocusGroup/FocusGroupContext.js.map +0 -7
  132. package/cjs/FocusGroup/FocusGroupManager.js.map +0 -7
  133. package/cjs/FocusGroup/focusGroupManagerHoc.js.map +0 -7
  134. package/cjs/FocusGroup/index.js.map +0 -7
  135. package/cjs/FocusGroup/useFocusGroupItem.js.map +0 -7
  136. package/cjs/FocusGroup/utils/getNextCellPosition.js.map +0 -7
  137. package/cjs/GroupContext/Group.js.map +0 -7
  138. package/cjs/GroupContext/GroupContext.js.map +0 -7
  139. package/cjs/GroupContext/GroupItem.js.map +0 -7
  140. package/cjs/GroupContext/index.js.map +0 -7
  141. package/cjs/ScrollSync/ScrollSync.js.map +0 -7
  142. package/cjs/ScrollSync/ScrollSyncPane.js.map +0 -7
  143. package/cjs/ScrollSync/ScrollSyncProvider.js.map +0 -7
  144. package/cjs/ScrollSync/index.js.map +0 -7
  145. package/cjs/ScrollSync/useScrollSync.js.map +0 -7
  146. package/cjs/constants.js.map +0 -7
  147. package/cjs/createDataInstance/createInstancePlugin.js.map +0 -7
  148. package/cjs/createDataInstance/createInstanceRef.js.map +0 -7
  149. package/cjs/createDataInstance/utils.js.map +0 -7
  150. package/cjs/defer-render-hoc/index.js.map +0 -7
  151. package/cjs/dimsum.config.js.map +0 -7
  152. package/cjs/index.js.map +0 -7
  153. package/cjs/prop-types.js.map +0 -7
  154. package/cjs/react-spring/index.js.map +0 -7
  155. package/cjs/react-spring/renderprops.js.map +0 -7
  156. package/cjs/toolbar/ToolbarProvider.js.map +0 -7
  157. package/cjs/useDataGrid/VolatileRowsListener.js.map +0 -7
  158. package/cjs/useDataGrid/index.js.map +0 -7
  159. package/cjs/useDataGrid/initColumnDefinition.js.map +0 -7
  160. package/cjs/useDataGrid/useDataGrid.js.map +0 -7
  161. package/cjs/useDataList/index.js.map +0 -7
  162. package/cjs/useDataList/recordIterator.js.map +0 -7
  163. package/cjs/useDataList/useDataList.js.map +0 -7
  164. package/cjs/utils.js.map +0 -7
  165. package/cjs/virtualization/AutoHeightList.js.map +0 -7
  166. package/cjs/virtualization/FluidHeightList.js.map +0 -7
  167. package/cjs/virtualization/index.js.map +0 -7
  168. package/esm/Animations/BaseAnimation.js.map +0 -7
  169. package/esm/Animations/Grow.js.map +0 -7
  170. package/esm/Animations/GrowRight.js.map +0 -7
  171. package/esm/Animations/GrowVertical.js.map +0 -7
  172. package/esm/CheckableGroup.js.map +0 -7
  173. package/esm/DeferRenderAfterComputation.js.map +0 -7
  174. package/esm/FocusGroup/FocusGrid.js.map +0 -7
  175. package/esm/FocusGroup/FocusGroup.js.map +0 -7
  176. package/esm/FocusGroup/FocusGroupContext.js.map +0 -7
  177. package/esm/FocusGroup/FocusGroupManager.js.map +0 -7
  178. package/esm/FocusGroup/focusGroupManagerHoc.js.map +0 -7
  179. package/esm/FocusGroup/index.js.map +0 -7
  180. package/esm/FocusGroup/useFocusGroupItem.js.map +0 -7
  181. package/esm/FocusGroup/utils/getNextCellPosition.js.map +0 -7
  182. package/esm/GroupContext/Group.js.map +0 -7
  183. package/esm/GroupContext/GroupContext.js.map +0 -7
  184. package/esm/GroupContext/GroupItem.js.map +0 -7
  185. package/esm/GroupContext/index.js.map +0 -7
  186. package/esm/ScrollSync/ScrollSync.js.map +0 -7
  187. package/esm/ScrollSync/ScrollSyncPane.js.map +0 -7
  188. package/esm/ScrollSync/ScrollSyncProvider.js.map +0 -7
  189. package/esm/ScrollSync/index.js.map +0 -7
  190. package/esm/ScrollSync/useScrollSync.js.map +0 -7
  191. package/esm/constants.js.map +0 -7
  192. package/esm/createDataInstance/createInstancePlugin.js.map +0 -7
  193. package/esm/createDataInstance/createInstanceRef.js.map +0 -7
  194. package/esm/createDataInstance/utils.js.map +0 -7
  195. package/esm/defer-render-hoc/index.js.map +0 -7
  196. package/esm/dimsum.config.js.map +0 -7
  197. package/esm/index.js.map +0 -7
  198. package/esm/prop-types.js.map +0 -7
  199. package/esm/react-spring/index.js.map +0 -7
  200. package/esm/react-spring/renderprops.js.map +0 -7
  201. package/esm/toolbar/ToolbarProvider.js.map +0 -7
  202. package/esm/useDataGrid/VolatileRowsListener.js.map +0 -7
  203. package/esm/useDataGrid/index.js.map +0 -7
  204. package/esm/useDataGrid/initColumnDefinition.js.map +0 -7
  205. package/esm/useDataGrid/useDataGrid.js.map +0 -7
  206. package/esm/useDataList/index.js.map +0 -7
  207. package/esm/useDataList/recordIterator.js.map +0 -7
  208. package/esm/useDataList/useDataList.js.map +0 -7
  209. package/esm/utils.js.map +0 -7
  210. package/esm/virtualization/AutoHeightList.js.map +0 -7
  211. package/esm/virtualization/FluidHeightList.js.map +0 -7
  212. package/esm/virtualization/index.js.map +0 -7
@@ -1,51 +1,86 @@
1
- import * as React from "react";
2
- import { isFunction, get } from "@elliemae/ds-utilities";
3
- import hotkeys from "hotkeys-js";
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.filter.js';
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';
10
+ import { get, isFunction } from '@elliemae/ds-utilities';
11
+ import hotkeys from 'hotkeys-js';
12
+
13
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
+
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
16
  const defaultOptions = {
5
- orientation: "vertical"
17
+ orientation: 'vertical'
6
18
  };
7
- const safeCallAction = (e, fun, ...args) => {
19
+
20
+ const safeCallAction = function (e, fun) {
8
21
  if (isFunction(fun)) {
9
22
  e.preventDefault();
23
+
24
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
25
+ args[_key - 2] = arguments[_key];
26
+ }
27
+
10
28
  fun(...args);
11
29
  }
12
30
  };
13
- const registerHotkeys = (hotKeys = {}, params, getContainer = () => document) => {
14
- Object.keys(hotKeys).forEach((hotkey) => {
15
- const { options, handler, allowDocumentHandler = false } = hotKeys[hotkey];
16
- const parameterizedHandler = (e) => {
31
+
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 => {
17
44
  const handlerParams = isFunction(params) ? params() : params;
18
- if (!allowDocumentHandler && handlerParams.item !== document.activeElement)
19
- return;
45
+ if (!allowDocumentHandler && handlerParams.item !== document.activeElement) return;
20
46
  e.preventDefault();
21
47
  handler(handlerParams);
22
48
  };
23
- hotkeys(hotkey, { element: getContainer(), ...options }, parameterizedHandler);
49
+
50
+ hotkeys(hotkey, _objectSpread({
51
+ element: getContainer()
52
+ }, options), parameterizedHandler);
24
53
  });
25
54
  };
26
- const unregisterHotKeys = (hotKeys = {}) => {
27
- Object.keys(hotKeys).forEach((hotkey) => {
55
+
56
+ const unregisterHotKeys = function () {
57
+ let hotKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
58
+ Object.keys(hotKeys).forEach(hotkey => {
28
59
  hotkeys.unbind(hotkey);
29
60
  });
30
61
  };
62
+
31
63
  const noop = () => null;
64
+
32
65
  class FocusGroup {
33
- constructor(options = {}) {
66
+ constructor() {
67
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
34
68
  this.items = [];
35
- this.options = { ...defaultOptions, ...options };
36
- const { orientation } = this.options;
37
- this.keyBindings = {
38
- ArrowUp: orientation !== "horizontal" && "previous",
39
- ArrowRight: orientation !== "vertical" && "next",
40
- ArrowDown: orientation !== "horizontal" && "next",
41
- ArrowLeft: orientation !== "vertical" && "previous",
42
- Home: "first",
43
- End: "last",
44
- PageUp: "first",
45
- PageDown: "last",
46
- Escape: "exit",
47
- ...options.keyBindings
48
- };
69
+ this.options = _objectSpread(_objectSpread({}, defaultOptions), options);
70
+ const {
71
+ orientation
72
+ } = this.options;
73
+ this.keyBindings = _objectSpread({
74
+ ArrowUp: orientation !== 'horizontal' && 'previous',
75
+ ArrowRight: orientation !== 'vertical' && 'next',
76
+ ArrowDown: orientation !== 'horizontal' && 'next',
77
+ ArrowLeft: orientation !== 'vertical' && 'previous',
78
+ Home: 'first',
79
+ End: 'last',
80
+ PageUp: 'first',
81
+ PageDown: 'last',
82
+ Escape: 'exit'
83
+ }, options.keyBindings);
49
84
  this.currentFocusedItem = null;
50
85
  this.currIndex = null;
51
86
  this.mapActions = {
@@ -67,154 +102,200 @@ class FocusGroup {
67
102
  this.focusCurrent = this.focusCurrent.bind(this);
68
103
  this.getHotKeysParams = this.getHotKeysParams.bind(this);
69
104
  }
105
+
70
106
  getHotKeysParams() {
71
107
  const item = this.currentFocusedItem;
72
- const { index } = get(item, ["dataset"], {});
108
+ const {
109
+ index
110
+ } = get(item, ['dataset'], {});
73
111
  return {
74
112
  item,
75
113
  index
76
114
  };
77
115
  }
116
+
78
117
  activate() {
79
- const { getContainer } = this.options;
80
- document.addEventListener("keydown", this.handleKeyDown, true);
118
+ const {
119
+ getContainer
120
+ } = this.options;
121
+ document.addEventListener('keydown', this.handleKeyDown, true);
81
122
  registerHotkeys(this.options.hotKeys, this.getHotKeysParams, getContainer);
82
123
  }
124
+
83
125
  deactivate() {
84
- document.removeEventListener("keydown", this.handleKeyDown, true);
126
+ document.removeEventListener('keydown', this.handleKeyDown, true);
85
127
  unregisterHotKeys(this.options.hotKeys);
86
128
  }
129
+
87
130
  handleKeyDown(e) {
88
- if (!this.isGroupActive())
89
- return;
131
+ if (!this.isGroupActive()) return;
90
132
  this.executeActionByEvent(e);
91
133
  }
134
+
92
135
  executeActionByEvent(e) {
93
136
  const actions = Array.isArray(this.keyBindings[e.key]) ? this.keyBindings[e.key] : [this.keyBindings[e.key]];
94
- return actions.map((action) => typeof action === "string" ? safeCallAction(e, this.mapActions[action]) : safeCallAction(e, action));
137
+ return actions.map(action => typeof action === 'string' ? safeCallAction(e, this.mapActions[action]) : safeCallAction(e, action));
95
138
  }
96
- register(node, props = {}) {
97
- const afterIndex = this.items.findIndex((item) => item.compareDocumentPosition(node) === Node.DOCUMENT_POSITION_PRECEDING);
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);
98
143
  node.specialOnFocus = props.onFocus || noop;
99
144
  node.specialOnBlur = props.onBlur || noop;
145
+
100
146
  node.onclick = () => this.focusItem(node);
147
+
101
148
  node.onfocus = () => {
102
149
  this.focusItem(node);
103
150
  };
151
+
104
152
  if (afterIndex === -1) {
105
153
  this.items.push(node);
106
154
  } else {
107
155
  this.items.splice(afterIndex, 0, node);
108
156
  }
109
157
  }
158
+
110
159
  unregister(node) {
111
160
  const index = this.getItemIndexByNode(node);
112
- if (index > -1)
113
- this.items.splice(index, 1);
161
+ if (index > -1) this.items.splice(index, 1);
114
162
  }
163
+
115
164
  exit() {
116
- const { onExitFocusGroup } = this.options;
165
+ const {
166
+ onExitFocusGroup
167
+ } = this.options;
117
168
  onExitFocusGroup();
118
169
  }
170
+
119
171
  focusItem(node) {
120
172
  if (this.currentFocusedItem && this.currentFocusedItem !== node) {
121
173
  this.currentFocusedItem.specialOnBlur();
122
- this.currentFocusedItem.setAttribute("tabindex", -1);
174
+ this.currentFocusedItem.setAttribute('tabindex', -1);
123
175
  }
124
- if (!node)
125
- return;
176
+
177
+ if (!node) return;
126
178
  this.currentFocusedItem = node;
127
- node.setAttribute("tabindex", 0);
179
+ node.setAttribute('tabindex', 0);
128
180
  node.focus();
129
181
  node.specialOnFocus();
130
182
  }
183
+
131
184
  focusNext() {
132
185
  const item = this.getNextItem();
133
186
  this.focusItem(item);
134
187
  }
188
+
135
189
  focusByNode(node) {
136
190
  const index = this.getItemIndexByNode(node);
137
191
  this.focusByIndex(index);
138
192
  }
193
+
139
194
  focusByIndex(index) {
140
195
  const item = this.getItemByIndex(index);
141
196
  this.focusItem(item);
142
197
  }
198
+
143
199
  focusPrevious() {
144
200
  const prevItem = this.getPreviousItem();
145
201
  this.focusItem(prevItem);
146
202
  }
203
+
147
204
  focusFirst() {
148
205
  const item = this.getFirstItem();
149
206
  this.focusItem(item);
150
207
  }
208
+
151
209
  focusLast() {
152
210
  const item = this.getLastItem();
153
211
  this.focusItem(item);
154
212
  }
213
+
155
214
  focusCurrent() {
156
215
  this.focusItem(this.currentFocusedItem);
157
216
  }
217
+
158
218
  focusNextGroup() {
159
- const { onFocusNextGroup } = this.options;
219
+ const {
220
+ onFocusNextGroup
221
+ } = this.options;
160
222
  this.exit();
161
223
  onFocusNextGroup();
162
224
  }
225
+
163
226
  focusPreviousGroup() {
164
- const { onFocusPreviousGroup } = this.options;
227
+ const {
228
+ onFocusPreviousGroup
229
+ } = this.options;
165
230
  this.exit();
166
231
  onFocusPreviousGroup();
167
232
  }
233
+
168
234
  getNextItem() {
169
- const { loop } = this.options;
235
+ const {
236
+ loop
237
+ } = this.options;
170
238
  const currentIndex = this.getFocusedIndex();
171
239
  const supposedNextIndex = currentIndex + 1;
240
+
172
241
  if (!this.checkCanFocusNext(supposedNextIndex)) {
173
242
  return loop ? this.getFirstItem() : this.focusNextGroup();
174
243
  }
244
+
175
245
  return this.getItemByIndex(supposedNextIndex);
176
246
  }
247
+
177
248
  getPreviousItem() {
178
- const { loop } = this.options;
249
+ const {
250
+ loop
251
+ } = this.options;
179
252
  const currentIndex = this.getFocusedIndex();
180
253
  const supposedPrevIndex = currentIndex - 1;
254
+
181
255
  if (!this.checkCanFocusPrev(supposedPrevIndex)) {
182
256
  return loop ? this.getLastItem() : this.focusPreviousGroup();
183
257
  }
258
+
184
259
  return this.getItemByIndex(supposedPrevIndex);
185
260
  }
261
+
186
262
  checkCanFocusNext(index) {
187
263
  return this.items.length > index;
188
264
  }
265
+
189
266
  checkCanFocusPrev(index) {
190
267
  return index >= 0;
191
268
  }
269
+
192
270
  getItemByIndex(index) {
193
271
  return this.items[index];
194
272
  }
273
+
195
274
  getItemIndexByNode(node) {
196
- return this.items.findIndex((item) => item === node);
275
+ return this.items.findIndex(item => item === node);
197
276
  }
277
+
198
278
  getFocusedIndex() {
199
279
  return this.getItemIndexByNode(document.activeElement);
200
280
  }
281
+
201
282
  getFocusedItem() {
202
283
  const index = this.getFocusedIndex();
203
284
  return index > -1 && this.items[index];
204
285
  }
286
+
205
287
  isGroupActive() {
206
288
  return this.getFocusedIndex() !== -1;
207
289
  }
290
+
208
291
  getFirstItem() {
209
292
  return !!this.items.length && this.items[0];
210
293
  }
294
+
211
295
  getLastItem() {
212
296
  return !!this.items.length && this.items[this.items.length - 1];
213
297
  }
298
+
214
299
  }
215
- var FocusGroup_default = FocusGroup;
216
- export {
217
- FocusGroup,
218
- FocusGroup_default as default
219
- };
220
- //# sourceMappingURL=FocusGroup.js.map
300
+
301
+ export { FocusGroup as default };
@@ -1,9 +1,5 @@
1
- import * as React from "react";
2
- import React2 from "react";
3
- const FocusGroupContext = React2.createContext();
4
- var FocusGroupContext_default = FocusGroupContext;
5
- export {
6
- FocusGroupContext,
7
- FocusGroupContext_default as default
8
- };
9
- //# sourceMappingURL=FocusGroupContext.js.map
1
+ import React from 'react';
2
+
3
+ var FocusGroupContext = /*#__PURE__*/React.createContext();
4
+
5
+ export { FocusGroupContext as default };
@@ -1,9 +1,11 @@
1
- import * as React from "react";
2
- import React2, { Component } from "react";
3
- import { isFunction } from "@elliemae/ds-utilities";
4
- import { FocusGroup } from "./FocusGroup";
5
- import { FocusGroupContext } from "./FocusGroupContext";
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import { Component } from 'react';
3
+ import { isFunction } from '@elliemae/ds-utilities';
4
+ import FocusGroup from './FocusGroup.js';
5
+ import FocusGroupContext from './FocusGroupContext.js';
6
+
6
7
  const noop = () => null;
8
+
7
9
  class FocusGroupProvider extends Component {
8
10
  constructor(props) {
9
11
  super(props);
@@ -25,58 +27,75 @@ class FocusGroupProvider extends Component {
25
27
  focusPrevious: this.focusGroup.focusPrevious
26
28
  };
27
29
  }
30
+
28
31
  componentDidMount() {
29
- const { autoFocusOnMount } = this.props;
32
+ const {
33
+ autoFocusOnMount
34
+ } = this.props;
30
35
  this.activate();
36
+
31
37
  if (autoFocusOnMount) {
32
38
  setTimeout(() => {
33
39
  this.actions.focusFirst();
34
40
  }, 0);
35
41
  }
36
42
  }
43
+
37
44
  componentWillUnmount() {
38
45
  this.deactivate();
39
46
  }
47
+
40
48
  activate() {
41
- const { onActivate } = this.props;
49
+ const {
50
+ onActivate
51
+ } = this.props;
42
52
  this.focusGroup.activate();
43
53
  this.activated = true;
44
- if (isFunction(onActivate))
45
- onActivate();
54
+ if (isFunction(onActivate)) onActivate();
46
55
  }
56
+
47
57
  deactivate() {
48
- const { onExitFocusGroup } = this.props;
58
+ const {
59
+ onExitFocusGroup
60
+ } = this.props;
49
61
  this.activated = false;
50
62
  this.focusGroup.deactivate();
63
+
51
64
  if (isFunction(onExitFocusGroup)) {
52
65
  onExitFocusGroup();
53
66
  }
54
67
  }
68
+
55
69
  register(item) {
56
70
  this.focusGroup.register(item);
57
71
  }
72
+
58
73
  unregister(item) {
59
74
  this.focusGroup.unregister(item);
60
75
  }
76
+
61
77
  focusItemByIndex(index) {
62
- if (!this.activated)
63
- this.activate();
78
+ if (!this.activated) this.activate();
64
79
  setTimeout(() => {
65
80
  this.focusGroup.focusByIndex(index);
66
81
  }, 200);
67
82
  }
83
+
68
84
  focusItemByNode(node) {
69
- if (!this.activated)
70
- this.activate();
85
+ if (!this.activated) this.activate();
71
86
  const index = this.focusGroup.getItemIndexByNode(node);
72
87
  this.focusItemByIndex(index);
73
88
  }
89
+
74
90
  render() {
75
- const { children } = this.props;
76
- return /* @__PURE__ */ React2.createElement(FocusGroupContext.Provider, {
91
+ const {
92
+ children
93
+ } = this.props;
94
+ return /*#__PURE__*/_jsx(FocusGroupContext.Provider, {
77
95
  value: this.actions
78
- }, children);
96
+ }, void 0, children);
79
97
  }
98
+
80
99
  }
81
100
  FocusGroupProvider.defaultProps = {
82
101
  exitWhenNoPrevious: false,
@@ -88,10 +107,5 @@ FocusGroupProvider.defaultProps = {
88
107
  onFocusNextGroup: noop,
89
108
  onFocusGroupSet: noop
90
109
  };
91
- var FocusGroupManager_default = FocusGroupProvider;
92
- export {
93
- FocusGroupProvider as FocusGroupManager,
94
- FocusGroupProvider,
95
- FocusGroupManager_default as default
96
- };
97
- //# sourceMappingURL=FocusGroupManager.js.map
110
+
111
+ export { FocusGroupProvider as default };
@@ -1,25 +1,37 @@
1
- import * as React from "react";
2
- import React2 from "react";
3
- import { FocusGroupProvider } from "./FocusGroupManager";
4
- function FocusGroupHoc(WrappedComponent, options = {}) {
5
- return ({
6
- onExitFocusGroup,
7
- onFocusPrevGroup,
8
- focusKeyBindings,
9
- ...props
10
- }) => /* @__PURE__ */ React2.createElement(FocusGroupProvider, {
11
- keyBindings: focusKeyBindings,
12
- onExitFocusGroup,
13
- onFocusPrevGroup,
14
- ...options
15
- }, /* @__PURE__ */ React2.createElement(WrappedComponent, {
16
- ...props,
17
- ...options
18
- }));
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
8
+ import 'react';
9
+ import FocusGroupProvider from './FocusGroupManager.js';
10
+ import { jsx } from 'react/jsx-runtime';
11
+
12
+ const _excluded = ["onExitFocusGroup", "onFocusPrevGroup", "focusKeyBindings"];
13
+
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
+
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
+ function FocusGroupHoc(WrappedComponent) {
18
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
19
+ return _ref => {
20
+ let {
21
+ onExitFocusGroup,
22
+ onFocusPrevGroup,
23
+ focusKeyBindings
24
+ } = _ref,
25
+ props = _objectWithoutProperties(_ref, _excluded);
26
+
27
+ return /*#__PURE__*/jsx(FocusGroupProvider, _objectSpread(_objectSpread({
28
+ keyBindings: focusKeyBindings,
29
+ onExitFocusGroup: onExitFocusGroup,
30
+ onFocusPrevGroup: onFocusPrevGroup
31
+ }, options), {}, {
32
+ children: /*#__PURE__*/jsx(WrappedComponent, _objectSpread(_objectSpread({}, props), options))
33
+ }));
34
+ };
19
35
  }
20
- var focusGroupManagerHoc_default = FocusGroupHoc;
21
- export {
22
- FocusGroupHoc,
23
- focusGroupManagerHoc_default as default
24
- };
25
- //# sourceMappingURL=focusGroupManagerHoc.js.map
36
+
37
+ export { FocusGroupHoc as default };
@@ -1,18 +1,6 @@
1
- import * as React from "react";
2
- import { FocusGroup } from "./FocusGroup";
3
- import { FocusGroupContext } from "./FocusGroupContext";
4
- import { FocusGroupManager } from "./FocusGroupManager";
5
- import { useFocusGroupItem, useFocusGroupWithState } from "./useFocusGroupItem";
6
- import { FocusGroupHoc } from "./focusGroupManagerHoc";
7
- import { FocusGridProvider, FocusGridContext } from "./FocusGrid";
8
- export {
9
- FocusGridProvider as FocusGrid,
10
- FocusGridContext,
11
- FocusGroup,
12
- FocusGroupContext,
13
- FocusGroupManager,
14
- FocusGroupHoc as focusGroupManagerHoc,
15
- useFocusGroupItem,
16
- useFocusGroupWithState
17
- };
18
- //# sourceMappingURL=index.js.map
1
+ export { default as FocusGroup } from './FocusGroup.js';
2
+ export { default as FocusGroupContext } from './FocusGroupContext.js';
3
+ export { default as FocusGroupManager } from './FocusGroupManager.js';
4
+ export { default as useFocusGroupItem, useFocusGroupWithState } from './useFocusGroupItem.js';
5
+ export { default as focusGroupManagerHoc } from './focusGroupManagerHoc.js';
6
+ export { default as FocusGrid, FocusGridContext } from './FocusGrid.js';
@@ -1,38 +1,50 @@
1
- import * as React from "react";
2
- import { useContext, useEffect } from "react";
3
- import { FocusGroupContext } from "./FocusGroupContext";
4
- function useFocusGroupItem(ref = {}, props) {
5
- const { register, unregister, ...otherActions } = useContext(FocusGroupContext) || {};
1
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
2
+ import { useContext, useEffect } from 'react';
3
+ import FocusGroupContext from './FocusGroupContext.js';
4
+
5
+ const _excluded = ["register", "unregister"],
6
+ _excluded2 = ["register", "unregister"];
7
+ function useFocusGroupItem() {
8
+ let ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9
+ let props = arguments.length > 1 ? arguments[1] : undefined;
10
+
11
+ const _ref = useContext(FocusGroupContext) || {},
12
+ {
13
+ register,
14
+ unregister
15
+ } = _ref,
16
+ otherActions = _objectWithoutProperties(_ref, _excluded);
17
+
6
18
  useEffect(() => {
7
- if (ref.current && register)
8
- register(ref.current, props);
19
+ if (ref.current && register) register(ref.current, props);
9
20
  return () => {
10
- if (ref.current && unregister)
11
- unregister(ref.current);
21
+ if (ref.current && unregister) unregister(ref.current);
12
22
  };
13
- });
14
- if (!register)
15
- return {};
23
+ }); // if the focus item is not wrapped with the focus provider then return null
24
+
25
+ if (!register) return {};
16
26
  return otherActions;
17
27
  }
18
- const useFocusGroupWithState = (ref = {}, props) => {
19
- const { register, unregister, ...otherActions } = useContext(FocusGroupContext) || {};
28
+ const useFocusGroupWithState = function () {
29
+ let ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
30
+ let props = arguments.length > 1 ? arguments[1] : undefined;
31
+
32
+ const _ref2 = useContext(FocusGroupContext) || {},
33
+ {
34
+ register,
35
+ unregister
36
+ } = _ref2,
37
+ otherActions = _objectWithoutProperties(_ref2, _excluded2);
38
+
20
39
  useEffect(() => {
21
- if (ref && register)
22
- register(ref, props);
40
+ if (ref && register) register(ref, props);
23
41
  return () => {
24
- if (ref && unregister)
25
- unregister(ref);
42
+ if (ref && unregister) unregister(ref);
26
43
  };
27
- }, [ref]);
28
- if (!register)
29
- return {};
44
+ }, [ref]); // if the focus item is not wrapped with the focus provider then return null
45
+
46
+ if (!register) return {};
30
47
  return otherActions;
31
48
  };
32
- var useFocusGroupItem_default = useFocusGroupItem;
33
- export {
34
- useFocusGroupItem_default as default,
35
- useFocusGroupItem,
36
- useFocusGroupWithState
37
- };
38
- //# sourceMappingURL=useFocusGroupItem.js.map
49
+
50
+ export { useFocusGroupItem as default, useFocusGroupWithState };