@instructure/ui-dom-utils 10.26.1-snapshot-1 → 10.26.1-snapshot-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 +23 -2
- package/es/findDOMNode.js +41 -15
- package/es/findFocusable.js +6 -5
- package/es/{getComputedStyle.js → getCSSStyleDeclaration.js} +11 -7
- 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 +40 -15
- package/lib/findFocusable.js +5 -4
- package/lib/{getComputedStyle.js → getCSSStyleDeclaration.js} +11 -7
- 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 +48 -34
- package/src/findFocusable.ts +10 -11
- package/src/{getComputedStyle.ts → getCSSStyleDeclaration.ts} +14 -8
- 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 +10 -8
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/findDOMNode.d.ts +11 -3
- package/types/findDOMNode.d.ts.map +1 -1
- package/types/findFocusable.d.ts.map +1 -1
- package/types/{getComputedStyle.d.ts → getCSSStyleDeclaration.d.ts} +6 -6
- package/types/getCSSStyleDeclaration.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/getComputedStyle.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,30 @@
|
|
|
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.1-snapshot-
|
|
6
|
+
## [10.26.1-snapshot-2](https://github.com/instructure/instructure-ui/compare/v10.26.0...v10.26.1-snapshot-2) (2025-10-06)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **many:** instUI v11 release ([36f5438](https://github.com/instructure/instructure-ui/commit/36f54382669186227ba24798bbf7201ef2f5cd4c))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* **many:** InstUI v11 contains the following breaking changes:
|
|
17
|
+
- React 16 and 17 are no longer supported
|
|
18
|
+
- remove `PropTypes` from all packages
|
|
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`
|
|
9
30
|
|
|
10
31
|
|
|
11
32
|
|
package/es/findDOMNode.js
CHANGED
|
@@ -23,22 +23,41 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import ReactDOM from 'react-dom';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Return the ref of an element in a way that is compatible both with
|
|
29
|
+
* React 18 (element.ref) and React 19+ (element.props.ref)
|
|
30
|
+
*/
|
|
31
|
+
function getElementRef(elem) {
|
|
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
|
+
|
|
32
43
|
/**
|
|
33
44
|
* ---
|
|
34
45
|
* category: utilities/DOM
|
|
35
46
|
* ---
|
|
36
47
|
*
|
|
37
|
-
*
|
|
48
|
+
* Returns the underlying DOM node. It looks the following places:
|
|
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
|
|
38
57
|
* @module findDOMNode
|
|
39
58
|
*
|
|
40
|
-
* @param
|
|
41
|
-
* @returns
|
|
59
|
+
* @param el - component, DOM node, or function returning a DOM node
|
|
60
|
+
* @returns The native DOM node of this element or `undefined`
|
|
42
61
|
*/
|
|
43
62
|
function findDOMNode(el) {
|
|
44
63
|
const node = typeof el === 'function' ? el() : el;
|
|
@@ -47,17 +66,24 @@ function findDOMNode(el) {
|
|
|
47
66
|
} else if (node instanceof Element || node === window || node && typeof node.nodeType !== 'undefined') {
|
|
48
67
|
return node;
|
|
49
68
|
} else if (node) {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
69
|
+
const ref = getElementRef(node);
|
|
70
|
+
const refElement = ref !== null && ref !== void 0 && ref.current ? ref.current : ref;
|
|
71
|
+
if (refElement) {
|
|
53
72
|
if (!(refElement instanceof HTMLElement)) {
|
|
54
73
|
return findDOMNode(refElement);
|
|
55
74
|
}
|
|
56
75
|
return refElement;
|
|
57
|
-
} else {
|
|
58
|
-
|
|
59
|
-
return
|
|
76
|
+
} else if (refElement === null) {
|
|
77
|
+
// weird, but changing it would be a breaking change
|
|
78
|
+
return void 0;
|
|
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);
|
|
60
85
|
}
|
|
86
|
+
return void 0;
|
|
61
87
|
}
|
|
62
88
|
return void 0;
|
|
63
89
|
}
|
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 { getCSSStyleDeclaration, 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,16 +79,17 @@ function findFocusable(el, filter, shouldSearchRootNode) {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
function hidden(element) {
|
|
82
|
-
const cs =
|
|
83
|
-
return cs.display === 'none';
|
|
82
|
+
const cs = getCSSStyleDeclaration(element);
|
|
83
|
+
return (cs === null || cs === void 0 ? void 0 : cs.display) === 'none';
|
|
84
84
|
}
|
|
85
85
|
function positioned(element) {
|
|
86
|
-
var _style$position,
|
|
86
|
+
var _style$position, _getCSSStyleDeclarati, _getCSSStyleDeclarati2;
|
|
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
|
-
|
|
91
|
+
const position = (_getCSSStyleDeclarati = getCSSStyleDeclaration(element)) === null || _getCSSStyleDeclarati === void 0 ? void 0 : (_getCSSStyleDeclarati2 = _getCSSStyleDeclarati.getPropertyValue('position')) === null || _getCSSStyleDeclarati2 === void 0 ? void 0 : _getCSSStyleDeclarati2.toLowerCase();
|
|
92
|
+
if (position && POS.includes(position)) {
|
|
92
93
|
return true;
|
|
93
94
|
}
|
|
94
95
|
return false;
|
|
@@ -32,22 +32,26 @@ 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 getCSSStyleDeclaration
|
|
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 { CSSStyleDeclaration | undefined } The style declaration containing css properties and values for the element or undefined
|
|
40
40
|
*/
|
|
41
|
-
function
|
|
42
|
-
let style
|
|
41
|
+
function getCSSStyleDeclaration(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
|
-
|
|
47
|
+
try {
|
|
48
|
+
style = window ? window.getComputedStyle(node, pseudoElt) : void 0;
|
|
49
|
+
} catch {
|
|
50
|
+
style = void 0;
|
|
51
|
+
}
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
return style;
|
|
51
55
|
}
|
|
52
|
-
export default
|
|
53
|
-
export {
|
|
56
|
+
export default getCSSStyleDeclaration;
|
|
57
|
+
export { getCSSStyleDeclaration };
|
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 { getCSSStyleDeclaration } from './getCSSStyleDeclaration';
|
|
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(getCSSStyleDeclaration(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 { getCSSStyleDeclaration } from './getCSSStyleDeclaration';
|
|
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 = getCSSStyleDeclaration(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 { getCSSStyleDeclaration } from './getCSSStyleDeclaration';
|
|
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.position;
|
|
51
|
+
const computedStyle = getCSSStyleDeclaration(node);
|
|
52
|
+
const position = computedStyle === null || computedStyle === void 0 ? void 0 : 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 = getCSSStyleDeclaration(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 { getCSSStyleDeclaration } from './getCSSStyleDeclaration';
|
|
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 { getCSSStyleDeclaration } from './getCSSStyleDeclaration';
|
|
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 ? getCSSStyleDeclaration(node) : {};
|
|
53
53
|
// physically and visually hidden
|
|
54
|
-
if (style.display === 'none') {
|
|
54
|
+
if ((style === null || style === void 0 ? void 0 : style.display) === 'none') {
|
|
55
55
|
return false;
|
|
56
56
|
}
|
|
57
57
|
// visually hidden
|
|
58
|
-
if (style.visibility === 'hidden' || style.opacity === '0') {
|
|
58
|
+
if ((style === null || style === void 0 ? void 0 : style.visibility) === 'hidden' || (style === null || style === void 0 ? void 0 : style.opacity) === '0') {
|
|
59
59
|
return false;
|
|
60
60
|
}
|
|
61
61
|
// hidden by clipping
|
|
62
|
-
if (style.overflow === 'hidden' && style.position === 'absolute' && style.clip !== 'auto') {
|
|
63
|
-
const rect = style.clip.substring(5).slice(0, -1).split(', ');
|
|
62
|
+
if ((style === null || style === void 0 ? void 0 : style.overflow) === 'hidden' && (style === null || style === void 0 ? void 0 : style.position) === 'absolute' && (style === null || style === void 0 ? void 0 : style.clip) !== 'auto') {
|
|
63
|
+
const rect = style === null || style === void 0 ? void 0 : 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,22 +31,40 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
|
31
31
|
* SOFTWARE.
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
+
|
|
40
50
|
/**
|
|
41
51
|
* ---
|
|
42
52
|
* category: utilities/DOM
|
|
43
53
|
* ---
|
|
44
54
|
*
|
|
45
|
-
*
|
|
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
|
|
46
64
|
* @module findDOMNode
|
|
47
65
|
*
|
|
48
|
-
* @param
|
|
49
|
-
* @returns
|
|
66
|
+
* @param el - component, DOM node, or function returning a DOM node
|
|
67
|
+
* @returns The native DOM node of this element or `undefined`
|
|
50
68
|
*/
|
|
51
69
|
function findDOMNode(el) {
|
|
52
70
|
const node = typeof el === 'function' ? el() : el;
|
|
@@ -55,17 +73,24 @@ function findDOMNode(el) {
|
|
|
55
73
|
} else if (node instanceof Element || node === window || node && typeof node.nodeType !== 'undefined') {
|
|
56
74
|
return node;
|
|
57
75
|
} else if (node) {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
76
|
+
const ref = getElementRef(node);
|
|
77
|
+
const refElement = ref !== null && ref !== void 0 && ref.current ? ref.current : ref;
|
|
78
|
+
if (refElement) {
|
|
61
79
|
if (!(refElement instanceof HTMLElement)) {
|
|
62
80
|
return findDOMNode(refElement);
|
|
63
81
|
}
|
|
64
82
|
return refElement;
|
|
65
|
-
} else {
|
|
66
|
-
|
|
67
|
-
return
|
|
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);
|
|
68
92
|
}
|
|
93
|
+
return void 0;
|
|
69
94
|
}
|
|
70
95
|
return void 0;
|
|
71
96
|
}
|
package/lib/findFocusable.js
CHANGED
|
@@ -87,16 +87,17 @@ function findFocusable(el, filter, shouldSearchRootNode) {
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
function hidden(element) {
|
|
90
|
-
const cs = (0, _.
|
|
91
|
-
return cs.display === 'none';
|
|
90
|
+
const cs = (0, _.getCSSStyleDeclaration)(element);
|
|
91
|
+
return (cs === null || cs === void 0 ? void 0 : cs.display) === 'none';
|
|
92
92
|
}
|
|
93
93
|
function positioned(element) {
|
|
94
|
-
var _style$position,
|
|
94
|
+
var _style$position, _getCSSStyleDeclarati, _getCSSStyleDeclarati2;
|
|
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
|
-
|
|
99
|
+
const position = (_getCSSStyleDeclarati = (0, _.getCSSStyleDeclaration)(element)) === null || _getCSSStyleDeclarati === void 0 ? void 0 : (_getCSSStyleDeclarati2 = _getCSSStyleDeclarati.getPropertyValue('position')) === null || _getCSSStyleDeclarati2 === void 0 ? void 0 : _getCSSStyleDeclarati2.toLowerCase();
|
|
100
|
+
if (position && POS.includes(position)) {
|
|
100
101
|
return true;
|
|
101
102
|
}
|
|
102
103
|
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.getCSSStyleDeclaration = getCSSStyleDeclaration;
|
|
8
8
|
var _findDOMNode = require("./findDOMNode");
|
|
9
9
|
var _ownerWindow = require("./ownerWindow");
|
|
10
10
|
var _canUseDOM = require("./canUseDOM");
|
|
@@ -39,21 +39,25 @@ 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 getCSSStyleDeclaration
|
|
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 { CSSStyleDeclaration | undefined } The style declaration containing css properties and values for the element or undefined
|
|
47
47
|
*/
|
|
48
|
-
function
|
|
49
|
-
let style
|
|
48
|
+
function getCSSStyleDeclaration(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
|
-
|
|
54
|
+
try {
|
|
55
|
+
style = window ? window.getComputedStyle(node, pseudoElt) : void 0;
|
|
56
|
+
} catch {
|
|
57
|
+
style = void 0;
|
|
58
|
+
}
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
return style;
|
|
58
62
|
}
|
|
59
|
-
var _default = exports.default =
|
|
63
|
+
var _default = exports.default = getCSSStyleDeclaration;
|
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 _getCSSStyleDeclaration = require("./getCSSStyleDeclaration");
|
|
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, _getCSSStyleDeclaration.getCSSStyleDeclaration)(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 _getCSSStyleDeclaration = require("./getCSSStyleDeclaration");
|
|
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, _getCSSStyleDeclaration.getCSSStyleDeclaration)(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 _getCSSStyleDeclaration = require("./getCSSStyleDeclaration");
|
|
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.position;
|
|
58
|
+
const computedStyle = (0, _getCSSStyleDeclaration.getCSSStyleDeclaration)(node);
|
|
59
|
+
const position = computedStyle === null || computedStyle === void 0 ? void 0 : 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, _getCSSStyleDeclaration.getCSSStyleDeclaration)(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, "getCSSStyleDeclaration", {
|
|
73
73
|
enumerable: true,
|
|
74
74
|
get: function () {
|
|
75
|
-
return
|
|
75
|
+
return _getCSSStyleDeclaration.getCSSStyleDeclaration;
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
-
Object.defineProperty(exports, "
|
|
78
|
+
Object.defineProperty(exports, "getClassList", {
|
|
79
79
|
enumerable: true,
|
|
80
80
|
get: function () {
|
|
81
|
-
return
|
|
81
|
+
return _getClassList.getClassList;
|
|
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 _getCSSStyleDeclaration = require("./getCSSStyleDeclaration");
|
|
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 _getCSSStyleDeclaration = require("./getCSSStyleDeclaration");
|
|
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, _getCSSStyleDeclaration.getCSSStyleDeclaration)(node) : {};
|
|
60
60
|
// physically and visually hidden
|
|
61
|
-
if (style.display === 'none') {
|
|
61
|
+
if ((style === null || style === void 0 ? void 0 : style.display) === 'none') {
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
64
|
// visually hidden
|
|
65
|
-
if (style.visibility === 'hidden' || style.opacity === '0') {
|
|
65
|
+
if ((style === null || style === void 0 ? void 0 : style.visibility) === 'hidden' || (style === null || style === void 0 ? void 0 : style.opacity) === '0') {
|
|
66
66
|
return false;
|
|
67
67
|
}
|
|
68
68
|
// hidden by clipping
|
|
69
|
-
if (style.overflow === 'hidden' && style.position === 'absolute' && style.clip !== 'auto') {
|
|
70
|
-
const rect = style.clip.substring(5).slice(0, -1).split(', ');
|
|
69
|
+
if ((style === null || style === void 0 ? void 0 : style.overflow) === 'hidden' && (style === null || style === void 0 ? void 0 : style.position) === 'absolute' && (style === null || style === void 0 ? void 0 : style.clip) !== 'auto') {
|
|
70
|
+
const rect = style === null || style === void 0 ? void 0 : 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.1-snapshot-
|
|
3
|
+
"version": "10.26.1-snapshot-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.1-snapshot-
|
|
25
|
+
"@instructure/ui-babel-preset": "10.26.1-snapshot-2",
|
|
26
26
|
"@testing-library/jest-dom": "^6.6.3",
|
|
27
|
-
"@testing-library/react": "
|
|
27
|
+
"@testing-library/react": "15.0.7",
|
|
28
28
|
"vitest": "^3.2.2"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/runtime": "^7.27.6",
|
|
32
|
-
"@instructure/console": "10.26.1-snapshot-
|
|
33
|
-
"@instructure/shared-types": "10.26.1-snapshot-
|
|
32
|
+
"@instructure/console": "10.26.1-snapshot-2",
|
|
33
|
+
"@instructure/shared-types": "10.26.1-snapshot-2"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"react": ">=
|
|
37
|
-
"react-dom": ">=
|
|
36
|
+
"react": ">=18 <=19",
|
|
37
|
+
"react-dom": ">=18 <=19"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|