@instructure/ui-focusable 8.56.2-pr-snapshot-1721749364069 → 8.56.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 +1 -1
- package/lib/Focusable/index.js +11 -8
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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
|
-
## [8.56.2
|
|
6
|
+
## [8.56.2](https://github.com/instructure/instructure-ui/compare/v8.56.1...v8.56.2) (2024-08-06)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-focusable
|
|
9
9
|
|
package/lib/Focusable/index.js
CHANGED
|
@@ -5,10 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.Focusable = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
var
|
|
8
|
+
var _addInputModeListener = require("@instructure/ui-dom-utils/lib/addInputModeListener.js");
|
|
9
|
+
var _addEventListener = require("@instructure/ui-dom-utils/lib/addEventListener.js");
|
|
10
|
+
var _containsActiveElement = require("@instructure/ui-dom-utils/lib/containsActiveElement.js");
|
|
11
|
+
var _findFocusable = require("@instructure/ui-dom-utils/lib/findFocusable.js");
|
|
9
12
|
var _console = require("@instructure/console");
|
|
10
13
|
var _props = require("./props");
|
|
11
|
-
var
|
|
14
|
+
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
12
15
|
/*
|
|
13
16
|
* The MIT License (MIT)
|
|
14
17
|
*
|
|
@@ -72,7 +75,7 @@ class Focusable extends _react.Component {
|
|
|
72
75
|
const focusable = this.focusable,
|
|
73
76
|
focused = this.focused;
|
|
74
77
|
this.addFocusableListeners(focused, focusable);
|
|
75
|
-
this._inputModeListener = (0,
|
|
78
|
+
this._inputModeListener = (0, _addInputModeListener.addInputModeListener)({
|
|
76
79
|
onInputModeChange: this.handleInputModeChange
|
|
77
80
|
});
|
|
78
81
|
this.setState({
|
|
@@ -122,9 +125,9 @@ class Focusable extends _react.Component {
|
|
|
122
125
|
addFocusableListeners(focused, focusable) {
|
|
123
126
|
if (!focusable) return;
|
|
124
127
|
if (focused && !this._blurListener) {
|
|
125
|
-
this._blurListener = (0,
|
|
128
|
+
this._blurListener = (0, _addEventListener.addEventListener)(focusable, 'blur', this.handleBlur, true);
|
|
126
129
|
} else if (!this._focusListener) {
|
|
127
|
-
this._focusListener = (0,
|
|
130
|
+
this._focusListener = (0, _addEventListener.addEventListener)(focusable, 'focus', this.handleFocus, true);
|
|
128
131
|
}
|
|
129
132
|
}
|
|
130
133
|
removeFocusableListeners() {
|
|
@@ -144,10 +147,10 @@ class Focusable extends _react.Component {
|
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
get focused() {
|
|
147
|
-
return (0,
|
|
150
|
+
return (0, _containsActiveElement.containsActiveElement)(this);
|
|
148
151
|
}
|
|
149
152
|
get focusable() {
|
|
150
|
-
const focusableArr = (0,
|
|
153
|
+
const focusableArr = (0, _findFocusable.findFocusable)(this, () => true, true) || [];
|
|
151
154
|
const focusableCount = focusableArr && focusableArr.length || 0;
|
|
152
155
|
(0, _console.logWarn)(focusableCount === 1, `[Focusable] Exactly one focusable child is required (${focusableCount} found).`);
|
|
153
156
|
const focusable = focusableArr ? focusableArr[0] : false;
|
|
@@ -205,7 +208,7 @@ class Focusable extends _react.Component {
|
|
|
205
208
|
attachRef: this.attachRef
|
|
206
209
|
});
|
|
207
210
|
return /*#__PURE__*/(0, _react.cloneElement)(rendered, {
|
|
208
|
-
ref: rendered.ref ? (0,
|
|
211
|
+
ref: rendered.ref ? (0, _createChainedFunction.createChainedFunction)(rendered.ref, this.attachRef) : this.attachRef
|
|
209
212
|
});
|
|
210
213
|
} else {
|
|
211
214
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-focusable",
|
|
3
|
-
"version": "8.56.2
|
|
3
|
+
"version": "8.56.2",
|
|
4
4
|
"description": "A utility used to identify when an element receives focus.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "8.56.2
|
|
27
|
-
"@instructure/ui-test-utils": "8.56.2
|
|
26
|
+
"@instructure/ui-babel-preset": "8.56.2",
|
|
27
|
+
"@instructure/ui-test-utils": "8.56.2"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@babel/runtime": "^7.23.2",
|
|
31
|
-
"@instructure/console": "8.56.2
|
|
32
|
-
"@instructure/ui-dom-utils": "8.56.2
|
|
33
|
-
"@instructure/ui-react-utils": "8.56.2
|
|
34
|
-
"@instructure/ui-utils": "8.56.2
|
|
35
|
-
"@instructure/ui-view": "8.56.2
|
|
31
|
+
"@instructure/console": "8.56.2",
|
|
32
|
+
"@instructure/ui-dom-utils": "8.56.2",
|
|
33
|
+
"@instructure/ui-react-utils": "8.56.2",
|
|
34
|
+
"@instructure/ui-utils": "8.56.2",
|
|
35
|
+
"@instructure/ui-view": "8.56.2",
|
|
36
36
|
"prop-types": "^15.8.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|