@instructure/ui-focusable 11.6.0 → 11.6.1-pr-snapshot-1779894247159
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 +8 -0
- package/{lib/Focusable/props.js → babel.config.cjs} +13 -7
- package/package.json +10 -12
- package/lib/Focusable/index.js +0 -236
- package/lib/index.js +0 -12
- package/lib/package.json +0 -1
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
|
+
## [11.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-focusable
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @instructure/ui-focusable
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
1
|
/*
|
|
8
2
|
* The MIT License (MIT)
|
|
9
3
|
*
|
|
@@ -28,4 +22,16 @@ exports.allowedProps = void 0;
|
|
|
28
22
|
* SOFTWARE.
|
|
29
23
|
*/
|
|
30
24
|
|
|
31
|
-
|
|
25
|
+
module.exports = {
|
|
26
|
+
presets: [
|
|
27
|
+
[
|
|
28
|
+
require('@instructure/ui-babel-preset'),
|
|
29
|
+
{
|
|
30
|
+
coverage: Boolean(process.env.COVERAGE),
|
|
31
|
+
esModules: Boolean(process.env.ES_MODULES),
|
|
32
|
+
removeConsole: process.env.NODE_ENV === 'production',
|
|
33
|
+
transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
]
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-focusable",
|
|
3
|
-
"version": "11.6.
|
|
3
|
+
"version": "11.6.1-pr-snapshot-1779894247159",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "A utility used to identify when an element receives focus.",
|
|
5
6
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
7
|
"module": "./es/index.js",
|
|
7
|
-
"main": "./lib/index.js",
|
|
8
8
|
"types": "./types/index.d.ts",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.27.6",
|
|
18
|
-
"@instructure/console": "11.6.
|
|
19
|
-
"@instructure/shared-types": "11.6.
|
|
20
|
-
"@instructure/ui-
|
|
21
|
-
"@instructure/ui-
|
|
22
|
-
"@instructure/ui-utils": "11.6.
|
|
23
|
-
"@instructure/ui-view": "11.6.
|
|
18
|
+
"@instructure/console": "11.6.1-pr-snapshot-1779894247159",
|
|
19
|
+
"@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159",
|
|
20
|
+
"@instructure/ui-utils": "11.6.1-pr-snapshot-1779894247159",
|
|
21
|
+
"@instructure/ui-dom-utils": "11.6.1-pr-snapshot-1779894247159",
|
|
22
|
+
"@instructure/ui-react-utils": "11.6.1-pr-snapshot-1779894247159",
|
|
23
|
+
"@instructure/ui-view": "11.6.1-pr-snapshot-1779894247159"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@testing-library/jest-dom": "^6.6.3",
|
|
27
27
|
"@testing-library/react": "15.0.7",
|
|
28
28
|
"@testing-library/user-event": "^14.6.1",
|
|
29
29
|
"vitest": "^3.2.2",
|
|
30
|
-
"@instructure/ui-babel-preset": "11.6.
|
|
30
|
+
"@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": ">=18 <=19"
|
|
@@ -40,10 +40,8 @@
|
|
|
40
40
|
".": {
|
|
41
41
|
"types": "./types/index.d.ts",
|
|
42
42
|
"import": "./es/index.js",
|
|
43
|
-
"require": "./lib/index.js",
|
|
44
43
|
"default": "./es/index.js"
|
|
45
44
|
},
|
|
46
|
-
"./lib/*": "./lib/*",
|
|
47
45
|
"./es/*": "./es/*",
|
|
48
46
|
"./types/*": "./types/*",
|
|
49
47
|
"./package.json": "./package.json",
|
|
@@ -53,7 +51,7 @@
|
|
|
53
51
|
"lint": "ui-scripts lint",
|
|
54
52
|
"lint:fix": "ui-scripts lint --fix",
|
|
55
53
|
"clean": "ui-scripts clean",
|
|
56
|
-
"build": "ui-scripts build
|
|
54
|
+
"build": "ui-scripts build",
|
|
57
55
|
"build:watch": "pnpm run ts:check -- --watch & ui-scripts build --watch",
|
|
58
56
|
"build:types": "tsc -p tsconfig.build.json",
|
|
59
57
|
"ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
|
package/lib/Focusable/index.js
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.Focusable = void 0;
|
|
7
|
-
var _react = require("react");
|
|
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");
|
|
12
|
-
var _console = require("@instructure/console");
|
|
13
|
-
var _props = require("./props");
|
|
14
|
-
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
15
|
-
/*
|
|
16
|
-
* The MIT License (MIT)
|
|
17
|
-
*
|
|
18
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
19
|
-
*
|
|
20
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
21
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
22
|
-
* in the Software without restriction, including without limitation the rights
|
|
23
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
24
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
25
|
-
* furnished to do so, subject to the following conditions:
|
|
26
|
-
*
|
|
27
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
28
|
-
* copies or substantial portions of the Software.
|
|
29
|
-
*
|
|
30
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
31
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
32
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
33
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
34
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
35
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
36
|
-
* SOFTWARE.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
---
|
|
41
|
-
category: components/utilities
|
|
42
|
-
---
|
|
43
|
-
**/
|
|
44
|
-
class Focusable extends _react.Component {
|
|
45
|
-
constructor(...args) {
|
|
46
|
-
super(...args);
|
|
47
|
-
this._focusListener = null;
|
|
48
|
-
this._blurListener = null;
|
|
49
|
-
this._inputModeListener = null;
|
|
50
|
-
this.state = {
|
|
51
|
-
focused: false,
|
|
52
|
-
focusable: void 0
|
|
53
|
-
};
|
|
54
|
-
this.handleInputModeChange = () => {
|
|
55
|
-
this.forceUpdate();
|
|
56
|
-
};
|
|
57
|
-
this.handleFocus = () => {
|
|
58
|
-
this.removeFocusListener();
|
|
59
|
-
this.setState({
|
|
60
|
-
focused: true
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
this.handleBlur = () => {
|
|
64
|
-
this.removeBlurListener();
|
|
65
|
-
this.setState({
|
|
66
|
-
focused: false
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
this.ref = null;
|
|
70
|
-
this.attachRef = el => {
|
|
71
|
-
this.ref = el;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
componentDidMount() {
|
|
75
|
-
const focusable = this.focusable,
|
|
76
|
-
focused = this.focused;
|
|
77
|
-
this.addFocusableListeners(focused, focusable);
|
|
78
|
-
this._inputModeListener = (0, _addInputModeListener.addInputModeListener)({
|
|
79
|
-
onInputModeChange: this.handleInputModeChange
|
|
80
|
-
});
|
|
81
|
-
this.setState({
|
|
82
|
-
focusable,
|
|
83
|
-
focused
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
getSnapshotBeforeUpdate(prevProps) {
|
|
87
|
-
const _this$props = this.props,
|
|
88
|
-
render = _this$props.render,
|
|
89
|
-
children = _this$props.children;
|
|
90
|
-
// prevent blur from firing when focusable element is replaced
|
|
91
|
-
if (prevProps.children !== children || prevProps.render !== render) {
|
|
92
|
-
this.removeFocusableListeners();
|
|
93
|
-
}
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
componentDidUpdate() {
|
|
97
|
-
const focusable = this.focusable;
|
|
98
|
-
if (!focusable && this.state.focusable) {
|
|
99
|
-
this.removeFocusableListeners();
|
|
100
|
-
this.setState({
|
|
101
|
-
focusable: void 0,
|
|
102
|
-
focused: false
|
|
103
|
-
});
|
|
104
|
-
} else if (focusable !== this.state.focusable) {
|
|
105
|
-
this.removeFocusableListeners();
|
|
106
|
-
if (this.state.focused) {
|
|
107
|
-
;
|
|
108
|
-
focusable.focus();
|
|
109
|
-
}
|
|
110
|
-
this.addFocusableListeners(this.state.focused, focusable);
|
|
111
|
-
this.setState({
|
|
112
|
-
focusable
|
|
113
|
-
});
|
|
114
|
-
} else {
|
|
115
|
-
this.addFocusableListeners(this.state.focused, focusable);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
componentWillUnmount() {
|
|
119
|
-
if (this._inputModeListener) {
|
|
120
|
-
this._inputModeListener.remove();
|
|
121
|
-
this._inputModeListener = null;
|
|
122
|
-
}
|
|
123
|
-
this.removeFocusableListeners();
|
|
124
|
-
}
|
|
125
|
-
addFocusableListeners(focused, focusable) {
|
|
126
|
-
if (!focusable) return;
|
|
127
|
-
if (focused && !this._blurListener) {
|
|
128
|
-
this._blurListener = (0, _addEventListener.addEventListener)(focusable, 'blur', this.handleBlur, true);
|
|
129
|
-
} else if (!this._focusListener) {
|
|
130
|
-
this._focusListener = (0, _addEventListener.addEventListener)(focusable, 'focus', this.handleFocus, true);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
removeFocusableListeners() {
|
|
134
|
-
this.removeFocusListener();
|
|
135
|
-
this.removeBlurListener();
|
|
136
|
-
}
|
|
137
|
-
removeFocusListener() {
|
|
138
|
-
if (this._focusListener) {
|
|
139
|
-
this._focusListener.remove();
|
|
140
|
-
this._focusListener = null;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
removeBlurListener() {
|
|
144
|
-
if (this._blurListener) {
|
|
145
|
-
this._blurListener.remove();
|
|
146
|
-
this._blurListener = null;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
get focused() {
|
|
150
|
-
return (0, _containsActiveElement.containsActiveElement)(this);
|
|
151
|
-
}
|
|
152
|
-
get focusable() {
|
|
153
|
-
const focusableArr = (0, _findFocusable.findFocusable)(this, () => true, true) || [];
|
|
154
|
-
const focusableCount = focusableArr && focusableArr.length || 0;
|
|
155
|
-
(0, _console.logWarn)(focusableCount === 1, `[Focusable] Exactly one focusable child is required (${focusableCount} found).`);
|
|
156
|
-
const focusable = focusableArr ? focusableArr[0] : false;
|
|
157
|
-
if (focusable && typeof focusable.focus === 'function') {
|
|
158
|
-
return focusable;
|
|
159
|
-
} else {
|
|
160
|
-
return void 0;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
get focusVisible() {
|
|
164
|
-
const _this$state = this.state,
|
|
165
|
-
focusable = _this$state.focusable,
|
|
166
|
-
focused = _this$state.focused;
|
|
167
|
-
return this.isFocusVisible(focused, focusable);
|
|
168
|
-
}
|
|
169
|
-
focus() {
|
|
170
|
-
const focusable = this.focusable;
|
|
171
|
-
if (focusable) {
|
|
172
|
-
focusable.focus();
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
isFocusVisible(focused, focusable) {
|
|
176
|
-
if (!focusable || !focused) return false;
|
|
177
|
-
|
|
178
|
-
// always show focus for keyboard input mode
|
|
179
|
-
if (this._inputModeListener && this._inputModeListener.isKeyboardMode()) return true;
|
|
180
|
-
// note: the type property exist on input fields like HtmlInputElement
|
|
181
|
-
const tagName = focusable.tagName,
|
|
182
|
-
type = focusable.type,
|
|
183
|
-
isContentEditable = focusable.isContentEditable;
|
|
184
|
-
if (tagName == 'INPUT' && Focusable.inputTypes[type]) {
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
if (tagName == 'TEXTAREA') {
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
|
-
return isContentEditable;
|
|
191
|
-
}
|
|
192
|
-
render() {
|
|
193
|
-
const _this$props2 = this.props,
|
|
194
|
-
children = _this$props2.children,
|
|
195
|
-
_this$props2$render = _this$props2.render,
|
|
196
|
-
render = _this$props2$render === void 0 ? children : _this$props2$render;
|
|
197
|
-
const _this$state2 = this.state,
|
|
198
|
-
focusable = _this$state2.focusable,
|
|
199
|
-
focused = _this$state2.focused;
|
|
200
|
-
if (typeof render === 'function') {
|
|
201
|
-
const rendered = render({
|
|
202
|
-
focused,
|
|
203
|
-
focusable,
|
|
204
|
-
focusVisible: this.isFocusVisible(focused, focusable),
|
|
205
|
-
attachRef: this.attachRef
|
|
206
|
-
});
|
|
207
|
-
return /*#__PURE__*/(0, _react.cloneElement)(rendered, {
|
|
208
|
-
ref: rendered.ref ? (0, _createChainedFunction.createChainedFunction)(rendered.ref, this.attachRef) : this.attachRef
|
|
209
|
-
});
|
|
210
|
-
} else {
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
exports.Focusable = Focusable;
|
|
216
|
-
Focusable.displayName = "Focusable";
|
|
217
|
-
Focusable.allowedProps = _props.allowedProps;
|
|
218
|
-
Focusable.defaultProps = {
|
|
219
|
-
children: null
|
|
220
|
-
};
|
|
221
|
-
Focusable.inputTypes = {
|
|
222
|
-
text: true,
|
|
223
|
-
search: true,
|
|
224
|
-
url: true,
|
|
225
|
-
tel: true,
|
|
226
|
-
email: true,
|
|
227
|
-
password: true,
|
|
228
|
-
number: true,
|
|
229
|
-
date: true,
|
|
230
|
-
month: true,
|
|
231
|
-
week: true,
|
|
232
|
-
time: true,
|
|
233
|
-
datetime: true,
|
|
234
|
-
'datetime-local': true
|
|
235
|
-
};
|
|
236
|
-
var _default = exports.default = Focusable;
|
package/lib/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Focusable", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _Focusable.Focusable;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _Focusable = require("./Focusable");
|
package/lib/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|