@instructure/ui-select 8.33.1 → 8.33.2
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 +1 -0
- package/es/Select/Option/index.js +2 -3
- package/es/Select/Option/props.js +1 -0
- package/es/Select/SelectLocator.js +5 -5
- package/es/Select/index.js +92 -144
- package/es/Select/props.js +1 -0
- package/es/Select/styles.js +0 -1
- package/es/Select/theme.js +3 -3
- package/es/index.js +1 -0
- package/lib/Select/Group/index.js +0 -5
- package/lib/Select/Group/props.js +1 -5
- package/lib/Select/Option/index.js +0 -5
- package/lib/Select/Option/props.js +1 -3
- package/lib/Select/SelectLocator.js +2 -6
- package/lib/Select/index.js +92 -165
- package/lib/Select/locator.js +0 -2
- package/lib/Select/props.js +1 -8
- package/lib/Select/styles.js +0 -2
- package/lib/Select/theme.js +3 -4
- package/lib/index.js +0 -1
- package/package.json +22 -22
- package/tsconfig.build.tsbuildinfo +1 -1
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.33.2](https://github.com/instructure/instructure-ui/compare/v8.33.1...v8.33.2) (2023-01-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-select
|
|
9
|
+
|
|
6
10
|
## [8.33.1](https://github.com/instructure/instructure-ui/compare/v8.33.0...v8.33.1) (2023-01-06)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @instructure/ui-select
|
package/es/Select/Group/index.js
CHANGED
|
@@ -21,8 +21,10 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import { Component } from 'react';
|
|
25
26
|
import { allowedProps, propTypes } from './props';
|
|
27
|
+
|
|
26
28
|
/**
|
|
27
29
|
---
|
|
28
30
|
parent: Select
|
|
@@ -31,7 +33,6 @@ id: Select.Group
|
|
|
31
33
|
@module Group
|
|
32
34
|
@tsProps
|
|
33
35
|
**/
|
|
34
|
-
|
|
35
36
|
class Group extends Component {
|
|
36
37
|
/* istanbul ignore next */
|
|
37
38
|
render() {
|
|
@@ -39,9 +40,7 @@ class Group extends Component {
|
|
|
39
40
|
// are parsed in Select and rendered as Options components
|
|
40
41
|
return null;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
43
|
}
|
|
44
|
-
|
|
45
44
|
Group.displayName = "Group";
|
|
46
45
|
Group.componentId = 'Select.Group';
|
|
47
46
|
Group.allowedProps = allowedProps;
|
package/es/Select/Group/props.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import PropTypes from 'prop-types';
|
|
25
26
|
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
26
27
|
import { Option } from '../Option';
|
|
@@ -21,8 +21,10 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import { Component } from 'react';
|
|
25
26
|
import { allowedProps, propTypes } from './props';
|
|
27
|
+
|
|
26
28
|
/**
|
|
27
29
|
---
|
|
28
30
|
parent: Select
|
|
@@ -31,7 +33,6 @@ id: Select.Option
|
|
|
31
33
|
@module Option
|
|
32
34
|
@tsProps
|
|
33
35
|
**/
|
|
34
|
-
|
|
35
36
|
class Option extends Component {
|
|
36
37
|
/* istanbul ignore next */
|
|
37
38
|
render() {
|
|
@@ -39,9 +40,7 @@ class Option extends Component {
|
|
|
39
40
|
// are parsed in Select and rendered as Options.Item components
|
|
40
41
|
return null;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
43
|
}
|
|
44
|
-
|
|
45
44
|
Option.displayName = "Option";
|
|
46
45
|
Option.componentId = 'Select.Option';
|
|
47
46
|
Option.allowedProps = allowedProps;
|
|
@@ -22,16 +22,17 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
|
+
|
|
25
26
|
/* eslint-disable no-restricted-imports */
|
|
26
27
|
// @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
|
-
|
|
29
|
-
|
|
28
|
+
import { OptionsLocator } from '@instructure/ui-options/es/Options/OptionsLocator';
|
|
29
|
+
// @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
|
|
30
30
|
import { PopoverLocator } from '@instructure/ui-popover/es/Popover/PopoverLocator';
|
|
31
31
|
/* eslint-enable no-restricted-imports */
|
|
32
32
|
|
|
33
|
-
import { Select } from './index';
|
|
33
|
+
import { Select } from './index';
|
|
34
34
|
|
|
35
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
35
36
|
export const SelectLocator = locator(Select.selector, {
|
|
36
37
|
findInput: function () {
|
|
37
38
|
return locator('input').find(...arguments);
|
|
@@ -40,7 +41,6 @@ export const SelectLocator = locator(Select.selector, {
|
|
|
40
41
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
41
42
|
args[_key - 1] = arguments[_key];
|
|
42
43
|
}
|
|
43
|
-
|
|
44
44
|
const content = await PopoverLocator.findContent(element, ...args);
|
|
45
45
|
return content ? OptionsLocator.find(content.getDOMNode()) : null;
|
|
46
46
|
}
|
package/es/Select/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
const _excluded = ["id", "renderLabel", "children"],
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
_excluded2 = ["renderLabel", "inputValue", "placeholder", "isRequired", "shouldNotWrap", "size", "isInline", "width", "htmlSize", "messages", "renderBeforeInput", "renderAfterInput", "onFocus", "onBlur", "onInputChange", "onRequestHideOptions"],
|
|
4
|
+
_excluded3 = ["ref"];
|
|
6
5
|
var _dec, _dec2, _dec3, _class, _class2, _Options$Separator, _Options$Separator2, _IconArrowOpenUpLine, _IconArrowOpenDownLin;
|
|
7
|
-
|
|
8
6
|
/*
|
|
9
7
|
* The MIT License (MIT)
|
|
10
8
|
*
|
|
@@ -47,7 +45,6 @@ import generateComponentTheme from './theme';
|
|
|
47
45
|
import { Group } from './Group';
|
|
48
46
|
import { Option } from './Option';
|
|
49
47
|
import { allowedProps, propTypes } from './props';
|
|
50
|
-
|
|
51
48
|
/**
|
|
52
49
|
---
|
|
53
50
|
category: components
|
|
@@ -68,80 +65,64 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
68
65
|
this._listView = null;
|
|
69
66
|
this._optionIds = [];
|
|
70
67
|
this._optionHeight = 36;
|
|
71
|
-
|
|
72
68
|
this.handleInputRef = node => {
|
|
73
69
|
var _this$props$inputRef, _this$props;
|
|
74
|
-
|
|
75
70
|
// ensures list is positioned with respect to input if list is open on mount
|
|
76
71
|
if (!this.state.hasInputRef) {
|
|
77
72
|
this.setState({
|
|
78
73
|
hasInputRef: true
|
|
79
74
|
});
|
|
80
75
|
}
|
|
81
|
-
|
|
82
76
|
this._input = node;
|
|
83
77
|
(_this$props$inputRef = (_this$props = this.props).inputRef) === null || _this$props$inputRef === void 0 ? void 0 : _this$props$inputRef.call(_this$props, node);
|
|
84
78
|
};
|
|
85
|
-
|
|
86
79
|
this.handleListRef = node => {
|
|
87
80
|
var _this$props$listRef, _this$props2;
|
|
81
|
+
(_this$props$listRef = (_this$props2 = this.props).listRef) === null || _this$props$listRef === void 0 ? void 0 : _this$props$listRef.call(_this$props2, node);
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
// store option height to calculate list maxHeight
|
|
91
84
|
if (node && node.querySelector('[role="option"]')) {
|
|
92
85
|
this._optionHeight = node.querySelector('[role="option"]').offsetHeight;
|
|
93
86
|
}
|
|
94
87
|
};
|
|
95
|
-
|
|
96
88
|
this.handleInputContainerRef = node => {
|
|
97
89
|
this._inputContainer = node;
|
|
98
90
|
};
|
|
99
91
|
}
|
|
100
|
-
|
|
101
92
|
componentDidMount() {
|
|
102
93
|
var _this$props$makeStyle, _this$props3;
|
|
103
|
-
|
|
104
94
|
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
105
95
|
}
|
|
106
|
-
|
|
107
96
|
componentDidUpdate() {
|
|
108
97
|
var _this$props$makeStyle2, _this$props4;
|
|
98
|
+
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
109
99
|
|
|
110
|
-
|
|
111
|
-
|
|
100
|
+
// scroll option into view if needed
|
|
112
101
|
this.scrollToOption(this.highlightedOptionId);
|
|
113
102
|
}
|
|
114
|
-
|
|
115
103
|
focus() {
|
|
116
104
|
this._input && this._input.focus();
|
|
117
105
|
}
|
|
118
|
-
|
|
119
106
|
get childrenArray() {
|
|
120
107
|
return Children.toArray(this.props.children);
|
|
121
108
|
}
|
|
122
|
-
|
|
123
109
|
getGroupChildrenArray(group) {
|
|
124
110
|
return Children.toArray(group.props.children);
|
|
125
111
|
}
|
|
126
|
-
|
|
127
112
|
get focused() {
|
|
128
113
|
return this._input ? isActiveElement(this._input) : false;
|
|
129
114
|
}
|
|
130
|
-
|
|
131
115
|
get id() {
|
|
132
116
|
return this.props.id || this._defaultId;
|
|
133
117
|
}
|
|
134
|
-
|
|
135
118
|
get width() {
|
|
136
119
|
return this._inputContainer ? this._inputContainer.offsetWidth : void 0;
|
|
137
120
|
}
|
|
138
|
-
|
|
139
121
|
get interaction() {
|
|
140
122
|
return getInteraction({
|
|
141
123
|
props: this.props
|
|
142
124
|
});
|
|
143
125
|
}
|
|
144
|
-
|
|
145
126
|
get highlightedOptionId() {
|
|
146
127
|
let highlightedOptionId;
|
|
147
128
|
this.childrenArray.forEach(child => {
|
|
@@ -162,7 +143,6 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
162
143
|
});
|
|
163
144
|
return highlightedOptionId;
|
|
164
145
|
}
|
|
165
|
-
|
|
166
146
|
get selectedOptionId() {
|
|
167
147
|
const selectedOptionId = [];
|
|
168
148
|
this.childrenArray.forEach(child => {
|
|
@@ -181,29 +161,23 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
181
161
|
}
|
|
182
162
|
}
|
|
183
163
|
});
|
|
184
|
-
|
|
185
164
|
if (selectedOptionId.length === 1) {
|
|
186
165
|
return selectedOptionId[0];
|
|
187
166
|
}
|
|
188
|
-
|
|
189
167
|
if (selectedOptionId.length === 0) {
|
|
190
168
|
return void 0;
|
|
191
169
|
}
|
|
192
|
-
|
|
193
170
|
return selectedOptionId;
|
|
194
171
|
}
|
|
195
|
-
|
|
196
172
|
scrollToOption(id) {
|
|
197
173
|
if (this._listView) {
|
|
198
174
|
const option = this._listView.querySelector(`[id="${id}"]`);
|
|
199
|
-
|
|
200
175
|
if (!option) return;
|
|
201
176
|
const listItem = option.parentNode;
|
|
202
177
|
const parentTop = getBoundingClientRect(this._listView).top;
|
|
203
178
|
const elemTop = getBoundingClientRect(listItem).top;
|
|
204
179
|
const parentBottom = parentTop + this._listView.clientHeight;
|
|
205
180
|
const elemBottom = elemTop + (listItem ? listItem.clientHeight : 0);
|
|
206
|
-
|
|
207
181
|
if (elemBottom > parentBottom) {
|
|
208
182
|
this._listView.scrollTop += elemBottom - parentBottom;
|
|
209
183
|
} else if (elemTop < parentTop) {
|
|
@@ -211,29 +185,25 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
211
185
|
}
|
|
212
186
|
}
|
|
213
187
|
}
|
|
214
|
-
|
|
215
188
|
highlightOption(event, id) {
|
|
216
189
|
const onRequestHighlightOption = this.props.onRequestHighlightOption;
|
|
217
|
-
|
|
218
190
|
if (id) {
|
|
219
191
|
onRequestHighlightOption === null || onRequestHighlightOption === void 0 ? void 0 : onRequestHighlightOption(event, {
|
|
220
192
|
id
|
|
221
193
|
});
|
|
222
194
|
}
|
|
223
195
|
}
|
|
224
|
-
|
|
225
196
|
getEventHandlers() {
|
|
226
197
|
const _this$props5 = this.props,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
198
|
+
isShowingOptions = _this$props5.isShowingOptions,
|
|
199
|
+
onRequestShowOptions = _this$props5.onRequestShowOptions,
|
|
200
|
+
onRequestHideOptions = _this$props5.onRequestHideOptions,
|
|
201
|
+
onRequestSelectOption = _this$props5.onRequestSelectOption;
|
|
231
202
|
const highlightedOptionId = this.highlightedOptionId;
|
|
232
203
|
const selectedOptionId = this.selectedOptionId;
|
|
233
204
|
return this.interaction === 'enabled' ? {
|
|
234
205
|
onRequestShowOptions: event => {
|
|
235
206
|
onRequestShowOptions === null || onRequestShowOptions === void 0 ? void 0 : onRequestShowOptions(event);
|
|
236
|
-
|
|
237
207
|
if (selectedOptionId && !Array.isArray(selectedOptionId)) {
|
|
238
208
|
// highlight selected option on show
|
|
239
209
|
this.highlightOption(event, selectedOptionId);
|
|
@@ -244,11 +214,10 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
244
214
|
},
|
|
245
215
|
onRequestHighlightOption: (event, _ref) => {
|
|
246
216
|
let id = _ref.id,
|
|
247
|
-
|
|
248
|
-
if (!isShowingOptions) return;
|
|
249
|
-
|
|
217
|
+
direction = _ref.direction;
|
|
218
|
+
if (!isShowingOptions) return;
|
|
219
|
+
// if id exists, use that
|
|
250
220
|
let highlightId = this._optionIds.indexOf(id) > -1 ? id : void 0;
|
|
251
|
-
|
|
252
221
|
if (!highlightId) {
|
|
253
222
|
if (!highlightedOptionId) {
|
|
254
223
|
// nothing highlighted yet, highlight first option
|
|
@@ -256,11 +225,9 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
256
225
|
} else {
|
|
257
226
|
// find next id based on direction
|
|
258
227
|
const index = this._optionIds.indexOf(highlightedOptionId);
|
|
259
|
-
|
|
260
228
|
highlightId = index > -1 ? this._optionIds[index + direction] : void 0;
|
|
261
229
|
}
|
|
262
230
|
}
|
|
263
|
-
|
|
264
231
|
if (highlightId) {
|
|
265
232
|
// only highlight if id exists as a valid option
|
|
266
233
|
this.highlightOption(event, highlightId);
|
|
@@ -274,7 +241,6 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
274
241
|
},
|
|
275
242
|
onRequestSelectOption: (event, _ref2) => {
|
|
276
243
|
let id = _ref2.id;
|
|
277
|
-
|
|
278
244
|
if (id && this._optionIds.indexOf(id) !== -1) {
|
|
279
245
|
// only select if id exists as a valid option
|
|
280
246
|
onRequestSelectOption === null || onRequestSelectOption === void 0 ? void 0 : onRequestSelectOption(event, {
|
|
@@ -284,22 +250,19 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
284
250
|
}
|
|
285
251
|
} : {};
|
|
286
252
|
}
|
|
287
|
-
|
|
288
253
|
renderOption(option, data) {
|
|
289
254
|
const getOptionProps = data.getOptionProps,
|
|
290
|
-
|
|
255
|
+
getDisabledOptionProps = data.getDisabledOptionProps;
|
|
291
256
|
const _option$props = option.props,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
257
|
+
id = _option$props.id,
|
|
258
|
+
isDisabled = _option$props.isDisabled,
|
|
259
|
+
isHighlighted = _option$props.isHighlighted,
|
|
260
|
+
isSelected = _option$props.isSelected,
|
|
261
|
+
renderBeforeLabel = _option$props.renderBeforeLabel,
|
|
262
|
+
renderAfterLabel = _option$props.renderAfterLabel,
|
|
263
|
+
children = _option$props.children;
|
|
300
264
|
const getRenderOptionLabel = renderOptionLabel => {
|
|
301
265
|
var _renderOptionLabel$pr;
|
|
302
|
-
|
|
303
266
|
return typeof renderOptionLabel === 'function' && !(renderOptionLabel !== null && renderOptionLabel !== void 0 && (_renderOptionLabel$pr = renderOptionLabel.prototype) !== null && _renderOptionLabel$pr !== void 0 && _renderOptionLabel$pr.isReactComponent) ? renderOptionLabel.bind(null, {
|
|
304
267
|
id,
|
|
305
268
|
isDisabled,
|
|
@@ -308,8 +271,8 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
308
271
|
children
|
|
309
272
|
}) : renderOptionLabel;
|
|
310
273
|
};
|
|
311
|
-
|
|
312
|
-
|
|
274
|
+
let optionProps = {
|
|
275
|
+
// passthrough props
|
|
313
276
|
...omitProps(option.props, [...Option.allowedProps, ...Options.Item.allowedProps]),
|
|
314
277
|
// props from selectable
|
|
315
278
|
...getOptionProps({
|
|
@@ -318,49 +281,44 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
318
281
|
// Options.Item props
|
|
319
282
|
renderBeforeLabel: getRenderOptionLabel(renderBeforeLabel),
|
|
320
283
|
renderAfterLabel: getRenderOptionLabel(renderAfterLabel)
|
|
321
|
-
};
|
|
322
|
-
|
|
284
|
+
};
|
|
285
|
+
// should option be treated as highlighted or selected
|
|
323
286
|
if (isSelected) {
|
|
324
287
|
optionProps.variant = 'selected';
|
|
325
288
|
} else if (isHighlighted) {
|
|
326
289
|
optionProps.variant = 'highlighted';
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
|
|
290
|
+
}
|
|
291
|
+
// should option be treated as disabled
|
|
330
292
|
if (isDisabled) {
|
|
331
293
|
optionProps.variant = 'disabled';
|
|
332
|
-
optionProps = {
|
|
294
|
+
optionProps = {
|
|
295
|
+
...optionProps,
|
|
333
296
|
...getDisabledOptionProps()
|
|
334
297
|
};
|
|
335
298
|
} else {
|
|
336
299
|
// track as valid option if not disabled
|
|
337
300
|
this._optionIds.push(id);
|
|
338
301
|
}
|
|
339
|
-
|
|
340
302
|
return jsx(Options.Item, optionProps, children);
|
|
341
303
|
}
|
|
342
|
-
|
|
343
304
|
renderGroup(group, data) {
|
|
344
305
|
const getOptionProps = data.getOptionProps,
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
306
|
+
getDisabledOptionProps = data.getDisabledOptionProps,
|
|
307
|
+
isFirstChild = data.isFirstChild,
|
|
308
|
+
isLastChild = data.isLastChild,
|
|
309
|
+
afterGroup = data.afterGroup;
|
|
350
310
|
const _group$props = group.props,
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
311
|
+
id = _group$props.id,
|
|
312
|
+
renderLabel = _group$props.renderLabel,
|
|
313
|
+
children = _group$props.children,
|
|
314
|
+
rest = _objectWithoutProperties(_group$props, _excluded);
|
|
315
|
+
const groupChildren = [];
|
|
316
|
+
// add a separator above
|
|
358
317
|
if (!isFirstChild && !afterGroup) {
|
|
359
318
|
groupChildren.push(_Options$Separator || (_Options$Separator = jsx(Options.Separator, null)));
|
|
360
|
-
}
|
|
319
|
+
}
|
|
320
|
+
// create a sublist as a group
|
|
361
321
|
// a wrapping listitem will be created by Options
|
|
362
|
-
|
|
363
|
-
|
|
364
322
|
groupChildren.push(jsx(Options, Object.assign({
|
|
365
323
|
id: id,
|
|
366
324
|
as: "ul",
|
|
@@ -371,25 +329,23 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
371
329
|
getOptionProps,
|
|
372
330
|
getDisabledOptionProps
|
|
373
331
|
});
|
|
374
|
-
})));
|
|
375
|
-
|
|
332
|
+
})));
|
|
333
|
+
// add a separator below
|
|
376
334
|
if (!isLastChild) {
|
|
377
335
|
groupChildren.push(_Options$Separator2 || (_Options$Separator2 = jsx(Options.Separator, null)));
|
|
378
336
|
}
|
|
379
|
-
|
|
380
337
|
return groupChildren;
|
|
381
338
|
}
|
|
382
|
-
|
|
383
339
|
renderList(data) {
|
|
384
340
|
const getListProps = data.getListProps,
|
|
385
|
-
|
|
386
|
-
|
|
341
|
+
getOptionProps = data.getOptionProps,
|
|
342
|
+
getDisabledOptionProps = data.getDisabledOptionProps;
|
|
387
343
|
const _this$props6 = this.props,
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
344
|
+
isShowingOptions = _this$props6.isShowingOptions,
|
|
345
|
+
optionsMaxWidth = _this$props6.optionsMaxWidth,
|
|
346
|
+
optionsMaxHeight = _this$props6.optionsMaxHeight,
|
|
347
|
+
visibleOptionsCount = _this$props6.visibleOptionsCount,
|
|
348
|
+
children = _this$props6.children;
|
|
393
349
|
let lastWasGroup = false;
|
|
394
350
|
const viewProps = isShowingOptions ? {
|
|
395
351
|
display: 'block',
|
|
@@ -416,7 +372,6 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
416
372
|
getDisabledOptionProps
|
|
417
373
|
});
|
|
418
374
|
}
|
|
419
|
-
|
|
420
375
|
if (matchComponentTypes(child, [Group])) {
|
|
421
376
|
const afterGroup = lastWasGroup;
|
|
422
377
|
lastWasGroup = true;
|
|
@@ -429,15 +384,13 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
429
384
|
afterGroup
|
|
430
385
|
});
|
|
431
386
|
}
|
|
432
|
-
|
|
433
387
|
return;
|
|
434
388
|
}) : null));
|
|
435
389
|
}
|
|
436
|
-
|
|
437
390
|
renderIcon() {
|
|
438
391
|
const _this$props7 = this.props,
|
|
439
|
-
|
|
440
|
-
|
|
392
|
+
styles = _this$props7.styles,
|
|
393
|
+
isShowingOptions = _this$props7.isShowingOptions;
|
|
441
394
|
return jsx("span", {
|
|
442
395
|
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
443
396
|
}, isShowingOptions ? _IconArrowOpenUpLine || (_IconArrowOpenUpLine = jsx(IconArrowOpenUpLine, {
|
|
@@ -446,51 +399,48 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
446
399
|
inline: false
|
|
447
400
|
})));
|
|
448
401
|
}
|
|
449
|
-
|
|
450
402
|
renderInput(data) {
|
|
451
403
|
const getInputProps = data.getInputProps,
|
|
452
|
-
|
|
453
|
-
|
|
404
|
+
getTriggerProps = data.getTriggerProps;
|
|
454
405
|
const _this$props8 = this.props,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
406
|
+
renderLabel = _this$props8.renderLabel,
|
|
407
|
+
inputValue = _this$props8.inputValue,
|
|
408
|
+
placeholder = _this$props8.placeholder,
|
|
409
|
+
isRequired = _this$props8.isRequired,
|
|
410
|
+
shouldNotWrap = _this$props8.shouldNotWrap,
|
|
411
|
+
size = _this$props8.size,
|
|
412
|
+
isInline = _this$props8.isInline,
|
|
413
|
+
width = _this$props8.width,
|
|
414
|
+
htmlSize = _this$props8.htmlSize,
|
|
415
|
+
messages = _this$props8.messages,
|
|
416
|
+
renderBeforeInput = _this$props8.renderBeforeInput,
|
|
417
|
+
renderAfterInput = _this$props8.renderAfterInput,
|
|
418
|
+
onFocus = _this$props8.onFocus,
|
|
419
|
+
onBlur = _this$props8.onBlur,
|
|
420
|
+
onInputChange = _this$props8.onInputChange,
|
|
421
|
+
onRequestHideOptions = _this$props8.onRequestHideOptions,
|
|
422
|
+
rest = _objectWithoutProperties(_this$props8, _excluded2);
|
|
473
423
|
const interaction = this.interaction;
|
|
474
424
|
const passthroughProps = omitProps(rest, Select.allowedProps);
|
|
425
|
+
const _getTriggerProps = getTriggerProps({
|
|
426
|
+
...passthroughProps
|
|
427
|
+
}),
|
|
428
|
+
ref = _getTriggerProps.ref,
|
|
429
|
+
triggerProps = _objectWithoutProperties(_getTriggerProps, _excluded3);
|
|
430
|
+
const isEditable = typeof onInputChange !== 'undefined';
|
|
475
431
|
|
|
476
|
-
|
|
477
|
-
}),
|
|
478
|
-
ref = _getTriggerProps.ref,
|
|
479
|
-
triggerProps = _objectWithoutProperties(_getTriggerProps, _excluded3);
|
|
480
|
-
|
|
481
|
-
const isEditable = typeof onInputChange !== 'undefined'; // props to ensure screen readers treat uneditable selects as accessible
|
|
432
|
+
// props to ensure screen readers treat uneditable selects as accessible
|
|
482
433
|
// popup buttons rather than comboboxes.
|
|
483
|
-
|
|
484
434
|
const overrideProps = !isEditable ? {
|
|
485
435
|
role: 'button',
|
|
486
436
|
title: inputValue,
|
|
487
437
|
'aria-autocomplete': void 0
|
|
488
|
-
} : {};
|
|
438
|
+
} : {};
|
|
489
439
|
|
|
440
|
+
// backdoor to autocomplete attr to work around chrome autofill issues
|
|
490
441
|
if (passthroughProps['autoComplete']) {
|
|
491
442
|
overrideProps.autoComplete = passthroughProps['autoComplete'];
|
|
492
443
|
}
|
|
493
|
-
|
|
494
444
|
const inputProps = {
|
|
495
445
|
id: this.id,
|
|
496
446
|
renderLabel,
|
|
@@ -520,16 +470,15 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
520
470
|
};
|
|
521
471
|
return jsx(TextInput, Object.assign({}, triggerProps, getInputProps(inputProps)));
|
|
522
472
|
}
|
|
523
|
-
|
|
524
473
|
render() {
|
|
525
474
|
const _this$props9 = this.props,
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
475
|
+
constrain = _this$props9.constrain,
|
|
476
|
+
placement = _this$props9.placement,
|
|
477
|
+
mountNode = _this$props9.mountNode,
|
|
478
|
+
assistiveText = _this$props9.assistiveText,
|
|
479
|
+
isShowingOptions = _this$props9.isShowingOptions,
|
|
480
|
+
styles = _this$props9.styles;
|
|
481
|
+
// clear temporary option store
|
|
533
482
|
this._optionIds = [];
|
|
534
483
|
const highlightedOptionId = this.highlightedOptionId;
|
|
535
484
|
const selectedOptionId = this.selectedOptionId;
|
|
@@ -539,12 +488,12 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
539
488
|
selectedOptionId: selectedOptionId
|
|
540
489
|
}, this.getEventHandlers()), _ref3 => {
|
|
541
490
|
let getRootProps = _ref3.getRootProps,
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
491
|
+
getInputProps = _ref3.getInputProps,
|
|
492
|
+
getTriggerProps = _ref3.getTriggerProps,
|
|
493
|
+
getListProps = _ref3.getListProps,
|
|
494
|
+
getOptionProps = _ref3.getOptionProps,
|
|
495
|
+
getDisabledOptionProps = _ref3.getDisabledOptionProps,
|
|
496
|
+
getDescriptionProps = _ref3.getDescriptionProps;
|
|
548
497
|
return jsx("span", Object.assign({}, getRootProps({
|
|
549
498
|
css: styles === null || styles === void 0 ? void 0 : styles.select
|
|
550
499
|
}), {
|
|
@@ -569,7 +518,6 @@ let Select = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gen
|
|
|
569
518
|
})));
|
|
570
519
|
});
|
|
571
520
|
}
|
|
572
|
-
|
|
573
521
|
}, _class2.displayName = "Select", _class2.componentId = 'Select', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
574
522
|
inputValue: '',
|
|
575
523
|
isShowingOptions: false,
|
package/es/Select/props.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import PropTypes from 'prop-types';
|
|
25
26
|
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
26
27
|
import { FormPropTypes } from '@instructure/ui-form-field';
|
package/es/Select/styles.js
CHANGED
package/es/Select/theme.js
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const colors = theme.colors,
|
|
32
|
-
|
|
32
|
+
typography = theme.typography;
|
|
33
33
|
const componentVariables = {
|
|
34
34
|
fontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
|
|
35
35
|
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
@@ -40,8 +40,8 @@ const generateComponentTheme = theme => {
|
|
|
40
40
|
color: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
|
|
41
41
|
background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest
|
|
42
42
|
};
|
|
43
|
-
return {
|
|
43
|
+
return {
|
|
44
|
+
...componentVariables
|
|
44
45
|
};
|
|
45
46
|
};
|
|
46
|
-
|
|
47
47
|
export default generateComponentTheme;
|