@instructure/ui-select 11.7.3-snapshot-25 → 11.7.3-snapshot-27
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 +5 -2
- package/es/Select/v1/Group/index.js +5 -4
- package/es/Select/v1/Option/index.js +9 -8
- package/es/Select/v1/index.js +187 -169
- package/es/Select/v1/styles.js +3 -1
- package/es/Select/v1/theme.js +12 -11
- package/es/Select/v2/Group/index.js +5 -4
- package/es/Select/v2/Option/index.js +9 -8
- package/es/Select/v2/index.js +187 -170
- package/lib/Select/v1/Group/index.js +5 -4
- package/lib/Select/v1/Option/index.js +9 -8
- package/lib/Select/v1/index.js +189 -171
- package/lib/Select/v1/styles.js +3 -1
- package/lib/Select/v1/theme.js +12 -11
- package/lib/Select/v2/Group/index.js +5 -4
- package/lib/Select/v2/Option/index.js +9 -8
- package/lib/Select/v2/index.js +188 -171
- package/package.json +20 -20
- package/tsconfig.build.tsbuildinfo +1 -1
package/lib/Select/v2/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = exports.Select = void 0;
|
|
9
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
9
|
var _react = require("react");
|
|
11
10
|
var utils = _interopRequireWildcard(require("@instructure/ui-utils"));
|
|
12
11
|
var _combineDataCid = require("@instructure/ui-utils/lib/combineDataCid.js");
|
|
@@ -28,10 +27,7 @@ var _Group = require("./Group");
|
|
|
28
27
|
var _Option = require("./Option");
|
|
29
28
|
var _props = require("./props");
|
|
30
29
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
31
|
-
|
|
32
|
-
_excluded2 = ["renderLabel", "inputValue", "placeholder", "isRequired", "shouldNotWrap", "size", "isInline", "width", "htmlSize", "messages", "renderBeforeInput", "renderAfterInput", "onFocus", "onBlur", "onInputChange", "onRequestHideOptions", "layout"],
|
|
33
|
-
_excluded3 = ["ref"];
|
|
34
|
-
var _dec, _dec2, _class, _Select, _Options$Separator, _Options$Separator2;
|
|
30
|
+
var _dec, _dec2, _class;
|
|
35
31
|
/*
|
|
36
32
|
* The MIT License (MIT)
|
|
37
33
|
*
|
|
@@ -65,8 +61,10 @@ const selectSizeToIconSize = {
|
|
|
65
61
|
// because the Select component is re-rendered on every prop change of the <Select.Option>
|
|
66
62
|
// and with a large amount of options, this can cause a lot of unnecessary re-renders.
|
|
67
63
|
const MemoedOption = /*#__PURE__*/(0, _react.memo)(function Opt(props) {
|
|
68
|
-
const
|
|
69
|
-
|
|
64
|
+
const {
|
|
65
|
+
optionsItemProps,
|
|
66
|
+
children
|
|
67
|
+
} = props;
|
|
70
68
|
return (
|
|
71
69
|
// The main <Options> that renders this is always an "ul"
|
|
72
70
|
(0, _jsxRuntime.jsx)(_latest4.Options.Item, {
|
|
@@ -91,58 +89,50 @@ category: components
|
|
|
91
89
|
tags: autocomplete, typeahead, combobox, dropdown, search, form
|
|
92
90
|
---
|
|
93
91
|
**/
|
|
94
|
-
let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default), _dec(_class = _dec2(_class =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
this._input = node;
|
|
119
|
-
(_this$props$inputRef = (_this$props = this.props).inputRef) === null || _this$props$inputRef === void 0 ? void 0 : _this$props$inputRef.call(_this$props, node);
|
|
120
|
-
};
|
|
121
|
-
this.handleListRef = node => {
|
|
122
|
-
var _this$props$listRef, _this$props2;
|
|
123
|
-
(_this$props$listRef = (_this$props2 = this.props).listRef) === null || _this$props$listRef === void 0 ? void 0 : _this$props$listRef.call(_this$props2, node);
|
|
124
|
-
|
|
125
|
-
// store option height to calculate list maxHeight
|
|
126
|
-
if (node && node.querySelector('[role="option"]')) {
|
|
127
|
-
this._optionHeight = node.querySelector('[role="option"]').offsetHeight;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
this.handleInputContainerRef = node => {
|
|
131
|
-
this._inputContainer = node;
|
|
132
|
-
};
|
|
133
|
-
}
|
|
92
|
+
let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default), _dec(_class = _dec2(_class = class Select extends _react.Component {
|
|
93
|
+
static displayName = "Select";
|
|
94
|
+
static componentId = 'Select';
|
|
95
|
+
SCROLL_TOLERANCE = 0.5;
|
|
96
|
+
static allowedProps = _props.allowedProps;
|
|
97
|
+
static defaultProps = {
|
|
98
|
+
inputValue: '',
|
|
99
|
+
isShowingOptions: false,
|
|
100
|
+
size: 'medium',
|
|
101
|
+
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
102
|
+
interaction: undefined,
|
|
103
|
+
isRequired: false,
|
|
104
|
+
isInline: false,
|
|
105
|
+
visibleOptionsCount: 8,
|
|
106
|
+
placement: 'bottom stretch',
|
|
107
|
+
constrain: 'window',
|
|
108
|
+
shouldNotWrap: false,
|
|
109
|
+
scrollToHighlightedOption: true,
|
|
110
|
+
isOptionContentAppliedToInput: false
|
|
111
|
+
};
|
|
112
|
+
static Option = _Option.Option;
|
|
113
|
+
static Group = _Group.Group;
|
|
134
114
|
componentDidMount() {
|
|
135
|
-
|
|
136
|
-
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
115
|
+
this.props.makeStyles?.();
|
|
137
116
|
}
|
|
138
117
|
componentDidUpdate() {
|
|
139
|
-
|
|
140
|
-
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
118
|
+
this.props.makeStyles?.();
|
|
141
119
|
if (this.props.scrollToHighlightedOption) {
|
|
142
120
|
// scroll option into view if needed
|
|
143
121
|
requestAnimationFrame(() => this.scrollToOption(this.highlightedOptionId));
|
|
144
122
|
}
|
|
145
123
|
}
|
|
124
|
+
state = {
|
|
125
|
+
hasInputRef: false
|
|
126
|
+
};
|
|
127
|
+
ref = null;
|
|
128
|
+
_input = null;
|
|
129
|
+
_defaultId = this.props.deterministicId();
|
|
130
|
+
_inputContainer = null;
|
|
131
|
+
_listView = null;
|
|
132
|
+
// temporarily stores actionable options
|
|
133
|
+
_optionIds = [];
|
|
134
|
+
// best guess for first calculation of list height
|
|
135
|
+
_optionHeight = 36;
|
|
146
136
|
focus() {
|
|
147
137
|
this._input && this._input.focus();
|
|
148
138
|
}
|
|
@@ -162,7 +152,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
162
152
|
return this.props.id || this._defaultId;
|
|
163
153
|
}
|
|
164
154
|
get width() {
|
|
165
|
-
return this._inputContainer ? this._inputContainer.offsetWidth :
|
|
155
|
+
return this._inputContainer ? this._inputContainer.offsetWidth : undefined;
|
|
166
156
|
}
|
|
167
157
|
get interaction() {
|
|
168
158
|
return (0, _getInteraction.getInteraction)({
|
|
@@ -211,10 +201,31 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
211
201
|
return selectedOptionId[0];
|
|
212
202
|
}
|
|
213
203
|
if (selectedOptionId.length === 0) {
|
|
214
|
-
return
|
|
204
|
+
return undefined;
|
|
215
205
|
}
|
|
216
206
|
return selectedOptionId;
|
|
217
207
|
}
|
|
208
|
+
handleInputRef = node => {
|
|
209
|
+
// ensures list is positioned with respect to input if list is open on mount
|
|
210
|
+
if (!this.state.hasInputRef) {
|
|
211
|
+
this.setState({
|
|
212
|
+
hasInputRef: true
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
this._input = node;
|
|
216
|
+
this.props.inputRef?.(node);
|
|
217
|
+
};
|
|
218
|
+
handleListRef = node => {
|
|
219
|
+
this.props.listRef?.(node);
|
|
220
|
+
|
|
221
|
+
// store option height to calculate list maxHeight
|
|
222
|
+
if (node && node.querySelector('[role="option"]')) {
|
|
223
|
+
this._optionHeight = node.querySelector('[role="option"]').offsetHeight;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
handleInputContainerRef = node => {
|
|
227
|
+
this._inputContainer = node;
|
|
228
|
+
};
|
|
218
229
|
scrollToOption(id) {
|
|
219
230
|
if (!this._listView || !id) return;
|
|
220
231
|
const option = this._listView.querySelector(`[id="${CSS.escape(id)}"]`);
|
|
@@ -231,22 +242,25 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
231
242
|
}
|
|
232
243
|
}
|
|
233
244
|
highlightOption(event, id) {
|
|
234
|
-
const
|
|
245
|
+
const {
|
|
246
|
+
onRequestHighlightOption
|
|
247
|
+
} = this.props;
|
|
235
248
|
if (id) {
|
|
236
|
-
onRequestHighlightOption
|
|
249
|
+
onRequestHighlightOption?.(event, {
|
|
237
250
|
id
|
|
238
251
|
});
|
|
239
252
|
}
|
|
240
253
|
}
|
|
241
254
|
getEventHandlers() {
|
|
242
|
-
const
|
|
243
|
-
isShowingOptions
|
|
244
|
-
onRequestShowOptions
|
|
245
|
-
onRequestHideOptions
|
|
246
|
-
onRequestSelectOption
|
|
255
|
+
const {
|
|
256
|
+
isShowingOptions,
|
|
257
|
+
onRequestShowOptions,
|
|
258
|
+
onRequestHideOptions,
|
|
259
|
+
onRequestSelectOption
|
|
260
|
+
} = this.props;
|
|
247
261
|
return this.interaction === 'enabled' ? {
|
|
248
262
|
onRequestShowOptions: event => {
|
|
249
|
-
onRequestShowOptions
|
|
263
|
+
onRequestShowOptions?.(event);
|
|
250
264
|
const selectedOptionId = this.selectedOptionId;
|
|
251
265
|
if (selectedOptionId && !Array.isArray(selectedOptionId)) {
|
|
252
266
|
// highlight selected option on show
|
|
@@ -254,7 +268,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
254
268
|
}
|
|
255
269
|
},
|
|
256
270
|
onRequestHideOptions: event => {
|
|
257
|
-
onRequestHideOptions
|
|
271
|
+
onRequestHideOptions?.(event);
|
|
258
272
|
},
|
|
259
273
|
onRequestHighlightOption: (event, {
|
|
260
274
|
id,
|
|
@@ -263,7 +277,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
263
277
|
if (!isShowingOptions) return;
|
|
264
278
|
const highlightedOptionId = this.highlightedOptionId;
|
|
265
279
|
// if id exists, use that
|
|
266
|
-
let highlightId = this._optionIds.indexOf(id) > -1 ? id :
|
|
280
|
+
let highlightId = this._optionIds.indexOf(id) > -1 ? id : undefined;
|
|
267
281
|
if (!highlightId) {
|
|
268
282
|
if (!highlightedOptionId) {
|
|
269
283
|
// nothing highlighted yet, highlight first option
|
|
@@ -271,7 +285,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
271
285
|
} else {
|
|
272
286
|
// find next id based on direction
|
|
273
287
|
const index = this._optionIds.indexOf(highlightedOptionId);
|
|
274
|
-
highlightId = index > -1 ? this._optionIds[index + direction] :
|
|
288
|
+
highlightId = index > -1 ? this._optionIds[index + direction] : undefined;
|
|
275
289
|
}
|
|
276
290
|
}
|
|
277
291
|
if (highlightId) {
|
|
@@ -290,7 +304,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
290
304
|
}) => {
|
|
291
305
|
if (id && this._optionIds.indexOf(id) !== -1) {
|
|
292
306
|
// only select if id exists as a valid option
|
|
293
|
-
onRequestSelectOption
|
|
307
|
+
onRequestSelectOption?.(event, {
|
|
294
308
|
id
|
|
295
309
|
});
|
|
296
310
|
}
|
|
@@ -298,19 +312,21 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
298
312
|
} : {};
|
|
299
313
|
}
|
|
300
314
|
renderOption(option, data) {
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
315
|
+
const {
|
|
316
|
+
getOptionProps,
|
|
317
|
+
getDisabledOptionProps
|
|
318
|
+
} = data;
|
|
319
|
+
const {
|
|
320
|
+
id,
|
|
321
|
+
isDisabled,
|
|
322
|
+
isHighlighted,
|
|
323
|
+
isSelected,
|
|
324
|
+
renderBeforeLabel,
|
|
325
|
+
renderAfterLabel,
|
|
326
|
+
children
|
|
327
|
+
} = option.props;
|
|
311
328
|
const getRenderOptionLabel = renderOptionLabel => {
|
|
312
|
-
|
|
313
|
-
return typeof renderOptionLabel === 'function' && !(renderOptionLabel !== null && renderOptionLabel !== void 0 && (_renderOptionLabel$pr = renderOptionLabel.prototype) !== null && _renderOptionLabel$pr !== void 0 && _renderOptionLabel$pr.isReactComponent) ? renderOptionLabel.bind(null, {
|
|
329
|
+
return typeof renderOptionLabel === 'function' && !renderOptionLabel?.prototype?.isReactComponent ? renderOptionLabel.bind(null, {
|
|
314
330
|
id,
|
|
315
331
|
isDisabled,
|
|
316
332
|
isSelected,
|
|
@@ -318,10 +334,10 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
318
334
|
children
|
|
319
335
|
}) : renderOptionLabel;
|
|
320
336
|
};
|
|
321
|
-
const
|
|
322
|
-
isOptionContentAppliedToInput
|
|
323
|
-
|
|
324
|
-
|
|
337
|
+
const {
|
|
338
|
+
isOptionContentAppliedToInput,
|
|
339
|
+
size = 'medium'
|
|
340
|
+
} = this.props;
|
|
325
341
|
const iconSize = selectSizeToIconSize[size];
|
|
326
342
|
const checkIcon = isSelected && !isOptionContentAppliedToInput ? (0, _jsxRuntime.jsx)(_uiIcons.CheckInstUIIcon, {
|
|
327
343
|
inline: false,
|
|
@@ -337,7 +353,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
337
353
|
}),
|
|
338
354
|
// Options.Item props
|
|
339
355
|
renderBeforeLabel: getRenderOptionLabel(renderBeforeLabel),
|
|
340
|
-
renderAfterLabel: checkIcon
|
|
356
|
+
renderAfterLabel: checkIcon ?? getRenderOptionLabel(renderAfterLabel)
|
|
341
357
|
};
|
|
342
358
|
// should option be treated as highlighted or selected
|
|
343
359
|
if (isSelected && isHighlighted) {
|
|
@@ -367,20 +383,23 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
367
383
|
});
|
|
368
384
|
}
|
|
369
385
|
renderGroup(group, data) {
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
386
|
+
const {
|
|
387
|
+
getOptionProps,
|
|
388
|
+
getDisabledOptionProps,
|
|
389
|
+
isFirstChild,
|
|
390
|
+
isLastChild,
|
|
391
|
+
afterGroup
|
|
392
|
+
} = data;
|
|
393
|
+
const {
|
|
394
|
+
id,
|
|
395
|
+
renderLabel,
|
|
396
|
+
children,
|
|
397
|
+
...rest
|
|
398
|
+
} = group.props;
|
|
380
399
|
const groupChildren = [];
|
|
381
400
|
// add a separator above
|
|
382
401
|
if (!isFirstChild && !afterGroup) {
|
|
383
|
-
groupChildren.push(
|
|
402
|
+
groupChildren.push((0, _jsxRuntime.jsx)(_latest4.Options.Separator, {}));
|
|
384
403
|
}
|
|
385
404
|
// create a sublist as a group
|
|
386
405
|
// a wrapping listitem will be created by Options
|
|
@@ -399,20 +418,23 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
399
418
|
}));
|
|
400
419
|
// add a separator below
|
|
401
420
|
if (!isLastChild) {
|
|
402
|
-
groupChildren.push(
|
|
421
|
+
groupChildren.push((0, _jsxRuntime.jsx)(_latest4.Options.Separator, {}));
|
|
403
422
|
}
|
|
404
423
|
return groupChildren;
|
|
405
424
|
}
|
|
406
425
|
renderList(data) {
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
426
|
+
const {
|
|
427
|
+
getListProps,
|
|
428
|
+
getOptionProps,
|
|
429
|
+
getDisabledOptionProps
|
|
430
|
+
} = data;
|
|
431
|
+
const {
|
|
432
|
+
isShowingOptions,
|
|
433
|
+
optionsMaxWidth,
|
|
434
|
+
optionsMaxHeight,
|
|
435
|
+
visibleOptionsCount,
|
|
436
|
+
children
|
|
437
|
+
} = this.props;
|
|
416
438
|
let lastWasGroup = false;
|
|
417
439
|
const viewProps = isShowingOptions ? {
|
|
418
440
|
display: 'block',
|
|
@@ -463,10 +485,10 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
463
485
|
});
|
|
464
486
|
}
|
|
465
487
|
renderIcon() {
|
|
466
|
-
const
|
|
467
|
-
isShowingOptions
|
|
468
|
-
|
|
469
|
-
|
|
488
|
+
const {
|
|
489
|
+
isShowingOptions,
|
|
490
|
+
size = 'medium'
|
|
491
|
+
} = this.props;
|
|
470
492
|
const iconSize = selectSizeToIconSize[size];
|
|
471
493
|
return (0, _jsxRuntime.jsx)("span", {
|
|
472
494
|
children: isShowingOptions ? (0, _jsxRuntime.jsx)(_uiIcons.ChevronUpInstUIIcon, {
|
|
@@ -523,50 +545,58 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
523
545
|
return defaultReturn;
|
|
524
546
|
}
|
|
525
547
|
handleRenderBeforeInput() {
|
|
526
|
-
const
|
|
527
|
-
renderBeforeInput
|
|
528
|
-
inputValue
|
|
529
|
-
isOptionContentAppliedToInput
|
|
548
|
+
const {
|
|
549
|
+
renderBeforeInput,
|
|
550
|
+
inputValue,
|
|
551
|
+
isOptionContentAppliedToInput
|
|
552
|
+
} = this.props;
|
|
530
553
|
return this.handleInputContentRender(renderBeforeInput, inputValue, isOptionContentAppliedToInput, 'before', null // default for before
|
|
531
554
|
);
|
|
532
555
|
}
|
|
533
556
|
handleRenderAfterInput() {
|
|
534
|
-
const
|
|
535
|
-
renderAfterInput
|
|
536
|
-
inputValue
|
|
537
|
-
isOptionContentAppliedToInput
|
|
557
|
+
const {
|
|
558
|
+
renderAfterInput,
|
|
559
|
+
inputValue,
|
|
560
|
+
isOptionContentAppliedToInput
|
|
561
|
+
} = this.props;
|
|
538
562
|
return this.handleInputContentRender(renderAfterInput, inputValue, isOptionContentAppliedToInput, 'after', this.renderIcon() // default for after
|
|
539
563
|
);
|
|
540
564
|
}
|
|
541
565
|
renderInput(data) {
|
|
542
|
-
const
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
566
|
+
const {
|
|
567
|
+
getInputProps,
|
|
568
|
+
getTriggerProps
|
|
569
|
+
} = data;
|
|
570
|
+
const {
|
|
571
|
+
renderLabel,
|
|
572
|
+
inputValue,
|
|
573
|
+
placeholder,
|
|
574
|
+
isRequired,
|
|
575
|
+
shouldNotWrap,
|
|
576
|
+
size,
|
|
577
|
+
isInline,
|
|
578
|
+
width,
|
|
579
|
+
htmlSize,
|
|
580
|
+
messages,
|
|
581
|
+
renderBeforeInput,
|
|
582
|
+
renderAfterInput,
|
|
583
|
+
onFocus,
|
|
584
|
+
onBlur,
|
|
585
|
+
onInputChange,
|
|
586
|
+
onRequestHideOptions,
|
|
587
|
+
layout,
|
|
588
|
+
...rest
|
|
589
|
+
} = this.props;
|
|
590
|
+
const {
|
|
591
|
+
interaction
|
|
592
|
+
} = this;
|
|
564
593
|
const passthroughProps = (0, _omitProps.omitProps)(rest, Select.allowedProps);
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
594
|
+
const {
|
|
595
|
+
ref,
|
|
596
|
+
...triggerProps
|
|
597
|
+
} = getTriggerProps({
|
|
598
|
+
...passthroughProps
|
|
599
|
+
});
|
|
570
600
|
const isEditable = typeof onInputChange !== 'undefined';
|
|
571
601
|
|
|
572
602
|
// props to ensure screen readers treat uneditable selects as accessible
|
|
@@ -581,7 +611,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
581
611
|
// that its 'read-only' and that this is a 'textfield', see INSTUI-4500
|
|
582
612
|
role: utils.isSafari() || utils.isAndroidOrIOS() || interaction === 'disabled' && utils.isChromium() ? 'button' : 'combobox',
|
|
583
613
|
title: inputValue,
|
|
584
|
-
'aria-autocomplete':
|
|
614
|
+
'aria-autocomplete': undefined,
|
|
585
615
|
'aria-readonly': true
|
|
586
616
|
} : interaction === 'disabled' && utils.isChromium() ? {
|
|
587
617
|
role: 'button'
|
|
@@ -612,14 +642,14 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
612
642
|
// On iOS VoiceOver, if there is a custom element instead of the changing up and down arrow button
|
|
613
643
|
// the listbox closes on a swipe, so a DOM change is enforced by the key change
|
|
614
644
|
// that seems to inform VoiceOver to behave the correct way
|
|
615
|
-
renderAfterInput: utils.isAndroidOrIOS() && renderAfterInput !==
|
|
645
|
+
renderAfterInput: utils.isAndroidOrIOS() && renderAfterInput !== undefined ? (0, _jsxRuntime.jsx)("span", {
|
|
616
646
|
children: this.handleRenderAfterInput()
|
|
617
647
|
}, this.props.isShowingOptions ? 'open' : 'closed') : this.handleRenderAfterInput(),
|
|
618
648
|
// If `inputValue` is provided, we need to pass a default onChange handler,
|
|
619
649
|
// because TextInput `value` is a controlled prop,
|
|
620
650
|
// and onChange is not required for Select
|
|
621
651
|
// (before it was handled by TextInput's defaultProp)
|
|
622
|
-
onChange: typeof onInputChange === 'function' ? onInputChange : inputValue ? () => {} :
|
|
652
|
+
onChange: typeof onInputChange === 'function' ? onInputChange : inputValue ? () => {} : undefined,
|
|
623
653
|
onFocus,
|
|
624
654
|
onBlur: utils.createChainedFunction(onBlur, onRequestHideOptions),
|
|
625
655
|
...overrideProps
|
|
@@ -637,13 +667,14 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
637
667
|
});
|
|
638
668
|
}
|
|
639
669
|
render() {
|
|
640
|
-
const
|
|
641
|
-
constrain
|
|
642
|
-
placement
|
|
643
|
-
mountNode
|
|
644
|
-
assistiveText
|
|
645
|
-
isShowingOptions
|
|
646
|
-
styles
|
|
670
|
+
const {
|
|
671
|
+
constrain,
|
|
672
|
+
placement,
|
|
673
|
+
mountNode,
|
|
674
|
+
assistiveText,
|
|
675
|
+
isShowingOptions,
|
|
676
|
+
styles
|
|
677
|
+
} = this.props;
|
|
647
678
|
// clear temporary option store
|
|
648
679
|
this._optionIds = [];
|
|
649
680
|
const highlightedOptionId = this.highlightedOptionId;
|
|
@@ -672,7 +703,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
672
703
|
getTriggerProps
|
|
673
704
|
}), (0, _jsxRuntime.jsx)("span", {
|
|
674
705
|
...getDescriptionProps(),
|
|
675
|
-
css: styles
|
|
706
|
+
css: styles?.assistiveText,
|
|
676
707
|
children: assistiveText
|
|
677
708
|
}), (0, _jsxRuntime.jsx)(_latest2.Popover, {
|
|
678
709
|
constrain: constrain,
|
|
@@ -681,12 +712,12 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
681
712
|
// in order to be able to navigate through the list items with a swipe.
|
|
682
713
|
// The swipe would result in closing the listbox if mounted elsewhere.
|
|
683
714
|
,
|
|
684
|
-
mountNode: mountNode !==
|
|
715
|
+
mountNode: mountNode !== undefined ? mountNode : utils.isAndroidOrIOS() ? this.ref : undefined,
|
|
685
716
|
positionTarget: this._inputContainer,
|
|
686
717
|
isShowingContent: isShowingOptions,
|
|
687
718
|
shouldReturnFocus: false,
|
|
688
719
|
withArrow: false,
|
|
689
|
-
borderWidth: styles
|
|
720
|
+
borderWidth: styles?.popoverBorderWidth,
|
|
690
721
|
children: this.renderList({
|
|
691
722
|
getListProps,
|
|
692
723
|
getOptionProps,
|
|
@@ -696,19 +727,5 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
696
727
|
})
|
|
697
728
|
});
|
|
698
729
|
}
|
|
699
|
-
}
|
|
700
|
-
inputValue: '',
|
|
701
|
-
isShowingOptions: false,
|
|
702
|
-
size: 'medium',
|
|
703
|
-
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
704
|
-
interaction: void 0,
|
|
705
|
-
isRequired: false,
|
|
706
|
-
isInline: false,
|
|
707
|
-
visibleOptionsCount: 8,
|
|
708
|
-
placement: 'bottom stretch',
|
|
709
|
-
constrain: 'window',
|
|
710
|
-
shouldNotWrap: false,
|
|
711
|
-
scrollToHighlightedOption: true,
|
|
712
|
-
isOptionContentAppliedToInput: false
|
|
713
|
-
}, _Select.Option = _Option.Option, _Select.Group = _Group.Group, _Select)) || _class) || _class);
|
|
730
|
+
}) || _class) || _class);
|
|
714
731
|
var _default = exports.default = Select;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-select",
|
|
3
|
-
"version": "11.7.3-snapshot-
|
|
3
|
+
"version": "11.7.3-snapshot-27",
|
|
4
4
|
"description": "A component for select and autocomplete behavior.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -14,31 +14,31 @@
|
|
|
14
14
|
"bugs": "https://github.com/instructure/instructure-ui/issues",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@babel/runtime": "^7.
|
|
18
|
-
"@instructure/emotion": "11.7.3-snapshot-
|
|
19
|
-
"@instructure/shared-types": "11.7.3-snapshot-
|
|
20
|
-
"@instructure/ui-
|
|
21
|
-
"@instructure/ui-
|
|
22
|
-
"@instructure/ui-dom-utils": "11.7.3-snapshot-
|
|
23
|
-
"@instructure/ui-options": "11.7.3-snapshot-
|
|
24
|
-
"@instructure/ui-popover": "11.7.3-snapshot-
|
|
25
|
-
"@instructure/ui-react-utils": "11.7.3-snapshot-
|
|
26
|
-
"@instructure/ui-
|
|
27
|
-
"@instructure/ui-
|
|
28
|
-
"@instructure/ui-
|
|
29
|
-
"@instructure/ui-
|
|
30
|
-
"@instructure/
|
|
31
|
-
"@instructure/ui-
|
|
32
|
-
"@instructure/
|
|
17
|
+
"@babel/runtime": "^7.29.2",
|
|
18
|
+
"@instructure/emotion": "11.7.3-snapshot-27",
|
|
19
|
+
"@instructure/shared-types": "11.7.3-snapshot-27",
|
|
20
|
+
"@instructure/ui-icons": "11.7.3-snapshot-27",
|
|
21
|
+
"@instructure/ui-form-field": "11.7.3-snapshot-27",
|
|
22
|
+
"@instructure/ui-dom-utils": "11.7.3-snapshot-27",
|
|
23
|
+
"@instructure/ui-options": "11.7.3-snapshot-27",
|
|
24
|
+
"@instructure/ui-popover": "11.7.3-snapshot-27",
|
|
25
|
+
"@instructure/ui-react-utils": "11.7.3-snapshot-27",
|
|
26
|
+
"@instructure/ui-position": "11.7.3-snapshot-27",
|
|
27
|
+
"@instructure/ui-selectable": "11.7.3-snapshot-27",
|
|
28
|
+
"@instructure/ui-text-input": "11.7.3-snapshot-27",
|
|
29
|
+
"@instructure/ui-utils": "11.7.3-snapshot-27",
|
|
30
|
+
"@instructure/uid": "11.7.3-snapshot-27",
|
|
31
|
+
"@instructure/ui-view": "11.7.3-snapshot-27",
|
|
32
|
+
"@instructure/ui-themes": "11.7.3-snapshot-27"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@testing-library/jest-dom": "^6.6.3",
|
|
36
36
|
"@testing-library/react": "15.0.7",
|
|
37
37
|
"@testing-library/user-event": "^14.6.1",
|
|
38
38
|
"vitest": "^3.2.2",
|
|
39
|
-
"@instructure/ui-
|
|
40
|
-
"@instructure/ui-
|
|
41
|
-
"@instructure/ui-
|
|
39
|
+
"@instructure/ui-babel-preset": "11.7.3-snapshot-27",
|
|
40
|
+
"@instructure/ui-scripts": "11.7.3-snapshot-27",
|
|
41
|
+
"@instructure/ui-color-utils": "11.7.3-snapshot-27"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=18 <=19"
|