@instructure/ui-select 8.13.1-snapshot.14 → 8.13.1-snapshot.26
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/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 -23
- 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/lib/Select/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
@@ -9,12 +11,14 @@ exports.default = exports.Select = void 0;
|
|
|
9
11
|
|
|
10
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
13
|
|
|
12
|
-
var _react = require("react");
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
15
|
|
|
14
16
|
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
15
17
|
|
|
16
18
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
17
19
|
|
|
20
|
+
var _uid = require("@instructure/uid");
|
|
21
|
+
|
|
18
22
|
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
|
19
23
|
|
|
20
24
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
@@ -39,8 +43,6 @@ var _IconArrowOpenDownLine = require("@instructure/ui-icons/lib/IconArrowOpenDow
|
|
|
39
43
|
|
|
40
44
|
var _IconArrowOpenUpLine2 = require("@instructure/ui-icons/lib/IconArrowOpenUpLine.js");
|
|
41
45
|
|
|
42
|
-
var _uid = require("@instructure/uid");
|
|
43
|
-
|
|
44
46
|
var _emotion = require("@instructure/emotion");
|
|
45
47
|
|
|
46
48
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
@@ -64,22 +66,24 @@ var _dec, _dec2, _class, _class2, _temp, _Options$Separator, _Options$Separator2
|
|
|
64
66
|
category: components
|
|
65
67
|
tags: autocomplete, typeahead, combobox, dropdown, search, form
|
|
66
68
|
---
|
|
69
|
+
@tsProps
|
|
67
70
|
**/
|
|
68
71
|
let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_temp = _class2 = class Select extends _react.Component {
|
|
69
72
|
constructor() {
|
|
70
73
|
super(...arguments);
|
|
71
|
-
this.ref = null;
|
|
72
74
|
this.state = {
|
|
73
75
|
hasInputRef: false
|
|
74
76
|
};
|
|
77
|
+
this.ref = null;
|
|
75
78
|
this._defaultId = (0, _uid.uid)('Select');
|
|
76
|
-
this.
|
|
77
|
-
this.
|
|
78
|
-
this._list = null;
|
|
79
|
+
this._inputContainer = null;
|
|
80
|
+
this._listView = null;
|
|
79
81
|
this._optionIds = [];
|
|
80
82
|
this._optionHeight = 36;
|
|
81
83
|
|
|
82
84
|
this.handleInputRef = node => {
|
|
85
|
+
var _this$props$inputRef, _this$props;
|
|
86
|
+
|
|
83
87
|
// ensures list is positioned with respect to input if list is open on mount
|
|
84
88
|
if (!this.state.hasInputRef) {
|
|
85
89
|
this.setState({
|
|
@@ -88,12 +92,13 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
this.ref = node;
|
|
91
|
-
this.props.inputRef(node);
|
|
95
|
+
(_this$props$inputRef = (_this$props = this.props).inputRef) === null || _this$props$inputRef === void 0 ? void 0 : _this$props$inputRef.call(_this$props, node);
|
|
92
96
|
};
|
|
93
97
|
|
|
94
98
|
this.handleListRef = node => {
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
var _this$props$listRef, _this$props2;
|
|
100
|
+
|
|
101
|
+
(_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
|
|
97
102
|
|
|
98
103
|
if (node && node.querySelector('[role="option"]')) {
|
|
99
104
|
this._optionHeight = node.querySelector('[role="option"]').offsetHeight;
|
|
@@ -106,15 +111,15 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
componentDidMount() {
|
|
109
|
-
var _this$props$makeStyle, _this$
|
|
114
|
+
var _this$props$makeStyle, _this$props3;
|
|
110
115
|
|
|
111
|
-
(_this$props$makeStyle = (_this$
|
|
116
|
+
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
componentDidUpdate() {
|
|
115
|
-
var _this$props$makeStyle2, _this$
|
|
120
|
+
var _this$props$makeStyle2, _this$props4;
|
|
116
121
|
|
|
117
|
-
(_this$props$makeStyle2 = (_this$
|
|
122
|
+
(_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
|
|
118
123
|
|
|
119
124
|
this.scrollToOption(this.highlightedOptionId);
|
|
120
125
|
}
|
|
@@ -136,7 +141,7 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
136
141
|
}
|
|
137
142
|
|
|
138
143
|
get width() {
|
|
139
|
-
return this._inputContainer
|
|
144
|
+
return this._inputContainer ? this._inputContainer.offsetWidth : void 0;
|
|
140
145
|
}
|
|
141
146
|
|
|
142
147
|
get interaction() {
|
|
@@ -146,11 +151,13 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
146
151
|
}
|
|
147
152
|
|
|
148
153
|
get highlightedOptionId() {
|
|
149
|
-
let highlightedOptionId
|
|
154
|
+
let highlightedOptionId;
|
|
150
155
|
|
|
151
156
|
_react.Children.toArray(this.props.children).forEach(child => {
|
|
152
157
|
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
|
|
153
158
|
// group found
|
|
159
|
+
;
|
|
160
|
+
|
|
154
161
|
_react.Children.toArray(child.props.children).forEach(option => {
|
|
155
162
|
// check options in group
|
|
156
163
|
if (option.props.isHighlighted) {
|
|
@@ -174,6 +181,8 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
174
181
|
_react.Children.toArray(this.props.children).forEach(child => {
|
|
175
182
|
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
|
|
176
183
|
// group found
|
|
184
|
+
;
|
|
185
|
+
|
|
177
186
|
_react.Children.toArray(child.props.children).forEach(option => {
|
|
178
187
|
// check options in group
|
|
179
188
|
if (option.props.isSelected) {
|
|
@@ -188,8 +197,14 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
188
197
|
}
|
|
189
198
|
});
|
|
190
199
|
|
|
191
|
-
if (selectedOptionId.length === 1)
|
|
192
|
-
|
|
200
|
+
if (selectedOptionId.length === 1) {
|
|
201
|
+
return selectedOptionId[0];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (selectedOptionId.length === 0) {
|
|
205
|
+
return void 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
193
208
|
return selectedOptionId;
|
|
194
209
|
}
|
|
195
210
|
|
|
@@ -202,7 +217,7 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
202
217
|
const parentTop = (0, _getBoundingClientRect.getBoundingClientRect)(this._listView).top;
|
|
203
218
|
const elemTop = (0, _getBoundingClientRect.getBoundingClientRect)(listItem).top;
|
|
204
219
|
const parentBottom = parentTop + this._listView.clientHeight;
|
|
205
|
-
const elemBottom = elemTop + listItem.clientHeight;
|
|
220
|
+
const elemBottom = elemTop + (listItem ? listItem.clientHeight : 0);
|
|
206
221
|
|
|
207
222
|
if (elemBottom > parentBottom) {
|
|
208
223
|
this._listView.scrollTop += elemBottom - parentBottom;
|
|
@@ -216,23 +231,23 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
216
231
|
const onRequestHighlightOption = this.props.onRequestHighlightOption;
|
|
217
232
|
|
|
218
233
|
if (id) {
|
|
219
|
-
onRequestHighlightOption(event, {
|
|
234
|
+
onRequestHighlightOption === null || onRequestHighlightOption === void 0 ? void 0 : onRequestHighlightOption(event, {
|
|
220
235
|
id
|
|
221
236
|
});
|
|
222
237
|
}
|
|
223
238
|
}
|
|
224
239
|
|
|
225
240
|
getEventHandlers() {
|
|
226
|
-
const _this$
|
|
227
|
-
isShowingOptions = _this$
|
|
228
|
-
onRequestShowOptions = _this$
|
|
229
|
-
onRequestHideOptions = _this$
|
|
230
|
-
onRequestSelectOption = _this$
|
|
241
|
+
const _this$props5 = this.props,
|
|
242
|
+
isShowingOptions = _this$props5.isShowingOptions,
|
|
243
|
+
onRequestShowOptions = _this$props5.onRequestShowOptions,
|
|
244
|
+
onRequestHideOptions = _this$props5.onRequestHideOptions,
|
|
245
|
+
onRequestSelectOption = _this$props5.onRequestSelectOption;
|
|
231
246
|
const highlightedOptionId = this.highlightedOptionId;
|
|
232
247
|
const selectedOptionId = this.selectedOptionId;
|
|
233
248
|
return this.interaction === 'enabled' ? {
|
|
234
249
|
onRequestShowOptions: event => {
|
|
235
|
-
onRequestShowOptions(event);
|
|
250
|
+
onRequestShowOptions === null || onRequestShowOptions === void 0 ? void 0 : onRequestShowOptions(event);
|
|
236
251
|
|
|
237
252
|
if (selectedOptionId && !Array.isArray(selectedOptionId)) {
|
|
238
253
|
// highlight selected option on show
|
|
@@ -240,14 +255,14 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
240
255
|
}
|
|
241
256
|
},
|
|
242
257
|
onRequestHideOptions: event => {
|
|
243
|
-
onRequestHideOptions(event);
|
|
258
|
+
onRequestHideOptions === null || onRequestHideOptions === void 0 ? void 0 : onRequestHideOptions(event);
|
|
244
259
|
},
|
|
245
260
|
onRequestHighlightOption: (event, _ref) => {
|
|
246
261
|
let id = _ref.id,
|
|
247
262
|
direction = _ref.direction;
|
|
248
263
|
if (!isShowingOptions) return; // if id exists, use that
|
|
249
264
|
|
|
250
|
-
let highlightId = this._optionIds.indexOf(id) > -1 ? id :
|
|
265
|
+
let highlightId = this._optionIds.indexOf(id) > -1 ? id : void 0;
|
|
251
266
|
|
|
252
267
|
if (!highlightId) {
|
|
253
268
|
if (!highlightedOptionId) {
|
|
@@ -257,7 +272,7 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
257
272
|
// find next id based on direction
|
|
258
273
|
const index = this._optionIds.indexOf(highlightedOptionId);
|
|
259
274
|
|
|
260
|
-
highlightId = index > -1 ? this._optionIds[index + direction] :
|
|
275
|
+
highlightId = index > -1 ? this._optionIds[index + direction] : void 0;
|
|
261
276
|
}
|
|
262
277
|
}
|
|
263
278
|
|
|
@@ -277,7 +292,7 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
277
292
|
|
|
278
293
|
if (id && this._optionIds.indexOf(id) !== -1) {
|
|
279
294
|
// only select if id exists as a valid option
|
|
280
|
-
onRequestSelectOption(event, {
|
|
295
|
+
onRequestSelectOption === null || onRequestSelectOption === void 0 ? void 0 : onRequestSelectOption(event, {
|
|
281
296
|
id
|
|
282
297
|
});
|
|
283
298
|
}
|
|
@@ -297,14 +312,14 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
297
312
|
renderAfterLabel = _option$props.renderAfterLabel,
|
|
298
313
|
children = _option$props.children;
|
|
299
314
|
|
|
300
|
-
const
|
|
301
|
-
return typeof
|
|
315
|
+
const getRenderOptionLabel = renderOptionLabel => {
|
|
316
|
+
return typeof renderOptionLabel === 'function' ? renderOptionLabel.bind(null, {
|
|
302
317
|
id,
|
|
303
318
|
isDisabled,
|
|
304
319
|
isSelected,
|
|
305
320
|
isHighlighted,
|
|
306
321
|
children
|
|
307
|
-
}) :
|
|
322
|
+
}) : renderOptionLabel;
|
|
308
323
|
};
|
|
309
324
|
|
|
310
325
|
let optionProps = { // passthrough props
|
|
@@ -314,8 +329,8 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
314
329
|
id
|
|
315
330
|
}),
|
|
316
331
|
// Options.Item props
|
|
317
|
-
renderBeforeLabel:
|
|
318
|
-
renderAfterLabel:
|
|
332
|
+
renderBeforeLabel: getRenderOptionLabel(renderBeforeLabel),
|
|
333
|
+
renderAfterLabel: getRenderOptionLabel(renderAfterLabel)
|
|
319
334
|
}; // should option be treated as highlighted or selected
|
|
320
335
|
|
|
321
336
|
if (isSelected) {
|
|
@@ -380,11 +395,11 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
380
395
|
const getListProps = data.getListProps,
|
|
381
396
|
getOptionProps = data.getOptionProps,
|
|
382
397
|
getDisabledOptionProps = data.getDisabledOptionProps;
|
|
383
|
-
const _this$
|
|
384
|
-
isShowingOptions = _this$
|
|
385
|
-
optionsMaxWidth = _this$
|
|
386
|
-
visibleOptionsCount = _this$
|
|
387
|
-
children = _this$
|
|
398
|
+
const _this$props6 = this.props,
|
|
399
|
+
isShowingOptions = _this$props6.isShowingOptions,
|
|
400
|
+
optionsMaxWidth = _this$props6.optionsMaxWidth,
|
|
401
|
+
visibleOptionsCount = _this$props6.visibleOptionsCount,
|
|
402
|
+
children = _this$props6.children;
|
|
388
403
|
let lastWasGroup = false;
|
|
389
404
|
const viewProps = isShowingOptions ? {
|
|
390
405
|
display: 'block',
|
|
@@ -413,7 +428,7 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
413
428
|
}
|
|
414
429
|
|
|
415
430
|
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
|
|
416
|
-
const afterGroup = lastWasGroup
|
|
431
|
+
const afterGroup = lastWasGroup;
|
|
417
432
|
lastWasGroup = true;
|
|
418
433
|
return this.renderGroup(child, {
|
|
419
434
|
getOptionProps,
|
|
@@ -424,13 +439,15 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
424
439
|
afterGroup
|
|
425
440
|
});
|
|
426
441
|
}
|
|
442
|
+
|
|
443
|
+
return;
|
|
427
444
|
}) : null));
|
|
428
445
|
}
|
|
429
446
|
|
|
430
447
|
renderIcon() {
|
|
431
|
-
const _this$
|
|
432
|
-
styles = _this$
|
|
433
|
-
isShowingOptions = _this$
|
|
448
|
+
const _this$props7 = this.props,
|
|
449
|
+
styles = _this$props7.styles,
|
|
450
|
+
isShowingOptions = _this$props7.isShowingOptions;
|
|
434
451
|
return (0, _emotion.jsx)("span", {
|
|
435
452
|
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
436
453
|
}, isShowingOptions ? _IconArrowOpenUpLine || (_IconArrowOpenUpLine = (0, _emotion.jsx)(_IconArrowOpenUpLine2.IconArrowOpenUpLine, {
|
|
@@ -443,24 +460,24 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
443
460
|
renderInput(data) {
|
|
444
461
|
const getInputProps = data.getInputProps,
|
|
445
462
|
getTriggerProps = data.getTriggerProps;
|
|
446
|
-
const _this$
|
|
447
|
-
renderLabel = _this$
|
|
448
|
-
inputValue = _this$
|
|
449
|
-
placeholder = _this$
|
|
450
|
-
isRequired = _this$
|
|
451
|
-
shouldNotWrap = _this$
|
|
452
|
-
size = _this$
|
|
453
|
-
isInline = _this$
|
|
454
|
-
width = _this$
|
|
455
|
-
htmlSize = _this$
|
|
456
|
-
messages = _this$
|
|
457
|
-
renderBeforeInput = _this$
|
|
458
|
-
renderAfterInput = _this$
|
|
459
|
-
onFocus = _this$
|
|
460
|
-
onBlur = _this$
|
|
461
|
-
onInputChange = _this$
|
|
462
|
-
onRequestHideOptions = _this$
|
|
463
|
-
rest = (0, _objectWithoutProperties2.default)(_this$
|
|
463
|
+
const _this$props8 = this.props,
|
|
464
|
+
renderLabel = _this$props8.renderLabel,
|
|
465
|
+
inputValue = _this$props8.inputValue,
|
|
466
|
+
placeholder = _this$props8.placeholder,
|
|
467
|
+
isRequired = _this$props8.isRequired,
|
|
468
|
+
shouldNotWrap = _this$props8.shouldNotWrap,
|
|
469
|
+
size = _this$props8.size,
|
|
470
|
+
isInline = _this$props8.isInline,
|
|
471
|
+
width = _this$props8.width,
|
|
472
|
+
htmlSize = _this$props8.htmlSize,
|
|
473
|
+
messages = _this$props8.messages,
|
|
474
|
+
renderBeforeInput = _this$props8.renderBeforeInput,
|
|
475
|
+
renderAfterInput = _this$props8.renderAfterInput,
|
|
476
|
+
onFocus = _this$props8.onFocus,
|
|
477
|
+
onBlur = _this$props8.onBlur,
|
|
478
|
+
onInputChange = _this$props8.onInputChange,
|
|
479
|
+
onRequestHideOptions = _this$props8.onRequestHideOptions,
|
|
480
|
+
rest = (0, _objectWithoutProperties2.default)(_this$props8, _excluded2);
|
|
464
481
|
const interaction = this.interaction;
|
|
465
482
|
const passthroughProps = (0, _omitProps.omitProps)(rest, Select.allowedProps);
|
|
466
483
|
|
|
@@ -475,14 +492,14 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
475
492
|
const overrideProps = !isEditable ? {
|
|
476
493
|
role: 'button',
|
|
477
494
|
title: inputValue,
|
|
478
|
-
'aria-autocomplete':
|
|
495
|
+
'aria-autocomplete': void 0
|
|
479
496
|
} : {}; // backdoor to autocomplete attr to work around chrome autofill issues
|
|
480
497
|
|
|
481
498
|
if (passthroughProps['autoComplete']) {
|
|
482
499
|
overrideProps.autoComplete = passthroughProps['autoComplete'];
|
|
483
500
|
}
|
|
484
501
|
|
|
485
|
-
|
|
502
|
+
const inputProps = {
|
|
486
503
|
id: this.id,
|
|
487
504
|
renderLabel,
|
|
488
505
|
placeholder,
|
|
@@ -500,21 +517,26 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
500
517
|
display: isInline ? 'inline-block' : 'block',
|
|
501
518
|
renderBeforeInput,
|
|
502
519
|
renderAfterInput: renderAfterInput || this.renderIcon(),
|
|
503
|
-
onChange
|
|
520
|
+
// If `inputValue` is provided, we need to pass a default onChange handler,
|
|
521
|
+
// because TextInput `value` is a controlled prop,
|
|
522
|
+
// and onChange is not required for Select
|
|
523
|
+
// (before it was handled by TextInput's defaultProp)
|
|
524
|
+
onChange: typeof onInputChange === 'function' ? onInputChange : inputValue ? () => {} : void 0,
|
|
504
525
|
onFocus,
|
|
505
526
|
onBlur: (0, _createChainedFunction.createChainedFunction)(onBlur, onRequestHideOptions),
|
|
506
527
|
...overrideProps
|
|
507
|
-
}
|
|
528
|
+
};
|
|
529
|
+
return (0, _emotion.jsx)(_TextInput.TextInput, Object.assign({}, triggerProps, getInputProps(inputProps)));
|
|
508
530
|
}
|
|
509
531
|
|
|
510
532
|
render() {
|
|
511
|
-
const _this$
|
|
512
|
-
constrain = _this$
|
|
513
|
-
placement = _this$
|
|
514
|
-
mountNode = _this$
|
|
515
|
-
assistiveText = _this$
|
|
516
|
-
isShowingOptions = _this$
|
|
517
|
-
styles = _this$
|
|
533
|
+
const _this$props9 = this.props,
|
|
534
|
+
constrain = _this$props9.constrain,
|
|
535
|
+
placement = _this$props9.placement,
|
|
536
|
+
mountNode = _this$props9.mountNode,
|
|
537
|
+
assistiveText = _this$props9.assistiveText,
|
|
538
|
+
isShowingOptions = _this$props9.isShowingOptions,
|
|
539
|
+
styles = _this$props9.styles; // clear temporary option store
|
|
518
540
|
|
|
519
541
|
this._optionIds = [];
|
|
520
542
|
const highlightedOptionId = this.highlightedOptionId;
|
|
@@ -522,7 +544,7 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
522
544
|
return (0, _emotion.jsx)(_Selectable.Selectable, Object.assign({
|
|
523
545
|
highlightedOptionId: highlightedOptionId,
|
|
524
546
|
isShowingOptions: isShowingOptions,
|
|
525
|
-
selectedOptionId: selectedOptionId
|
|
547
|
+
selectedOptionId: selectedOptionId
|
|
526
548
|
}, this.getEventHandlers()), _ref3 => {
|
|
527
549
|
let getRootProps = _ref3.getRootProps,
|
|
528
550
|
getInputProps = _ref3.getInputProps,
|
|
@@ -558,7 +580,6 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
558
580
|
inputValue: '',
|
|
559
581
|
isShowingOptions: false,
|
|
560
582
|
size: 'medium',
|
|
561
|
-
placeholder: null,
|
|
562
583
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
563
584
|
interaction: void 0,
|
|
564
585
|
isRequired: false,
|
|
@@ -566,17 +587,6 @@ let Select = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
566
587
|
visibleOptionsCount: 8,
|
|
567
588
|
placement: 'bottom stretch',
|
|
568
589
|
constrain: 'window',
|
|
569
|
-
onFocus: event => {},
|
|
570
|
-
onBlur: event => {},
|
|
571
|
-
onRequestShowOptions: event => {},
|
|
572
|
-
onRequestHideOptions: event => {},
|
|
573
|
-
onRequestHighlightOption: (event, data) => {},
|
|
574
|
-
onRequestSelectOption: (event, data) => {},
|
|
575
|
-
inputRef: node => {},
|
|
576
|
-
listRef: node => {},
|
|
577
|
-
renderBeforeInput: null,
|
|
578
|
-
renderAfterInput: null,
|
|
579
|
-
children: null,
|
|
580
590
|
shouldNotWrap: false
|
|
581
591
|
}, _class2.Option = _Option.Option, _class2.Group = _Group.Group, _temp)) || _class) || _class);
|
|
582
592
|
exports.Select = Select;
|
package/lib/Select/props.js
CHANGED
|
@@ -43,176 +43,36 @@ var _Option = require("./Option");
|
|
|
43
43
|
* SOFTWARE.
|
|
44
44
|
*/
|
|
45
45
|
const propTypes = {
|
|
46
|
-
/**
|
|
47
|
-
* The form field label.
|
|
48
|
-
*/
|
|
49
46
|
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* The value to display in the text input.
|
|
53
|
-
*/
|
|
54
47
|
inputValue: _propTypes.default.string,
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Whether or not to show the options list.
|
|
58
|
-
*/
|
|
59
|
-
isShowingOptions: _propTypes.default.bool,
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* The id of the text input. One is generated if not supplied.
|
|
63
|
-
*/
|
|
64
48
|
id: _propTypes.default.string,
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* The size of the text input.
|
|
68
|
-
*/
|
|
69
49
|
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Additional helpful text to provide to screen readers about the operation
|
|
73
|
-
* of the component.
|
|
74
|
-
*/
|
|
75
50
|
assistiveText: _propTypes.default.string,
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Html placeholder text to display when the input has no value. This should
|
|
79
|
-
* be hint text, not a label replacement.
|
|
80
|
-
*/
|
|
81
51
|
placeholder: _propTypes.default.string,
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Specifies if interaction with the input is enabled, disabled, or readonly.
|
|
85
|
-
* When "disabled", the input changes visibly to indicate that it cannot
|
|
86
|
-
* receive user interactions. When "readonly" the input still cannot receive
|
|
87
|
-
* user interactions but it keeps the same styles as if it were enabled.
|
|
88
|
-
*/
|
|
89
52
|
interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Whether or not the text input is required.
|
|
93
|
-
*/
|
|
94
53
|
isRequired: _propTypes.default.bool,
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Whether the input is rendered inline with other elements or if it
|
|
98
|
-
* is rendered as a block level element.
|
|
99
|
-
*/
|
|
100
54
|
isInline: _propTypes.default.bool,
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* The width of the text input.
|
|
104
|
-
*/
|
|
105
55
|
width: _propTypes.default.string,
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* The width of the text input, in characters, if a width is not explicitly
|
|
109
|
-
* provided via the `width` prop. Only applicable if `isInline={true}`.
|
|
110
|
-
*/
|
|
111
|
-
htmlSize: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* The max width the options list can be before option text wraps. If not
|
|
115
|
-
* set, the list will only display as wide as the text input.
|
|
116
|
-
*/
|
|
56
|
+
htmlSize: _propTypes.default.number,
|
|
117
57
|
optionsMaxWidth: _propTypes.default.string,
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* The number of options that should be visible before having to scroll.
|
|
121
|
-
*/
|
|
122
58
|
visibleOptionsCount: _propTypes.default.number,
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Displays messages and validation for the input. It should be an object
|
|
126
|
-
* with the following shape:
|
|
127
|
-
* `{
|
|
128
|
-
* text: PropTypes.node,
|
|
129
|
-
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
130
|
-
* }`
|
|
131
|
-
*/
|
|
132
59
|
messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* The placement of the options list.
|
|
136
|
-
*/
|
|
137
60
|
placement: _PositionPropTypes.PositionPropTypes.placement,
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* The parent in which to constrain the placement.
|
|
141
|
-
*/
|
|
142
61
|
constrain: _PositionPropTypes.PositionPropTypes.constrain,
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* An element or a function returning an element to use mount the options
|
|
146
|
-
* list to in the DOM (defaults to `document.body`)
|
|
147
|
-
*/
|
|
148
62
|
mountNode: _PositionPropTypes.PositionPropTypes.mountNode,
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Callback fired when text input receives focus.
|
|
152
|
-
*/
|
|
153
63
|
onFocus: _propTypes.default.func,
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Callback fired when text input loses focus.
|
|
157
|
-
*/
|
|
158
64
|
onBlur: _propTypes.default.func,
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Callback fired when text input value changes.
|
|
162
|
-
*/
|
|
163
65
|
onInputChange: _propTypes.default.func,
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Callback fired requesting that the options list be shown.
|
|
167
|
-
*/
|
|
66
|
+
isShowingOptions: _propTypes.default.bool,
|
|
168
67
|
onRequestShowOptions: _propTypes.default.func,
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Callback fired requesting that the options list be hidden.
|
|
172
|
-
*/
|
|
173
68
|
onRequestHideOptions: _propTypes.default.func,
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Callback fired requesting a particular option be highlighted.
|
|
177
|
-
*/
|
|
178
69
|
onRequestHighlightOption: _propTypes.default.func,
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Callback fired requesting a particular option be selected.
|
|
182
|
-
*/
|
|
183
70
|
onRequestSelectOption: _propTypes.default.func,
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* A ref to the html `input` element.
|
|
187
|
-
*/
|
|
188
71
|
inputRef: _propTypes.default.func,
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* A ref to the html `ul` element.
|
|
192
|
-
*/
|
|
193
72
|
listRef: _propTypes.default.func,
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Content to display before the text input. This will commonly be an icon or
|
|
197
|
-
* tags to show multiple selections.
|
|
198
|
-
*/
|
|
199
73
|
renderBeforeInput: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Content to display after the text input. This content will replace the
|
|
203
|
-
* default arrow icons.
|
|
204
|
-
*/
|
|
205
74
|
renderAfterInput: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Children of type `<Select.Option />` or `<Select.Group />`.
|
|
209
|
-
*/
|
|
210
75
|
children: _Children.Children.oneOf([_Group.Group, _Option.Option]),
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Prevents the default behavior of wrapping the input and rendered content
|
|
214
|
-
* when available space is exceeded.
|
|
215
|
-
*/
|
|
216
76
|
shouldNotWrap: _propTypes.default.bool
|
|
217
77
|
};
|
|
218
78
|
exports.propTypes = propTypes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-select",
|
|
3
|
-
"version": "8.13.1-snapshot.
|
|
3
|
+
"version": "8.13.1-snapshot.26+46fefbe37",
|
|
4
4
|
"description": "A component for select and autocomplete behavior.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -24,30 +24,30 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@instructure/ui-babel-preset": "8.13.1-snapshot.
|
|
28
|
-
"@instructure/ui-color-utils": "8.13.1-snapshot.
|
|
29
|
-
"@instructure/ui-test-locator": "8.13.1-snapshot.
|
|
30
|
-
"@instructure/ui-test-utils": "8.13.1-snapshot.
|
|
31
|
-
"@instructure/ui-themes": "8.13.1-snapshot.
|
|
27
|
+
"@instructure/ui-babel-preset": "8.13.1-snapshot.26+46fefbe37",
|
|
28
|
+
"@instructure/ui-color-utils": "8.13.1-snapshot.26+46fefbe37",
|
|
29
|
+
"@instructure/ui-test-locator": "8.13.1-snapshot.26+46fefbe37",
|
|
30
|
+
"@instructure/ui-test-utils": "8.13.1-snapshot.26+46fefbe37",
|
|
31
|
+
"@instructure/ui-themes": "8.13.1-snapshot.26+46fefbe37"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.13.10",
|
|
35
|
-
"@instructure/emotion": "8.13.1-snapshot.
|
|
36
|
-
"@instructure/shared-types": "8.13.1-snapshot.
|
|
37
|
-
"@instructure/ui-dom-utils": "8.13.1-snapshot.
|
|
38
|
-
"@instructure/ui-form-field": "8.13.1-snapshot.
|
|
39
|
-
"@instructure/ui-icons": "8.13.1-snapshot.
|
|
40
|
-
"@instructure/ui-options": "8.13.1-snapshot.
|
|
41
|
-
"@instructure/ui-popover": "8.13.1-snapshot.
|
|
42
|
-
"@instructure/ui-position": "8.13.1-snapshot.
|
|
43
|
-
"@instructure/ui-prop-types": "8.13.1-snapshot.
|
|
44
|
-
"@instructure/ui-react-utils": "8.13.1-snapshot.
|
|
45
|
-
"@instructure/ui-selectable": "8.13.1-snapshot.
|
|
46
|
-
"@instructure/ui-testable": "8.13.1-snapshot.
|
|
47
|
-
"@instructure/ui-text-input": "8.13.1-snapshot.
|
|
48
|
-
"@instructure/ui-utils": "8.13.1-snapshot.
|
|
49
|
-
"@instructure/ui-view": "8.13.1-snapshot.
|
|
50
|
-
"@instructure/uid": "8.13.1-snapshot.
|
|
35
|
+
"@instructure/emotion": "8.13.1-snapshot.26+46fefbe37",
|
|
36
|
+
"@instructure/shared-types": "8.13.1-snapshot.26+46fefbe37",
|
|
37
|
+
"@instructure/ui-dom-utils": "8.13.1-snapshot.26+46fefbe37",
|
|
38
|
+
"@instructure/ui-form-field": "8.13.1-snapshot.26+46fefbe37",
|
|
39
|
+
"@instructure/ui-icons": "8.13.1-snapshot.26+46fefbe37",
|
|
40
|
+
"@instructure/ui-options": "8.13.1-snapshot.26+46fefbe37",
|
|
41
|
+
"@instructure/ui-popover": "8.13.1-snapshot.26+46fefbe37",
|
|
42
|
+
"@instructure/ui-position": "8.13.1-snapshot.26+46fefbe37",
|
|
43
|
+
"@instructure/ui-prop-types": "8.13.1-snapshot.26+46fefbe37",
|
|
44
|
+
"@instructure/ui-react-utils": "8.13.1-snapshot.26+46fefbe37",
|
|
45
|
+
"@instructure/ui-selectable": "8.13.1-snapshot.26+46fefbe37",
|
|
46
|
+
"@instructure/ui-testable": "8.13.1-snapshot.26+46fefbe37",
|
|
47
|
+
"@instructure/ui-text-input": "8.13.1-snapshot.26+46fefbe37",
|
|
48
|
+
"@instructure/ui-utils": "8.13.1-snapshot.26+46fefbe37",
|
|
49
|
+
"@instructure/ui-view": "8.13.1-snapshot.26+46fefbe37",
|
|
50
|
+
"@instructure/uid": "8.13.1-snapshot.26+46fefbe37",
|
|
51
51
|
"prop-types": "^15"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"sideEffects": false,
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "46fefbe371fc4000ebcc26609d003d75eb81eb69"
|
|
61
61
|
}
|