@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/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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.7.3-snapshot-
|
|
6
|
+
## [11.7.3-snapshot-27](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-27) (2026-05-05)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **many:** update dependencies, remove lots of Babel plugins, remove Webpack 4 support ([f916fca](https://github.com/instructure/instructure-ui/commit/f916fcafdddcb2d7de401f93e8ff92cfdfa47bba))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
|
@@ -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/v1/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, _IconArrowOpenUpLine, _IconArrowOpenDownLin;
|
|
1
|
+
var _dec, _dec2, _class;
|
|
6
2
|
/*
|
|
7
3
|
* The MIT License (MIT)
|
|
8
4
|
*
|
|
@@ -50,8 +46,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
|
50
46
|
// because the Select component is re-rendered on every prop change of the <Select.Option>
|
|
51
47
|
// and with a large amount of options, this can cause a lot of unnecessary re-renders.
|
|
52
48
|
const MemoedOption = /*#__PURE__*/memo(function Opt(props) {
|
|
53
|
-
const
|
|
54
|
-
|
|
49
|
+
const {
|
|
50
|
+
optionsItemProps,
|
|
51
|
+
children
|
|
52
|
+
} = props;
|
|
55
53
|
return (
|
|
56
54
|
// The main <Options> that renders this is always an "ul"
|
|
57
55
|
_jsx(Options.Item, {
|
|
@@ -76,58 +74,50 @@ category: components
|
|
|
76
74
|
tags: autocomplete, typeahead, combobox, dropdown, search, form
|
|
77
75
|
---
|
|
78
76
|
**/
|
|
79
|
-
let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
this._input = node;
|
|
104
|
-
(_this$props$inputRef = (_this$props = this.props).inputRef) === null || _this$props$inputRef === void 0 ? void 0 : _this$props$inputRef.call(_this$props, node);
|
|
105
|
-
};
|
|
106
|
-
this.handleListRef = node => {
|
|
107
|
-
var _this$props$listRef, _this$props2;
|
|
108
|
-
(_this$props$listRef = (_this$props2 = this.props).listRef) === null || _this$props$listRef === void 0 ? void 0 : _this$props$listRef.call(_this$props2, node);
|
|
109
|
-
|
|
110
|
-
// store option height to calculate list maxHeight
|
|
111
|
-
if (node && node.querySelector('[role="option"]')) {
|
|
112
|
-
this._optionHeight = node.querySelector('[role="option"]').offsetHeight;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
this.handleInputContainerRef = node => {
|
|
116
|
-
this._inputContainer = node;
|
|
117
|
-
};
|
|
118
|
-
}
|
|
77
|
+
let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = class Select extends Component {
|
|
78
|
+
static displayName = "Select";
|
|
79
|
+
static componentId = 'Select';
|
|
80
|
+
SCROLL_TOLERANCE = 0.5;
|
|
81
|
+
static allowedProps = allowedProps;
|
|
82
|
+
static defaultProps = {
|
|
83
|
+
inputValue: '',
|
|
84
|
+
isShowingOptions: false,
|
|
85
|
+
size: 'medium',
|
|
86
|
+
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
87
|
+
interaction: undefined,
|
|
88
|
+
isRequired: false,
|
|
89
|
+
isInline: false,
|
|
90
|
+
visibleOptionsCount: 8,
|
|
91
|
+
placement: 'bottom stretch',
|
|
92
|
+
constrain: 'window',
|
|
93
|
+
shouldNotWrap: false,
|
|
94
|
+
scrollToHighlightedOption: true,
|
|
95
|
+
isOptionContentAppliedToInput: false
|
|
96
|
+
};
|
|
97
|
+
static Option = Option;
|
|
98
|
+
static Group = Group;
|
|
119
99
|
componentDidMount() {
|
|
120
|
-
|
|
121
|
-
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
100
|
+
this.props.makeStyles?.();
|
|
122
101
|
}
|
|
123
102
|
componentDidUpdate() {
|
|
124
|
-
|
|
125
|
-
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
103
|
+
this.props.makeStyles?.();
|
|
126
104
|
if (this.props.scrollToHighlightedOption) {
|
|
127
105
|
// scroll option into view if needed
|
|
128
106
|
requestAnimationFrame(() => this.scrollToOption(this.highlightedOptionId));
|
|
129
107
|
}
|
|
130
108
|
}
|
|
109
|
+
state = {
|
|
110
|
+
hasInputRef: false
|
|
111
|
+
};
|
|
112
|
+
ref = null;
|
|
113
|
+
_input = null;
|
|
114
|
+
_defaultId = this.props.deterministicId();
|
|
115
|
+
_inputContainer = null;
|
|
116
|
+
_listView = null;
|
|
117
|
+
// temporarily stores actionable options
|
|
118
|
+
_optionIds = [];
|
|
119
|
+
// best guess for first calculation of list height
|
|
120
|
+
_optionHeight = 36;
|
|
131
121
|
focus() {
|
|
132
122
|
this._input && this._input.focus();
|
|
133
123
|
}
|
|
@@ -147,7 +137,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
147
137
|
return this.props.id || this._defaultId;
|
|
148
138
|
}
|
|
149
139
|
get width() {
|
|
150
|
-
return this._inputContainer ? this._inputContainer.offsetWidth :
|
|
140
|
+
return this._inputContainer ? this._inputContainer.offsetWidth : undefined;
|
|
151
141
|
}
|
|
152
142
|
get interaction() {
|
|
153
143
|
return getInteraction({
|
|
@@ -196,10 +186,31 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
196
186
|
return selectedOptionId[0];
|
|
197
187
|
}
|
|
198
188
|
if (selectedOptionId.length === 0) {
|
|
199
|
-
return
|
|
189
|
+
return undefined;
|
|
200
190
|
}
|
|
201
191
|
return selectedOptionId;
|
|
202
192
|
}
|
|
193
|
+
handleInputRef = node => {
|
|
194
|
+
// ensures list is positioned with respect to input if list is open on mount
|
|
195
|
+
if (!this.state.hasInputRef) {
|
|
196
|
+
this.setState({
|
|
197
|
+
hasInputRef: true
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
this._input = node;
|
|
201
|
+
this.props.inputRef?.(node);
|
|
202
|
+
};
|
|
203
|
+
handleListRef = node => {
|
|
204
|
+
this.props.listRef?.(node);
|
|
205
|
+
|
|
206
|
+
// store option height to calculate list maxHeight
|
|
207
|
+
if (node && node.querySelector('[role="option"]')) {
|
|
208
|
+
this._optionHeight = node.querySelector('[role="option"]').offsetHeight;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
handleInputContainerRef = node => {
|
|
212
|
+
this._inputContainer = node;
|
|
213
|
+
};
|
|
203
214
|
scrollToOption(id) {
|
|
204
215
|
if (!this._listView || !id) return;
|
|
205
216
|
const option = this._listView.querySelector(`[id="${CSS.escape(id)}"]`);
|
|
@@ -216,22 +227,25 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
216
227
|
}
|
|
217
228
|
}
|
|
218
229
|
highlightOption(event, id) {
|
|
219
|
-
const
|
|
230
|
+
const {
|
|
231
|
+
onRequestHighlightOption
|
|
232
|
+
} = this.props;
|
|
220
233
|
if (id) {
|
|
221
|
-
onRequestHighlightOption
|
|
234
|
+
onRequestHighlightOption?.(event, {
|
|
222
235
|
id
|
|
223
236
|
});
|
|
224
237
|
}
|
|
225
238
|
}
|
|
226
239
|
getEventHandlers() {
|
|
227
|
-
const
|
|
228
|
-
isShowingOptions
|
|
229
|
-
onRequestShowOptions
|
|
230
|
-
onRequestHideOptions
|
|
231
|
-
onRequestSelectOption
|
|
240
|
+
const {
|
|
241
|
+
isShowingOptions,
|
|
242
|
+
onRequestShowOptions,
|
|
243
|
+
onRequestHideOptions,
|
|
244
|
+
onRequestSelectOption
|
|
245
|
+
} = this.props;
|
|
232
246
|
return this.interaction === 'enabled' ? {
|
|
233
247
|
onRequestShowOptions: event => {
|
|
234
|
-
onRequestShowOptions
|
|
248
|
+
onRequestShowOptions?.(event);
|
|
235
249
|
const selectedOptionId = this.selectedOptionId;
|
|
236
250
|
if (selectedOptionId && !Array.isArray(selectedOptionId)) {
|
|
237
251
|
// highlight selected option on show
|
|
@@ -239,7 +253,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
239
253
|
}
|
|
240
254
|
},
|
|
241
255
|
onRequestHideOptions: event => {
|
|
242
|
-
onRequestHideOptions
|
|
256
|
+
onRequestHideOptions?.(event);
|
|
243
257
|
},
|
|
244
258
|
onRequestHighlightOption: (event, {
|
|
245
259
|
id,
|
|
@@ -248,7 +262,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
248
262
|
if (!isShowingOptions) return;
|
|
249
263
|
const highlightedOptionId = this.highlightedOptionId;
|
|
250
264
|
// if id exists, use that
|
|
251
|
-
let highlightId = this._optionIds.indexOf(id) > -1 ? id :
|
|
265
|
+
let highlightId = this._optionIds.indexOf(id) > -1 ? id : undefined;
|
|
252
266
|
if (!highlightId) {
|
|
253
267
|
if (!highlightedOptionId) {
|
|
254
268
|
// nothing highlighted yet, highlight first option
|
|
@@ -256,7 +270,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
256
270
|
} else {
|
|
257
271
|
// find next id based on direction
|
|
258
272
|
const index = this._optionIds.indexOf(highlightedOptionId);
|
|
259
|
-
highlightId = index > -1 ? this._optionIds[index + direction] :
|
|
273
|
+
highlightId = index > -1 ? this._optionIds[index + direction] : undefined;
|
|
260
274
|
}
|
|
261
275
|
}
|
|
262
276
|
if (highlightId) {
|
|
@@ -275,7 +289,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
275
289
|
}) => {
|
|
276
290
|
if (id && this._optionIds.indexOf(id) !== -1) {
|
|
277
291
|
// only select if id exists as a valid option
|
|
278
|
-
onRequestSelectOption
|
|
292
|
+
onRequestSelectOption?.(event, {
|
|
279
293
|
id
|
|
280
294
|
});
|
|
281
295
|
}
|
|
@@ -283,19 +297,21 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
283
297
|
} : {};
|
|
284
298
|
}
|
|
285
299
|
renderOption(option, data) {
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
300
|
+
const {
|
|
301
|
+
getOptionProps,
|
|
302
|
+
getDisabledOptionProps
|
|
303
|
+
} = data;
|
|
304
|
+
const {
|
|
305
|
+
id,
|
|
306
|
+
isDisabled,
|
|
307
|
+
isHighlighted,
|
|
308
|
+
isSelected,
|
|
309
|
+
renderBeforeLabel,
|
|
310
|
+
renderAfterLabel,
|
|
311
|
+
children
|
|
312
|
+
} = option.props;
|
|
296
313
|
const getRenderOptionLabel = renderOptionLabel => {
|
|
297
|
-
|
|
298
|
-
return typeof renderOptionLabel === 'function' && !(renderOptionLabel !== null && renderOptionLabel !== void 0 && (_renderOptionLabel$pr = renderOptionLabel.prototype) !== null && _renderOptionLabel$pr !== void 0 && _renderOptionLabel$pr.isReactComponent) ? renderOptionLabel.bind(null, {
|
|
314
|
+
return typeof renderOptionLabel === 'function' && !renderOptionLabel?.prototype?.isReactComponent ? renderOptionLabel.bind(null, {
|
|
299
315
|
id,
|
|
300
316
|
isDisabled,
|
|
301
317
|
isSelected,
|
|
@@ -342,20 +358,23 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
342
358
|
});
|
|
343
359
|
}
|
|
344
360
|
renderGroup(group, data) {
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
361
|
+
const {
|
|
362
|
+
getOptionProps,
|
|
363
|
+
getDisabledOptionProps,
|
|
364
|
+
isFirstChild,
|
|
365
|
+
isLastChild,
|
|
366
|
+
afterGroup
|
|
367
|
+
} = data;
|
|
368
|
+
const {
|
|
369
|
+
id,
|
|
370
|
+
renderLabel,
|
|
371
|
+
children,
|
|
372
|
+
...rest
|
|
373
|
+
} = group.props;
|
|
355
374
|
const groupChildren = [];
|
|
356
375
|
// add a separator above
|
|
357
376
|
if (!isFirstChild && !afterGroup) {
|
|
358
|
-
groupChildren.push(
|
|
377
|
+
groupChildren.push(_jsx(Options.Separator, {}));
|
|
359
378
|
}
|
|
360
379
|
// create a sublist as a group
|
|
361
380
|
// a wrapping listitem will be created by Options
|
|
@@ -374,20 +393,23 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
374
393
|
}));
|
|
375
394
|
// add a separator below
|
|
376
395
|
if (!isLastChild) {
|
|
377
|
-
groupChildren.push(
|
|
396
|
+
groupChildren.push(_jsx(Options.Separator, {}));
|
|
378
397
|
}
|
|
379
398
|
return groupChildren;
|
|
380
399
|
}
|
|
381
400
|
renderList(data) {
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
401
|
+
const {
|
|
402
|
+
getListProps,
|
|
403
|
+
getOptionProps,
|
|
404
|
+
getDisabledOptionProps
|
|
405
|
+
} = data;
|
|
406
|
+
const {
|
|
407
|
+
isShowingOptions,
|
|
408
|
+
optionsMaxWidth,
|
|
409
|
+
optionsMaxHeight,
|
|
410
|
+
visibleOptionsCount,
|
|
411
|
+
children
|
|
412
|
+
} = this.props;
|
|
391
413
|
let lastWasGroup = false;
|
|
392
414
|
const viewProps = isShowingOptions ? {
|
|
393
415
|
display: 'block',
|
|
@@ -438,16 +460,17 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
438
460
|
});
|
|
439
461
|
}
|
|
440
462
|
renderIcon() {
|
|
441
|
-
const
|
|
442
|
-
styles
|
|
443
|
-
isShowingOptions
|
|
463
|
+
const {
|
|
464
|
+
styles,
|
|
465
|
+
isShowingOptions
|
|
466
|
+
} = this.props;
|
|
444
467
|
return _jsx("span", {
|
|
445
|
-
css: styles
|
|
446
|
-
children: isShowingOptions ?
|
|
468
|
+
css: styles?.icon,
|
|
469
|
+
children: isShowingOptions ? _jsx(IconArrowOpenUpLine, {
|
|
447
470
|
inline: false
|
|
448
|
-
})
|
|
471
|
+
}) : _jsx(IconArrowOpenDownLine, {
|
|
449
472
|
inline: false
|
|
450
|
-
})
|
|
473
|
+
})
|
|
451
474
|
});
|
|
452
475
|
}
|
|
453
476
|
renderContentBeforeOrAfterInput(position) {
|
|
@@ -493,50 +516,58 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
493
516
|
return defaultReturn;
|
|
494
517
|
}
|
|
495
518
|
handleRenderBeforeInput() {
|
|
496
|
-
const
|
|
497
|
-
renderBeforeInput
|
|
498
|
-
inputValue
|
|
499
|
-
isOptionContentAppliedToInput
|
|
519
|
+
const {
|
|
520
|
+
renderBeforeInput,
|
|
521
|
+
inputValue,
|
|
522
|
+
isOptionContentAppliedToInput
|
|
523
|
+
} = this.props;
|
|
500
524
|
return this.handleInputContentRender(renderBeforeInput, inputValue, isOptionContentAppliedToInput, 'before', null // default for before
|
|
501
525
|
);
|
|
502
526
|
}
|
|
503
527
|
handleRenderAfterInput() {
|
|
504
|
-
const
|
|
505
|
-
renderAfterInput
|
|
506
|
-
inputValue
|
|
507
|
-
isOptionContentAppliedToInput
|
|
528
|
+
const {
|
|
529
|
+
renderAfterInput,
|
|
530
|
+
inputValue,
|
|
531
|
+
isOptionContentAppliedToInput
|
|
532
|
+
} = this.props;
|
|
508
533
|
return this.handleInputContentRender(renderAfterInput, inputValue, isOptionContentAppliedToInput, 'after', this.renderIcon() // default for after
|
|
509
534
|
);
|
|
510
535
|
}
|
|
511
536
|
renderInput(data) {
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
537
|
+
const {
|
|
538
|
+
getInputProps,
|
|
539
|
+
getTriggerProps
|
|
540
|
+
} = data;
|
|
541
|
+
const {
|
|
542
|
+
renderLabel,
|
|
543
|
+
inputValue,
|
|
544
|
+
placeholder,
|
|
545
|
+
isRequired,
|
|
546
|
+
shouldNotWrap,
|
|
547
|
+
size,
|
|
548
|
+
isInline,
|
|
549
|
+
width,
|
|
550
|
+
htmlSize,
|
|
551
|
+
messages,
|
|
552
|
+
renderBeforeInput,
|
|
553
|
+
renderAfterInput,
|
|
554
|
+
onFocus,
|
|
555
|
+
onBlur,
|
|
556
|
+
onInputChange,
|
|
557
|
+
onRequestHideOptions,
|
|
558
|
+
layout,
|
|
559
|
+
...rest
|
|
560
|
+
} = this.props;
|
|
561
|
+
const {
|
|
562
|
+
interaction
|
|
563
|
+
} = this;
|
|
534
564
|
const passthroughProps = omitProps(rest, Select.allowedProps);
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
565
|
+
const {
|
|
566
|
+
ref,
|
|
567
|
+
...triggerProps
|
|
568
|
+
} = getTriggerProps({
|
|
569
|
+
...passthroughProps
|
|
570
|
+
});
|
|
540
571
|
const isEditable = typeof onInputChange !== 'undefined';
|
|
541
572
|
|
|
542
573
|
// props to ensure screen readers treat uneditable selects as accessible
|
|
@@ -551,7 +582,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
551
582
|
// that its 'read-only' and that this is a 'textfield', see INSTUI-4500
|
|
552
583
|
role: utils.isSafari() || utils.isAndroidOrIOS() || interaction === 'disabled' && utils.isChromium() ? 'button' : 'combobox',
|
|
553
584
|
title: inputValue,
|
|
554
|
-
'aria-autocomplete':
|
|
585
|
+
'aria-autocomplete': undefined,
|
|
555
586
|
'aria-readonly': true
|
|
556
587
|
} : interaction === 'disabled' && utils.isChromium() ? {
|
|
557
588
|
role: 'button'
|
|
@@ -582,14 +613,14 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
582
613
|
// On iOS VoiceOver, if there is a custom element instead of the changing up and down arrow button
|
|
583
614
|
// the listbox closes on a swipe, so a DOM change is enforced by the key change
|
|
584
615
|
// that seems to inform VoiceOver to behave the correct way
|
|
585
|
-
renderAfterInput: utils.isAndroidOrIOS() && renderAfterInput !==
|
|
616
|
+
renderAfterInput: utils.isAndroidOrIOS() && renderAfterInput !== undefined ? _jsx("span", {
|
|
586
617
|
children: this.handleRenderAfterInput()
|
|
587
618
|
}, this.props.isShowingOptions ? 'open' : 'closed') : this.handleRenderAfterInput(),
|
|
588
619
|
// If `inputValue` is provided, we need to pass a default onChange handler,
|
|
589
620
|
// because TextInput `value` is a controlled prop,
|
|
590
621
|
// and onChange is not required for Select
|
|
591
622
|
// (before it was handled by TextInput's defaultProp)
|
|
592
|
-
onChange: typeof onInputChange === 'function' ? onInputChange : inputValue ? () => {} :
|
|
623
|
+
onChange: typeof onInputChange === 'function' ? onInputChange : inputValue ? () => {} : undefined,
|
|
593
624
|
onFocus,
|
|
594
625
|
onBlur: utils.createChainedFunction(onBlur, onRequestHideOptions),
|
|
595
626
|
...overrideProps
|
|
@@ -602,13 +633,14 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
602
633
|
});
|
|
603
634
|
}
|
|
604
635
|
render() {
|
|
605
|
-
const
|
|
606
|
-
constrain
|
|
607
|
-
placement
|
|
608
|
-
mountNode
|
|
609
|
-
assistiveText
|
|
610
|
-
isShowingOptions
|
|
611
|
-
styles
|
|
636
|
+
const {
|
|
637
|
+
constrain,
|
|
638
|
+
placement,
|
|
639
|
+
mountNode,
|
|
640
|
+
assistiveText,
|
|
641
|
+
isShowingOptions,
|
|
642
|
+
styles
|
|
643
|
+
} = this.props;
|
|
612
644
|
// clear temporary option store
|
|
613
645
|
this._optionIds = [];
|
|
614
646
|
const highlightedOptionId = this.highlightedOptionId;
|
|
@@ -628,7 +660,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
628
660
|
getDescriptionProps
|
|
629
661
|
}) => _jsxs("span", {
|
|
630
662
|
...getRootProps({
|
|
631
|
-
css: styles
|
|
663
|
+
css: styles?.select
|
|
632
664
|
}),
|
|
633
665
|
ref: el => {
|
|
634
666
|
this.ref = el;
|
|
@@ -639,7 +671,7 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
639
671
|
getTriggerProps
|
|
640
672
|
}), _jsx("span", {
|
|
641
673
|
...getDescriptionProps(),
|
|
642
|
-
css: styles
|
|
674
|
+
css: styles?.assistiveText,
|
|
643
675
|
children: assistiveText
|
|
644
676
|
}), _jsx(Popover, {
|
|
645
677
|
constrain: constrain,
|
|
@@ -648,12 +680,12 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
648
680
|
// in order to be able to navigate through the list items with a swipe.
|
|
649
681
|
// The swipe would result in closing the listbox if mounted elsewhere.
|
|
650
682
|
,
|
|
651
|
-
mountNode: mountNode !==
|
|
683
|
+
mountNode: mountNode !== undefined ? mountNode : utils.isAndroidOrIOS() ? this.ref : undefined,
|
|
652
684
|
positionTarget: this._inputContainer,
|
|
653
685
|
isShowingContent: isShowingOptions,
|
|
654
686
|
shouldReturnFocus: false,
|
|
655
687
|
withArrow: false,
|
|
656
|
-
borderWidth: styles
|
|
688
|
+
borderWidth: styles?.popoverBorderWidth,
|
|
657
689
|
children: this.renderList({
|
|
658
690
|
getListProps,
|
|
659
691
|
getOptionProps,
|
|
@@ -663,20 +695,6 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
663
695
|
})
|
|
664
696
|
});
|
|
665
697
|
}
|
|
666
|
-
}
|
|
667
|
-
inputValue: '',
|
|
668
|
-
isShowingOptions: false,
|
|
669
|
-
size: 'medium',
|
|
670
|
-
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
671
|
-
interaction: void 0,
|
|
672
|
-
isRequired: false,
|
|
673
|
-
isInline: false,
|
|
674
|
-
visibleOptionsCount: 8,
|
|
675
|
-
placement: 'bottom stretch',
|
|
676
|
-
constrain: 'window',
|
|
677
|
-
shouldNotWrap: false,
|
|
678
|
-
scrollToHighlightedOption: true,
|
|
679
|
-
isOptionContentAppliedToInput: false
|
|
680
|
-
}, _Select.Option = Option, _Select.Group = Group, _Select)) || _class) || _class);
|
|
698
|
+
}) || _class) || _class);
|
|
681
699
|
export default Select;
|
|
682
700
|
export { Select };
|
package/es/Select/v1/styles.js
CHANGED
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
* @return {Object} The final style object, which will be used in the component
|
|
31
31
|
*/
|
|
32
32
|
const generateStyle = (componentTheme, props) => {
|
|
33
|
-
const
|
|
33
|
+
const {
|
|
34
|
+
size
|
|
35
|
+
} = props;
|
|
34
36
|
const iconSizeVariants = {
|
|
35
37
|
small: {
|
|
36
38
|
fontSize: componentTheme.smallIconSize
|
package/es/Select/v1/theme.js
CHANGED
|
@@ -28,18 +28,19 @@
|
|
|
28
28
|
* @return {Object} The final theme object with the overrides and component variables
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
typography
|
|
31
|
+
const {
|
|
32
|
+
colors,
|
|
33
|
+
typography
|
|
34
|
+
} = theme;
|
|
34
35
|
const componentVariables = {
|
|
35
|
-
fontSize: typography
|
|
36
|
-
fontFamily: typography
|
|
37
|
-
fontWeight: typography
|
|
38
|
-
smallIconSize: typography
|
|
39
|
-
mediumIconSize: typography
|
|
40
|
-
largeIconSize: typography
|
|
41
|
-
color: colors
|
|
42
|
-
background: colors
|
|
36
|
+
fontSize: typography?.fontSizeMedium,
|
|
37
|
+
fontFamily: typography?.fontFamily,
|
|
38
|
+
fontWeight: typography?.fontWeightNormal,
|
|
39
|
+
smallIconSize: typography?.fontSizeXSmall,
|
|
40
|
+
mediumIconSize: typography?.fontSizeSmall,
|
|
41
|
+
largeIconSize: typography?.fontSizeMedium,
|
|
42
|
+
color: colors?.contrasts?.grey125125,
|
|
43
|
+
background: colors?.contrasts?.white1010,
|
|
43
44
|
popoverBorderWidth: 'small'
|
|
44
45
|
};
|
|
45
46
|
return {
|