@instructure/ui-selectable 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/Selectable/props.js → babel.config.cjs} +13 -7
- package/package.json +9 -11
- package/lib/Selectable/index.js +0 -279
- 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-selectable
|
|
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-selectable
|
|
@@ -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-selectable",
|
|
3
|
-
"version": "11.6.
|
|
3
|
+
"version": "11.6.1-pr-snapshot-1779894247159",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "A UI component library made by Instructure Inc.",
|
|
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",
|
|
@@ -16,18 +16,18 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.27.6",
|
|
18
18
|
"keycode": "^2",
|
|
19
|
-
"@instructure/
|
|
20
|
-
"@instructure/ui-
|
|
21
|
-
"@instructure/
|
|
22
|
-
"@instructure/ui-
|
|
23
|
-
"@instructure/
|
|
19
|
+
"@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159",
|
|
20
|
+
"@instructure/ui-react-utils": "11.6.1-pr-snapshot-1779894247159",
|
|
21
|
+
"@instructure/console": "11.6.1-pr-snapshot-1779894247159",
|
|
22
|
+
"@instructure/ui-utils": "11.6.1-pr-snapshot-1779894247159",
|
|
23
|
+
"@instructure/ui-dom-utils": "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/Selectable/index.js
DELETED
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.Selectable = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _keycode = _interopRequireDefault(require("keycode"));
|
|
10
|
-
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
11
|
-
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
12
|
-
var _console = require("@instructure/console");
|
|
13
|
-
var _props = require("./props");
|
|
14
|
-
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
15
|
-
var _dec, _class, _Selectable;
|
|
16
|
-
/*
|
|
17
|
-
* The MIT License (MIT)
|
|
18
|
-
*
|
|
19
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
20
|
-
*
|
|
21
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
22
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
23
|
-
* in the Software without restriction, including without limitation the rights
|
|
24
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
25
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
26
|
-
* furnished to do so, subject to the following conditions:
|
|
27
|
-
*
|
|
28
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
29
|
-
* copies or substantial portions of the Software.
|
|
30
|
-
*
|
|
31
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
32
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
33
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
34
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
35
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
36
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
37
|
-
* SOFTWARE.
|
|
38
|
-
*/
|
|
39
|
-
/**
|
|
40
|
-
---
|
|
41
|
-
category: components/utilities
|
|
42
|
-
tags: autocomplete, typeahead, combobox, dropdown, search
|
|
43
|
-
---
|
|
44
|
-
**/
|
|
45
|
-
let Selectable = exports.Selectable = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec(_class = (_Selectable = class Selectable extends _react.Component {
|
|
46
|
-
constructor(...args) {
|
|
47
|
-
super(...args);
|
|
48
|
-
this._id = this.props.id || this.props.deterministicId();
|
|
49
|
-
this._listId = `${this._id}-list`;
|
|
50
|
-
this._descriptionId = `${this._id}-description`;
|
|
51
|
-
this._trigger = null;
|
|
52
|
-
this.isSelectedOption = id => {
|
|
53
|
-
const selectedOptionId = this.props.selectedOptionId;
|
|
54
|
-
if (Array.isArray(selectedOptionId)) {
|
|
55
|
-
return selectedOptionId.indexOf(id) > -1;
|
|
56
|
-
}
|
|
57
|
-
return selectedOptionId === id;
|
|
58
|
-
};
|
|
59
|
-
this.handleOpenClose = event => {
|
|
60
|
-
const _this$props = this.props,
|
|
61
|
-
isShowingOptions = _this$props.isShowingOptions,
|
|
62
|
-
onRequestShowOptions = _this$props.onRequestShowOptions,
|
|
63
|
-
onRequestHideOptions = _this$props.onRequestHideOptions;
|
|
64
|
-
event.preventDefault();
|
|
65
|
-
if (isShowingOptions) {
|
|
66
|
-
onRequestHideOptions === null || onRequestHideOptions === void 0 ? void 0 : onRequestHideOptions(event);
|
|
67
|
-
} else {
|
|
68
|
-
if (!(0, _isActiveElement.isActiveElement)(this._trigger)) {
|
|
69
|
-
;
|
|
70
|
-
this._trigger.focus();
|
|
71
|
-
}
|
|
72
|
-
onRequestShowOptions === null || onRequestShowOptions === void 0 ? void 0 : onRequestShowOptions(event);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
this.handleKeyDown = event => {
|
|
76
|
-
const _this$props2 = this.props,
|
|
77
|
-
isShowingOptions = _this$props2.isShowingOptions,
|
|
78
|
-
highlightedOptionId = _this$props2.highlightedOptionId,
|
|
79
|
-
onRequestHighlightOption = _this$props2.onRequestHighlightOption,
|
|
80
|
-
onRequestHighlightFirstOption = _this$props2.onRequestHighlightFirstOption,
|
|
81
|
-
onRequestHighlightLastOption = _this$props2.onRequestHighlightLastOption,
|
|
82
|
-
onRequestSelectOption = _this$props2.onRequestSelectOption;
|
|
83
|
-
const key = _keycode.default.names[event.keyCode];
|
|
84
|
-
switch (key) {
|
|
85
|
-
case 'space':
|
|
86
|
-
if (!isShowingOptions) {
|
|
87
|
-
// if options hidden, show them
|
|
88
|
-
this.handleOpenClose(event);
|
|
89
|
-
}
|
|
90
|
-
break;
|
|
91
|
-
case 'enter':
|
|
92
|
-
if (highlightedOptionId) {
|
|
93
|
-
// select highlighted option
|
|
94
|
-
event.preventDefault();
|
|
95
|
-
onRequestSelectOption === null || onRequestSelectOption === void 0 ? void 0 : onRequestSelectOption(event, {
|
|
96
|
-
id: highlightedOptionId
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
break;
|
|
100
|
-
case 'down':
|
|
101
|
-
event.preventDefault();
|
|
102
|
-
if (isShowingOptions) {
|
|
103
|
-
// if options showing, change highlight
|
|
104
|
-
onRequestHighlightOption === null || onRequestHighlightOption === void 0 ? void 0 : onRequestHighlightOption(event, {
|
|
105
|
-
direction: 1
|
|
106
|
-
});
|
|
107
|
-
} else {
|
|
108
|
-
// otherwise, show options
|
|
109
|
-
this.handleOpenClose(event);
|
|
110
|
-
}
|
|
111
|
-
break;
|
|
112
|
-
case 'up':
|
|
113
|
-
event.preventDefault();
|
|
114
|
-
if (isShowingOptions) {
|
|
115
|
-
// if options showing, change highlight
|
|
116
|
-
onRequestHighlightOption === null || onRequestHighlightOption === void 0 ? void 0 : onRequestHighlightOption(event, {
|
|
117
|
-
direction: -1
|
|
118
|
-
});
|
|
119
|
-
} else {
|
|
120
|
-
// otherwise, show options
|
|
121
|
-
this.handleOpenClose(event);
|
|
122
|
-
}
|
|
123
|
-
break;
|
|
124
|
-
case 'home':
|
|
125
|
-
if (isShowingOptions) {
|
|
126
|
-
// if options showing, highlight first option
|
|
127
|
-
event.preventDefault();
|
|
128
|
-
onRequestHighlightFirstOption === null || onRequestHighlightFirstOption === void 0 ? void 0 : onRequestHighlightFirstOption(event);
|
|
129
|
-
}
|
|
130
|
-
break;
|
|
131
|
-
case 'end':
|
|
132
|
-
if (isShowingOptions) {
|
|
133
|
-
// if options showing, highlight last option
|
|
134
|
-
event.preventDefault();
|
|
135
|
-
onRequestHighlightLastOption === null || onRequestHighlightLastOption === void 0 ? void 0 : onRequestHighlightLastOption(event);
|
|
136
|
-
}
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
this.handleKeyUp = event => {
|
|
141
|
-
const isShowingOptions = this.props.isShowingOptions;
|
|
142
|
-
const key = _keycode.default.names[event.keyCode];
|
|
143
|
-
if (key === 'esc') {
|
|
144
|
-
if (isShowingOptions) {
|
|
145
|
-
// if options showing, hide them
|
|
146
|
-
this.handleOpenClose(event);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
render() {
|
|
152
|
-
const _this$props3 = this.props,
|
|
153
|
-
isShowingOptions = _this$props3.isShowingOptions,
|
|
154
|
-
highlightedOptionId = _this$props3.highlightedOptionId,
|
|
155
|
-
onRequestHighlightOption = _this$props3.onRequestHighlightOption,
|
|
156
|
-
onRequestSelectOption = _this$props3.onRequestSelectOption,
|
|
157
|
-
children = _this$props3.children,
|
|
158
|
-
_this$props3$render = _this$props3.render,
|
|
159
|
-
render = _this$props3$render === void 0 ? children : _this$props3$render;
|
|
160
|
-
if (typeof render === 'function') {
|
|
161
|
-
return render({
|
|
162
|
-
getRootProps: ({
|
|
163
|
-
onMouseDown,
|
|
164
|
-
...rest
|
|
165
|
-
} = {}) => {
|
|
166
|
-
return {
|
|
167
|
-
onMouseDown: (0, _createChainedFunction.createChainedFunction)(event => {
|
|
168
|
-
// if we call preventDefault, label can't be selected and copied, so we only call it when the options are shown
|
|
169
|
-
if (event.target !== this._trigger && isShowingOptions) {
|
|
170
|
-
event.preventDefault(); // prevent trigger from losing focus
|
|
171
|
-
}
|
|
172
|
-
}, onMouseDown),
|
|
173
|
-
...rest
|
|
174
|
-
};
|
|
175
|
-
},
|
|
176
|
-
getLabelProps: props => {
|
|
177
|
-
return {
|
|
178
|
-
htmlFor: this._id,
|
|
179
|
-
...props
|
|
180
|
-
};
|
|
181
|
-
},
|
|
182
|
-
getTriggerProps: ({
|
|
183
|
-
ref,
|
|
184
|
-
onKeyDown,
|
|
185
|
-
onKeyUp,
|
|
186
|
-
onClick,
|
|
187
|
-
...rest
|
|
188
|
-
} = {}) => {
|
|
189
|
-
return {
|
|
190
|
-
id: this._id,
|
|
191
|
-
ref: (0, _createChainedFunction.createChainedFunction)(ref, el => this._trigger = el),
|
|
192
|
-
'aria-haspopup': 'listbox',
|
|
193
|
-
'aria-expanded': isShowingOptions,
|
|
194
|
-
'aria-controls': isShowingOptions ? this._listId : void 0,
|
|
195
|
-
'aria-describedby': this._descriptionId,
|
|
196
|
-
'aria-activedescendant': isShowingOptions ? highlightedOptionId : void 0,
|
|
197
|
-
onKeyDown: (0, _createChainedFunction.createChainedFunction)(this.handleKeyDown, onKeyDown),
|
|
198
|
-
onKeyUp: (0, _createChainedFunction.createChainedFunction)(this.handleKeyUp, onKeyUp),
|
|
199
|
-
onClick: (0, _createChainedFunction.createChainedFunction)(this.handleOpenClose, onClick),
|
|
200
|
-
...rest
|
|
201
|
-
};
|
|
202
|
-
},
|
|
203
|
-
getInputProps: ({
|
|
204
|
-
readOnly,
|
|
205
|
-
...rest
|
|
206
|
-
} = {}) => {
|
|
207
|
-
return {
|
|
208
|
-
role: 'combobox',
|
|
209
|
-
'aria-autocomplete': readOnly ? 'none' : 'both',
|
|
210
|
-
autoComplete: 'off',
|
|
211
|
-
readOnly,
|
|
212
|
-
...rest
|
|
213
|
-
};
|
|
214
|
-
},
|
|
215
|
-
getListProps: ({
|
|
216
|
-
onMouseDown,
|
|
217
|
-
onClick,
|
|
218
|
-
...rest
|
|
219
|
-
} = {}) => {
|
|
220
|
-
return {
|
|
221
|
-
id: this._listId,
|
|
222
|
-
role: 'listbox',
|
|
223
|
-
onMouseDown: (0, _createChainedFunction.createChainedFunction)(event => {
|
|
224
|
-
event.preventDefault(); // prevent trigger from losing focus
|
|
225
|
-
}, onMouseDown),
|
|
226
|
-
onClick: (0, _createChainedFunction.createChainedFunction)(event => {
|
|
227
|
-
// prevent synthetic event from firing on the document
|
|
228
|
-
// this event could inadvertently close a parent dialog
|
|
229
|
-
event.stopPropagation();
|
|
230
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
231
|
-
}, onClick),
|
|
232
|
-
...rest
|
|
233
|
-
};
|
|
234
|
-
},
|
|
235
|
-
getOptionProps: ({
|
|
236
|
-
id,
|
|
237
|
-
onMouseOver,
|
|
238
|
-
onClick,
|
|
239
|
-
...rest
|
|
240
|
-
} = {}) => {
|
|
241
|
-
(0, _console.logError)(Boolean(id), `[Selectable] Must provide id for each option via \`getOptionProps\`.`);
|
|
242
|
-
return {
|
|
243
|
-
id,
|
|
244
|
-
role: 'option',
|
|
245
|
-
'aria-selected': this.isSelectedOption(id) ? 'true' : 'false',
|
|
246
|
-
onClick: (0, _createChainedFunction.createChainedFunction)(event => {
|
|
247
|
-
onRequestSelectOption === null || onRequestSelectOption === void 0 ? void 0 : onRequestSelectOption(event, {
|
|
248
|
-
id
|
|
249
|
-
});
|
|
250
|
-
}, onClick),
|
|
251
|
-
onMouseOver: (0, _createChainedFunction.createChainedFunction)(event => {
|
|
252
|
-
onRequestHighlightOption === null || onRequestHighlightOption === void 0 ? void 0 : onRequestHighlightOption(event, {
|
|
253
|
-
id
|
|
254
|
-
});
|
|
255
|
-
}, onMouseOver),
|
|
256
|
-
...rest
|
|
257
|
-
};
|
|
258
|
-
},
|
|
259
|
-
getDisabledOptionProps: props => {
|
|
260
|
-
return {
|
|
261
|
-
'aria-disabled': 'true',
|
|
262
|
-
...props
|
|
263
|
-
};
|
|
264
|
-
},
|
|
265
|
-
getDescriptionProps: props => {
|
|
266
|
-
return {
|
|
267
|
-
id: this._descriptionId,
|
|
268
|
-
...props
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
} else {
|
|
273
|
-
return null;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}, _Selectable.displayName = "Selectable", _Selectable.allowedProps = _props.allowedProps, _Selectable.defaultProps = {
|
|
277
|
-
isShowingOptions: false
|
|
278
|
-
}, _Selectable)) || _class);
|
|
279
|
-
var _default = exports.default = Selectable;
|
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, "Selectable", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _Selectable.Selectable;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _Selectable = require("./Selectable");
|
package/lib/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|