@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
|
@@ -32,6 +32,11 @@ id: Select.Group
|
|
|
32
32
|
@module Group
|
|
33
33
|
**/
|
|
34
34
|
class Group extends Component {
|
|
35
|
+
static displayName = "Group";
|
|
36
|
+
static componentId = 'Select.Group';
|
|
37
|
+
static allowedProps = allowedProps;
|
|
38
|
+
static defaultProps = {};
|
|
39
|
+
|
|
35
40
|
/* istanbul ignore next */
|
|
36
41
|
render() {
|
|
37
42
|
// this component is only used for prop validation. Select.Group children
|
|
@@ -39,9 +44,5 @@ class Group extends Component {
|
|
|
39
44
|
return null;
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
|
-
Group.displayName = "Group";
|
|
43
|
-
Group.componentId = 'Select.Group';
|
|
44
|
-
Group.allowedProps = allowedProps;
|
|
45
|
-
Group.defaultProps = {};
|
|
46
47
|
export default Group;
|
|
47
48
|
export { Group };
|
|
@@ -32,6 +32,15 @@ id: Select.Option
|
|
|
32
32
|
@module Option
|
|
33
33
|
**/
|
|
34
34
|
class Option extends Component {
|
|
35
|
+
static displayName = "Option";
|
|
36
|
+
static componentId = 'Select.Option';
|
|
37
|
+
static allowedProps = allowedProps;
|
|
38
|
+
static defaultProps = {
|
|
39
|
+
isHighlighted: false,
|
|
40
|
+
isSelected: false,
|
|
41
|
+
isDisabled: false
|
|
42
|
+
};
|
|
43
|
+
|
|
35
44
|
/* istanbul ignore next */
|
|
36
45
|
render() {
|
|
37
46
|
// this component is only used for prop validation. Select.Option children
|
|
@@ -39,13 +48,5 @@ class Option extends Component {
|
|
|
39
48
|
return null;
|
|
40
49
|
}
|
|
41
50
|
}
|
|
42
|
-
Option.displayName = "Option";
|
|
43
|
-
Option.componentId = 'Select.Option';
|
|
44
|
-
Option.allowedProps = allowedProps;
|
|
45
|
-
Option.defaultProps = {
|
|
46
|
-
isHighlighted: false,
|
|
47
|
-
isSelected: false,
|
|
48
|
-
isDisabled: false
|
|
49
|
-
};
|
|
50
51
|
export default Option;
|
|
51
52
|
export { Option };
|
package/es/Select/v2/index.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const _excluded = ["id", "renderLabel", "children"],
|
|
3
|
-
_excluded2 = ["renderLabel", "inputValue", "placeholder", "isRequired", "shouldNotWrap", "size", "isInline", "width", "htmlSize", "messages", "renderBeforeInput", "renderAfterInput", "onFocus", "onBlur", "onInputChange", "onRequestHideOptions", "layout"],
|
|
4
|
-
_excluded3 = ["ref"];
|
|
5
|
-
var _dec, _dec2, _class, _Select, _Options$Separator, _Options$Separator2;
|
|
1
|
+
var _dec, _dec2, _class;
|
|
6
2
|
/*
|
|
7
3
|
* The MIT License (MIT)
|
|
8
4
|
*
|
|
@@ -54,8 +50,10 @@ const selectSizeToIconSize = {
|
|
|
54
50
|
// because the Select component is re-rendered on every prop change of the <Select.Option>
|
|
55
51
|
// and with a large amount of options, this can cause a lot of unnecessary re-renders.
|
|
56
52
|
const MemoedOption = /*#__PURE__*/memo(function Opt(props) {
|
|
57
|
-
const
|
|
58
|
-
|
|
53
|
+
const {
|
|
54
|
+
optionsItemProps,
|
|
55
|
+
children
|
|
56
|
+
} = props;
|
|
59
57
|
return (
|
|
60
58
|
// The main <Options> that renders this is always an "ul"
|
|
61
59
|
_jsx(Options.Item, {
|
|
@@ -80,58 +78,50 @@ category: components
|
|
|
80
78
|
tags: autocomplete, typeahead, combobox, dropdown, search, form
|
|
81
79
|
---
|
|
82
80
|
**/
|
|
83
|
-
let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _dec(_class = _dec2(_class =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
this._input = node;
|
|
108
|
-
(_this$props$inputRef = (_this$props = this.props).inputRef) === null || _this$props$inputRef === void 0 ? void 0 : _this$props$inputRef.call(_this$props, node);
|
|
109
|
-
};
|
|
110
|
-
this.handleListRef = node => {
|
|
111
|
-
var _this$props$listRef, _this$props2;
|
|
112
|
-
(_this$props$listRef = (_this$props2 = this.props).listRef) === null || _this$props$listRef === void 0 ? void 0 : _this$props$listRef.call(_this$props2, node);
|
|
113
|
-
|
|
114
|
-
// store option height to calculate list maxHeight
|
|
115
|
-
if (node && node.querySelector('[role="option"]')) {
|
|
116
|
-
this._optionHeight = node.querySelector('[role="option"]').offsetHeight;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
this.handleInputContainerRef = node => {
|
|
120
|
-
this._inputContainer = node;
|
|
121
|
-
};
|
|
122
|
-
}
|
|
81
|
+
let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _dec(_class = _dec2(_class = class Select extends Component {
|
|
82
|
+
static displayName = "Select";
|
|
83
|
+
static componentId = 'Select';
|
|
84
|
+
SCROLL_TOLERANCE = 0.5;
|
|
85
|
+
static allowedProps = allowedProps;
|
|
86
|
+
static defaultProps = {
|
|
87
|
+
inputValue: '',
|
|
88
|
+
isShowingOptions: false,
|
|
89
|
+
size: 'medium',
|
|
90
|
+
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
91
|
+
interaction: undefined,
|
|
92
|
+
isRequired: false,
|
|
93
|
+
isInline: false,
|
|
94
|
+
visibleOptionsCount: 8,
|
|
95
|
+
placement: 'bottom stretch',
|
|
96
|
+
constrain: 'window',
|
|
97
|
+
shouldNotWrap: false,
|
|
98
|
+
scrollToHighlightedOption: true,
|
|
99
|
+
isOptionContentAppliedToInput: false
|
|
100
|
+
};
|
|
101
|
+
static Option = Option;
|
|
102
|
+
static Group = Group;
|
|
123
103
|
componentDidMount() {
|
|
124
|
-
|
|
125
|
-
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
104
|
+
this.props.makeStyles?.();
|
|
126
105
|
}
|
|
127
106
|
componentDidUpdate() {
|
|
128
|
-
|
|
129
|
-
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
107
|
+
this.props.makeStyles?.();
|
|
130
108
|
if (this.props.scrollToHighlightedOption) {
|
|
131
109
|
// scroll option into view if needed
|
|
132
110
|
requestAnimationFrame(() => this.scrollToOption(this.highlightedOptionId));
|
|
133
111
|
}
|
|
134
112
|
}
|
|
113
|
+
state = {
|
|
114
|
+
hasInputRef: false
|
|
115
|
+
};
|
|
116
|
+
ref = null;
|
|
117
|
+
_input = null;
|
|
118
|
+
_defaultId = this.props.deterministicId();
|
|
119
|
+
_inputContainer = null;
|
|
120
|
+
_listView = null;
|
|
121
|
+
// temporarily stores actionable options
|
|
122
|
+
_optionIds = [];
|
|
123
|
+
// best guess for first calculation of list height
|
|
124
|
+
_optionHeight = 36;
|
|
135
125
|
focus() {
|
|
136
126
|
this._input && this._input.focus();
|
|
137
127
|
}
|
|
@@ -151,7 +141,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
151
141
|
return this.props.id || this._defaultId;
|
|
152
142
|
}
|
|
153
143
|
get width() {
|
|
154
|
-
return this._inputContainer ? this._inputContainer.offsetWidth :
|
|
144
|
+
return this._inputContainer ? this._inputContainer.offsetWidth : undefined;
|
|
155
145
|
}
|
|
156
146
|
get interaction() {
|
|
157
147
|
return getInteraction({
|
|
@@ -200,10 +190,31 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
200
190
|
return selectedOptionId[0];
|
|
201
191
|
}
|
|
202
192
|
if (selectedOptionId.length === 0) {
|
|
203
|
-
return
|
|
193
|
+
return undefined;
|
|
204
194
|
}
|
|
205
195
|
return selectedOptionId;
|
|
206
196
|
}
|
|
197
|
+
handleInputRef = node => {
|
|
198
|
+
// ensures list is positioned with respect to input if list is open on mount
|
|
199
|
+
if (!this.state.hasInputRef) {
|
|
200
|
+
this.setState({
|
|
201
|
+
hasInputRef: true
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
this._input = node;
|
|
205
|
+
this.props.inputRef?.(node);
|
|
206
|
+
};
|
|
207
|
+
handleListRef = node => {
|
|
208
|
+
this.props.listRef?.(node);
|
|
209
|
+
|
|
210
|
+
// store option height to calculate list maxHeight
|
|
211
|
+
if (node && node.querySelector('[role="option"]')) {
|
|
212
|
+
this._optionHeight = node.querySelector('[role="option"]').offsetHeight;
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
handleInputContainerRef = node => {
|
|
216
|
+
this._inputContainer = node;
|
|
217
|
+
};
|
|
207
218
|
scrollToOption(id) {
|
|
208
219
|
if (!this._listView || !id) return;
|
|
209
220
|
const option = this._listView.querySelector(`[id="${CSS.escape(id)}"]`);
|
|
@@ -220,22 +231,25 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
220
231
|
}
|
|
221
232
|
}
|
|
222
233
|
highlightOption(event, id) {
|
|
223
|
-
const
|
|
234
|
+
const {
|
|
235
|
+
onRequestHighlightOption
|
|
236
|
+
} = this.props;
|
|
224
237
|
if (id) {
|
|
225
|
-
onRequestHighlightOption
|
|
238
|
+
onRequestHighlightOption?.(event, {
|
|
226
239
|
id
|
|
227
240
|
});
|
|
228
241
|
}
|
|
229
242
|
}
|
|
230
243
|
getEventHandlers() {
|
|
231
|
-
const
|
|
232
|
-
isShowingOptions
|
|
233
|
-
onRequestShowOptions
|
|
234
|
-
onRequestHideOptions
|
|
235
|
-
onRequestSelectOption
|
|
244
|
+
const {
|
|
245
|
+
isShowingOptions,
|
|
246
|
+
onRequestShowOptions,
|
|
247
|
+
onRequestHideOptions,
|
|
248
|
+
onRequestSelectOption
|
|
249
|
+
} = this.props;
|
|
236
250
|
return this.interaction === 'enabled' ? {
|
|
237
251
|
onRequestShowOptions: event => {
|
|
238
|
-
onRequestShowOptions
|
|
252
|
+
onRequestShowOptions?.(event);
|
|
239
253
|
const selectedOptionId = this.selectedOptionId;
|
|
240
254
|
if (selectedOptionId && !Array.isArray(selectedOptionId)) {
|
|
241
255
|
// highlight selected option on show
|
|
@@ -243,7 +257,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
243
257
|
}
|
|
244
258
|
},
|
|
245
259
|
onRequestHideOptions: event => {
|
|
246
|
-
onRequestHideOptions
|
|
260
|
+
onRequestHideOptions?.(event);
|
|
247
261
|
},
|
|
248
262
|
onRequestHighlightOption: (event, {
|
|
249
263
|
id,
|
|
@@ -252,7 +266,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
252
266
|
if (!isShowingOptions) return;
|
|
253
267
|
const highlightedOptionId = this.highlightedOptionId;
|
|
254
268
|
// if id exists, use that
|
|
255
|
-
let highlightId = this._optionIds.indexOf(id) > -1 ? id :
|
|
269
|
+
let highlightId = this._optionIds.indexOf(id) > -1 ? id : undefined;
|
|
256
270
|
if (!highlightId) {
|
|
257
271
|
if (!highlightedOptionId) {
|
|
258
272
|
// nothing highlighted yet, highlight first option
|
|
@@ -260,7 +274,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
260
274
|
} else {
|
|
261
275
|
// find next id based on direction
|
|
262
276
|
const index = this._optionIds.indexOf(highlightedOptionId);
|
|
263
|
-
highlightId = index > -1 ? this._optionIds[index + direction] :
|
|
277
|
+
highlightId = index > -1 ? this._optionIds[index + direction] : undefined;
|
|
264
278
|
}
|
|
265
279
|
}
|
|
266
280
|
if (highlightId) {
|
|
@@ -279,7 +293,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
279
293
|
}) => {
|
|
280
294
|
if (id && this._optionIds.indexOf(id) !== -1) {
|
|
281
295
|
// only select if id exists as a valid option
|
|
282
|
-
onRequestSelectOption
|
|
296
|
+
onRequestSelectOption?.(event, {
|
|
283
297
|
id
|
|
284
298
|
});
|
|
285
299
|
}
|
|
@@ -287,19 +301,21 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
287
301
|
} : {};
|
|
288
302
|
}
|
|
289
303
|
renderOption(option, data) {
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
304
|
+
const {
|
|
305
|
+
getOptionProps,
|
|
306
|
+
getDisabledOptionProps
|
|
307
|
+
} = data;
|
|
308
|
+
const {
|
|
309
|
+
id,
|
|
310
|
+
isDisabled,
|
|
311
|
+
isHighlighted,
|
|
312
|
+
isSelected,
|
|
313
|
+
renderBeforeLabel,
|
|
314
|
+
renderAfterLabel,
|
|
315
|
+
children
|
|
316
|
+
} = option.props;
|
|
300
317
|
const getRenderOptionLabel = renderOptionLabel => {
|
|
301
|
-
|
|
302
|
-
return typeof renderOptionLabel === 'function' && !(renderOptionLabel !== null && renderOptionLabel !== void 0 && (_renderOptionLabel$pr = renderOptionLabel.prototype) !== null && _renderOptionLabel$pr !== void 0 && _renderOptionLabel$pr.isReactComponent) ? renderOptionLabel.bind(null, {
|
|
318
|
+
return typeof renderOptionLabel === 'function' && !renderOptionLabel?.prototype?.isReactComponent ? renderOptionLabel.bind(null, {
|
|
303
319
|
id,
|
|
304
320
|
isDisabled,
|
|
305
321
|
isSelected,
|
|
@@ -307,10 +323,10 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
307
323
|
children
|
|
308
324
|
}) : renderOptionLabel;
|
|
309
325
|
};
|
|
310
|
-
const
|
|
311
|
-
isOptionContentAppliedToInput
|
|
312
|
-
|
|
313
|
-
|
|
326
|
+
const {
|
|
327
|
+
isOptionContentAppliedToInput,
|
|
328
|
+
size = 'medium'
|
|
329
|
+
} = this.props;
|
|
314
330
|
const iconSize = selectSizeToIconSize[size];
|
|
315
331
|
const checkIcon = isSelected && !isOptionContentAppliedToInput ? _jsx(CheckInstUIIcon, {
|
|
316
332
|
inline: false,
|
|
@@ -326,7 +342,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
326
342
|
}),
|
|
327
343
|
// Options.Item props
|
|
328
344
|
renderBeforeLabel: getRenderOptionLabel(renderBeforeLabel),
|
|
329
|
-
renderAfterLabel: checkIcon
|
|
345
|
+
renderAfterLabel: checkIcon ?? getRenderOptionLabel(renderAfterLabel)
|
|
330
346
|
};
|
|
331
347
|
// should option be treated as highlighted or selected
|
|
332
348
|
if (isSelected && isHighlighted) {
|
|
@@ -356,20 +372,23 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
356
372
|
});
|
|
357
373
|
}
|
|
358
374
|
renderGroup(group, data) {
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
375
|
+
const {
|
|
376
|
+
getOptionProps,
|
|
377
|
+
getDisabledOptionProps,
|
|
378
|
+
isFirstChild,
|
|
379
|
+
isLastChild,
|
|
380
|
+
afterGroup
|
|
381
|
+
} = data;
|
|
382
|
+
const {
|
|
383
|
+
id,
|
|
384
|
+
renderLabel,
|
|
385
|
+
children,
|
|
386
|
+
...rest
|
|
387
|
+
} = group.props;
|
|
369
388
|
const groupChildren = [];
|
|
370
389
|
// add a separator above
|
|
371
390
|
if (!isFirstChild && !afterGroup) {
|
|
372
|
-
groupChildren.push(
|
|
391
|
+
groupChildren.push(_jsx(Options.Separator, {}));
|
|
373
392
|
}
|
|
374
393
|
// create a sublist as a group
|
|
375
394
|
// a wrapping listitem will be created by Options
|
|
@@ -388,20 +407,23 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
388
407
|
}));
|
|
389
408
|
// add a separator below
|
|
390
409
|
if (!isLastChild) {
|
|
391
|
-
groupChildren.push(
|
|
410
|
+
groupChildren.push(_jsx(Options.Separator, {}));
|
|
392
411
|
}
|
|
393
412
|
return groupChildren;
|
|
394
413
|
}
|
|
395
414
|
renderList(data) {
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
415
|
+
const {
|
|
416
|
+
getListProps,
|
|
417
|
+
getOptionProps,
|
|
418
|
+
getDisabledOptionProps
|
|
419
|
+
} = data;
|
|
420
|
+
const {
|
|
421
|
+
isShowingOptions,
|
|
422
|
+
optionsMaxWidth,
|
|
423
|
+
optionsMaxHeight,
|
|
424
|
+
visibleOptionsCount,
|
|
425
|
+
children
|
|
426
|
+
} = this.props;
|
|
405
427
|
let lastWasGroup = false;
|
|
406
428
|
const viewProps = isShowingOptions ? {
|
|
407
429
|
display: 'block',
|
|
@@ -452,10 +474,10 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
452
474
|
});
|
|
453
475
|
}
|
|
454
476
|
renderIcon() {
|
|
455
|
-
const
|
|
456
|
-
isShowingOptions
|
|
457
|
-
|
|
458
|
-
|
|
477
|
+
const {
|
|
478
|
+
isShowingOptions,
|
|
479
|
+
size = 'medium'
|
|
480
|
+
} = this.props;
|
|
459
481
|
const iconSize = selectSizeToIconSize[size];
|
|
460
482
|
return _jsx("span", {
|
|
461
483
|
children: isShowingOptions ? _jsx(ChevronUpInstUIIcon, {
|
|
@@ -512,50 +534,58 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
512
534
|
return defaultReturn;
|
|
513
535
|
}
|
|
514
536
|
handleRenderBeforeInput() {
|
|
515
|
-
const
|
|
516
|
-
renderBeforeInput
|
|
517
|
-
inputValue
|
|
518
|
-
isOptionContentAppliedToInput
|
|
537
|
+
const {
|
|
538
|
+
renderBeforeInput,
|
|
539
|
+
inputValue,
|
|
540
|
+
isOptionContentAppliedToInput
|
|
541
|
+
} = this.props;
|
|
519
542
|
return this.handleInputContentRender(renderBeforeInput, inputValue, isOptionContentAppliedToInput, 'before', null // default for before
|
|
520
543
|
);
|
|
521
544
|
}
|
|
522
545
|
handleRenderAfterInput() {
|
|
523
|
-
const
|
|
524
|
-
renderAfterInput
|
|
525
|
-
inputValue
|
|
526
|
-
isOptionContentAppliedToInput
|
|
546
|
+
const {
|
|
547
|
+
renderAfterInput,
|
|
548
|
+
inputValue,
|
|
549
|
+
isOptionContentAppliedToInput
|
|
550
|
+
} = this.props;
|
|
527
551
|
return this.handleInputContentRender(renderAfterInput, inputValue, isOptionContentAppliedToInput, 'after', this.renderIcon() // default for after
|
|
528
552
|
);
|
|
529
553
|
}
|
|
530
554
|
renderInput(data) {
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
555
|
+
const {
|
|
556
|
+
getInputProps,
|
|
557
|
+
getTriggerProps
|
|
558
|
+
} = data;
|
|
559
|
+
const {
|
|
560
|
+
renderLabel,
|
|
561
|
+
inputValue,
|
|
562
|
+
placeholder,
|
|
563
|
+
isRequired,
|
|
564
|
+
shouldNotWrap,
|
|
565
|
+
size,
|
|
566
|
+
isInline,
|
|
567
|
+
width,
|
|
568
|
+
htmlSize,
|
|
569
|
+
messages,
|
|
570
|
+
renderBeforeInput,
|
|
571
|
+
renderAfterInput,
|
|
572
|
+
onFocus,
|
|
573
|
+
onBlur,
|
|
574
|
+
onInputChange,
|
|
575
|
+
onRequestHideOptions,
|
|
576
|
+
layout,
|
|
577
|
+
...rest
|
|
578
|
+
} = this.props;
|
|
579
|
+
const {
|
|
580
|
+
interaction
|
|
581
|
+
} = this;
|
|
553
582
|
const passthroughProps = omitProps(rest, Select.allowedProps);
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
583
|
+
const {
|
|
584
|
+
ref,
|
|
585
|
+
...triggerProps
|
|
586
|
+
} = getTriggerProps({
|
|
587
|
+
...passthroughProps
|
|
588
|
+
});
|
|
559
589
|
const isEditable = typeof onInputChange !== 'undefined';
|
|
560
590
|
|
|
561
591
|
// props to ensure screen readers treat uneditable selects as accessible
|
|
@@ -570,7 +600,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
570
600
|
// that its 'read-only' and that this is a 'textfield', see INSTUI-4500
|
|
571
601
|
role: utils.isSafari() || utils.isAndroidOrIOS() || interaction === 'disabled' && utils.isChromium() ? 'button' : 'combobox',
|
|
572
602
|
title: inputValue,
|
|
573
|
-
'aria-autocomplete':
|
|
603
|
+
'aria-autocomplete': undefined,
|
|
574
604
|
'aria-readonly': true
|
|
575
605
|
} : interaction === 'disabled' && utils.isChromium() ? {
|
|
576
606
|
role: 'button'
|
|
@@ -601,14 +631,14 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
601
631
|
// On iOS VoiceOver, if there is a custom element instead of the changing up and down arrow button
|
|
602
632
|
// the listbox closes on a swipe, so a DOM change is enforced by the key change
|
|
603
633
|
// that seems to inform VoiceOver to behave the correct way
|
|
604
|
-
renderAfterInput: utils.isAndroidOrIOS() && renderAfterInput !==
|
|
634
|
+
renderAfterInput: utils.isAndroidOrIOS() && renderAfterInput !== undefined ? _jsx("span", {
|
|
605
635
|
children: this.handleRenderAfterInput()
|
|
606
636
|
}, this.props.isShowingOptions ? 'open' : 'closed') : this.handleRenderAfterInput(),
|
|
607
637
|
// If `inputValue` is provided, we need to pass a default onChange handler,
|
|
608
638
|
// because TextInput `value` is a controlled prop,
|
|
609
639
|
// and onChange is not required for Select
|
|
610
640
|
// (before it was handled by TextInput's defaultProp)
|
|
611
|
-
onChange: typeof onInputChange === 'function' ? onInputChange : inputValue ? () => {} :
|
|
641
|
+
onChange: typeof onInputChange === 'function' ? onInputChange : inputValue ? () => {} : undefined,
|
|
612
642
|
onFocus,
|
|
613
643
|
onBlur: utils.createChainedFunction(onBlur, onRequestHideOptions),
|
|
614
644
|
...overrideProps
|
|
@@ -626,13 +656,14 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
626
656
|
});
|
|
627
657
|
}
|
|
628
658
|
render() {
|
|
629
|
-
const
|
|
630
|
-
constrain
|
|
631
|
-
placement
|
|
632
|
-
mountNode
|
|
633
|
-
assistiveText
|
|
634
|
-
isShowingOptions
|
|
635
|
-
styles
|
|
659
|
+
const {
|
|
660
|
+
constrain,
|
|
661
|
+
placement,
|
|
662
|
+
mountNode,
|
|
663
|
+
assistiveText,
|
|
664
|
+
isShowingOptions,
|
|
665
|
+
styles
|
|
666
|
+
} = this.props;
|
|
636
667
|
// clear temporary option store
|
|
637
668
|
this._optionIds = [];
|
|
638
669
|
const highlightedOptionId = this.highlightedOptionId;
|
|
@@ -661,7 +692,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
661
692
|
getTriggerProps
|
|
662
693
|
}), _jsx("span", {
|
|
663
694
|
...getDescriptionProps(),
|
|
664
|
-
css: styles
|
|
695
|
+
css: styles?.assistiveText,
|
|
665
696
|
children: assistiveText
|
|
666
697
|
}), _jsx(Popover, {
|
|
667
698
|
constrain: constrain,
|
|
@@ -670,12 +701,12 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
670
701
|
// in order to be able to navigate through the list items with a swipe.
|
|
671
702
|
// The swipe would result in closing the listbox if mounted elsewhere.
|
|
672
703
|
,
|
|
673
|
-
mountNode: mountNode !==
|
|
704
|
+
mountNode: mountNode !== undefined ? mountNode : utils.isAndroidOrIOS() ? this.ref : undefined,
|
|
674
705
|
positionTarget: this._inputContainer,
|
|
675
706
|
isShowingContent: isShowingOptions,
|
|
676
707
|
shouldReturnFocus: false,
|
|
677
708
|
withArrow: false,
|
|
678
|
-
borderWidth: styles
|
|
709
|
+
borderWidth: styles?.popoverBorderWidth,
|
|
679
710
|
children: this.renderList({
|
|
680
711
|
getListProps,
|
|
681
712
|
getOptionProps,
|
|
@@ -685,20 +716,6 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _d
|
|
|
685
716
|
})
|
|
686
717
|
});
|
|
687
718
|
}
|
|
688
|
-
}
|
|
689
|
-
inputValue: '',
|
|
690
|
-
isShowingOptions: false,
|
|
691
|
-
size: 'medium',
|
|
692
|
-
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
693
|
-
interaction: void 0,
|
|
694
|
-
isRequired: false,
|
|
695
|
-
isInline: false,
|
|
696
|
-
visibleOptionsCount: 8,
|
|
697
|
-
placement: 'bottom stretch',
|
|
698
|
-
constrain: 'window',
|
|
699
|
-
shouldNotWrap: false,
|
|
700
|
-
scrollToHighlightedOption: true,
|
|
701
|
-
isOptionContentAppliedToInput: false
|
|
702
|
-
}, _Select.Option = Option, _Select.Group = Group, _Select)) || _class) || _class);
|
|
719
|
+
}) || _class) || _class);
|
|
703
720
|
export default Select;
|
|
704
721
|
export { Select };
|
|
@@ -38,6 +38,11 @@ id: Select.Group
|
|
|
38
38
|
@module Group
|
|
39
39
|
**/
|
|
40
40
|
class Group extends _react.Component {
|
|
41
|
+
static displayName = "Group";
|
|
42
|
+
static componentId = 'Select.Group';
|
|
43
|
+
static allowedProps = _props.allowedProps;
|
|
44
|
+
static defaultProps = {};
|
|
45
|
+
|
|
41
46
|
/* istanbul ignore next */
|
|
42
47
|
render() {
|
|
43
48
|
// this component is only used for prop validation. Select.Group children
|
|
@@ -46,8 +51,4 @@ class Group extends _react.Component {
|
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
53
|
exports.Group = Group;
|
|
49
|
-
Group.displayName = "Group";
|
|
50
|
-
Group.componentId = 'Select.Group';
|
|
51
|
-
Group.allowedProps = _props.allowedProps;
|
|
52
|
-
Group.defaultProps = {};
|
|
53
54
|
var _default = exports.default = Group;
|
|
@@ -38,6 +38,15 @@ id: Select.Option
|
|
|
38
38
|
@module Option
|
|
39
39
|
**/
|
|
40
40
|
class Option extends _react.Component {
|
|
41
|
+
static displayName = "Option";
|
|
42
|
+
static componentId = 'Select.Option';
|
|
43
|
+
static allowedProps = _props.allowedProps;
|
|
44
|
+
static defaultProps = {
|
|
45
|
+
isHighlighted: false,
|
|
46
|
+
isSelected: false,
|
|
47
|
+
isDisabled: false
|
|
48
|
+
};
|
|
49
|
+
|
|
41
50
|
/* istanbul ignore next */
|
|
42
51
|
render() {
|
|
43
52
|
// this component is only used for prop validation. Select.Option children
|
|
@@ -46,12 +55,4 @@ class Option extends _react.Component {
|
|
|
46
55
|
}
|
|
47
56
|
}
|
|
48
57
|
exports.Option = Option;
|
|
49
|
-
Option.displayName = "Option";
|
|
50
|
-
Option.componentId = 'Select.Option';
|
|
51
|
-
Option.allowedProps = _props.allowedProps;
|
|
52
|
-
Option.defaultProps = {
|
|
53
|
-
isHighlighted: false,
|
|
54
|
-
isSelected: false,
|
|
55
|
-
isDisabled: false
|
|
56
|
-
};
|
|
57
58
|
var _default = exports.default = Option;
|