@instructure/ui-dom-utils 10.26.1-snapshot-2 → 10.26.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.
- package/CHANGELOG.md +5 -18
- package/es/findDOMNode.js +15 -41
- package/es/findFocusable.js +5 -6
- package/es/{getCSSStyleDeclaration.js → getComputedStyle.js} +7 -11
- package/es/getFontSize.js +2 -2
- package/es/getOffsetParents.js +2 -2
- package/es/getScrollParents.js +4 -4
- package/es/index.js +1 -1
- package/es/isVisible.js +6 -6
- package/lib/findDOMNode.js +15 -40
- package/lib/findFocusable.js +4 -5
- package/lib/{getCSSStyleDeclaration.js → getComputedStyle.js} +7 -11
- package/lib/getFontSize.js +2 -2
- package/lib/getOffsetParents.js +2 -2
- package/lib/getScrollParents.js +4 -4
- package/lib/index.js +5 -5
- package/lib/isVisible.js +6 -6
- package/package.json +7 -7
- package/src/findDOMNode.ts +34 -48
- package/src/findFocusable.ts +11 -10
- package/src/{getCSSStyleDeclaration.ts → getComputedStyle.ts} +8 -14
- package/src/getFontSize.ts +2 -2
- package/src/getOffsetParents.ts +2 -2
- package/src/getScrollParents.ts +4 -4
- package/src/index.ts +1 -1
- package/src/isVisible.ts +8 -10
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/findDOMNode.d.ts +3 -11
- package/types/findDOMNode.d.ts.map +1 -1
- package/types/findFocusable.d.ts.map +1 -1
- package/types/{getCSSStyleDeclaration.d.ts → getComputedStyle.d.ts} +6 -6
- package/types/getComputedStyle.d.ts.map +1 -0
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/isVisible.d.ts.map +1 -1
- package/types/getCSSStyleDeclaration.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,30 +3,17 @@
|
|
|
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
|
-
## [10.26.
|
|
6
|
+
## [10.26.2](https://github.com/instructure/instructure-ui/compare/v10.26.1...v10.26.2) (2025-10-13)
|
|
7
7
|
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-dom-utils
|
|
8
9
|
|
|
9
|
-
### Features
|
|
10
10
|
|
|
11
|
-
* **many:** instUI v11 release ([36f5438](https://github.com/instructure/instructure-ui/commit/36f54382669186227ba24798bbf7201ef2f5cd4c))
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
### BREAKING CHANGES
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- remove `CodeEditor` component
|
|
20
|
-
- remove `@instui/theme-registry` package
|
|
21
|
-
- remove `@testable`, `@experimental`, `@hack` decorators
|
|
22
|
-
- InstUISettingsProvider's `as` prop is removed
|
|
23
|
-
- `canvas.use()`, `canvasHighContrast.use()` functions are removed
|
|
24
|
-
- `canvasThemeLocal`, `canvasHighContrastThemeLocal` are removed
|
|
25
|
-
- `variables` field on theme objects are removed
|
|
26
|
-
- remove deprecated props from Table: Row's `isStacked`, Body's
|
|
27
|
-
`isStacked`, `hover`, and `headers`
|
|
28
|
-
- `Table`'s `caption` prop is now required
|
|
29
|
-
- `ui-dom-utils`'s `getComputedStyle` can now return `undefined`
|
|
14
|
+
## [10.26.1](https://github.com/instructure/instructure-ui/compare/v10.26.0...v10.26.1) (2025-10-06)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @instructure/ui-dom-utils
|
|
30
17
|
|
|
31
18
|
|
|
32
19
|
|
package/es/findDOMNode.js
CHANGED
|
@@ -23,41 +23,22 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import ReactDOM from 'react-dom';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var _elem$props;
|
|
33
|
-
// Note that this is added by InstUI components like Position
|
|
34
|
-
if (elem.ref) {
|
|
35
|
-
return elem.ref;
|
|
36
|
-
}
|
|
37
|
-
// note that trying to access this will display a warning in React 18.
|
|
38
|
-
// this is OK because without it React itself would show an error because
|
|
39
|
-
// its using findDOMNode
|
|
40
|
-
return elem === null || elem === void 0 ? void 0 : (_elem$props = elem.props) === null || _elem$props === void 0 ? void 0 : _elem$props.ref;
|
|
41
|
-
}
|
|
42
|
-
|
|
26
|
+
const isReactNodeWithRef = el => {
|
|
27
|
+
return !!el && el.ref !== void 0;
|
|
28
|
+
};
|
|
29
|
+
const isRefObject = obj => {
|
|
30
|
+
return !!obj && obj.current !== void 0;
|
|
31
|
+
};
|
|
43
32
|
/**
|
|
44
33
|
* ---
|
|
45
34
|
* category: utilities/DOM
|
|
46
35
|
* ---
|
|
47
36
|
*
|
|
48
|
-
*
|
|
49
|
-
* - If it's a native HTML element e.g. `HtmlSpanElement` its returned as is.
|
|
50
|
-
* - If the element has a non-nullish `ref` prop or instance variable which is a
|
|
51
|
-
* `HTMLElement` its returned. If it`s something else then `findDOMNode` is called
|
|
52
|
-
* on the object. (it also checks `ref.current`)
|
|
53
|
-
* - If the element has a `ref` prop or instance variable whose value is `null`,
|
|
54
|
-
* `undefined` is returned.
|
|
55
|
-
* - If the element does not have a `ref` prop or instance variable `undefined`
|
|
56
|
-
* is returned with a warning
|
|
37
|
+
* Wrapper function for React.findDOMNode
|
|
57
38
|
* @module findDOMNode
|
|
58
39
|
*
|
|
59
|
-
* @param el - component, DOM node, or function returning a DOM node
|
|
60
|
-
* @returns The
|
|
40
|
+
* @param { Node | Window | React.ReactElement | React.Component | function } el - component, DOM node, or function returning a DOM node
|
|
41
|
+
* @returns { Node | Window | null | undefined } The root node of this element
|
|
61
42
|
*/
|
|
62
43
|
function findDOMNode(el) {
|
|
63
44
|
const node = typeof el === 'function' ? el() : el;
|
|
@@ -66,24 +47,17 @@ function findDOMNode(el) {
|
|
|
66
47
|
} else if (node instanceof Element || node === window || node && typeof node.nodeType !== 'undefined') {
|
|
67
48
|
return node;
|
|
68
49
|
} else if (node) {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
50
|
+
const reactNode = node;
|
|
51
|
+
if (isReactNodeWithRef(reactNode)) {
|
|
52
|
+
const refElement = isRefObject(reactNode.ref) ? reactNode.ref.current : reactNode.ref;
|
|
72
53
|
if (!(refElement instanceof HTMLElement)) {
|
|
73
54
|
return findDOMNode(refElement);
|
|
74
55
|
}
|
|
75
56
|
return refElement;
|
|
76
|
-
} else
|
|
77
|
-
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
const elName = node.constructor.componentId ? node.constructor.componentId : node.constructor.name;
|
|
81
|
-
// TODO remove when we only support React 19 or greater
|
|
82
|
-
const ReactDomInstance = ReactDOM;
|
|
83
|
-
if (typeof ReactDomInstance.findDOMNode === 'function') {
|
|
84
|
-
return ReactDomInstance.findDOMNode(node);
|
|
57
|
+
} else {
|
|
58
|
+
const elName = reactNode.constructor.componentId ? reactNode.constructor.componentId : reactNode.constructor.name;
|
|
59
|
+
return ReactDOM.findDOMNode(node);
|
|
85
60
|
}
|
|
86
|
-
return void 0;
|
|
87
61
|
}
|
|
88
62
|
return void 0;
|
|
89
63
|
}
|
package/es/findFocusable.js
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
// or even better use the native <dialog> component.
|
|
38
38
|
// tabbable has issues with scrollable containers, e.g.
|
|
39
39
|
// https://github.com/focus-trap/tabbable/issues/167
|
|
40
|
-
import {
|
|
40
|
+
import { getComputedStyle, findDOMNode } from './';
|
|
41
41
|
const focusableSelector = ['a[href]', 'frame', 'iframe', 'object', 'input:not([type=hidden])', 'select', 'textarea', 'button', '*[tabindex]', '[contenteditable="true"]'].join(',');
|
|
42
42
|
function hasQuerySelectorAll(el) {
|
|
43
43
|
if (!el || typeof el.querySelectorAll !== 'function') {
|
|
@@ -79,17 +79,16 @@ function findFocusable(el, filter, shouldSearchRootNode) {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
function hidden(element) {
|
|
82
|
-
const cs =
|
|
83
|
-
return
|
|
82
|
+
const cs = getComputedStyle(element);
|
|
83
|
+
return cs.display === 'none';
|
|
84
84
|
}
|
|
85
85
|
function positioned(element) {
|
|
86
|
-
var _style$position,
|
|
86
|
+
var _style$position, _getComputedStyle$get;
|
|
87
87
|
const POS = ['fixed', 'absolute'];
|
|
88
88
|
if (POS.includes((_style$position = element.style.position) === null || _style$position === void 0 ? void 0 : _style$position.toLowerCase())) {
|
|
89
89
|
return true;
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
if (position && POS.includes(position)) {
|
|
91
|
+
if (POS.includes((_getComputedStyle$get = getComputedStyle(element).getPropertyValue('position')) === null || _getComputedStyle$get === void 0 ? void 0 : _getComputedStyle$get.toLowerCase())) {
|
|
93
92
|
return true;
|
|
94
93
|
}
|
|
95
94
|
return false;
|
|
@@ -32,26 +32,22 @@ import { canUseDOM } from './canUseDOM';
|
|
|
32
32
|
*
|
|
33
33
|
* Get the associated CSS properties and values for a
|
|
34
34
|
* specified element
|
|
35
|
-
* @module
|
|
35
|
+
* @module getComputedStyle
|
|
36
36
|
*
|
|
37
37
|
* @param { Node | Window | React.ReactElement | React.Component | function } el - component or DOM node
|
|
38
38
|
* @param { string | null | undefined } pseudoElt - A string specifying the pseudo-element to match. Omitted (or null ) for real elements.
|
|
39
|
-
* @returns {
|
|
39
|
+
* @returns { Object } object containing css properties and values for the element
|
|
40
40
|
*/
|
|
41
|
-
function
|
|
42
|
-
let style;
|
|
41
|
+
function getComputedStyle(el, pseudoElt) {
|
|
42
|
+
let style = {};
|
|
43
43
|
if (canUseDOM) {
|
|
44
44
|
const node = el && findDOMNode(el);
|
|
45
45
|
if (node) {
|
|
46
46
|
const window = ownerWindow(el);
|
|
47
|
-
|
|
48
|
-
style = window ? window.getComputedStyle(node, pseudoElt) : void 0;
|
|
49
|
-
} catch {
|
|
50
|
-
style = void 0;
|
|
51
|
-
}
|
|
47
|
+
style = window ? window.getComputedStyle(node, pseudoElt) : {};
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
50
|
return style;
|
|
55
51
|
}
|
|
56
|
-
export default
|
|
57
|
-
export {
|
|
52
|
+
export default getComputedStyle;
|
|
53
|
+
export { getComputedStyle };
|
package/es/getFontSize.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import { canUseDOM } from './canUseDOM';
|
|
25
25
|
import { ownerDocument } from './ownerDocument';
|
|
26
|
-
import {
|
|
26
|
+
import { getComputedStyle } from './getComputedStyle';
|
|
27
27
|
const COMPUTED_CACHE = new WeakMap();
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -50,7 +50,7 @@ function getFontSize(el, ignoreCache = false) {
|
|
|
50
50
|
if (!ignoreCache && cachedValue) {
|
|
51
51
|
return cachedValue;
|
|
52
52
|
}
|
|
53
|
-
const fontSize = parseInt(
|
|
53
|
+
const fontSize = parseInt(getComputedStyle(container).getPropertyValue('font-size'));
|
|
54
54
|
|
|
55
55
|
// cache the computed font size so that we don't have to compute it again
|
|
56
56
|
COMPUTED_CACHE.set(container, fontSize);
|
package/es/getOffsetParents.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import { findDOMNode } from './findDOMNode';
|
|
26
26
|
import { canUseDOM } from './canUseDOM';
|
|
27
|
-
import {
|
|
27
|
+
import { getComputedStyle } from './getComputedStyle';
|
|
28
28
|
import { ownerDocument } from './ownerDocument';
|
|
29
29
|
/**
|
|
30
30
|
* ---
|
|
@@ -48,7 +48,7 @@ function getOffsetParents(el) {
|
|
|
48
48
|
if (node) {
|
|
49
49
|
let parent = node;
|
|
50
50
|
while ((parent = parent.parentNode) && parent && parent.nodeType === 1 && parent.tagName !== 'BODY') {
|
|
51
|
-
const style =
|
|
51
|
+
const style = getComputedStyle(parent);
|
|
52
52
|
const transform = style.getPropertyValue('-webkit-transform') || style.getPropertyValue('-moz-transform') || style.getPropertyValue('-ms-transform') || style.getPropertyValue('-o-transform') || style.getPropertyValue('transform') || 'none';
|
|
53
53
|
// initial value of transform can be 'none' or a matrix equivalent
|
|
54
54
|
const transformDefault = transform === 'none' || transform === 'matrix(1, 0, 0, 1, 0, 0)' ? true : false;
|
package/es/getScrollParents.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import { findDOMNode } from './findDOMNode';
|
|
26
26
|
import { canUseDOM } from './canUseDOM';
|
|
27
|
-
import {
|
|
27
|
+
import { getComputedStyle } from './getComputedStyle';
|
|
28
28
|
/**
|
|
29
29
|
* ---
|
|
30
30
|
* category: utilities/DOM
|
|
@@ -48,8 +48,8 @@ function getScrollParents(el) {
|
|
|
48
48
|
if (node) {
|
|
49
49
|
// In firefox if the element is inside an iframe with display: none; window.getComputedStyle() will return null;
|
|
50
50
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=548397
|
|
51
|
-
const computedStyle =
|
|
52
|
-
const position = computedStyle
|
|
51
|
+
const computedStyle = getComputedStyle(node) || {};
|
|
52
|
+
const position = computedStyle.position;
|
|
53
53
|
if (position === 'fixed') {
|
|
54
54
|
return [node.ownerDocument];
|
|
55
55
|
}
|
|
@@ -57,7 +57,7 @@ function getScrollParents(el) {
|
|
|
57
57
|
while (parent && parent.nodeType === 1 && (parent = parent.parentNode)) {
|
|
58
58
|
let style;
|
|
59
59
|
try {
|
|
60
|
-
style =
|
|
60
|
+
style = getComputedStyle(parent);
|
|
61
61
|
} catch (err) {} // eslint-disable-line no-empty
|
|
62
62
|
|
|
63
63
|
if (typeof style === 'undefined' || style === null) {
|
package/es/index.js
CHANGED
|
@@ -35,7 +35,7 @@ export { findTabbable } from './findTabbable';
|
|
|
35
35
|
export { getActiveElement } from './getActiveElement';
|
|
36
36
|
export { getBoundingClientRect } from './getBoundingClientRect';
|
|
37
37
|
export { getClassList } from './getClassList';
|
|
38
|
-
export {
|
|
38
|
+
export { getComputedStyle } from './getComputedStyle';
|
|
39
39
|
export { getFontSize } from './getFontSize';
|
|
40
40
|
export { getOffsetParents } from './getOffsetParents';
|
|
41
41
|
export { getScrollParents } from './getScrollParents';
|
package/es/isVisible.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { findDOMNode } from './findDOMNode';
|
|
26
|
-
import {
|
|
26
|
+
import { getComputedStyle } from './getComputedStyle';
|
|
27
27
|
/**
|
|
28
28
|
* ---
|
|
29
29
|
* category: utilities/DOM
|
|
@@ -49,18 +49,18 @@ function isVisible(el, recursive = true) {
|
|
|
49
49
|
if (node.nodeType === 3) {
|
|
50
50
|
return isVisible(parent, recursive);
|
|
51
51
|
}
|
|
52
|
-
const style = node ?
|
|
52
|
+
const style = node ? getComputedStyle(node) : {};
|
|
53
53
|
// physically and visually hidden
|
|
54
|
-
if (
|
|
54
|
+
if (style.display === 'none') {
|
|
55
55
|
return false;
|
|
56
56
|
}
|
|
57
57
|
// visually hidden
|
|
58
|
-
if (
|
|
58
|
+
if (style.visibility === 'hidden' || style.opacity === '0') {
|
|
59
59
|
return false;
|
|
60
60
|
}
|
|
61
61
|
// hidden by clipping
|
|
62
|
-
if (
|
|
63
|
-
const rect = style
|
|
62
|
+
if (style.overflow === 'hidden' && style.position === 'absolute' && style.clip !== 'auto') {
|
|
63
|
+
const rect = style.clip.substring(5).slice(0, -1).split(', ');
|
|
64
64
|
let zeros = true;
|
|
65
65
|
rect.forEach(a => {
|
|
66
66
|
if (a !== '0px') {
|
package/lib/findDOMNode.js
CHANGED
|
@@ -31,40 +31,22 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
|
31
31
|
* SOFTWARE.
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
34
|
+
const isReactNodeWithRef = el => {
|
|
35
|
+
return !!el && el.ref !== void 0;
|
|
36
|
+
};
|
|
37
|
+
const isRefObject = obj => {
|
|
38
|
+
return !!obj && obj.current !== void 0;
|
|
39
|
+
};
|
|
50
40
|
/**
|
|
51
41
|
* ---
|
|
52
42
|
* category: utilities/DOM
|
|
53
43
|
* ---
|
|
54
44
|
*
|
|
55
|
-
*
|
|
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
|
|
45
|
+
* Wrapper function for React.findDOMNode
|
|
64
46
|
* @module findDOMNode
|
|
65
47
|
*
|
|
66
|
-
* @param el - component, DOM node, or function returning a DOM node
|
|
67
|
-
* @returns The
|
|
48
|
+
* @param { Node | Window | React.ReactElement | React.Component | function } el - component, DOM node, or function returning a DOM node
|
|
49
|
+
* @returns { Node | Window | null | undefined } The root node of this element
|
|
68
50
|
*/
|
|
69
51
|
function findDOMNode(el) {
|
|
70
52
|
const node = typeof el === 'function' ? el() : el;
|
|
@@ -73,24 +55,17 @@ function findDOMNode(el) {
|
|
|
73
55
|
} else if (node instanceof Element || node === window || node && typeof node.nodeType !== 'undefined') {
|
|
74
56
|
return node;
|
|
75
57
|
} else if (node) {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
58
|
+
const reactNode = node;
|
|
59
|
+
if (isReactNodeWithRef(reactNode)) {
|
|
60
|
+
const refElement = isRefObject(reactNode.ref) ? reactNode.ref.current : reactNode.ref;
|
|
79
61
|
if (!(refElement instanceof HTMLElement)) {
|
|
80
62
|
return findDOMNode(refElement);
|
|
81
63
|
}
|
|
82
64
|
return refElement;
|
|
83
|
-
} else
|
|
84
|
-
|
|
85
|
-
return
|
|
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);
|
|
65
|
+
} else {
|
|
66
|
+
const elName = reactNode.constructor.componentId ? reactNode.constructor.componentId : reactNode.constructor.name;
|
|
67
|
+
return _reactDom.default.findDOMNode(node);
|
|
92
68
|
}
|
|
93
|
-
return void 0;
|
|
94
69
|
}
|
|
95
70
|
return void 0;
|
|
96
71
|
}
|
package/lib/findFocusable.js
CHANGED
|
@@ -87,17 +87,16 @@ function findFocusable(el, filter, shouldSearchRootNode) {
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
function hidden(element) {
|
|
90
|
-
const cs = (0, _.
|
|
91
|
-
return
|
|
90
|
+
const cs = (0, _.getComputedStyle)(element);
|
|
91
|
+
return cs.display === 'none';
|
|
92
92
|
}
|
|
93
93
|
function positioned(element) {
|
|
94
|
-
var _style$position,
|
|
94
|
+
var _style$position, _getComputedStyle$get;
|
|
95
95
|
const POS = ['fixed', 'absolute'];
|
|
96
96
|
if (POS.includes((_style$position = element.style.position) === null || _style$position === void 0 ? void 0 : _style$position.toLowerCase())) {
|
|
97
97
|
return true;
|
|
98
98
|
}
|
|
99
|
-
|
|
100
|
-
if (position && POS.includes(position)) {
|
|
99
|
+
if (POS.includes((_getComputedStyle$get = (0, _.getComputedStyle)(element).getPropertyValue('position')) === null || _getComputedStyle$get === void 0 ? void 0 : _getComputedStyle$get.toLowerCase())) {
|
|
101
100
|
return true;
|
|
102
101
|
}
|
|
103
102
|
return false;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
exports.
|
|
7
|
+
exports.getComputedStyle = getComputedStyle;
|
|
8
8
|
var _findDOMNode = require("./findDOMNode");
|
|
9
9
|
var _ownerWindow = require("./ownerWindow");
|
|
10
10
|
var _canUseDOM = require("./canUseDOM");
|
|
@@ -39,25 +39,21 @@ var _canUseDOM = require("./canUseDOM");
|
|
|
39
39
|
*
|
|
40
40
|
* Get the associated CSS properties and values for a
|
|
41
41
|
* specified element
|
|
42
|
-
* @module
|
|
42
|
+
* @module getComputedStyle
|
|
43
43
|
*
|
|
44
44
|
* @param { Node | Window | React.ReactElement | React.Component | function } el - component or DOM node
|
|
45
45
|
* @param { string | null | undefined } pseudoElt - A string specifying the pseudo-element to match. Omitted (or null ) for real elements.
|
|
46
|
-
* @returns {
|
|
46
|
+
* @returns { Object } object containing css properties and values for the element
|
|
47
47
|
*/
|
|
48
|
-
function
|
|
49
|
-
let style;
|
|
48
|
+
function getComputedStyle(el, pseudoElt) {
|
|
49
|
+
let style = {};
|
|
50
50
|
if (_canUseDOM.canUseDOM) {
|
|
51
51
|
const node = el && (0, _findDOMNode.findDOMNode)(el);
|
|
52
52
|
if (node) {
|
|
53
53
|
const window = (0, _ownerWindow.ownerWindow)(el);
|
|
54
|
-
|
|
55
|
-
style = window ? window.getComputedStyle(node, pseudoElt) : void 0;
|
|
56
|
-
} catch {
|
|
57
|
-
style = void 0;
|
|
58
|
-
}
|
|
54
|
+
style = window ? window.getComputedStyle(node, pseudoElt) : {};
|
|
59
55
|
}
|
|
60
56
|
}
|
|
61
57
|
return style;
|
|
62
58
|
}
|
|
63
|
-
var _default = exports.default =
|
|
59
|
+
var _default = exports.default = getComputedStyle;
|
package/lib/getFontSize.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
exports.getFontSize = getFontSize;
|
|
8
8
|
var _canUseDOM = require("./canUseDOM");
|
|
9
9
|
var _ownerDocument2 = require("./ownerDocument");
|
|
10
|
-
var
|
|
10
|
+
var _getComputedStyle = require("./getComputedStyle");
|
|
11
11
|
/*
|
|
12
12
|
* The MIT License (MIT)
|
|
13
13
|
*
|
|
@@ -58,7 +58,7 @@ function getFontSize(el, ignoreCache = false) {
|
|
|
58
58
|
if (!ignoreCache && cachedValue) {
|
|
59
59
|
return cachedValue;
|
|
60
60
|
}
|
|
61
|
-
const fontSize = parseInt((0,
|
|
61
|
+
const fontSize = parseInt((0, _getComputedStyle.getComputedStyle)(container).getPropertyValue('font-size'));
|
|
62
62
|
|
|
63
63
|
// cache the computed font size so that we don't have to compute it again
|
|
64
64
|
COMPUTED_CACHE.set(container, fontSize);
|
package/lib/getOffsetParents.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
exports.getOffsetParents = getOffsetParents;
|
|
8
8
|
var _findDOMNode = require("./findDOMNode");
|
|
9
9
|
var _canUseDOM = require("./canUseDOM");
|
|
10
|
-
var
|
|
10
|
+
var _getComputedStyle = require("./getComputedStyle");
|
|
11
11
|
var _ownerDocument = require("./ownerDocument");
|
|
12
12
|
/*
|
|
13
13
|
* The MIT License (MIT)
|
|
@@ -55,7 +55,7 @@ function getOffsetParents(el) {
|
|
|
55
55
|
if (node) {
|
|
56
56
|
let parent = node;
|
|
57
57
|
while ((parent = parent.parentNode) && parent && parent.nodeType === 1 && parent.tagName !== 'BODY') {
|
|
58
|
-
const style = (0,
|
|
58
|
+
const style = (0, _getComputedStyle.getComputedStyle)(parent);
|
|
59
59
|
const transform = style.getPropertyValue('-webkit-transform') || style.getPropertyValue('-moz-transform') || style.getPropertyValue('-ms-transform') || style.getPropertyValue('-o-transform') || style.getPropertyValue('transform') || 'none';
|
|
60
60
|
// initial value of transform can be 'none' or a matrix equivalent
|
|
61
61
|
const transformDefault = transform === 'none' || transform === 'matrix(1, 0, 0, 1, 0, 0)' ? true : false;
|
package/lib/getScrollParents.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
exports.getScrollParents = getScrollParents;
|
|
8
8
|
var _findDOMNode = require("./findDOMNode");
|
|
9
9
|
var _canUseDOM = require("./canUseDOM");
|
|
10
|
-
var
|
|
10
|
+
var _getComputedStyle = require("./getComputedStyle");
|
|
11
11
|
/*
|
|
12
12
|
* The MIT License (MIT)
|
|
13
13
|
*
|
|
@@ -55,8 +55,8 @@ function getScrollParents(el) {
|
|
|
55
55
|
if (node) {
|
|
56
56
|
// In firefox if the element is inside an iframe with display: none; window.getComputedStyle() will return null;
|
|
57
57
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=548397
|
|
58
|
-
const computedStyle = (0,
|
|
59
|
-
const position = computedStyle
|
|
58
|
+
const computedStyle = (0, _getComputedStyle.getComputedStyle)(node) || {};
|
|
59
|
+
const position = computedStyle.position;
|
|
60
60
|
if (position === 'fixed') {
|
|
61
61
|
return [node.ownerDocument];
|
|
62
62
|
}
|
|
@@ -64,7 +64,7 @@ function getScrollParents(el) {
|
|
|
64
64
|
while (parent && parent.nodeType === 1 && (parent = parent.parentNode)) {
|
|
65
65
|
let style;
|
|
66
66
|
try {
|
|
67
|
-
style = (0,
|
|
67
|
+
style = (0, _getComputedStyle.getComputedStyle)(parent);
|
|
68
68
|
} catch (err) {} // eslint-disable-line no-empty
|
|
69
69
|
|
|
70
70
|
if (typeof style === 'undefined' || style === null) {
|
package/lib/index.js
CHANGED
|
@@ -69,16 +69,16 @@ Object.defineProperty(exports, "getBoundingClientRect", {
|
|
|
69
69
|
return _getBoundingClientRect.getBoundingClientRect;
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
-
Object.defineProperty(exports, "
|
|
72
|
+
Object.defineProperty(exports, "getClassList", {
|
|
73
73
|
enumerable: true,
|
|
74
74
|
get: function () {
|
|
75
|
-
return
|
|
75
|
+
return _getClassList.getClassList;
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
-
Object.defineProperty(exports, "
|
|
78
|
+
Object.defineProperty(exports, "getComputedStyle", {
|
|
79
79
|
enumerable: true,
|
|
80
80
|
get: function () {
|
|
81
|
-
return
|
|
81
|
+
return _getComputedStyle.getComputedStyle;
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
Object.defineProperty(exports, "getFontSize", {
|
|
@@ -159,7 +159,7 @@ var _findTabbable = require("./findTabbable");
|
|
|
159
159
|
var _getActiveElement = require("./getActiveElement");
|
|
160
160
|
var _getBoundingClientRect = require("./getBoundingClientRect");
|
|
161
161
|
var _getClassList = require("./getClassList");
|
|
162
|
-
var
|
|
162
|
+
var _getComputedStyle = require("./getComputedStyle");
|
|
163
163
|
var _getFontSize = require("./getFontSize");
|
|
164
164
|
var _getOffsetParents = require("./getOffsetParents");
|
|
165
165
|
var _getScrollParents = require("./getScrollParents");
|
package/lib/isVisible.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.isVisible = isVisible;
|
|
8
8
|
var _findDOMNode = require("./findDOMNode");
|
|
9
|
-
var
|
|
9
|
+
var _getComputedStyle = require("./getComputedStyle");
|
|
10
10
|
/*
|
|
11
11
|
* The MIT License (MIT)
|
|
12
12
|
*
|
|
@@ -56,18 +56,18 @@ function isVisible(el, recursive = true) {
|
|
|
56
56
|
if (node.nodeType === 3) {
|
|
57
57
|
return isVisible(parent, recursive);
|
|
58
58
|
}
|
|
59
|
-
const style = node ? (0,
|
|
59
|
+
const style = node ? (0, _getComputedStyle.getComputedStyle)(node) : {};
|
|
60
60
|
// physically and visually hidden
|
|
61
|
-
if (
|
|
61
|
+
if (style.display === 'none') {
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
64
|
// visually hidden
|
|
65
|
-
if (
|
|
65
|
+
if (style.visibility === 'hidden' || style.opacity === '0') {
|
|
66
66
|
return false;
|
|
67
67
|
}
|
|
68
68
|
// hidden by clipping
|
|
69
|
-
if (
|
|
70
|
-
const rect = style
|
|
69
|
+
if (style.overflow === 'hidden' && style.position === 'absolute' && style.clip !== 'auto') {
|
|
70
|
+
const rect = style.clip.substring(5).slice(0, -1).split(', ');
|
|
71
71
|
let zeros = true;
|
|
72
72
|
rect.forEach(a => {
|
|
73
73
|
if (a !== '0px') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-dom-utils",
|
|
3
|
-
"version": "10.26.
|
|
3
|
+
"version": "10.26.2",
|
|
4
4
|
"description": "A DOM utility library made by Instructure Inc.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@instructure/ui-babel-preset": "10.26.
|
|
25
|
+
"@instructure/ui-babel-preset": "10.26.2",
|
|
26
26
|
"@testing-library/jest-dom": "^6.6.3",
|
|
27
|
-
"@testing-library/react": "
|
|
27
|
+
"@testing-library/react": "^16.0.1",
|
|
28
28
|
"vitest": "^3.2.2"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/runtime": "^7.27.6",
|
|
32
|
-
"@instructure/console": "10.26.
|
|
33
|
-
"@instructure/shared-types": "10.26.
|
|
32
|
+
"@instructure/console": "10.26.2",
|
|
33
|
+
"@instructure/shared-types": "10.26.2"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"react": ">=
|
|
37
|
-
"react-dom": ">=
|
|
36
|
+
"react": ">=16.14 <=18",
|
|
37
|
+
"react-dom": ">=16.14 <=18"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|