@instructure/ui-dom-utils 11.6.0 → 11.6.1-pr-snapshot-1779894247159

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
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
+ ## [11.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-dom-utils
9
+
10
+
11
+
12
+
13
+
6
14
  # [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
7
15
 
8
16
  **Note:** Version bump only for package @instructure/ui-dom-utils
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.canUseDOM = void 0;
7
1
  /*
8
2
  * The MIT License (MIT)
9
3
  *
@@ -28,14 +22,16 @@ exports.default = exports.canUseDOM = void 0;
28
22
  * SOFTWARE.
29
23
  */
30
24
 
31
- /**
32
- * ---
33
- * category: utilities/DOM
34
- * ---
35
- *
36
- * Performs simple test to determine if DOM can be accessed
37
- * @module
38
- * @returns {boolean} whether the dom can be used
39
- */
40
- const canUseDOM = exports.canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
41
- var _default = exports.default = canUseDOM;
25
+ module.exports = {
26
+ presets: [
27
+ [
28
+ require('@instructure/ui-babel-preset'),
29
+ {
30
+ coverage: Boolean(process.env.COVERAGE),
31
+ esModules: Boolean(process.env.ES_MODULES),
32
+ removeConsole: process.env.NODE_ENV === 'production',
33
+ transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
34
+ }
35
+ ]
36
+ ]
37
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@instructure/ui-dom-utils",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-pr-snapshot-1779894247159",
4
+ "type": "module",
4
5
  "description": "A DOM utility library made by Instructure Inc.",
5
6
  "author": "Instructure, Inc. Engineering and Product Design",
6
7
  "module": "./es/index.js",
7
- "main": "./lib/index.js",
8
8
  "types": "./types/index.d.ts",
9
9
  "repository": {
10
10
  "type": "git",
@@ -15,14 +15,14 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
- "@instructure/console": "11.6.0",
19
- "@instructure/shared-types": "11.6.0"
18
+ "@instructure/console": "11.6.1-pr-snapshot-1779894247159",
19
+ "@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@testing-library/jest-dom": "^6.6.3",
23
23
  "@testing-library/react": "15.0.7",
24
24
  "vitest": "^3.2.2",
25
- "@instructure/ui-babel-preset": "11.6.0"
25
+ "@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": ">=18 <=19",
@@ -36,10 +36,8 @@
36
36
  ".": {
37
37
  "types": "./types/index.d.ts",
38
38
  "import": "./es/index.js",
39
- "require": "./lib/index.js",
40
39
  "default": "./es/index.js"
41
40
  },
42
- "./lib/*": "./lib/*",
43
41
  "./es/*": "./es/*",
44
42
  "./types/*": "./types/*",
45
43
  "./package.json": "./package.json",
@@ -49,7 +47,7 @@
49
47
  "lint": "ui-scripts lint",
50
48
  "lint:fix": "ui-scripts lint --fix",
51
49
  "clean": "ui-scripts clean",
52
- "build": "ui-scripts build --modules es,cjs",
50
+ "build": "ui-scripts build",
53
51
  "build:watch": "ui-scripts build --watch",
54
52
  "build:types": "tsc -p tsconfig.build.json"
55
53
  }
@@ -1,92 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.MODES = exports.InputModeListener = void 0;
7
- var _console = require("@instructure/console");
8
- var _addEventListener = require("./addEventListener");
9
- var _canUseDOM = require("./canUseDOM");
10
- /*
11
- * The MIT License (MIT)
12
- *
13
- * Copyright (c) 2015 - present Instructure, Inc.
14
- *
15
- * Permission is hereby granted, free of charge, to any person obtaining a copy
16
- * of this software and associated documentation files (the "Software"), to deal
17
- * in the Software without restriction, including without limitation the rights
18
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
- * copies of the Software, and to permit persons to whom the Software is
20
- * furnished to do so, subject to the following conditions:
21
- *
22
- * The above copyright notice and this permission notice shall be included in all
23
- * copies or substantial portions of the Software.
24
- *
25
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
- * SOFTWARE.
32
- */
33
-
34
- const MODES = exports.MODES = {
35
- keyboard: 'keyboard',
36
- pointer: 'pointer'
37
- };
38
- class InputModeListenerImpl {
39
- constructor() {
40
- this._listeners = [];
41
- this._initialized = false;
42
- this._mode = MODES.keyboard;
43
- this.onInitialPointerMove = event => {
44
- var _event$target, _event$target$nodeNam;
45
- // Work around a Safari quirk that fires a mousemove on <html> whenever the
46
- // window blurs, even if you're tabbing out of the page. ¯\_(ツ)_/¯
47
- 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') {
48
- return;
49
- }
50
- this._mode = MODES.pointer;
51
- this._listeners.forEach(listener => listener.remove());
52
- };
53
- this.onKeyDown = () => {
54
- this._mode = MODES.keyboard;
55
- };
56
- this.onPointerDown = () => {
57
- this._mode = MODES.pointer;
58
- };
59
- this.init = () => {
60
- if (!_canUseDOM.canUseDOM || this._initialized) return;
61
- (0, _addEventListener.addEventListener)(document, 'keydown', this.onKeyDown, true);
62
- (0, _addEventListener.addEventListener)(document, 'mousedown', this.onPointerDown, true);
63
- (0, _addEventListener.addEventListener)(document, 'pointerdown', this.onPointerDown, true);
64
- (0, _addEventListener.addEventListener)(document, 'touchstart', this.onPointerDown, true);
65
- this.addInitialPointerMoveListeners();
66
- this._initialized = true;
67
- };
68
- (0, _console.logWarn)(false, `[InputModeListener] is deprecated and will be removed in version 7.0.0. Use addInputModeListener instead.`);
69
- this.init();
70
- }
71
- addInitialPointerMoveListeners() {
72
- this._listeners.push((0, _addEventListener.addEventListener)(document, 'mousemove', this.onInitialPointerMove, true));
73
- this._listeners.push((0, _addEventListener.addEventListener)(document, 'mousedown', this.onInitialPointerMove, true));
74
- this._listeners.push((0, _addEventListener.addEventListener)(document, 'mouseup', this.onInitialPointerMove, true));
75
- this._listeners.push((0, _addEventListener.addEventListener)(document, 'pointermove', this.onInitialPointerMove, true));
76
- this._listeners.push((0, _addEventListener.addEventListener)(document, 'pointerdown', this.onInitialPointerMove, true));
77
- this._listeners.push((0, _addEventListener.addEventListener)(document, 'pointerup', this.onInitialPointerMove, true));
78
- this._listeners.push((0, _addEventListener.addEventListener)(document, 'touchmove', this.onInitialPointerMove, true));
79
- this._listeners.push((0, _addEventListener.addEventListener)(document, 'touchstart', this.onInitialPointerMove, true));
80
- this._listeners.push((0, _addEventListener.addEventListener)(document, 'touchend', this.onInitialPointerMove, true));
81
- }
82
- get mode() {
83
- this.init();
84
- return this._mode;
85
- }
86
- isKeyboardMode() {
87
- this.init();
88
- return this._mode === MODES.keyboard;
89
- }
90
- }
91
- const InputModeListener = exports.InputModeListener = new InputModeListenerImpl();
92
- var _default = exports.default = InputModeListener;
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.addEventListener = addEventListener;
7
- exports.default = void 0;
8
- var _findDOMNode = require("./findDOMNode");
9
- /*
10
- * The MIT License (MIT)
11
- *
12
- * Copyright (c) 2015 - present Instructure, Inc.
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- * copies of the Software, and to permit persons to whom the Software is
19
- * furnished to do so, subject to the following conditions:
20
- *
21
- * The above copyright notice and this permission notice shall be included in all
22
- * copies or substantial portions of the Software.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
- * SOFTWARE.
31
- */
32
-
33
- /**
34
- * ---
35
- * category: utilities/DOM
36
- * ---
37
- * Wrapper function for DOM addEventListener
38
- * @module addEventListener
39
- * @param { Node | Window } el - DOM node which will have the event listener attached
40
- * @param { string } event - a string specifying the event name ('click', 'focus', etc)
41
- * @param { React.EventHandler<React.SyntheticEvent<any, any>> } handler - function to run when event occurs
42
- * @param { boolean } capture - should the event be executed in the capturing or bubbling phase
43
- * @returns {{ remove(): void }} a method to remove the event listener
44
- */
45
- function addEventListener(el, event, handler, capture) {
46
- const node = el === window || el === document ? el : (0, _findDOMNode.findDOMNode)(el);
47
- node === null || node === void 0 ? void 0 : node.addEventListener(event, handler, capture);
48
- return {
49
- remove() {
50
- node === null || node === void 0 ? void 0 : node.removeEventListener(event, handler, capture);
51
- }
52
- };
53
- }
54
- var _default = exports.default = addEventListener;
@@ -1,113 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.addInputModeListener = exports.MODES = void 0;
7
- var _addEventListener = require("./addEventListener");
8
- var _canUseDOM = require("./canUseDOM");
9
- /*
10
- * The MIT License (MIT)
11
- *
12
- * Copyright (c) 2015 - present Instructure, Inc.
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- * copies of the Software, and to permit persons to whom the Software is
19
- * furnished to do so, subject to the following conditions:
20
- *
21
- * The above copyright notice and this permission notice shall be included in all
22
- * copies or substantial portions of the Software.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
- * SOFTWARE.
31
- */
32
-
33
- const MODES = exports.MODES = {
34
- keyboard: 'keyboard',
35
- pointer: 'pointer'
36
- };
37
- let _moveListeners = [];
38
- let _downListeners = [];
39
- let _mode = MODES.keyboard;
40
- let _registeredCount = 0;
41
- const _modeChangeHandlers = {};
42
- const handleInitialPointerMove = event => {
43
- // Work around a Safari quirk that fires a mousemove on <html> whenever the
44
- // window blurs, even if you're tabbing out of the page. ¯\_(ツ)_/¯
45
- if (event.target.nodeName.toLowerCase() === 'html') {
46
- return;
47
- }
48
- handleInputModeChange(_mode, MODES.pointer);
49
- _moveListeners.forEach(listener => listener.remove());
50
- };
51
- const handleInputModeChange = (currentMode, newMode) => {
52
- if (currentMode === newMode) return;
53
- _mode = newMode;
54
- Object.keys(_modeChangeHandlers).forEach(handlerId => _modeChangeHandlers[handlerId](currentMode, newMode));
55
- };
56
- const handleKeyDown = () => {
57
- handleInputModeChange(_mode, MODES.keyboard);
58
- };
59
- const handlePointerDown = () => {
60
- handleInputModeChange(_mode, MODES.pointer);
61
- };
62
- const addMoveListeners = () => {
63
- if (_moveListeners.length === 0) {
64
- _moveListeners.push((0, _addEventListener.addEventListener)(document, 'mousemove', handleInitialPointerMove, true));
65
- _moveListeners.push((0, _addEventListener.addEventListener)(document, 'mousedown', handleInitialPointerMove, true));
66
- _moveListeners.push((0, _addEventListener.addEventListener)(document, 'mouseup', handleInitialPointerMove, true));
67
- _moveListeners.push((0, _addEventListener.addEventListener)(document, 'pointermove', handleInitialPointerMove, true));
68
- _moveListeners.push((0, _addEventListener.addEventListener)(document, 'pointerdown', handleInitialPointerMove, true));
69
- _moveListeners.push((0, _addEventListener.addEventListener)(document, 'pointerup', handleInitialPointerMove, true));
70
- _moveListeners.push((0, _addEventListener.addEventListener)(document, 'touchmove', handleInitialPointerMove, true));
71
- _moveListeners.push((0, _addEventListener.addEventListener)(document, 'touchstart', handleInitialPointerMove, true));
72
- _moveListeners.push((0, _addEventListener.addEventListener)(document, 'touchend', handleInitialPointerMove, true));
73
- }
74
- };
75
- const addDownListeners = () => {
76
- if (_downListeners.length === 0) {
77
- _downListeners.push((0, _addEventListener.addEventListener)(document, 'keydown', handleKeyDown, true));
78
- _downListeners.push((0, _addEventListener.addEventListener)(document, 'mousedown', handlePointerDown, true));
79
- _downListeners.push((0, _addEventListener.addEventListener)(document, 'pointerdown', handlePointerDown, true));
80
- _downListeners.push((0, _addEventListener.addEventListener)(document, 'touchstart', handlePointerDown, true));
81
- }
82
- };
83
- const removeListeners = () => {
84
- _moveListeners.forEach(listener => listener.remove());
85
- _moveListeners = [];
86
- _downListeners.forEach(listener => listener.remove());
87
- _downListeners = [];
88
- };
89
- const addInputModeListener = handlerObject => {
90
- const onInputModeChange = handlerObject.onInputModeChange;
91
- const id = _registeredCount++;
92
- if (typeof onInputModeChange === 'function') {
93
- _modeChangeHandlers[id] = onInputModeChange;
94
- }
95
- if (_canUseDOM.canUseDOM) {
96
- addDownListeners();
97
- addMoveListeners();
98
- }
99
- return {
100
- isKeyboardMode: () => {
101
- return _mode === MODES.keyboard;
102
- },
103
- remove: () => {
104
- if (_registeredCount === 1) {
105
- removeListeners();
106
- }
107
- delete _modeChangeHandlers[id];
108
- _registeredCount--;
109
- }
110
- };
111
- };
112
- exports.addInputModeListener = addInputModeListener;
113
- var _default = exports.default = addInputModeListener;
@@ -1,70 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.addPositionChangeListener = addPositionChangeListener;
7
- exports.default = void 0;
8
- var _findDOMNode = require("./findDOMNode");
9
- var _getBoundingClientRect = require("./getBoundingClientRect");
10
- var _requestAnimationFrame = require("./requestAnimationFrame");
11
- /*
12
- * The MIT License (MIT)
13
- *
14
- * Copyright (c) 2015 - present Instructure, Inc.
15
- *
16
- * Permission is hereby granted, free of charge, to any person obtaining a copy
17
- * of this software and associated documentation files (the "Software"), to deal
18
- * in the Software without restriction, including without limitation the rights
19
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
- * copies of the Software, and to permit persons to whom the Software is
21
- * furnished to do so, subject to the following conditions:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all
24
- * copies or substantial portions of the Software.
25
- *
26
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
- * SOFTWARE.
33
- */
34
-
35
- /**
36
- * ---
37
- * category: utilities/DOM
38
- * ---
39
- * Adds a listener to an element and calls a specified handler
40
- * function whenever the position changes
41
- * @module
42
- * @param { Node | Window | React.ReactElement | React.Component | function } el - component or DOM node
43
- * @param {function} handler - function to run if the position has changed
44
- * @returns {function} remove - cancel the listener and no longer execute the handler function
45
- */
46
- function addPositionChangeListener(el, handler) {
47
- const node = (0, _findDOMNode.findDOMNode)(el);
48
- const raf = [];
49
- let coords = (0, _getBoundingClientRect.getBoundingClientRect)(node) || {};
50
- let cancelled = false;
51
- function checkPosition() {
52
- if (!cancelled) {
53
- const newCoords = (0, _getBoundingClientRect.getBoundingClientRect)(node) || {};
54
- 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;
55
- if (positionChanged && typeof handler === 'function') {
56
- handler(newCoords);
57
- }
58
- coords = newCoords;
59
- raf.push((0, _requestAnimationFrame.requestAnimationFrame)(checkPosition));
60
- }
61
- }
62
- checkPosition();
63
- return {
64
- remove() {
65
- cancelled = true;
66
- raf.forEach(req => req.cancel());
67
- }
68
- };
69
- }
70
- var _default = exports.default = addPositionChangeListener;
package/lib/contains.js DELETED
@@ -1,69 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.contains = void 0;
7
- var _findDOMNode = require("./findDOMNode");
8
- var _canUseDOM = require("./canUseDOM");
9
- /*
10
- * The MIT License (MIT)
11
- *
12
- * Copyright (c) 2015 - present Instructure, Inc.
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- * copies of the Software, and to permit persons to whom the Software is
19
- * furnished to do so, subject to the following conditions:
20
- *
21
- * The above copyright notice and this permission notice shall be included in all
22
- * copies or substantial portions of the Software.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
- * SOFTWARE.
31
- */
32
-
33
- function containsWithDOM(context, el) {
34
- const container = context && (0, _findDOMNode.findDOMNode)(context);
35
- const node = el && (0, _findDOMNode.findDOMNode)(el);
36
- if (!container || !node) {
37
- return false;
38
- } else if (!(container instanceof Window) && !(node instanceof Window)) {
39
- return container.contains(node);
40
- } else {
41
- return containsFallback(container, node);
42
- }
43
- }
44
-
45
- /* istanbul ignore next */
46
- function containsFallback(context, el) {
47
- let node = el;
48
- while (node) {
49
- if (node === context) {
50
- return true;
51
- }
52
- node = node.parentNode;
53
- }
54
- return false;
55
- }
56
-
57
- /**
58
- * ---
59
- * category: utilities/DOM
60
- * ---
61
- *
62
- * Determine if an element contains another DOM node
63
- * @module containsWithDOM
64
- * @param { Node | Window | React.ReactElement | function | null } context - component or DOM node
65
- * @param { Node | Window | React.ReactElement | function | null } el - component or DOM node which we want to determine if contained within the context
66
- * @returns { boolean } if the element is contained within the context
67
- */
68
- const contains = exports.contains = _canUseDOM.canUseDOM ? containsWithDOM : containsFallback;
69
- var _default = exports.default = contains;
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.containsActiveElement = containsActiveElement;
7
- exports.default = void 0;
8
- var _findDOMNode = require("./findDOMNode");
9
- var _contains = require("./contains");
10
- var _getActiveElement = require("./getActiveElement");
11
- /*
12
- * The MIT License (MIT)
13
- *
14
- * Copyright (c) 2015 - present Instructure, Inc.
15
- *
16
- * Permission is hereby granted, free of charge, to any person obtaining a copy
17
- * of this software and associated documentation files (the "Software"), to deal
18
- * in the Software without restriction, including without limitation the rights
19
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
- * copies of the Software, and to permit persons to whom the Software is
21
- * furnished to do so, subject to the following conditions:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all
24
- * copies or substantial portions of the Software.
25
- *
26
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
- * SOFTWARE.
33
- */
34
-
35
- /**
36
- * ---
37
- * category: utilities/DOM
38
- * ---
39
- *
40
- * Determine if an element contains the active element
41
- * @module containsActiveElement
42
- * @param { Node | Window | React.ReactElement | React.Component | function | null } el - component or DOM node
43
- * @returns {boolean} if the element contains the active element
44
- */
45
- function containsActiveElement(el) {
46
- const node = el && (0, _findDOMNode.findDOMNode)(el);
47
- const active = (0, _getActiveElement.getActiveElement)();
48
- return !!node && (active === node || (0, _contains.contains)(node, active));
49
- }
50
- var _default = exports.default = containsActiveElement;
@@ -1,97 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- exports.findDOMNode = findDOMNode;
9
- var _reactDom = _interopRequireDefault(require("react-dom"));
10
- /*
11
- * The MIT License (MIT)
12
- *
13
- * Copyright (c) 2015 - present Instructure, Inc.
14
- *
15
- * Permission is hereby granted, free of charge, to any person obtaining a copy
16
- * of this software and associated documentation files (the "Software"), to deal
17
- * in the Software without restriction, including without limitation the rights
18
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
- * copies of the Software, and to permit persons to whom the Software is
20
- * furnished to do so, subject to the following conditions:
21
- *
22
- * The above copyright notice and this permission notice shall be included in all
23
- * copies or substantial portions of the Software.
24
- *
25
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
- * SOFTWARE.
32
- */
33
-
34
- /**
35
- * Return the ref of an element in a way that is compatible both with
36
- * React 18 (element.ref) and React 19+ (element.props.ref)
37
- */
38
- function getElementRef(elem) {
39
- var _elem$props;
40
- // Note that this is added by InstUI components like Position
41
- if (elem.ref) {
42
- return elem.ref;
43
- }
44
- // note that trying to access this will display a warning in React 18.
45
- // this is OK because without it React itself would show an error because
46
- // its using findDOMNode
47
- return elem === null || elem === void 0 ? void 0 : (_elem$props = elem.props) === null || _elem$props === void 0 ? void 0 : _elem$props.ref;
48
- }
49
-
50
- /**
51
- * ---
52
- * category: utilities/DOM
53
- * ---
54
- *
55
- * Returns the underlying DOM node. It looks the following places:
56
- * - If it's a native HTML element e.g. `HtmlSpanElement` its returned as is.
57
- * - If the element has a non-nullish `ref` prop or instance variable which is a
58
- * `HTMLElement` its returned. If it`s something else then `findDOMNode` is called
59
- * on the object. (it also checks `ref.current`)
60
- * - If the element has a `ref` prop or instance variable whose value is `null`,
61
- * `undefined` is returned.
62
- * - If the element does not have a `ref` prop or instance variable `undefined`
63
- * is returned with a warning
64
- * @module findDOMNode
65
- *
66
- * @param el - component, DOM node, or function returning a DOM node
67
- * @returns The native DOM node of this element or `undefined`
68
- */
69
- function findDOMNode(el) {
70
- const node = typeof el === 'function' ? el() : el;
71
- if (node && node === document) {
72
- return document.documentElement; // HTMLElement
73
- } else if (node instanceof Element || node === window || node && typeof node.nodeType !== 'undefined') {
74
- return node;
75
- } else if (node) {
76
- const ref = getElementRef(node);
77
- const refElement = ref !== null && ref !== void 0 && ref.current ? ref.current : ref;
78
- if (refElement) {
79
- if (!(refElement instanceof HTMLElement)) {
80
- return findDOMNode(refElement);
81
- }
82
- return refElement;
83
- } else if (refElement === null) {
84
- // weird, but changing it would be a breaking change
85
- return void 0;
86
- }
87
- const elName = node.constructor.componentId ? node.constructor.componentId : node.constructor.name;
88
- // TODO remove when we only support React 19 or greater
89
- const ReactDomInstance = _reactDom.default;
90
- if (typeof ReactDomInstance.findDOMNode === 'function') {
91
- return ReactDomInstance.findDOMNode(node);
92
- }
93
- return void 0;
94
- }
95
- return void 0;
96
- }
97
- var _default = exports.default = findDOMNode;