@instructure/ui-dom-utils 8.33.2-snapshot-0 → 8.33.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 (59) hide show
  1. package/CHANGELOG.md +1 -5
  2. package/es/InputModeListener.js +1 -22
  3. package/es/addEventListener.js +1 -3
  4. package/es/addInputModeListener.js +1 -29
  5. package/es/addPositionChangeListener.js +1 -7
  6. package/es/addResizeListener.js +1 -8
  7. package/es/contains.js +2 -8
  8. package/es/containsActiveElement.js +1 -2
  9. package/es/elementMatches.js +3 -4
  10. package/es/findDOMNode.js +4 -11
  11. package/es/findFocusable.js +1 -12
  12. package/es/findTabbable.js +1 -3
  13. package/es/getActiveElement.js +4 -4
  14. package/es/getBoundingClientRect.js +1 -13
  15. package/es/getClassList.js +2 -7
  16. package/es/getComputedStyle.js +1 -5
  17. package/es/getFontSize.js +5 -8
  18. package/es/getOffsetParents.js +5 -11
  19. package/es/getScrollParents.js +8 -20
  20. package/es/handleMouseOverOut.js +2 -3
  21. package/es/isActiveElement.js +1 -2
  22. package/es/isDefinedCustomElement.js +0 -1
  23. package/es/isVisible.js +11 -18
  24. package/es/matchMedia.js +1 -4
  25. package/es/ownerDocument.js +1 -4
  26. package/es/ownerWindow.js +1 -2
  27. package/es/requestAnimationFrame.js +2 -5
  28. package/es/transformSelection.js +4 -10
  29. package/lib/InputModeListener.js +1 -26
  30. package/lib/addEventListener.js +0 -4
  31. package/lib/addInputModeListener.js +1 -32
  32. package/lib/addPositionChangeListener.js +0 -10
  33. package/lib/addResizeListener.js +0 -11
  34. package/lib/canUseDOM.js +0 -1
  35. package/lib/contains.js +1 -10
  36. package/lib/containsActiveElement.js +0 -5
  37. package/lib/elementMatches.js +2 -5
  38. package/lib/findDOMNode.js +4 -13
  39. package/lib/findFocusable.js +1 -13
  40. package/lib/findTabbable.js +1 -4
  41. package/lib/getActiveElement.js +2 -5
  42. package/lib/getBoundingClientRect.js +0 -17
  43. package/lib/getClassList.js +2 -9
  44. package/lib/getComputedStyle.js +0 -8
  45. package/lib/getFontSize.js +6 -12
  46. package/lib/getOffsetParents.js +4 -15
  47. package/lib/getScrollParents.js +7 -23
  48. package/lib/handleMouseOverOut.js +0 -4
  49. package/lib/index.js +0 -26
  50. package/lib/isActiveElement.js +0 -4
  51. package/lib/isDefinedCustomElement.js +0 -2
  52. package/lib/isVisible.js +10 -20
  53. package/lib/matchMedia.js +0 -7
  54. package/lib/ownerDocument.js +0 -5
  55. package/lib/ownerWindow.js +0 -4
  56. package/lib/requestAnimationFrame.js +1 -6
  57. package/lib/transformSelection.js +4 -11
  58. package/package.json +5 -5
  59. package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -3,14 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [8.33.2-snapshot-0](https://github.com/instructure/instructure-ui/compare/v8.33.1...v8.33.2-snapshot-0) (2023-01-13)
6
+ ## [8.33.2](https://github.com/instructure/instructure-ui/compare/v8.33.1...v8.33.2) (2023-01-25)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-dom-utils
9
9
 
10
-
11
-
12
-
13
-
14
10
  ## [8.33.1](https://github.com/instructure/instructure-ui/compare/v8.33.0...v8.33.1) (2023-01-06)
15
11
 
16
12
  **Note:** Version bump only for package @instructure/ui-dom-utils
@@ -21,6 +21,7 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
+
24
25
  import { logWarn as warn } from '@instructure/console';
25
26
  import { addEventListener } from './addEventListener';
26
27
  import { canUseDOM } from './canUseDOM';
@@ -28,35 +29,27 @@ export const MODES = {
28
29
  keyboard: 'keyboard',
29
30
  pointer: 'pointer'
30
31
  };
31
-
32
32
  class InputModeListenerImpl {
33
33
  constructor() {
34
34
  this._listeners = [];
35
35
  this._initialized = false;
36
36
  this._mode = MODES.keyboard;
37
-
38
37
  this.onInitialPointerMove = event => {
39
38
  var _event$target, _event$target$nodeNam;
40
-
41
39
  // Work around a Safari quirk that fires a mousemove on <html> whenever the
42
40
  // window blurs, even if you're tabbing out of the page. ¯\_(ツ)_/¯
43
41
  if ((event === null || event === void 0 ? void 0 : (_event$target = event.target) === null || _event$target === void 0 ? void 0 : (_event$target$nodeNam = _event$target.nodeName) === null || _event$target$nodeNam === void 0 ? void 0 : _event$target$nodeNam.toLowerCase()) === 'html') {
44
42
  return;
45
43
  }
46
-
47
44
  this._mode = MODES.pointer;
48
-
49
45
  this._listeners.forEach(listener => listener.remove());
50
46
  };
51
-
52
47
  this.onKeyDown = () => {
53
48
  this._mode = MODES.keyboard;
54
49
  };
55
-
56
50
  this.onPointerDown = () => {
57
51
  this._mode = MODES.pointer;
58
52
  };
59
-
60
53
  this.init = () => {
61
54
  if (!canUseDOM || this._initialized) return;
62
55
  addEventListener(document, 'keydown', this.onKeyDown, true);
@@ -66,43 +59,29 @@ class InputModeListenerImpl {
66
59
  this.addInitialPointerMoveListeners();
67
60
  this._initialized = true;
68
61
  };
69
-
70
62
  warn(false, `[InputModeListener] is deprecated and will be removed in version 7.0.0. Use addInputModeListener instead.`);
71
63
  this.init();
72
64
  }
73
-
74
65
  addInitialPointerMoveListeners() {
75
66
  this._listeners.push(addEventListener(document, 'mousemove', this.onInitialPointerMove, true));
76
-
77
67
  this._listeners.push(addEventListener(document, 'mousedown', this.onInitialPointerMove, true));
78
-
79
68
  this._listeners.push(addEventListener(document, 'mouseup', this.onInitialPointerMove, true));
80
-
81
69
  this._listeners.push(addEventListener(document, 'pointermove', this.onInitialPointerMove, true));
82
-
83
70
  this._listeners.push(addEventListener(document, 'pointerdown', this.onInitialPointerMove, true));
84
-
85
71
  this._listeners.push(addEventListener(document, 'pointerup', this.onInitialPointerMove, true));
86
-
87
72
  this._listeners.push(addEventListener(document, 'touchmove', this.onInitialPointerMove, true));
88
-
89
73
  this._listeners.push(addEventListener(document, 'touchstart', this.onInitialPointerMove, true));
90
-
91
74
  this._listeners.push(addEventListener(document, 'touchend', this.onInitialPointerMove, true));
92
75
  }
93
-
94
76
  get mode() {
95
77
  this.init();
96
78
  return this._mode;
97
79
  }
98
-
99
80
  isKeyboardMode() {
100
81
  this.init();
101
82
  return this._mode === MODES.keyboard;
102
83
  }
103
-
104
84
  }
105
-
106
85
  const InputModeListener = new InputModeListenerImpl();
107
86
  export default InputModeListener;
108
87
  export { InputModeListener };
@@ -21,8 +21,8 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- import { findDOMNode } from './findDOMNode';
25
24
 
25
+ import { findDOMNode } from './findDOMNode';
26
26
  /**
27
27
  * ---
28
28
  * category: utilities/DOM
@@ -42,9 +42,7 @@ function addEventListener(el, event, handler, capture) {
42
42
  remove() {
43
43
  node === null || node === void 0 ? void 0 : node.removeEventListener(event, handler, capture);
44
44
  }
45
-
46
45
  };
47
46
  }
48
-
49
47
  export default addEventListener;
50
48
  export { addEventListener };
@@ -21,6 +21,7 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
+
24
25
  import { addEventListener } from './addEventListener';
25
26
  import { canUseDOM } from './canUseDOM';
26
27
  const MODES = {
@@ -32,90 +33,63 @@ let _downListeners = [];
32
33
  let _mode = MODES.keyboard;
33
34
  let _registeredCount = 0;
34
35
  const _modeChangeHandlers = {};
35
-
36
36
  const handleInitialPointerMove = event => {
37
37
  // Work around a Safari quirk that fires a mousemove on <html> whenever the
38
38
  // window blurs, even if you're tabbing out of the page. ¯\_(ツ)_/¯
39
39
  if (event.target.nodeName.toLowerCase() === 'html') {
40
40
  return;
41
41
  }
42
-
43
42
  handleInputModeChange(_mode, MODES.pointer);
44
-
45
43
  _moveListeners.forEach(listener => listener.remove());
46
44
  };
47
-
48
45
  const handleInputModeChange = (currentMode, newMode) => {
49
46
  if (currentMode === newMode) return;
50
47
  _mode = newMode;
51
48
  Object.keys(_modeChangeHandlers).forEach(handlerId => _modeChangeHandlers[handlerId](currentMode, newMode));
52
49
  };
53
-
54
50
  const handleKeyDown = () => {
55
51
  handleInputModeChange(_mode, MODES.keyboard);
56
52
  };
57
-
58
53
  const handlePointerDown = () => {
59
54
  handleInputModeChange(_mode, MODES.pointer);
60
55
  };
61
-
62
56
  const addMoveListeners = () => {
63
57
  if (_moveListeners.length === 0) {
64
58
  _moveListeners.push(addEventListener(document, 'mousemove', handleInitialPointerMove, true));
65
-
66
59
  _moveListeners.push(addEventListener(document, 'mousedown', handleInitialPointerMove, true));
67
-
68
60
  _moveListeners.push(addEventListener(document, 'mouseup', handleInitialPointerMove, true));
69
-
70
61
  _moveListeners.push(addEventListener(document, 'pointermove', handleInitialPointerMove, true));
71
-
72
62
  _moveListeners.push(addEventListener(document, 'pointerdown', handleInitialPointerMove, true));
73
-
74
63
  _moveListeners.push(addEventListener(document, 'pointerup', handleInitialPointerMove, true));
75
-
76
64
  _moveListeners.push(addEventListener(document, 'touchmove', handleInitialPointerMove, true));
77
-
78
65
  _moveListeners.push(addEventListener(document, 'touchstart', handleInitialPointerMove, true));
79
-
80
66
  _moveListeners.push(addEventListener(document, 'touchend', handleInitialPointerMove, true));
81
67
  }
82
68
  };
83
-
84
69
  const addDownListeners = () => {
85
70
  if (_downListeners.length === 0) {
86
71
  _downListeners.push(addEventListener(document, 'keydown', handleKeyDown, true));
87
-
88
72
  _downListeners.push(addEventListener(document, 'mousedown', handlePointerDown, true));
89
-
90
73
  _downListeners.push(addEventListener(document, 'pointerdown', handlePointerDown, true));
91
-
92
74
  _downListeners.push(addEventListener(document, 'touchstart', handlePointerDown, true));
93
75
  }
94
76
  };
95
-
96
77
  const removeListeners = () => {
97
78
  _moveListeners.forEach(listener => listener.remove());
98
-
99
79
  _moveListeners = [];
100
-
101
80
  _downListeners.forEach(listener => listener.remove());
102
-
103
81
  _downListeners = [];
104
82
  };
105
-
106
83
  const addInputModeListener = handlerObject => {
107
84
  const onInputModeChange = handlerObject.onInputModeChange;
108
85
  const id = _registeredCount++;
109
-
110
86
  if (typeof onInputModeChange === 'function') {
111
87
  _modeChangeHandlers[id] = onInputModeChange;
112
88
  }
113
-
114
89
  if (canUseDOM) {
115
90
  addDownListeners();
116
91
  addMoveListeners();
117
92
  }
118
-
119
93
  return {
120
94
  isKeyboardMode: () => {
121
95
  return _mode === MODES.keyboard;
@@ -124,12 +98,10 @@ const addInputModeListener = handlerObject => {
124
98
  if (_registeredCount === 1) {
125
99
  removeListeners();
126
100
  }
127
-
128
101
  delete _modeChangeHandlers[id];
129
102
  _registeredCount--;
130
103
  }
131
104
  };
132
105
  };
133
-
134
106
  export default addInputModeListener;
135
107
  export { addInputModeListener, MODES };
@@ -21,10 +21,10 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
+
24
25
  import { findDOMNode } from './findDOMNode';
25
26
  import { getBoundingClientRect } from './getBoundingClientRect';
26
27
  import { requestAnimationFrame } from './requestAnimationFrame';
27
-
28
28
  /**
29
29
  * ---
30
30
  * category: utilities/DOM
@@ -41,30 +41,24 @@ function addPositionChangeListener(el, handler) {
41
41
  const raf = [];
42
42
  let coords = getBoundingClientRect(node) || {};
43
43
  let cancelled = false;
44
-
45
44
  function checkPosition() {
46
45
  if (!cancelled) {
47
46
  const newCoords = getBoundingClientRect(node) || {};
48
47
  const positionChanged = newCoords.top !== coords.top || newCoords.left !== coords.left || newCoords.right !== coords.right || newCoords.bottom !== coords.bottom || newCoords.width !== coords.width || newCoords.height !== coords.height;
49
-
50
48
  if (positionChanged && typeof handler === 'function') {
51
49
  handler(newCoords);
52
50
  }
53
-
54
51
  coords = newCoords;
55
52
  raf.push(requestAnimationFrame(checkPosition));
56
53
  }
57
54
  }
58
-
59
55
  checkPosition();
60
56
  return {
61
57
  remove() {
62
58
  cancelled = true;
63
59
  raf.forEach(req => req.cancel());
64
60
  }
65
-
66
61
  };
67
62
  }
68
-
69
63
  export default addPositionChangeListener;
70
64
  export { addPositionChangeListener };
@@ -21,10 +21,10 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
+
24
25
  import { findDOMNode } from './findDOMNode';
25
26
  import { getBoundingClientRect } from './getBoundingClientRect';
26
27
  import { requestAnimationFrame } from './requestAnimationFrame';
27
-
28
28
  /**
29
29
  * ---
30
30
  * category: utilities/DOM
@@ -67,35 +67,28 @@ function addResizeListener(el, handler) {
67
67
  let origSize = getBoundingClientRect(node);
68
68
  let cancelled = false;
69
69
  let raf;
70
-
71
70
  const checkDimensions = () => {
72
71
  if (cancelled) {
73
72
  return;
74
73
  }
75
-
76
74
  const boundingRect = getBoundingClientRect(node);
77
75
  const size = {
78
76
  width: boundingRect.width,
79
77
  height: boundingRect.height
80
78
  };
81
-
82
79
  if (dimensions.some(dim => size[dim] != origSize[dim]) && typeof handler === 'function') {
83
80
  handler(size);
84
81
  }
85
-
86
82
  origSize = size;
87
83
  raf = requestAnimationFrame(checkDimensions);
88
84
  };
89
-
90
85
  checkDimensions();
91
86
  return {
92
87
  remove() {
93
88
  cancelled = true;
94
89
  raf.cancel();
95
90
  }
96
-
97
91
  };
98
92
  }
99
-
100
93
  export default addResizeListener;
101
94
  export { addResizeListener };
package/es/contains.js CHANGED
@@ -21,9 +21,9 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
+
24
25
  import { findDOMNode } from './findDOMNode';
25
26
  import { canUseDOM } from './canUseDOM';
26
-
27
27
  /**
28
28
  * ---
29
29
  * category: utilities/DOM
@@ -38,7 +38,6 @@ import { canUseDOM } from './canUseDOM';
38
38
  function containsWithDOM(context, el) {
39
39
  const container = context && findDOMNode(context);
40
40
  const node = el && findDOMNode(el);
41
-
42
41
  if (!container || !node) {
43
42
  return false;
44
43
  } else if (!(container instanceof Window) && !(node instanceof Window)) {
@@ -47,23 +46,18 @@ function containsWithDOM(context, el) {
47
46
  return containsFallback(container, node);
48
47
  }
49
48
  }
50
- /* istanbul ignore next */
51
-
52
49
 
50
+ /* istanbul ignore next */
53
51
  function containsFallback(context, el) {
54
52
  let node = el;
55
-
56
53
  while (node) {
57
54
  if (node === context) {
58
55
  return true;
59
56
  }
60
-
61
57
  node = node.parentNode;
62
58
  }
63
-
64
59
  return false;
65
60
  }
66
-
67
61
  const contains = canUseDOM ? containsWithDOM : containsFallback;
68
62
  export default contains;
69
63
  export { contains };
@@ -21,10 +21,10 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
+
24
25
  import { findDOMNode } from './findDOMNode';
25
26
  import { contains } from './contains';
26
27
  import { getActiveElement } from './getActiveElement';
27
-
28
28
  /**
29
29
  * ---
30
30
  * category: utilities/DOM
@@ -40,6 +40,5 @@ function containsActiveElement(el) {
40
40
  const active = getActiveElement();
41
41
  return !!node && (active === node || contains(node, active));
42
42
  }
43
-
44
43
  export default containsActiveElement;
45
44
  export { containsActiveElement };
@@ -21,8 +21,8 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- import { findDOMNode } from './findDOMNode';
25
24
 
25
+ import { findDOMNode } from './findDOMNode';
26
26
  /**
27
27
  * ---
28
28
  * category: utilities/DOM
@@ -37,11 +37,10 @@ import { findDOMNode } from './findDOMNode';
37
37
  */
38
38
  function elementMatches(el, selectorString) {
39
39
  const node = el && findDOMNode(el);
40
- if (!node) return false; // this cast is in a separate line to circumvent a react-docgen bug
41
-
40
+ if (!node) return false;
41
+ // this cast is in a separate line to circumvent a react-docgen bug
42
42
  const elem = node;
43
43
  return elem.matches(selectorString);
44
44
  }
45
-
46
45
  export default elementMatches;
47
46
  export { elementMatches };
package/es/findDOMNode.js CHANGED
@@ -21,12 +21,11 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- import ReactDOM from 'react-dom';
25
24
 
25
+ import ReactDOM from 'react-dom';
26
26
  const isReactNodeWithRef = el => {
27
27
  return !!el && el.ref !== void 0;
28
28
  };
29
-
30
29
  const isRefObject = obj => {
31
30
  return !!obj && obj.current !== void 0;
32
31
  };
@@ -41,35 +40,29 @@ const isRefObject = obj => {
41
40
  * @param { Node | Window | React.ReactElement | React.Component | function } el - component, DOM node, or function returning a DOM node
42
41
  * @returns { Node | Window | null | undefined } The root node of this element
43
42
  */
44
-
45
-
46
43
  function findDOMNode(el) {
47
44
  const node = typeof el === 'function' ? el() : el;
48
-
49
45
  if (node === document) {
50
46
  return document.documentElement; // HTMLElement
51
47
  } else if (node instanceof Element || node === window || node && typeof node.nodeType !== 'undefined') {
52
48
  return node;
53
49
  } else if (node) {
54
50
  const reactNode = node;
55
-
56
51
  if (isReactNodeWithRef(reactNode)) {
57
52
  const refElement = isRefObject(reactNode.ref) ? reactNode.ref.current : reactNode.ref;
58
-
59
53
  if (!(refElement instanceof HTMLElement)) {
60
54
  return findDOMNode(refElement);
61
55
  }
62
-
63
56
  return refElement;
64
57
  } else {
65
- const elName = reactNode.constructor.componentId ? reactNode.constructor.componentId : reactNode.constructor.name; // eslint-disable-next-line no-console
58
+ const elName = reactNode.constructor.componentId ? reactNode.constructor.componentId : reactNode.constructor.name;
59
+
60
+ // eslint-disable-next-line no-console
66
61
 
67
62
  return ReactDOM.findDOMNode(node);
68
63
  }
69
64
  }
70
-
71
65
  return void 0;
72
66
  }
73
-
74
67
  export default findDOMNode;
75
68
  export { findDOMNode };
@@ -33,22 +33,18 @@
33
33
  *
34
34
  * http://api.jqueryui.com/category/ui-core/
35
35
  **/
36
- import { getComputedStyle, findDOMNode, elementMatches } from './';
37
36
 
37
+ import { getComputedStyle, findDOMNode, elementMatches } from './';
38
38
  function findFocusable(el, filter, shouldSearchRootNode) {
39
39
  const element = el && findDOMNode(el);
40
-
41
40
  if (!element || typeof element.querySelectorAll !== 'function') {
42
41
  return [];
43
42
  }
44
-
45
43
  const focusableSelector = 'a[href],frame,iframe,object,input:not([type=hidden]),select,textarea,button,*[tabindex]';
46
44
  let matches = Array.from(element.querySelectorAll(focusableSelector));
47
-
48
45
  if (shouldSearchRootNode && elementMatches(element, focusableSelector)) {
49
46
  matches = [...matches, element];
50
47
  }
51
-
52
48
  return matches.filter(el => {
53
49
  if (typeof filter === 'function') {
54
50
  return filter(el) && focusable(el);
@@ -57,22 +53,18 @@ function findFocusable(el, filter, shouldSearchRootNode) {
57
53
  }
58
54
  });
59
55
  }
60
-
61
56
  function hidden(element) {
62
57
  const cs = getComputedStyle(element);
63
58
  return cs.display !== 'inline' && element.offsetWidth <= 0 && element.offsetHeight <= 0 || cs.display === 'none';
64
59
  }
65
-
66
60
  function positioned(element) {
67
61
  const POS = ['fixed', 'absolute'];
68
62
  if (POS.includes(element.style.position.toLowerCase())) return true;
69
63
  if (POS.includes(getComputedStyle(element).getPropertyValue('position').toLowerCase())) return true;
70
64
  return false;
71
65
  }
72
-
73
66
  function visible(element) {
74
67
  let el = element;
75
-
76
68
  while (el) {
77
69
  if (el === document.body) break;
78
70
  if (el instanceof ShadowRoot) break;
@@ -80,14 +72,11 @@ function visible(element) {
80
72
  if (positioned(el)) break;
81
73
  el = el.parentNode;
82
74
  }
83
-
84
75
  return true;
85
76
  }
86
-
87
77
  function focusable(element) {
88
78
  return !element.disabled && visible(element);
89
79
  }
90
-
91
80
  export default findFocusable;
92
81
  export {
93
82
  /**
@@ -21,19 +21,17 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- import { findFocusable } from './findFocusable';
25
24
 
25
+ import { findFocusable } from './findFocusable';
26
26
  function findTabbable(el, shouldSearchRootNode) {
27
27
  return findFocusable(el, element => {
28
28
  return !isInvalidTabIndex(element.getAttribute('tabindex'));
29
29
  }, shouldSearchRootNode);
30
30
  }
31
-
32
31
  function isInvalidTabIndex(tabIndex) {
33
32
  // TS wants it to be number to be valid, but this method in fact checks if the parameter is a valid positive number
34
33
  return !isNaN(tabIndex) && tabIndex < 0;
35
34
  }
36
-
37
35
  export default findTabbable;
38
36
  export {
39
37
  /**
@@ -21,7 +21,9 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
+
24
25
  import { isDefinedCustomElement } from './isDefinedCustomElement';
26
+
25
27
  /**
26
28
  * ---
27
29
  * category: utilities/DOM
@@ -32,16 +34,14 @@ import { isDefinedCustomElement } from './isDefinedCustomElement';
32
34
  * @param { Document } doc - document by default or user specified doc
33
35
  * @return { Element | null } the active element
34
36
  */
35
-
36
37
  function getActiveElement(doc) {
37
- const activeElement = (doc || document).activeElement; //check if activeElement is a custom element or not
38
+ const activeElement = (doc || document).activeElement;
38
39
 
40
+ //check if activeElement is a custom element or not
39
41
  if (activeElement && isDefinedCustomElement(activeElement)) {
40
42
  return activeElement.shadowRoot.activeElement;
41
43
  }
42
-
43
44
  return activeElement;
44
45
  }
45
-
46
46
  export default getActiveElement;
47
47
  export { getActiveElement };
@@ -21,11 +21,11 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
+
24
25
  import { findDOMNode } from './findDOMNode';
25
26
  import { canUseDOM } from './canUseDOM';
26
27
  import { contains } from './contains';
27
28
  import { ownerDocument } from './ownerDocument';
28
-
29
29
  /**
30
30
  * ---
31
31
  * category: utilities/DOM
@@ -46,17 +46,13 @@ function getBoundingClientRect(el) {
46
46
  height: 0,
47
47
  width: 0
48
48
  };
49
-
50
49
  if (!canUseDOM) {
51
50
  return rect;
52
51
  }
53
-
54
52
  const node = el && findDOMNode(el);
55
-
56
53
  if (!node) {
57
54
  return rect;
58
55
  }
59
-
60
56
  if (node === window) {
61
57
  return {
62
58
  left: window.pageXOffset,
@@ -67,24 +63,18 @@ function getBoundingClientRect(el) {
67
63
  bottom: window.innerHeight + window.pageYOffset
68
64
  };
69
65
  }
70
-
71
66
  const doc = el === document ? document : ownerDocument(node);
72
67
  const docEl = doc && doc.documentElement;
73
-
74
68
  if (!docEl || !contains(docEl, node)) {
75
69
  return rect;
76
70
  }
77
-
78
71
  const boundingRect = node.getBoundingClientRect();
79
72
  let k;
80
-
81
73
  for (k in rect) {
82
74
  rect[k] = boundingRect[k];
83
75
  }
84
-
85
76
  if (doc !== document && doc.defaultView) {
86
77
  const frameElement = doc.defaultView.frameElement;
87
-
88
78
  if (frameElement) {
89
79
  const frameRect = getBoundingClientRect(frameElement);
90
80
  rect.top += frameRect.top;
@@ -93,7 +83,6 @@ function getBoundingClientRect(el) {
93
83
  rect.right += frameRect.left;
94
84
  }
95
85
  }
96
-
97
86
  return {
98
87
  top: rect.top + (window.pageYOffset || docEl.scrollTop) - (docEl.clientTop || 0),
99
88
  left: rect.left + (window.pageXOffset || docEl.scrollLeft) - (docEl.clientLeft || 0),
@@ -104,6 +93,5 @@ function getBoundingClientRect(el) {
104
93
  bottom: doc.body.clientHeight - rect.height - rect.top
105
94
  };
106
95
  }
107
-
108
96
  export default getBoundingClientRect;
109
97
  export { getBoundingClientRect };