@instructure/ui-a11y-utils 10.13.0 → 10.13.1-pr-snapshot-1741357986437

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
+ ## [10.13.1-pr-snapshot-1741357986437](https://github.com/instructure/instructure-ui/compare/v10.13.0...v10.13.1-pr-snapshot-1741357986437) (2025-03-07)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-a11y-utils
9
+
10
+
11
+
12
+
13
+
6
14
  # [10.13.0](https://github.com/instructure/instructure-ui/compare/v10.12.0...v10.13.0) (2025-03-06)
7
15
 
8
16
 
@@ -6,10 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = exports.FocusRegion = void 0;
8
8
  var _keycode = _interopRequireDefault(require("keycode"));
9
- var _contains = require("@instructure/ui-dom-utils/lib/contains.js");
10
- var _addEventListener = require("@instructure/ui-dom-utils/lib/addEventListener.js");
11
- var _ownerDocument2 = require("@instructure/ui-dom-utils/lib/ownerDocument.js");
12
- var _findTabbable = require("@instructure/ui-dom-utils/lib/findTabbable.js");
9
+ var _uiDomUtils = require("@instructure/ui-dom-utils");
13
10
  var _uid = require("@instructure/uid");
14
11
  var _console = require("@instructure/console");
15
12
  var _ScreenReaderFocusRegion = require("./ScreenReaderFocusRegion");
@@ -59,12 +56,12 @@ class FocusRegion {
59
56
  this.handleDocumentClick = event => {
60
57
  if (this._options.shouldCloseOnDocumentClick && event.button === 0 && event.detail > 0 &&
61
58
  // if event.detail is 0 then this is a keyboard and not a mouse press
62
- this._documentMouseDownTarget !== null && !(0, _contains.contains)(this._contextElement, this._documentMouseDownTarget)) {
59
+ this._documentMouseDownTarget !== null && !(0, _uiDomUtils.contains)(this._contextElement, this._documentMouseDownTarget)) {
63
60
  this.handleDismiss(event, true);
64
61
  }
65
62
  };
66
63
  this.handleFrameClick = (event, frame) => {
67
- if (!(0, _contains.contains)(this._contextElement, frame)) {
64
+ if (!(0, _uiDomUtils.contains)(this._contextElement, frame)) {
68
65
  // dismiss if frame is not within the region
69
66
  this.handleDismiss(event, true);
70
67
  }
@@ -75,7 +72,7 @@ class FocusRegion {
75
72
  // If a dialog contains an <input type="file"/> element and the user opens the file picker and closes it with the
76
73
  // escape key then Firefox passes through that event which could close the parent dialog. This code prevents that
77
74
  // from happening (listening for a `cancel` event doesn't seem to work in firefox)
78
- const activeElement = (_ownerDocument = (0, _ownerDocument2.ownerDocument)(this._contextElement)) === null || _ownerDocument === void 0 ? void 0 : _ownerDocument.activeElement;
75
+ const activeElement = (_ownerDocument = (0, _uiDomUtils.ownerDocument)(this._contextElement)) === null || _ownerDocument === void 0 ? void 0 : _ownerDocument.activeElement;
79
76
  const fileInputFocused = (activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'INPUT' && activeElement.type === 'file';
80
77
  if (fileInputFocused) {
81
78
  ;
@@ -121,21 +118,21 @@ class FocusRegion {
121
118
  return this._active;
122
119
  }
123
120
  get keyboardFocusable() {
124
- return ((0, _findTabbable.findTabbable)(this._contextElement) || []).length > 0;
121
+ return ((0, _uiDomUtils.findTabbable)(this._contextElement) || []).length > 0;
125
122
  }
126
123
  activate() {
127
124
  if (!this._active) {
128
- const doc = (0, _ownerDocument2.ownerDocument)(this._contextElement);
125
+ const doc = (0, _uiDomUtils.ownerDocument)(this._contextElement);
129
126
  this._keyboardFocusRegion.activate();
130
127
  this._screenReaderFocusRegion.activate();
131
128
  if (this._options.shouldCloseOnDocumentClick) {
132
- this._listeners.push((0, _addEventListener.addEventListener)(doc, 'mousedown', this.captureDocumentMousedown));
133
- this._listeners.push((0, _addEventListener.addEventListener)(doc, 'click', this.handleDocumentClick));
129
+ this._listeners.push((0, _uiDomUtils.addEventListener)(doc, 'mousedown', this.captureDocumentMousedown));
130
+ this._listeners.push((0, _uiDomUtils.addEventListener)(doc, 'click', this.handleDocumentClick));
134
131
  Array.from(doc.getElementsByTagName('iframe')).forEach(el => {
135
132
  // listen for mouseup events on any iframes in the document
136
133
  const frameDoc = el.contentDocument;
137
134
  if (frameDoc) {
138
- this._listeners.push((0, _addEventListener.addEventListener)(frameDoc, 'mouseup', event => {
135
+ this._listeners.push((0, _uiDomUtils.addEventListener)(frameDoc, 'mouseup', event => {
139
136
  this.handleFrameClick(event, el);
140
137
  }));
141
138
  }
@@ -146,7 +143,7 @@ class FocusRegion {
146
143
  //so a Modal with a Tooltip will not get closed when closing the Tooltip with Escape
147
144
  const useCapture = this._options.isTooltip;
148
145
  if (this._options.shouldCloseOnEscape) {
149
- this._listeners.push((0, _addEventListener.addEventListener)(doc, 'keyup', this.handleKeyUp, useCapture));
146
+ this._listeners.push((0, _uiDomUtils.addEventListener)(doc, 'keyup', this.handleKeyUp, useCapture));
150
147
  }
151
148
  this._active = true;
152
149
  }
@@ -5,15 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = exports.KeyboardFocusRegion = void 0;
8
- var _findDOMNode = require("@instructure/ui-dom-utils/lib/findDOMNode.js");
9
- var _findTabbable = require("@instructure/ui-dom-utils/lib/findTabbable.js");
10
- var _findFocusable = require("@instructure/ui-dom-utils/lib/findFocusable.js");
11
- var _ownerWindow = require("@instructure/ui-dom-utils/lib/ownerWindow.js");
12
- var _getActiveElement = require("@instructure/ui-dom-utils/lib/getActiveElement.js");
13
- var _addEventListener = require("@instructure/ui-dom-utils/lib/addEventListener.js");
14
- var _ownerDocument = require("@instructure/ui-dom-utils/lib/ownerDocument.js");
15
- var _containsActiveElement = require("@instructure/ui-dom-utils/lib/containsActiveElement.js");
16
- var _requestAnimationFrame = require("@instructure/ui-dom-utils/lib/requestAnimationFrame.js");
8
+ var _uiDomUtils = require("@instructure/ui-dom-utils");
17
9
  var _console = require("@instructure/console");
18
10
  var _keycode = _interopRequireDefault(require("keycode"));
19
11
  var _scopeTab = require("./scopeTab");
@@ -77,8 +69,8 @@ class KeyboardFocusRegion {
77
69
  // the element outside of a setTimeout. Side-effect of this implementation
78
70
  // is that the document.body gets focus, and then we focus our element right
79
71
  // after, seems fine.
80
- this._raf.push((0, _requestAnimationFrame.requestAnimationFrame)(() => {
81
- if ((0, _containsActiveElement.containsActiveElement)(this._contextElement)) {
72
+ this._raf.push((0, _uiDomUtils.requestAnimationFrame)(() => {
73
+ if ((0, _uiDomUtils.containsActiveElement)(this._contextElement)) {
82
74
  return;
83
75
  }
84
76
  this.focusDefaultElement();
@@ -97,28 +89,28 @@ class KeyboardFocusRegion {
97
89
  (_this$_options$onBlur2 = (_this$_options2 = this._options).onBlur) === null || _this$_options$onBlur2 === void 0 ? void 0 : _this$_options$onBlur2.call(_this$_options2, event);
98
90
  }
99
91
  };
100
- this._contextElement = (0, _findDOMNode.findDOMNode)(element);
92
+ this._contextElement = (0, _uiDomUtils.findDOMNode)(element);
101
93
  this._options = options || {
102
94
  shouldContainFocus: true,
103
95
  shouldReturnFocus: true,
104
96
  defaultFocusElement: null
105
97
  };
106
98
  if (this._options.shouldReturnFocus) {
107
- this._focusLaterElement = (0, _getActiveElement.getActiveElement)(this.doc);
99
+ this._focusLaterElement = (0, _uiDomUtils.getActiveElement)(this.doc);
108
100
  }
109
101
  }
110
102
  get focused() {
111
- return (0, _containsActiveElement.containsActiveElement)(this._contextElement);
103
+ return (0, _uiDomUtils.containsActiveElement)(this._contextElement);
112
104
  }
113
105
  get shouldContainFocus() {
114
106
  const shouldContainFocus = this._options.shouldContainFocus;
115
107
  return shouldContainFocus === true || Array.isArray(shouldContainFocus) && shouldContainFocus.includes('keyboard');
116
108
  }
117
109
  get focusable() {
118
- return (0, _findFocusable.findFocusable)(this._contextElement, () => true, true) || [];
110
+ return (0, _uiDomUtils.findFocusable)(this._contextElement, () => true, true) || [];
119
111
  }
120
112
  get tabbable() {
121
- return (0, _findTabbable.findTabbable)(this._contextElement) || [];
113
+ return (0, _uiDomUtils.findTabbable)(this._contextElement) || [];
122
114
  }
123
115
  get firstTabbable() {
124
116
  return this.tabbable[0];
@@ -133,14 +125,14 @@ class KeyboardFocusRegion {
133
125
  return this.focusable.pop();
134
126
  }
135
127
  get doc() {
136
- return (0, _ownerDocument.ownerDocument)(this._contextElement);
128
+ return (0, _uiDomUtils.ownerDocument)(this._contextElement);
137
129
  }
138
130
  get win() {
139
- return (0, _ownerWindow.ownerWindow)(this._contextElement);
131
+ return (0, _uiDomUtils.ownerWindow)(this._contextElement);
140
132
  }
141
133
  get defaultFocusElement() {
142
134
  const defaultFocusElement = this._options.defaultFocusElement;
143
- const element = (0, _findDOMNode.findDOMNode)(typeof defaultFocusElement === 'function' ? defaultFocusElement() : defaultFocusElement);
135
+ const element = (0, _uiDomUtils.findDOMNode)(typeof defaultFocusElement === 'function' ? defaultFocusElement() : defaultFocusElement);
144
136
  if (element && this._contextElement && this._contextElement.contains(element)) {
145
137
  return element;
146
138
  }
@@ -153,7 +145,7 @@ class KeyboardFocusRegion {
153
145
  return null;
154
146
  }
155
147
  updateElement(element) {
156
- this._contextElement = (0, _findDOMNode.findDOMNode)(element);
148
+ this._contextElement = (0, _uiDomUtils.findDOMNode)(element);
157
149
  }
158
150
  focusDefaultElement() {
159
151
  if (this.defaultFocusElement) {
@@ -167,7 +159,7 @@ class KeyboardFocusRegion {
167
159
  } else {
168
160
  if (this.shouldContainFocus) {
169
161
  // Blur the active element to place focus on the document body
170
- (0, _getActiveElement.getActiveElement)(this.doc) && (0, _getActiveElement.getActiveElement)(this.doc).blur();
162
+ (0, _uiDomUtils.getActiveElement)(this.doc) && (0, _uiDomUtils.getActiveElement)(this.doc).blur();
171
163
  (0, _console.logError)(true, `
172
164
  [KeyboardFocusRegion] No \`defaultFocusElement\` was provided and
173
165
  \`shouldContainFocus\` was set to \`true\` or \`keyboard\`. Focus has
@@ -192,7 +184,7 @@ class KeyboardFocusRegion {
192
184
  if (!isHiddenOutside) {
193
185
  focusElement.focus();
194
186
  } else {
195
- this._raf.push((0, _requestAnimationFrame.requestAnimationFrame)(() => {
187
+ this._raf.push((0, _uiDomUtils.requestAnimationFrame)(() => {
196
188
  this.tryFocusOnPositionedElement(positionContainer, focusElement, tries - 1);
197
189
  }));
198
190
  }
@@ -201,7 +193,7 @@ class KeyboardFocusRegion {
201
193
  if (this.focused) {
202
194
  return;
203
195
  }
204
- this._raf.push((0, _requestAnimationFrame.requestAnimationFrame)(() => {
196
+ this._raf.push((0, _uiDomUtils.requestAnimationFrame)(() => {
205
197
  this.focusDefaultElement();
206
198
  }));
207
199
  }
@@ -225,14 +217,14 @@ class KeyboardFocusRegion {
225
217
  if (!this._active) {
226
218
  if (defaultFocusElement || shouldContainFocus) {
227
219
  if (shouldContainFocus) {
228
- this._listeners.push((0, _addEventListener.addEventListener)(this.doc, 'keydown', this.handleKeyDown));
220
+ this._listeners.push((0, _uiDomUtils.addEventListener)(this.doc, 'keydown', this.handleKeyDown));
229
221
  } else {
230
- this._listeners.push((0, _addEventListener.addEventListener)(this.firstTabbable || defaultFocusElement, 'keydown', this.handleFirstTabbableKeyDown));
231
- this._listeners.push((0, _addEventListener.addEventListener)(this.lastTabbable || defaultFocusElement, 'keydown', this.handleLastTabbableKeyDown));
222
+ this._listeners.push((0, _uiDomUtils.addEventListener)(this.firstTabbable || defaultFocusElement, 'keydown', this.handleFirstTabbableKeyDown));
223
+ this._listeners.push((0, _uiDomUtils.addEventListener)(this.lastTabbable || defaultFocusElement, 'keydown', this.handleLastTabbableKeyDown));
232
224
  }
233
- this._listeners.push((0, _addEventListener.addEventListener)(this.doc, 'click', this.handleClick, true));
234
- this._listeners.push((0, _addEventListener.addEventListener)(this.win, 'blur', this.handleWindowBlur, false));
235
- this._listeners.push((0, _addEventListener.addEventListener)(this.doc, 'focus', this.handleFocus, true));
225
+ this._listeners.push((0, _uiDomUtils.addEventListener)(this.doc, 'click', this.handleClick, true));
226
+ this._listeners.push((0, _uiDomUtils.addEventListener)(this.win, 'blur', this.handleWindowBlur, false));
227
+ this._listeners.push((0, _uiDomUtils.addEventListener)(this.doc, 'focus', this.handleFocus, true));
236
228
  this._active = true;
237
229
  }
238
230
  }
@@ -3,7 +3,7 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  var _react = _interopRequireDefault(require("react"));
5
5
  require("@testing-library/jest-dom");
6
- var _ScreenReaderContent2 = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
6
+ var _uiA11yContent = require("@instructure/ui-a11y-content");
7
7
  var _hasVisibleChildren = require("../hasVisibleChildren");
8
8
  var _ScreenReaderContent, _div;
9
9
  /*
@@ -31,7 +31,7 @@ var _ScreenReaderContent, _div;
31
31
  */
32
32
  describe('hasVisibleChildren', () => {
33
33
  it('should not count ScreenReaderContent as visible content', async () => {
34
- expect((0, _hasVisibleChildren.hasVisibleChildren)(_ScreenReaderContent || (_ScreenReaderContent = /*#__PURE__*/_react.default.createElement(_ScreenReaderContent2.ScreenReaderContent, null, "Foo")))).toBe(false);
34
+ expect((0, _hasVisibleChildren.hasVisibleChildren)(_ScreenReaderContent || (_ScreenReaderContent = /*#__PURE__*/_react.default.createElement(_uiA11yContent.ScreenReaderContent, null, "Foo")))).toBe(false);
35
35
  });
36
36
  it('should count everything else as visible', async () => {
37
37
  expect((0, _hasVisibleChildren.hasVisibleChildren)(_div || (_div = /*#__PURE__*/_react.default.createElement("div", null, "Foo")))).toBe(true);
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  exports.hasVisibleChildren = hasVisibleChildren;
9
9
  var _react = _interopRequireDefault(require("react"));
10
- var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
11
- var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
10
+ var _uiReactUtils = require("@instructure/ui-react-utils");
11
+ var _uiA11yContent = require("@instructure/ui-a11y-content");
12
12
  /*
13
13
  * The MIT License (MIT)
14
14
  *
@@ -36,7 +36,7 @@ var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReade
36
36
  function hasVisibleChildren(children) {
37
37
  let visible = false;
38
38
  _react.default.Children.forEach(children, child => {
39
- if (child && !(0, _matchComponentTypes.matchComponentTypes)(child, [_ScreenReaderContent.ScreenReaderContent])) {
39
+ if (child && !(0, _uiReactUtils.matchComponentTypes)(child, [_uiA11yContent.ScreenReaderContent])) {
40
40
  visible = true;
41
41
  }
42
42
  });
package/lib/scopeTab.js CHANGED
@@ -5,11 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  exports.scopeTab = scopeTab;
8
- var _findDOMNode = require("@instructure/ui-dom-utils/lib/findDOMNode.js");
9
- var _findTabbable = require("@instructure/ui-dom-utils/lib/findTabbable.js");
10
- var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
11
- var _containsActiveElement = require("@instructure/ui-dom-utils/lib/containsActiveElement.js");
12
- var _getActiveElement = require("@instructure/ui-dom-utils/lib/getActiveElement.js");
8
+ var _uiDomUtils = require("@instructure/ui-dom-utils");
13
9
  /*
14
10
  * The MIT License (MIT)
15
11
  *
@@ -35,8 +31,8 @@ var _getActiveElement = require("@instructure/ui-dom-utils/lib/getActiveElement.
35
31
  */
36
32
 
37
33
  function scopeTab(element, event, onLeavingFinalTabbable) {
38
- const node = (0, _findDOMNode.findDOMNode)(element);
39
- const tabbable = (0, _findTabbable.findTabbable)(node);
34
+ const node = (0, _uiDomUtils.findDOMNode)(element);
35
+ const tabbable = (0, _uiDomUtils.findTabbable)(node);
40
36
  if (!tabbable.length) {
41
37
  event.preventDefault();
42
38
  return;
@@ -44,18 +40,18 @@ function scopeTab(element, event, onLeavingFinalTabbable) {
44
40
 
45
41
  // Account for a changing tabindex of the active element
46
42
  // (a case that happens with Menu for KO a11y)
47
- if ((0, _containsActiveElement.containsActiveElement)(element)) {
48
- const activeElement = (0, _getActiveElement.getActiveElement)();
43
+ if ((0, _uiDomUtils.containsActiveElement)(element)) {
44
+ const activeElement = (0, _uiDomUtils.getActiveElement)();
49
45
  if (activeElement && tabbable.indexOf(activeElement) === -1) {
50
46
  tabbable.push(activeElement);
51
47
  }
52
48
  }
53
49
  const finalTabbable = tabbable[event.shiftKey ? 0 : tabbable.length - 1];
54
- const leavingFinalTabbable = (0, _isActiveElement.isActiveElement)(finalTabbable) ||
50
+ const leavingFinalTabbable = (0, _uiDomUtils.isActiveElement)(finalTabbable) ||
55
51
  // handle immediate shift+tab after opening with mouse
56
- (0, _isActiveElement.isActiveElement)(node) ||
52
+ (0, _uiDomUtils.isActiveElement)(node) ||
57
53
  // already left final tabbable
58
- !(0, _containsActiveElement.containsActiveElement)(element);
54
+ !(0, _uiDomUtils.containsActiveElement)(element);
59
55
  if (!leavingFinalTabbable) return;
60
56
  if (typeof onLeavingFinalTabbable === 'function') {
61
57
  onLeavingFinalTabbable();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-a11y-utils",
3
- "version": "10.13.0",
3
+ "version": "10.13.1-pr-snapshot-1741357986437",
4
4
  "description": "A collection of utilities for managing focus and screen reader behavior",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,17 +23,17 @@
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
25
  "@babel/runtime": "^7.26.0",
26
- "@instructure/console": "10.13.0",
27
- "@instructure/shared-types": "10.13.0",
28
- "@instructure/ui-a11y-content": "10.13.0",
29
- "@instructure/ui-dom-utils": "10.13.0",
30
- "@instructure/ui-react-utils": "10.13.0",
31
- "@instructure/uid": "10.13.0",
26
+ "@instructure/console": "10.13.1-pr-snapshot-1741357986437",
27
+ "@instructure/shared-types": "10.13.1-pr-snapshot-1741357986437",
28
+ "@instructure/ui-a11y-content": "10.13.1-pr-snapshot-1741357986437",
29
+ "@instructure/ui-dom-utils": "10.13.1-pr-snapshot-1741357986437",
30
+ "@instructure/ui-react-utils": "10.13.1-pr-snapshot-1741357986437",
31
+ "@instructure/uid": "10.13.1-pr-snapshot-1741357986437",
32
32
  "keycode": "^2"
33
33
  },
34
34
  "devDependencies": {
35
- "@instructure/ui-babel-preset": "10.13.0",
36
- "@instructure/ui-color-utils": "10.13.0",
35
+ "@instructure/ui-babel-preset": "10.13.1-pr-snapshot-1741357986437",
36
+ "@instructure/ui-color-utils": "10.13.1-pr-snapshot-1741357986437",
37
37
  "@testing-library/jest-dom": "^6.6.3",
38
38
  "@testing-library/react": "^16.0.1",
39
39
  "vitest": "^2.1.8"