@instructure/ui-select 8.13.1-snapshot.9 → 8.14.0
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 +4 -0
- package/es/Select/Group/index.js +2 -3
- package/es/Select/Group/props.js +0 -7
- package/es/Select/Option/index.js +2 -2
- package/es/Select/Option/props.js +0 -27
- package/es/Select/SelectLocator.js +5 -2
- package/es/Select/index.js +92 -85
- package/es/Select/props.js +2 -142
- package/lib/Select/Group/index.js +2 -3
- package/lib/Select/Group/props.js +0 -7
- package/lib/Select/Option/index.js +2 -2
- package/lib/Select/Option/props.js +0 -27
- package/lib/Select/SelectLocator.js +3 -0
- package/lib/Select/index.js +96 -86
- package/lib/Select/props.js +2 -142
- package/package.json +23 -24
- package/src/Select/Group/index.tsx +2 -3
- package/src/Select/Group/props.ts +8 -8
- package/src/Select/Option/index.tsx +2 -2
- package/src/Select/Option/props.ts +33 -25
- package/src/Select/index.tsx +160 -168
- package/src/Select/props.ts +176 -117
- package/tsconfig.build.json +27 -2
- package/tsconfig.build.tsbuildinfo +1 -0
- package/types/Select/Group/index.d.ts +4 -5
- package/types/Select/Group/index.d.ts.map +1 -1
- package/types/Select/Group/props.d.ts +7 -1
- package/types/Select/Group/props.d.ts.map +1 -1
- package/types/Select/Option/index.d.ts +3 -7
- package/types/Select/Option/index.d.ts.map +1 -1
- package/types/Select/Option/props.d.ts +28 -4
- package/types/Select/Option/props.d.ts.map +1 -1
- package/types/Select/SelectLocator.d.ts +117 -117
- package/types/Select/index.d.ts +68 -99
- package/types/Select/index.d.ts.map +1 -1
- package/types/Select/props.d.ts +146 -21
- package/types/Select/props.d.ts.map +1 -1
- package/LICENSE.md +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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
|
+
# [8.14.0](https://github.com/instructure/instructure-ui/compare/v8.13.0...v8.14.0) (2021-12-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-select
|
|
9
|
+
|
|
6
10
|
# [8.13.0](https://github.com/instructure/instructure-ui/compare/v8.12.0...v8.13.0) (2021-12-01)
|
|
7
11
|
|
|
8
12
|
### Features
|
package/es/Select/Group/index.js
CHANGED
|
@@ -29,6 +29,7 @@ parent: Select
|
|
|
29
29
|
id: Select.Group
|
|
30
30
|
---
|
|
31
31
|
@module Group
|
|
32
|
+
@tsProps
|
|
32
33
|
**/
|
|
33
34
|
|
|
34
35
|
class Group extends Component {
|
|
@@ -45,8 +46,6 @@ Group.displayName = "Group";
|
|
|
45
46
|
Group.componentId = 'Select.Group';
|
|
46
47
|
Group.allowedProps = allowedProps;
|
|
47
48
|
Group.propTypes = propTypes;
|
|
48
|
-
Group.defaultProps = {
|
|
49
|
-
children: null
|
|
50
|
-
};
|
|
49
|
+
Group.defaultProps = {};
|
|
51
50
|
export default Group;
|
|
52
51
|
export { Group };
|
package/es/Select/Group/props.js
CHANGED
|
@@ -25,14 +25,7 @@ import PropTypes from 'prop-types';
|
|
|
25
25
|
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
26
26
|
import { Option } from '../Option';
|
|
27
27
|
const propTypes = {
|
|
28
|
-
/**
|
|
29
|
-
* The label associated with the group options.
|
|
30
|
-
*/
|
|
31
28
|
renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Children of type `<SimpleSelect.Option />` that will be considered part of the group.
|
|
35
|
-
*/
|
|
36
29
|
children: ChildrenPropTypes.oneOf([Option])
|
|
37
30
|
};
|
|
38
31
|
const allowedProps = ['renderLabel', 'children'];
|
|
@@ -29,6 +29,7 @@ parent: Select
|
|
|
29
29
|
id: Select.Option
|
|
30
30
|
---
|
|
31
31
|
@module Option
|
|
32
|
+
@tsProps
|
|
32
33
|
**/
|
|
33
34
|
|
|
34
35
|
class Option extends Component {
|
|
@@ -48,8 +49,7 @@ Option.propTypes = propTypes;
|
|
|
48
49
|
Option.defaultProps = {
|
|
49
50
|
isHighlighted: false,
|
|
50
51
|
isSelected: false,
|
|
51
|
-
isDisabled: false
|
|
52
|
-
children: null
|
|
52
|
+
isDisabled: false
|
|
53
53
|
};
|
|
54
54
|
export default Option;
|
|
55
55
|
export { Option };
|
|
@@ -23,39 +23,12 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
const propTypes = {
|
|
26
|
-
/**
|
|
27
|
-
* The id for the option.
|
|
28
|
-
*/
|
|
29
26
|
id: PropTypes.string.isRequired,
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Whether or not this option is highlighted.
|
|
33
|
-
*/
|
|
34
27
|
isHighlighted: PropTypes.bool,
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Whether or not this option is selected.
|
|
38
|
-
*/
|
|
39
28
|
isSelected: PropTypes.bool,
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Whether or not this option is disabled.
|
|
43
|
-
*/
|
|
44
29
|
isDisabled: PropTypes.bool,
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Content to display before the option label, such as an icon.
|
|
48
|
-
*/
|
|
49
30
|
renderBeforeLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Content to display after the option label, such as an icon.
|
|
53
|
-
*/
|
|
54
31
|
renderAfterLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Content to display as the option label.
|
|
58
|
-
*/
|
|
59
32
|
children: PropTypes.node
|
|
60
33
|
};
|
|
61
34
|
const allowedProps = ['id', 'isHighlighted', 'isSelected', 'isDisabled', 'renderBeforeLabel', 'renderAfterLabel', 'children'];
|
|
@@ -23,12 +23,15 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
25
|
/* eslint-disable no-restricted-imports */
|
|
26
|
+
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module '@ins... Remove this comment to see the full error message
|
|
27
|
+
|
|
28
|
+
import { OptionsLocator } from '@instructure/ui-options/es/Options/OptionsLocator'; // @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module '@ins... Remove this comment to see the full error message
|
|
26
29
|
|
|
27
|
-
import { OptionsLocator } from '@instructure/ui-options/es/Options/OptionsLocator';
|
|
28
30
|
import { PopoverLocator } from '@instructure/ui-popover/es/Popover/PopoverLocator';
|
|
29
31
|
/* eslint-enable no-restricted-imports */
|
|
30
32
|
|
|
31
|
-
import { Select } from './index';
|
|
33
|
+
import { Select } from './index'; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
34
|
+
|
|
32
35
|
export const SelectLocator = locator(Select.selector, {
|
|
33
36
|
findInput: function () {
|
|
34
37
|
return locator('input').find(...arguments);
|
package/es/Select/index.js
CHANGED
|
@@ -30,9 +30,10 @@ var _dec, _dec2, _class, _class2, _temp, _Options$Separator, _Options$Separator2
|
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
/** @jsx jsx */
|
|
33
|
-
import { Children, Component } from 'react';
|
|
33
|
+
import React, { Children, Component } from 'react';
|
|
34
34
|
import { createChainedFunction } from '@instructure/ui-utils';
|
|
35
35
|
import { testable } from '@instructure/ui-testable';
|
|
36
|
+
import { uid } from '@instructure/uid';
|
|
36
37
|
import { matchComponentTypes, omitProps, getInteraction } from '@instructure/ui-react-utils';
|
|
37
38
|
import { getBoundingClientRect, isActiveElement } from '@instructure/ui-dom-utils';
|
|
38
39
|
import { View } from '@instructure/ui-view';
|
|
@@ -41,7 +42,6 @@ import { Popover } from '@instructure/ui-popover';
|
|
|
41
42
|
import { TextInput } from '@instructure/ui-text-input';
|
|
42
43
|
import { Options } from '@instructure/ui-options';
|
|
43
44
|
import { IconArrowOpenDownLine, IconArrowOpenUpLine } from '@instructure/ui-icons';
|
|
44
|
-
import { uid } from '@instructure/uid';
|
|
45
45
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
46
46
|
import generateStyle from './styles';
|
|
47
47
|
import generateComponentTheme from './theme';
|
|
@@ -53,23 +53,25 @@ import { allowedProps, propTypes } from './props';
|
|
|
53
53
|
category: components
|
|
54
54
|
tags: autocomplete, typeahead, combobox, dropdown, search, form
|
|
55
55
|
---
|
|
56
|
+
@tsProps
|
|
56
57
|
**/
|
|
57
58
|
|
|
58
59
|
let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class Select extends Component {
|
|
59
60
|
constructor() {
|
|
60
61
|
super(...arguments);
|
|
61
|
-
this.ref = null;
|
|
62
62
|
this.state = {
|
|
63
63
|
hasInputRef: false
|
|
64
64
|
};
|
|
65
|
+
this.ref = null;
|
|
65
66
|
this._defaultId = uid('Select');
|
|
66
|
-
this.
|
|
67
|
-
this.
|
|
68
|
-
this._list = null;
|
|
67
|
+
this._inputContainer = null;
|
|
68
|
+
this._listView = null;
|
|
69
69
|
this._optionIds = [];
|
|
70
70
|
this._optionHeight = 36;
|
|
71
71
|
|
|
72
72
|
this.handleInputRef = node => {
|
|
73
|
+
var _this$props$inputRef, _this$props;
|
|
74
|
+
|
|
73
75
|
// ensures list is positioned with respect to input if list is open on mount
|
|
74
76
|
if (!this.state.hasInputRef) {
|
|
75
77
|
this.setState({
|
|
@@ -78,12 +80,13 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
this.ref = node;
|
|
81
|
-
this.props.inputRef(node);
|
|
83
|
+
(_this$props$inputRef = (_this$props = this.props).inputRef) === null || _this$props$inputRef === void 0 ? void 0 : _this$props$inputRef.call(_this$props, node);
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
this.handleListRef = node => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
var _this$props$listRef, _this$props2;
|
|
88
|
+
|
|
89
|
+
(_this$props$listRef = (_this$props2 = this.props).listRef) === null || _this$props$listRef === void 0 ? void 0 : _this$props$listRef.call(_this$props2, node); // store option height to calculate list maxHeight
|
|
87
90
|
|
|
88
91
|
if (node && node.querySelector('[role="option"]')) {
|
|
89
92
|
this._optionHeight = node.querySelector('[role="option"]').offsetHeight;
|
|
@@ -96,15 +99,15 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
componentDidMount() {
|
|
99
|
-
var _this$props$makeStyle, _this$
|
|
102
|
+
var _this$props$makeStyle, _this$props3;
|
|
100
103
|
|
|
101
|
-
(_this$props$makeStyle = (_this$
|
|
104
|
+
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
componentDidUpdate() {
|
|
105
|
-
var _this$props$makeStyle2, _this$
|
|
108
|
+
var _this$props$makeStyle2, _this$props4;
|
|
106
109
|
|
|
107
|
-
(_this$props$makeStyle2 = (_this$
|
|
110
|
+
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4); // scroll option into view if needed
|
|
108
111
|
|
|
109
112
|
this.scrollToOption(this.highlightedOptionId);
|
|
110
113
|
}
|
|
@@ -126,7 +129,7 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
126
129
|
}
|
|
127
130
|
|
|
128
131
|
get width() {
|
|
129
|
-
return this._inputContainer
|
|
132
|
+
return this._inputContainer ? this._inputContainer.offsetWidth : void 0;
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
get interaction() {
|
|
@@ -136,10 +139,11 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
136
139
|
}
|
|
137
140
|
|
|
138
141
|
get highlightedOptionId() {
|
|
139
|
-
let highlightedOptionId
|
|
142
|
+
let highlightedOptionId;
|
|
140
143
|
Children.toArray(this.props.children).forEach(child => {
|
|
141
144
|
if (matchComponentTypes(child, [Group])) {
|
|
142
145
|
// group found
|
|
146
|
+
;
|
|
143
147
|
Children.toArray(child.props.children).forEach(option => {
|
|
144
148
|
// check options in group
|
|
145
149
|
if (option.props.isHighlighted) {
|
|
@@ -161,6 +165,7 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
161
165
|
Children.toArray(this.props.children).forEach(child => {
|
|
162
166
|
if (matchComponentTypes(child, [Group])) {
|
|
163
167
|
// group found
|
|
168
|
+
;
|
|
164
169
|
Children.toArray(child.props.children).forEach(option => {
|
|
165
170
|
// check options in group
|
|
166
171
|
if (option.props.isSelected) {
|
|
@@ -174,8 +179,15 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
174
179
|
}
|
|
175
180
|
}
|
|
176
181
|
});
|
|
177
|
-
|
|
178
|
-
if (selectedOptionId.length ===
|
|
182
|
+
|
|
183
|
+
if (selectedOptionId.length === 1) {
|
|
184
|
+
return selectedOptionId[0];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (selectedOptionId.length === 0) {
|
|
188
|
+
return void 0;
|
|
189
|
+
}
|
|
190
|
+
|
|
179
191
|
return selectedOptionId;
|
|
180
192
|
}
|
|
181
193
|
|
|
@@ -188,7 +200,7 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
188
200
|
const parentTop = getBoundingClientRect(this._listView).top;
|
|
189
201
|
const elemTop = getBoundingClientRect(listItem).top;
|
|
190
202
|
const parentBottom = parentTop + this._listView.clientHeight;
|
|
191
|
-
const elemBottom = elemTop + listItem.clientHeight;
|
|
203
|
+
const elemBottom = elemTop + (listItem ? listItem.clientHeight : 0);
|
|
192
204
|
|
|
193
205
|
if (elemBottom > parentBottom) {
|
|
194
206
|
this._listView.scrollTop += elemBottom - parentBottom;
|
|
@@ -202,23 +214,23 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
202
214
|
const onRequestHighlightOption = this.props.onRequestHighlightOption;
|
|
203
215
|
|
|
204
216
|
if (id) {
|
|
205
|
-
onRequestHighlightOption(event, {
|
|
217
|
+
onRequestHighlightOption === null || onRequestHighlightOption === void 0 ? void 0 : onRequestHighlightOption(event, {
|
|
206
218
|
id
|
|
207
219
|
});
|
|
208
220
|
}
|
|
209
221
|
}
|
|
210
222
|
|
|
211
223
|
getEventHandlers() {
|
|
212
|
-
const _this$
|
|
213
|
-
isShowingOptions = _this$
|
|
214
|
-
onRequestShowOptions = _this$
|
|
215
|
-
onRequestHideOptions = _this$
|
|
216
|
-
onRequestSelectOption = _this$
|
|
224
|
+
const _this$props5 = this.props,
|
|
225
|
+
isShowingOptions = _this$props5.isShowingOptions,
|
|
226
|
+
onRequestShowOptions = _this$props5.onRequestShowOptions,
|
|
227
|
+
onRequestHideOptions = _this$props5.onRequestHideOptions,
|
|
228
|
+
onRequestSelectOption = _this$props5.onRequestSelectOption;
|
|
217
229
|
const highlightedOptionId = this.highlightedOptionId;
|
|
218
230
|
const selectedOptionId = this.selectedOptionId;
|
|
219
231
|
return this.interaction === 'enabled' ? {
|
|
220
232
|
onRequestShowOptions: event => {
|
|
221
|
-
onRequestShowOptions(event);
|
|
233
|
+
onRequestShowOptions === null || onRequestShowOptions === void 0 ? void 0 : onRequestShowOptions(event);
|
|
222
234
|
|
|
223
235
|
if (selectedOptionId && !Array.isArray(selectedOptionId)) {
|
|
224
236
|
// highlight selected option on show
|
|
@@ -226,14 +238,14 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
226
238
|
}
|
|
227
239
|
},
|
|
228
240
|
onRequestHideOptions: event => {
|
|
229
|
-
onRequestHideOptions(event);
|
|
241
|
+
onRequestHideOptions === null || onRequestHideOptions === void 0 ? void 0 : onRequestHideOptions(event);
|
|
230
242
|
},
|
|
231
243
|
onRequestHighlightOption: (event, _ref) => {
|
|
232
244
|
let id = _ref.id,
|
|
233
245
|
direction = _ref.direction;
|
|
234
246
|
if (!isShowingOptions) return; // if id exists, use that
|
|
235
247
|
|
|
236
|
-
let highlightId = this._optionIds.indexOf(id) > -1 ? id :
|
|
248
|
+
let highlightId = this._optionIds.indexOf(id) > -1 ? id : void 0;
|
|
237
249
|
|
|
238
250
|
if (!highlightId) {
|
|
239
251
|
if (!highlightedOptionId) {
|
|
@@ -243,7 +255,7 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
243
255
|
// find next id based on direction
|
|
244
256
|
const index = this._optionIds.indexOf(highlightedOptionId);
|
|
245
257
|
|
|
246
|
-
highlightId = index > -1 ? this._optionIds[index + direction] :
|
|
258
|
+
highlightId = index > -1 ? this._optionIds[index + direction] : void 0;
|
|
247
259
|
}
|
|
248
260
|
}
|
|
249
261
|
|
|
@@ -263,7 +275,7 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
263
275
|
|
|
264
276
|
if (id && this._optionIds.indexOf(id) !== -1) {
|
|
265
277
|
// only select if id exists as a valid option
|
|
266
|
-
onRequestSelectOption(event, {
|
|
278
|
+
onRequestSelectOption === null || onRequestSelectOption === void 0 ? void 0 : onRequestSelectOption(event, {
|
|
267
279
|
id
|
|
268
280
|
});
|
|
269
281
|
}
|
|
@@ -283,14 +295,14 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
283
295
|
renderAfterLabel = _option$props.renderAfterLabel,
|
|
284
296
|
children = _option$props.children;
|
|
285
297
|
|
|
286
|
-
const
|
|
287
|
-
return typeof
|
|
298
|
+
const getRenderOptionLabel = renderOptionLabel => {
|
|
299
|
+
return typeof renderOptionLabel === 'function' ? renderOptionLabel.bind(null, {
|
|
288
300
|
id,
|
|
289
301
|
isDisabled,
|
|
290
302
|
isSelected,
|
|
291
303
|
isHighlighted,
|
|
292
304
|
children
|
|
293
|
-
}) :
|
|
305
|
+
}) : renderOptionLabel;
|
|
294
306
|
};
|
|
295
307
|
|
|
296
308
|
let optionProps = { // passthrough props
|
|
@@ -300,8 +312,8 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
300
312
|
id
|
|
301
313
|
}),
|
|
302
314
|
// Options.Item props
|
|
303
|
-
renderBeforeLabel:
|
|
304
|
-
renderAfterLabel:
|
|
315
|
+
renderBeforeLabel: getRenderOptionLabel(renderBeforeLabel),
|
|
316
|
+
renderAfterLabel: getRenderOptionLabel(renderAfterLabel)
|
|
305
317
|
}; // should option be treated as highlighted or selected
|
|
306
318
|
|
|
307
319
|
if (isSelected) {
|
|
@@ -368,11 +380,11 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
368
380
|
const getListProps = data.getListProps,
|
|
369
381
|
getOptionProps = data.getOptionProps,
|
|
370
382
|
getDisabledOptionProps = data.getDisabledOptionProps;
|
|
371
|
-
const _this$
|
|
372
|
-
isShowingOptions = _this$
|
|
373
|
-
optionsMaxWidth = _this$
|
|
374
|
-
visibleOptionsCount = _this$
|
|
375
|
-
children = _this$
|
|
383
|
+
const _this$props6 = this.props,
|
|
384
|
+
isShowingOptions = _this$props6.isShowingOptions,
|
|
385
|
+
optionsMaxWidth = _this$props6.optionsMaxWidth,
|
|
386
|
+
visibleOptionsCount = _this$props6.visibleOptionsCount,
|
|
387
|
+
children = _this$props6.children;
|
|
376
388
|
let lastWasGroup = false;
|
|
377
389
|
const viewProps = isShowingOptions ? {
|
|
378
390
|
display: 'block',
|
|
@@ -401,7 +413,7 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
401
413
|
}
|
|
402
414
|
|
|
403
415
|
if (matchComponentTypes(child, [Group])) {
|
|
404
|
-
const afterGroup = lastWasGroup
|
|
416
|
+
const afterGroup = lastWasGroup;
|
|
405
417
|
lastWasGroup = true;
|
|
406
418
|
return this.renderGroup(child, {
|
|
407
419
|
getOptionProps,
|
|
@@ -412,13 +424,15 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
412
424
|
afterGroup
|
|
413
425
|
});
|
|
414
426
|
}
|
|
427
|
+
|
|
428
|
+
return;
|
|
415
429
|
}) : null));
|
|
416
430
|
}
|
|
417
431
|
|
|
418
432
|
renderIcon() {
|
|
419
|
-
const _this$
|
|
420
|
-
styles = _this$
|
|
421
|
-
isShowingOptions = _this$
|
|
433
|
+
const _this$props7 = this.props,
|
|
434
|
+
styles = _this$props7.styles,
|
|
435
|
+
isShowingOptions = _this$props7.isShowingOptions;
|
|
422
436
|
return jsx("span", {
|
|
423
437
|
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
424
438
|
}, isShowingOptions ? _IconArrowOpenUpLine || (_IconArrowOpenUpLine = jsx(IconArrowOpenUpLine, {
|
|
@@ -432,24 +446,24 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
432
446
|
const getInputProps = data.getInputProps,
|
|
433
447
|
getTriggerProps = data.getTriggerProps;
|
|
434
448
|
|
|
435
|
-
const _this$
|
|
436
|
-
renderLabel = _this$
|
|
437
|
-
inputValue = _this$
|
|
438
|
-
placeholder = _this$
|
|
439
|
-
isRequired = _this$
|
|
440
|
-
shouldNotWrap = _this$
|
|
441
|
-
size = _this$
|
|
442
|
-
isInline = _this$
|
|
443
|
-
width = _this$
|
|
444
|
-
htmlSize = _this$
|
|
445
|
-
messages = _this$
|
|
446
|
-
renderBeforeInput = _this$
|
|
447
|
-
renderAfterInput = _this$
|
|
448
|
-
onFocus = _this$
|
|
449
|
-
onBlur = _this$
|
|
450
|
-
onInputChange = _this$
|
|
451
|
-
onRequestHideOptions = _this$
|
|
452
|
-
rest = _objectWithoutProperties(_this$
|
|
449
|
+
const _this$props8 = this.props,
|
|
450
|
+
renderLabel = _this$props8.renderLabel,
|
|
451
|
+
inputValue = _this$props8.inputValue,
|
|
452
|
+
placeholder = _this$props8.placeholder,
|
|
453
|
+
isRequired = _this$props8.isRequired,
|
|
454
|
+
shouldNotWrap = _this$props8.shouldNotWrap,
|
|
455
|
+
size = _this$props8.size,
|
|
456
|
+
isInline = _this$props8.isInline,
|
|
457
|
+
width = _this$props8.width,
|
|
458
|
+
htmlSize = _this$props8.htmlSize,
|
|
459
|
+
messages = _this$props8.messages,
|
|
460
|
+
renderBeforeInput = _this$props8.renderBeforeInput,
|
|
461
|
+
renderAfterInput = _this$props8.renderAfterInput,
|
|
462
|
+
onFocus = _this$props8.onFocus,
|
|
463
|
+
onBlur = _this$props8.onBlur,
|
|
464
|
+
onInputChange = _this$props8.onInputChange,
|
|
465
|
+
onRequestHideOptions = _this$props8.onRequestHideOptions,
|
|
466
|
+
rest = _objectWithoutProperties(_this$props8, _excluded2);
|
|
453
467
|
|
|
454
468
|
const interaction = this.interaction;
|
|
455
469
|
const passthroughProps = omitProps(rest, Select.allowedProps);
|
|
@@ -465,14 +479,14 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
465
479
|
const overrideProps = !isEditable ? {
|
|
466
480
|
role: 'button',
|
|
467
481
|
title: inputValue,
|
|
468
|
-
'aria-autocomplete':
|
|
482
|
+
'aria-autocomplete': void 0
|
|
469
483
|
} : {}; // backdoor to autocomplete attr to work around chrome autofill issues
|
|
470
484
|
|
|
471
485
|
if (passthroughProps['autoComplete']) {
|
|
472
486
|
overrideProps.autoComplete = passthroughProps['autoComplete'];
|
|
473
487
|
}
|
|
474
488
|
|
|
475
|
-
|
|
489
|
+
const inputProps = {
|
|
476
490
|
id: this.id,
|
|
477
491
|
renderLabel,
|
|
478
492
|
placeholder,
|
|
@@ -490,21 +504,26 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
490
504
|
display: isInline ? 'inline-block' : 'block',
|
|
491
505
|
renderBeforeInput,
|
|
492
506
|
renderAfterInput: renderAfterInput || this.renderIcon(),
|
|
493
|
-
onChange
|
|
507
|
+
// If `inputValue` is provided, we need to pass a default onChange handler,
|
|
508
|
+
// because TextInput `value` is a controlled prop,
|
|
509
|
+
// and onChange is not required for Select
|
|
510
|
+
// (before it was handled by TextInput's defaultProp)
|
|
511
|
+
onChange: typeof onInputChange === 'function' ? onInputChange : inputValue ? () => {} : void 0,
|
|
494
512
|
onFocus,
|
|
495
513
|
onBlur: createChainedFunction(onBlur, onRequestHideOptions),
|
|
496
514
|
...overrideProps
|
|
497
|
-
}
|
|
515
|
+
};
|
|
516
|
+
return jsx(TextInput, Object.assign({}, triggerProps, getInputProps(inputProps)));
|
|
498
517
|
}
|
|
499
518
|
|
|
500
519
|
render() {
|
|
501
|
-
const _this$
|
|
502
|
-
constrain = _this$
|
|
503
|
-
placement = _this$
|
|
504
|
-
mountNode = _this$
|
|
505
|
-
assistiveText = _this$
|
|
506
|
-
isShowingOptions = _this$
|
|
507
|
-
styles = _this$
|
|
520
|
+
const _this$props9 = this.props,
|
|
521
|
+
constrain = _this$props9.constrain,
|
|
522
|
+
placement = _this$props9.placement,
|
|
523
|
+
mountNode = _this$props9.mountNode,
|
|
524
|
+
assistiveText = _this$props9.assistiveText,
|
|
525
|
+
isShowingOptions = _this$props9.isShowingOptions,
|
|
526
|
+
styles = _this$props9.styles; // clear temporary option store
|
|
508
527
|
|
|
509
528
|
this._optionIds = [];
|
|
510
529
|
const highlightedOptionId = this.highlightedOptionId;
|
|
@@ -512,7 +531,7 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
512
531
|
return jsx(Selectable, Object.assign({
|
|
513
532
|
highlightedOptionId: highlightedOptionId,
|
|
514
533
|
isShowingOptions: isShowingOptions,
|
|
515
|
-
selectedOptionId: selectedOptionId
|
|
534
|
+
selectedOptionId: selectedOptionId
|
|
516
535
|
}, this.getEventHandlers()), _ref3 => {
|
|
517
536
|
let getRootProps = _ref3.getRootProps,
|
|
518
537
|
getInputProps = _ref3.getInputProps,
|
|
@@ -548,7 +567,6 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
548
567
|
inputValue: '',
|
|
549
568
|
isShowingOptions: false,
|
|
550
569
|
size: 'medium',
|
|
551
|
-
placeholder: null,
|
|
552
570
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
553
571
|
interaction: void 0,
|
|
554
572
|
isRequired: false,
|
|
@@ -556,17 +574,6 @@ let Select = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
556
574
|
visibleOptionsCount: 8,
|
|
557
575
|
placement: 'bottom stretch',
|
|
558
576
|
constrain: 'window',
|
|
559
|
-
onFocus: event => {},
|
|
560
|
-
onBlur: event => {},
|
|
561
|
-
onRequestShowOptions: event => {},
|
|
562
|
-
onRequestHideOptions: event => {},
|
|
563
|
-
onRequestHighlightOption: (event, data) => {},
|
|
564
|
-
onRequestSelectOption: (event, data) => {},
|
|
565
|
-
inputRef: node => {},
|
|
566
|
-
listRef: node => {},
|
|
567
|
-
renderBeforeInput: null,
|
|
568
|
-
renderAfterInput: null,
|
|
569
|
-
children: null,
|
|
570
577
|
shouldNotWrap: false
|
|
571
578
|
}, _class2.Option = Option, _class2.Group = Group, _temp)) || _class) || _class);
|
|
572
579
|
export default Select;
|