@instructure/ui-a11y-utils 11.7.8 → 11.7.9-pr-snapshot-1792147648392

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,19 @@
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.7.9-pr-snapshot-1792147648392](https://github.com/instructure/instructure-ui/compare/v11.7.8...v11.7.9-pr-snapshot-1792147648392) (2026-10-16)
7
+
8
+ ### Build System
9
+
10
+ * **many:** replace babel with swc ([7e36c54](https://github.com/instructure/instructure-ui/commit/7e36c54d240b4fa483801c03ab18e7f860f561e2))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ * **many:** `@instructure/ui-babel-preset` and
15
+ `@instructure/browserslist-config-instui` are removed and will no longer be
16
+ published. Packages depend on `@swc/helpers` instead of `@babel/runtime`.
17
+
18
+
6
19
  ## [11.7.8](https://github.com/instructure/instructure-ui/compare/v11.7.7...v11.7.8) (2026-10-02)
7
20
 
8
21
  **Note:** Version bump only for package @instructure/ui-a11y-utils
package/es/FocusRegion.js CHANGED
@@ -1,225 +1,151 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
1
  import keycode from 'keycode';
26
2
  import { contains, addEventListener, ownerDocument, findTabbable, canUseDOM } from '@instructure/ui-dom-utils';
27
3
  import { uid } from '@instructure/uid';
28
4
  import { logError as error } from '@instructure/console';
29
5
  import { ScreenReaderFocusRegion } from './ScreenReaderFocusRegion.js';
30
6
  import { KeyboardFocusRegion } from './KeyboardFocusRegion.js';
31
- /**
32
- * ---
33
- * category: utilities/a11y
34
- * ---
35
- *
36
- * Class for focus operations, manages [ScreenReaderFocusRegion](ScreenReaderFocusRegion)
37
- * and [KeyboardFocusRegion](KeyboardFocusRegion) for the given DOM element.
38
- * - Scoping focus within a given context (DOM node),
39
- * - Mark active element for focus later
40
- * - Return focus to the marked element
41
- * @module FocusRegion
42
- */
43
7
  class FocusRegion {
44
- _contextElement = null;
45
- _options;
46
- _screenReaderFocusRegion;
47
- _keyboardFocusRegion;
48
- _id;
49
- _mouseDownListener;
50
- _clickListener;
51
- _mouseUpListener;
52
- _keyUpListener;
53
- _active = false;
54
- _documentClickTarget = null;
55
- _contextContainsTarget = false;
56
- constructor(element, options) {
57
- this._options = options || {
58
- shouldCloseOnDocumentClick: true,
59
- shouldCloseOnEscape: true,
60
- isTooltip: false
61
- };
62
- this._id = uid();
63
- // eslint-disable-next-line no-param-reassign
64
- options.regionId = this._id;
65
- this._contextElement = element;
66
- this._screenReaderFocusRegion = new ScreenReaderFocusRegion(element, options);
67
- this._keyboardFocusRegion = new KeyboardFocusRegion(element, options);
68
- }
69
- updateElement(element, options) {
70
- this._contextElement = element;
71
- if (options) {
72
- this._options = options;
73
- if (this._active) {
74
- this.addOrRemoveListeners(options.shouldCloseOnDocumentClick, options.shouldCloseOnEscape);
75
- }
8
+ constructor(element, options){
9
+ this._contextElement = null;
10
+ this._active = false;
11
+ this._documentClickTarget = null;
12
+ this._contextContainsTarget = false;
13
+ this.handleDismiss = (event, documentClick)=>{
14
+ this._options.onDismiss?.(event, documentClick);
15
+ };
16
+ this.captureDocumentMousedown = (event)=>{
17
+ this._documentClickTarget = event.target;
18
+ this._contextContainsTarget = contains(this._contextElement, this._documentClickTarget);
19
+ if (!this._contextContainsTarget && this._options.shouldCloseOnDocumentClick) {
20
+ this._screenReaderFocusRegion.deactivate();
21
+ }
22
+ };
23
+ this.handleDocumentClick = (event)=>{
24
+ if (this._options.shouldCloseOnDocumentClick && event.button === 0 && event.detail > 0 && !this._contextContainsTarget && !(canUseDOM && this._documentClickTarget instanceof HTMLElement && this._documentClickTarget.closest('[role="tooltip"]'))) {
25
+ this.handleDismiss(event, true);
26
+ }
27
+ };
28
+ this.handleFrameClick = (event, frame)=>{
29
+ if (!contains(this._contextElement, frame)) {
30
+ this.handleDismiss(event, true);
31
+ }
32
+ };
33
+ this.handleKeyUp = (event)=>{
34
+ if (this._options.shouldCloseOnEscape && event.keyCode === keycode.codes.esc && !event.defaultPrevented) {
35
+ const activeElement = ownerDocument(this._contextElement)?.activeElement;
36
+ const fileInputFocused = activeElement?.tagName === 'INPUT' && activeElement.type === 'file';
37
+ if (fileInputFocused) {
38
+ ;
39
+ activeElement.blur();
40
+ } else {
41
+ if (this._options.isTooltip) {
42
+ event.stopPropagation();
43
+ }
44
+ this.handleDismiss(event);
45
+ }
46
+ }
47
+ };
48
+ this._options = options || {
49
+ shouldCloseOnDocumentClick: true,
50
+ shouldCloseOnEscape: true,
51
+ isTooltip: false
52
+ };
53
+ this._id = uid();
54
+ options.regionId = this._id;
55
+ this._contextElement = element;
56
+ this._screenReaderFocusRegion = new ScreenReaderFocusRegion(element, options);
57
+ this._keyboardFocusRegion = new KeyboardFocusRegion(element, options);
76
58
  }
77
- if (this._keyboardFocusRegion) {
78
- this._keyboardFocusRegion.updateElement(element);
79
- }
80
- if (this._screenReaderFocusRegion) {
81
- this._screenReaderFocusRegion.updateElement(element);
59
+ updateElement(element, options) {
60
+ this._contextElement = element;
61
+ if (options) {
62
+ this._options = options;
63
+ if (this._active) {
64
+ this.addOrRemoveListeners(options.shouldCloseOnDocumentClick, options.shouldCloseOnEscape);
65
+ }
66
+ }
67
+ if (this._keyboardFocusRegion) {
68
+ this._keyboardFocusRegion.updateElement(element);
69
+ }
70
+ if (this._screenReaderFocusRegion) {
71
+ this._screenReaderFocusRegion.updateElement(element);
72
+ }
82
73
  }
83
- }
84
- handleDismiss = (event, documentClick) => {
85
- this._options.onDismiss?.(event, documentClick);
86
- };
87
- captureDocumentMousedown = event => {
88
- this._documentClickTarget = event.target;
89
- this._contextContainsTarget = contains(this._contextElement, this._documentClickTarget);
90
- // Preemptively remove aria-hidden before focus moves to the clicked element
91
- // outside the region, preventing the "aria-hidden on focused ancestor" warning.
92
- if (!this._contextContainsTarget && this._options.shouldCloseOnDocumentClick) {
93
- this._screenReaderFocusRegion.deactivate();
74
+ get id() {
75
+ return this._id;
94
76
  }
95
- };
96
- handleDocumentClick = event => {
97
- // we used event.pointerType === 'mouse' here, but it is not supported in Safari
98
- // https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType
99
- // TODO: Check this in the future, because the linked Webkit bug is marked as fixed in 2025-09
100
- if (this._options.shouldCloseOnDocumentClick && event.button === 0 && event.detail > 0 &&
101
- // if event.detail is 0 then this is a keyboard and not a mouse press
102
- !this._contextContainsTarget &&
103
- //this prevents clicking on Tooltip from closing the parent dialog
104
- !(canUseDOM && this._documentClickTarget instanceof HTMLElement && this._documentClickTarget.closest('[role="tooltip"]'))) {
105
- this.handleDismiss(event, true);
77
+ get focused() {
78
+ return this._active;
106
79
  }
107
- };
108
- handleFrameClick = (event, frame) => {
109
- if (!contains(this._contextElement, frame)) {
110
- // dismiss if frame is not within the region
111
- this.handleDismiss(event, true);
80
+ get keyboardFocusable() {
81
+ return (findTabbable(this._contextElement) || []).length > 0;
112
82
  }
113
- };
114
- handleKeyUp = event => {
115
- if (this._options.shouldCloseOnEscape && event.keyCode === keycode.codes.esc && !event.defaultPrevented) {
116
- // If a dialog contains an <input type="file"/> element and the user opens the file picker and closes it with the
117
- // escape key then Firefox passes through that event which could close the parent dialog. This code prevents that
118
- // from happening (listening for a `cancel` event doesn't seem to work in firefox)
119
- const activeElement = ownerDocument(this._contextElement)?.activeElement;
120
- const fileInputFocused = activeElement?.tagName === 'INPUT' && activeElement.type === 'file';
121
- if (fileInputFocused) {
122
- ;
123
- activeElement.blur();
124
- } else {
125
- //This should prevent a Tooltip from closing when inside of a Modal
126
- if (this._options.isTooltip) {
127
- event.stopPropagation();
83
+ addOrRemoveListeners(shouldCloseOnDocumentClick, shouldCloseOnEscape) {
84
+ const doc = ownerDocument(this._contextElement);
85
+ if (shouldCloseOnDocumentClick) {
86
+ if (!this._mouseDownListener) {
87
+ this._mouseDownListener = addEventListener(doc, 'mousedown', this.captureDocumentMousedown);
88
+ }
89
+ if (!this._clickListener) {
90
+ this._clickListener = addEventListener(doc, 'click', this.handleDocumentClick);
91
+ }
92
+ Array.from(doc.getElementsByTagName('iframe')).forEach((el)=>{
93
+ const frameDoc = el.contentDocument;
94
+ if (frameDoc && !this._mouseUpListener) {
95
+ this._mouseUpListener = addEventListener(frameDoc, 'mouseup', (event)=>{
96
+ this.handleFrameClick(event, el);
97
+ });
98
+ }
99
+ });
100
+ } else {
101
+ this._mouseDownListener?.remove();
102
+ this._mouseDownListener = undefined;
103
+ this._clickListener?.remove();
104
+ this._clickListener = undefined;
105
+ this._mouseUpListener?.remove();
106
+ this._mouseUpListener = undefined;
107
+ }
108
+ if (shouldCloseOnEscape) {
109
+ if (!this._keyUpListener) {
110
+ const useCapture = this._options.isTooltip;
111
+ this._keyUpListener = addEventListener(doc, 'keyup', this.handleKeyUp, useCapture);
112
+ }
113
+ } else {
114
+ this._keyUpListener?.remove();
115
+ this._keyUpListener = undefined;
128
116
  }
129
- this.handleDismiss(event);
130
- }
131
117
  }
132
- };
133
- get id() {
134
- return this._id;
135
- }
136
-
137
- // Focused returns when the focus region is active. Checking focused with the active element
138
- // is inconsistent across browsers (Safari/Firefox do not focus elements on click)
139
- get focused() {
140
- return this._active;
141
- }
142
- get keyboardFocusable() {
143
- return (findTabbable(this._contextElement) || []).length > 0;
144
- }
145
-
146
- /**
147
- * Adds or removes mouse/keyboard listeners based on the input parameters
148
- * @param shouldCloseOnDocumentClick Should add listeners that close the region if there is an outside click?
149
- * @param shouldCloseOnEscape Should the region be closed if ESC is pressed?
150
- */
151
- addOrRemoveListeners(shouldCloseOnDocumentClick, shouldCloseOnEscape) {
152
- const doc = ownerDocument(this._contextElement);
153
- if (shouldCloseOnDocumentClick) {
154
- if (!this._mouseDownListener) {
155
- this._mouseDownListener = addEventListener(doc, 'mousedown', this.captureDocumentMousedown);
156
- }
157
- if (!this._clickListener) {
158
- this._clickListener = addEventListener(doc, 'click', this.handleDocumentClick);
159
- }
160
- Array.from(doc.getElementsByTagName('iframe')).forEach(el => {
161
- // listen for mouseup events on any iframes in the document
162
- const frameDoc = el.contentDocument;
163
- if (frameDoc && !this._mouseUpListener) {
164
- this._mouseUpListener = addEventListener(frameDoc, 'mouseup', event => {
165
- this.handleFrameClick(event, el);
166
- });
118
+ activate() {
119
+ if (!this._active) {
120
+ this._keyboardFocusRegion.activate();
121
+ this._screenReaderFocusRegion.activate();
122
+ this.addOrRemoveListeners(this._options.shouldCloseOnDocumentClick, this._options.shouldCloseOnEscape);
123
+ this._active = true;
167
124
  }
168
- });
169
- } else {
170
- this._mouseDownListener?.remove();
171
- this._mouseDownListener = undefined;
172
- this._clickListener?.remove();
173
- this._clickListener = undefined;
174
- this._mouseUpListener?.remove();
175
- this._mouseUpListener = undefined;
176
125
  }
177
- if (shouldCloseOnEscape) {
178
- if (!this._keyUpListener) {
179
- //This will ensure that the Tooltip's Escape event listener is executed first
180
- //because listeners in the capturing phase are called before other event listeners (like that of the Modal's Escape listener)
181
- //so a Modal with a Tooltip will not get closed when closing the Tooltip with Escape
182
- const useCapture = this._options.isTooltip;
183
- this._keyUpListener = addEventListener(doc, 'keyup', this.handleKeyUp, useCapture);
184
- }
185
- } else {
186
- this._keyUpListener?.remove();
187
- this._keyUpListener = undefined;
126
+ deactivate({ keyboard = true } = {}) {
127
+ this._mouseDownListener?.remove();
128
+ this._mouseDownListener = undefined;
129
+ this._clickListener?.remove();
130
+ this._clickListener = undefined;
131
+ this._mouseUpListener?.remove();
132
+ this._mouseUpListener = undefined;
133
+ this._keyUpListener?.remove();
134
+ this._keyUpListener = undefined;
135
+ if (keyboard) {
136
+ this._keyboardFocusRegion.deactivate();
137
+ }
138
+ this._screenReaderFocusRegion.deactivate();
139
+ this._active = false;
188
140
  }
189
- }
190
- activate() {
191
- if (!this._active) {
192
- this._keyboardFocusRegion.activate();
193
- this._screenReaderFocusRegion.activate();
194
- this.addOrRemoveListeners(this._options.shouldCloseOnDocumentClick, this._options.shouldCloseOnEscape);
195
- this._active = true;
141
+ focus() {
142
+ error(this._active, `[FocusRegion] Cannot call '.focus()' on a region that is not currently active.`);
143
+ this._keyboardFocusRegion.focus();
196
144
  }
197
- }
198
- deactivate({
199
- keyboard = true
200
- } = {}) {
201
- this._mouseDownListener?.remove();
202
- this._mouseDownListener = undefined;
203
- this._clickListener?.remove();
204
- this._clickListener = undefined;
205
- this._mouseUpListener?.remove();
206
- this._mouseUpListener = undefined;
207
- this._keyUpListener?.remove();
208
- this._keyUpListener = undefined;
209
- if (keyboard) {
210
- this._keyboardFocusRegion.deactivate();
145
+ blur() {
146
+ error(!this._active, `[FocusRegion] Cannot call '.blur()' on a region that is currently active.`);
147
+ this._keyboardFocusRegion.blur();
211
148
  }
212
- this._screenReaderFocusRegion.deactivate();
213
- this._active = false;
214
- }
215
- focus() {
216
- error(this._active, `[FocusRegion] Cannot call '.focus()' on a region that is not currently active.`);
217
- this._keyboardFocusRegion.focus();
218
- }
219
- blur() {
220
- error(!this._active, `[FocusRegion] Cannot call '.blur()' on a region that is currently active.`);
221
- this._keyboardFocusRegion.blur();
222
- }
223
149
  }
224
150
  export default FocusRegion;
225
- export { FocusRegion };
151
+ export { FocusRegion };
@@ -1,164 +1,124 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
1
  import { logError as error } from '@instructure/console';
26
2
  import { FocusRegion } from './FocusRegion.js';
27
3
  let ENTRIES = [];
28
-
29
- /**
30
- * ---
31
- * category: utilities/a11y
32
- * ---
33
- *
34
- * Class for focus operations, manages multiple [FocusRegion](FocusRegion)s.
35
- * - Scoping focus within a given context,
36
- * - Mark active element for focus later
37
- * - Return focus to the marked element
38
- * @module FocusManager
39
- */
40
4
  class FocusRegionManager {
41
- static focusRegion = (element, idOrOptions = {}) => {
42
- let entry;
43
- if (typeof idOrOptions === 'string') {
44
- entry = FocusRegionManager.getEntry(element, idOrOptions);
45
- } else {
46
- entry = FocusRegionManager.addEntry(element, idOrOptions);
5
+ static{
6
+ this.focusRegion = (element, idOrOptions = {})=>{
7
+ let entry;
8
+ if (typeof idOrOptions === 'string') {
9
+ entry = FocusRegionManager.getEntry(element, idOrOptions);
10
+ } else {
11
+ entry = FocusRegionManager.addEntry(element, idOrOptions);
12
+ }
13
+ if (entry && entry.region && typeof entry.region.focus === 'function') {
14
+ entry.region.focus();
15
+ return entry.region;
16
+ } else {
17
+ error(false, `[FocusRegionManager] Could not focus region with element: ${element}`);
18
+ }
19
+ return;
20
+ };
47
21
  }
48
- if (entry && entry.region && typeof entry.region.focus === 'function') {
49
- entry.region.focus();
50
- return entry.region;
51
- } else {
52
- error(false, `[FocusRegionManager] Could not focus region with element: ${element}`);
22
+ static{
23
+ this.activateRegion = (element, options)=>{
24
+ const { region } = FocusRegionManager.addEntry(element, options);
25
+ return region;
26
+ };
53
27
  }
54
- return;
55
- };
56
- static activateRegion = (element, options) => {
57
- const {
58
- region
59
- } = FocusRegionManager.addEntry(element, options);
60
- return region;
61
- };
62
- static getActiveEntry = () => {
63
- return ENTRIES.find(({
64
- region
65
- }) => region.focused);
66
- };
67
- static findEntry = (element, id) => {
68
- let index;
69
- if (id) {
70
- index = ENTRIES.findIndex(entry => entry.id === id);
71
- } else {
72
- index = ENTRIES.findIndex(entry => entry.element === element);
28
+ static{
29
+ this.getActiveEntry = ()=>{
30
+ return ENTRIES.find(({ region })=>region.focused);
31
+ };
73
32
  }
74
- return index;
75
- };
76
- static getEntry = (element, id) => {
77
- return ENTRIES[FocusRegionManager.findEntry(element, id)];
78
- };
79
- static addEntry = (element, options = {}) => {
80
- const region = new FocusRegion(element, options);
81
- const activeEntry = FocusRegionManager.getActiveEntry();
82
- const {
83
- keyboardFocusable
84
- } = region;
85
- ENTRIES.forEach(({
86
- region
87
- }) => {
88
- if (region) {
89
- // If the active region is triggering a new focus region that does not have
90
- // keyboard focusable content, don't deactivate the active region's keyboard
91
- // focus region
92
- const keyboard = region.focused && !keyboardFocusable ? {
93
- keyboard: false
94
- } : undefined;
95
- region.deactivate(keyboard);
96
- }
97
- });
98
- region.activate();
99
- if (options.shouldFocusOnOpen) {
100
- region.focus();
33
+ static{
34
+ this.findEntry = (element, id)=>{
35
+ let index;
36
+ if (id) {
37
+ index = ENTRIES.findIndex((entry)=>entry.id === id);
38
+ } else {
39
+ index = ENTRIES.findIndex((entry)=>entry.element === element);
40
+ }
41
+ return index;
42
+ };
101
43
  }
102
- const entry = {
103
- id: region.id,
104
- element,
105
- region,
106
- children: [],
107
- parent: activeEntry
108
- };
109
- ENTRIES.push(entry);
110
- if (activeEntry) {
111
- activeEntry.children.push(entry);
44
+ static{
45
+ this.getEntry = (element, id)=>{
46
+ return ENTRIES[FocusRegionManager.findEntry(element, id)];
47
+ };
112
48
  }
113
- return entry;
114
- };
115
- static removeEntry = (element, id) => {
116
- const index = FocusRegionManager.findEntry(element, id);
117
- const entry = ENTRIES[index];
118
- if (index > -1) {
119
- ENTRIES.splice(index, 1);
49
+ static{
50
+ this.addEntry = (element, options = {})=>{
51
+ const region = new FocusRegion(element, options);
52
+ const activeEntry = FocusRegionManager.getActiveEntry();
53
+ const { keyboardFocusable } = region;
54
+ ENTRIES.forEach(({ region })=>{
55
+ if (region) {
56
+ const keyboard = region.focused && !keyboardFocusable ? {
57
+ keyboard: false
58
+ } : undefined;
59
+ region.deactivate(keyboard);
60
+ }
61
+ });
62
+ region.activate();
63
+ if (options.shouldFocusOnOpen) {
64
+ region.focus();
65
+ }
66
+ const entry = {
67
+ id: region.id,
68
+ element,
69
+ region,
70
+ children: [],
71
+ parent: activeEntry
72
+ };
73
+ ENTRIES.push(entry);
74
+ if (activeEntry) {
75
+ activeEntry.children.push(entry);
76
+ }
77
+ return entry;
78
+ };
120
79
  }
121
- return entry;
122
- };
123
- static isFocused = (element, id) => {
124
- const entry = FocusRegionManager.getActiveEntry();
125
- if (id) {
126
- return entry && entry.region && entry.id === id;
127
- } else {
128
- return entry && entry.region && entry.element === element;
80
+ static{
81
+ this.removeEntry = (element, id)=>{
82
+ const index = FocusRegionManager.findEntry(element, id);
83
+ const entry = ENTRIES[index];
84
+ if (index > -1) {
85
+ ENTRIES.splice(index, 1);
86
+ }
87
+ return entry;
88
+ };
129
89
  }
130
- };
131
- static clearEntries = () => {
132
- ENTRIES = [];
133
- };
134
- static blurRegion = (element, id) => {
135
- const entry = FocusRegionManager.removeEntry(element, id);
136
- if (entry) {
137
- const {
138
- children,
139
- region,
140
- parent
141
- } = entry;
142
-
143
- // deactivate the region...
144
- region && region.deactivate();
145
-
146
- // and any regions created from it
147
- if (children) {
148
- children.forEach(({
149
- id,
150
- element
151
- }) => {
152
- const entry = FocusRegionManager.removeEntry(element, id);
153
- entry && entry.region && entry.region.deactivate();
154
- });
155
- }
156
-
157
- // activate the region's parent if it exists
158
- parent && parent.region && parent.region.activate();
159
- region && region.blur(); // this should focus the parent region
90
+ static{
91
+ this.isFocused = (element, id)=>{
92
+ const entry = FocusRegionManager.getActiveEntry();
93
+ if (id) {
94
+ return entry && entry.region && entry.id === id;
95
+ } else {
96
+ return entry && entry.region && entry.element === element;
97
+ }
98
+ };
99
+ }
100
+ static{
101
+ this.clearEntries = ()=>{
102
+ ENTRIES = [];
103
+ };
104
+ }
105
+ static{
106
+ this.blurRegion = (element, id)=>{
107
+ const entry = FocusRegionManager.removeEntry(element, id);
108
+ if (entry) {
109
+ const { children, region, parent } = entry;
110
+ region && region.deactivate();
111
+ if (children) {
112
+ children.forEach(({ id, element })=>{
113
+ const entry = FocusRegionManager.removeEntry(element, id);
114
+ entry && entry.region && entry.region.deactivate();
115
+ });
116
+ }
117
+ parent && parent.region && parent.region.activate();
118
+ region && region.blur();
119
+ }
120
+ };
160
121
  }
161
- };
162
122
  }
163
123
  export default FocusRegionManager;
164
- export { FocusRegionManager };
124
+ export { FocusRegionManager };
@@ -1 +1 @@
1
- export {};
1
+ export { };