@instructure/ui-select 8.33.1 → 8.33.2-snapshot-5
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 +8 -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/lib/Select/index.js
CHANGED
|
@@ -1,66 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.Select = void 0;
|
|
11
|
-
|
|
12
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
11
|
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
17
|
-
|
|
18
12
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
19
|
-
|
|
20
13
|
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
|
21
|
-
|
|
22
14
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
23
|
-
|
|
24
15
|
var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
|
|
25
|
-
|
|
26
16
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
27
|
-
|
|
28
17
|
var _getBoundingClientRect = require("@instructure/ui-dom-utils/lib/getBoundingClientRect.js");
|
|
29
|
-
|
|
30
18
|
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
31
|
-
|
|
32
19
|
var _View = require("@instructure/ui-view/lib/View");
|
|
33
|
-
|
|
34
20
|
var _Selectable = require("@instructure/ui-selectable/lib/Selectable");
|
|
35
|
-
|
|
36
21
|
var _Popover = require("@instructure/ui-popover/lib/Popover");
|
|
37
|
-
|
|
38
22
|
var _TextInput = require("@instructure/ui-text-input/lib/TextInput");
|
|
39
|
-
|
|
40
23
|
var _Options = require("@instructure/ui-options/lib/Options");
|
|
41
|
-
|
|
42
24
|
var _IconArrowOpenDownLine = require("@instructure/ui-icons/lib/IconArrowOpenDownLine.js");
|
|
43
|
-
|
|
44
25
|
var _IconArrowOpenUpLine2 = require("@instructure/ui-icons/lib/IconArrowOpenUpLine.js");
|
|
45
|
-
|
|
46
26
|
var _emotion = require("@instructure/emotion");
|
|
47
|
-
|
|
48
27
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
49
|
-
|
|
50
28
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
51
|
-
|
|
52
29
|
var _Group = require("./Group");
|
|
53
|
-
|
|
54
30
|
var _Option = require("./Option");
|
|
55
|
-
|
|
56
31
|
var _props = require("./props");
|
|
57
|
-
|
|
58
32
|
const _excluded = ["id", "renderLabel", "children"],
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
33
|
+
_excluded2 = ["renderLabel", "inputValue", "placeholder", "isRequired", "shouldNotWrap", "size", "isInline", "width", "htmlSize", "messages", "renderBeforeInput", "renderAfterInput", "onFocus", "onBlur", "onInputChange", "onRequestHideOptions"],
|
|
34
|
+
_excluded3 = ["ref"];
|
|
62
35
|
var _dec, _dec2, _dec3, _class, _class2, _Options$Separator, _Options$Separator2, _IconArrowOpenUpLine, _IconArrowOpenDownLin;
|
|
63
|
-
|
|
64
36
|
/**
|
|
65
37
|
---
|
|
66
38
|
category: components
|
|
@@ -81,80 +53,64 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
81
53
|
this._listView = null;
|
|
82
54
|
this._optionIds = [];
|
|
83
55
|
this._optionHeight = 36;
|
|
84
|
-
|
|
85
56
|
this.handleInputRef = node => {
|
|
86
57
|
var _this$props$inputRef, _this$props;
|
|
87
|
-
|
|
88
58
|
// ensures list is positioned with respect to input if list is open on mount
|
|
89
59
|
if (!this.state.hasInputRef) {
|
|
90
60
|
this.setState({
|
|
91
61
|
hasInputRef: true
|
|
92
62
|
});
|
|
93
63
|
}
|
|
94
|
-
|
|
95
64
|
this._input = node;
|
|
96
65
|
(_this$props$inputRef = (_this$props = this.props).inputRef) === null || _this$props$inputRef === void 0 ? void 0 : _this$props$inputRef.call(_this$props, node);
|
|
97
66
|
};
|
|
98
|
-
|
|
99
67
|
this.handleListRef = node => {
|
|
100
68
|
var _this$props$listRef, _this$props2;
|
|
69
|
+
(_this$props$listRef = (_this$props2 = this.props).listRef) === null || _this$props$listRef === void 0 ? void 0 : _this$props$listRef.call(_this$props2, node);
|
|
101
70
|
|
|
102
|
-
|
|
103
|
-
|
|
71
|
+
// store option height to calculate list maxHeight
|
|
104
72
|
if (node && node.querySelector('[role="option"]')) {
|
|
105
73
|
this._optionHeight = node.querySelector('[role="option"]').offsetHeight;
|
|
106
74
|
}
|
|
107
75
|
};
|
|
108
|
-
|
|
109
76
|
this.handleInputContainerRef = node => {
|
|
110
77
|
this._inputContainer = node;
|
|
111
78
|
};
|
|
112
79
|
}
|
|
113
|
-
|
|
114
80
|
componentDidMount() {
|
|
115
81
|
var _this$props$makeStyle, _this$props3;
|
|
116
|
-
|
|
117
82
|
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
118
83
|
}
|
|
119
|
-
|
|
120
84
|
componentDidUpdate() {
|
|
121
85
|
var _this$props$makeStyle2, _this$props4;
|
|
86
|
+
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
122
87
|
|
|
123
|
-
|
|
124
|
-
|
|
88
|
+
// scroll option into view if needed
|
|
125
89
|
this.scrollToOption(this.highlightedOptionId);
|
|
126
90
|
}
|
|
127
|
-
|
|
128
91
|
focus() {
|
|
129
92
|
this._input && this._input.focus();
|
|
130
93
|
}
|
|
131
|
-
|
|
132
94
|
get childrenArray() {
|
|
133
95
|
return _react.Children.toArray(this.props.children);
|
|
134
96
|
}
|
|
135
|
-
|
|
136
97
|
getGroupChildrenArray(group) {
|
|
137
98
|
return _react.Children.toArray(group.props.children);
|
|
138
99
|
}
|
|
139
|
-
|
|
140
100
|
get focused() {
|
|
141
101
|
return this._input ? (0, _isActiveElement.isActiveElement)(this._input) : false;
|
|
142
102
|
}
|
|
143
|
-
|
|
144
103
|
get id() {
|
|
145
104
|
return this.props.id || this._defaultId;
|
|
146
105
|
}
|
|
147
|
-
|
|
148
106
|
get width() {
|
|
149
107
|
return this._inputContainer ? this._inputContainer.offsetWidth : void 0;
|
|
150
108
|
}
|
|
151
|
-
|
|
152
109
|
get interaction() {
|
|
153
110
|
return (0, _getInteraction.getInteraction)({
|
|
154
111
|
props: this.props
|
|
155
112
|
});
|
|
156
113
|
}
|
|
157
|
-
|
|
158
114
|
get highlightedOptionId() {
|
|
159
115
|
let highlightedOptionId;
|
|
160
116
|
this.childrenArray.forEach(child => {
|
|
@@ -175,7 +131,6 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
175
131
|
});
|
|
176
132
|
return highlightedOptionId;
|
|
177
133
|
}
|
|
178
|
-
|
|
179
134
|
get selectedOptionId() {
|
|
180
135
|
const selectedOptionId = [];
|
|
181
136
|
this.childrenArray.forEach(child => {
|
|
@@ -194,29 +149,23 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
194
149
|
}
|
|
195
150
|
}
|
|
196
151
|
});
|
|
197
|
-
|
|
198
152
|
if (selectedOptionId.length === 1) {
|
|
199
153
|
return selectedOptionId[0];
|
|
200
154
|
}
|
|
201
|
-
|
|
202
155
|
if (selectedOptionId.length === 0) {
|
|
203
156
|
return void 0;
|
|
204
157
|
}
|
|
205
|
-
|
|
206
158
|
return selectedOptionId;
|
|
207
159
|
}
|
|
208
|
-
|
|
209
160
|
scrollToOption(id) {
|
|
210
161
|
if (this._listView) {
|
|
211
162
|
const option = this._listView.querySelector(`[id="${id}"]`);
|
|
212
|
-
|
|
213
163
|
if (!option) return;
|
|
214
164
|
const listItem = option.parentNode;
|
|
215
165
|
const parentTop = (0, _getBoundingClientRect.getBoundingClientRect)(this._listView).top;
|
|
216
166
|
const elemTop = (0, _getBoundingClientRect.getBoundingClientRect)(listItem).top;
|
|
217
167
|
const parentBottom = parentTop + this._listView.clientHeight;
|
|
218
168
|
const elemBottom = elemTop + (listItem ? listItem.clientHeight : 0);
|
|
219
|
-
|
|
220
169
|
if (elemBottom > parentBottom) {
|
|
221
170
|
this._listView.scrollTop += elemBottom - parentBottom;
|
|
222
171
|
} else if (elemTop < parentTop) {
|
|
@@ -224,29 +173,25 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
224
173
|
}
|
|
225
174
|
}
|
|
226
175
|
}
|
|
227
|
-
|
|
228
176
|
highlightOption(event, id) {
|
|
229
177
|
const onRequestHighlightOption = this.props.onRequestHighlightOption;
|
|
230
|
-
|
|
231
178
|
if (id) {
|
|
232
179
|
onRequestHighlightOption === null || onRequestHighlightOption === void 0 ? void 0 : onRequestHighlightOption(event, {
|
|
233
180
|
id
|
|
234
181
|
});
|
|
235
182
|
}
|
|
236
183
|
}
|
|
237
|
-
|
|
238
184
|
getEventHandlers() {
|
|
239
185
|
const _this$props5 = this.props,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
186
|
+
isShowingOptions = _this$props5.isShowingOptions,
|
|
187
|
+
onRequestShowOptions = _this$props5.onRequestShowOptions,
|
|
188
|
+
onRequestHideOptions = _this$props5.onRequestHideOptions,
|
|
189
|
+
onRequestSelectOption = _this$props5.onRequestSelectOption;
|
|
244
190
|
const highlightedOptionId = this.highlightedOptionId;
|
|
245
191
|
const selectedOptionId = this.selectedOptionId;
|
|
246
192
|
return this.interaction === 'enabled' ? {
|
|
247
193
|
onRequestShowOptions: event => {
|
|
248
194
|
onRequestShowOptions === null || onRequestShowOptions === void 0 ? void 0 : onRequestShowOptions(event);
|
|
249
|
-
|
|
250
195
|
if (selectedOptionId && !Array.isArray(selectedOptionId)) {
|
|
251
196
|
// highlight selected option on show
|
|
252
197
|
this.highlightOption(event, selectedOptionId);
|
|
@@ -257,11 +202,10 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
257
202
|
},
|
|
258
203
|
onRequestHighlightOption: (event, _ref) => {
|
|
259
204
|
let id = _ref.id,
|
|
260
|
-
|
|
261
|
-
if (!isShowingOptions) return;
|
|
262
|
-
|
|
205
|
+
direction = _ref.direction;
|
|
206
|
+
if (!isShowingOptions) return;
|
|
207
|
+
// if id exists, use that
|
|
263
208
|
let highlightId = this._optionIds.indexOf(id) > -1 ? id : void 0;
|
|
264
|
-
|
|
265
209
|
if (!highlightId) {
|
|
266
210
|
if (!highlightedOptionId) {
|
|
267
211
|
// nothing highlighted yet, highlight first option
|
|
@@ -269,11 +213,9 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
269
213
|
} else {
|
|
270
214
|
// find next id based on direction
|
|
271
215
|
const index = this._optionIds.indexOf(highlightedOptionId);
|
|
272
|
-
|
|
273
216
|
highlightId = index > -1 ? this._optionIds[index + direction] : void 0;
|
|
274
217
|
}
|
|
275
218
|
}
|
|
276
|
-
|
|
277
219
|
if (highlightId) {
|
|
278
220
|
// only highlight if id exists as a valid option
|
|
279
221
|
this.highlightOption(event, highlightId);
|
|
@@ -287,7 +229,6 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
287
229
|
},
|
|
288
230
|
onRequestSelectOption: (event, _ref2) => {
|
|
289
231
|
let id = _ref2.id;
|
|
290
|
-
|
|
291
232
|
if (id && this._optionIds.indexOf(id) !== -1) {
|
|
292
233
|
// only select if id exists as a valid option
|
|
293
234
|
onRequestSelectOption === null || onRequestSelectOption === void 0 ? void 0 : onRequestSelectOption(event, {
|
|
@@ -297,22 +238,19 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
297
238
|
}
|
|
298
239
|
} : {};
|
|
299
240
|
}
|
|
300
|
-
|
|
301
241
|
renderOption(option, data) {
|
|
302
242
|
const getOptionProps = data.getOptionProps,
|
|
303
|
-
|
|
243
|
+
getDisabledOptionProps = data.getDisabledOptionProps;
|
|
304
244
|
const _option$props = option.props,
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
245
|
+
id = _option$props.id,
|
|
246
|
+
isDisabled = _option$props.isDisabled,
|
|
247
|
+
isHighlighted = _option$props.isHighlighted,
|
|
248
|
+
isSelected = _option$props.isSelected,
|
|
249
|
+
renderBeforeLabel = _option$props.renderBeforeLabel,
|
|
250
|
+
renderAfterLabel = _option$props.renderAfterLabel,
|
|
251
|
+
children = _option$props.children;
|
|
313
252
|
const getRenderOptionLabel = renderOptionLabel => {
|
|
314
253
|
var _renderOptionLabel$pr;
|
|
315
|
-
|
|
316
254
|
return typeof renderOptionLabel === 'function' && !(renderOptionLabel !== null && renderOptionLabel !== void 0 && (_renderOptionLabel$pr = renderOptionLabel.prototype) !== null && _renderOptionLabel$pr !== void 0 && _renderOptionLabel$pr.isReactComponent) ? renderOptionLabel.bind(null, {
|
|
317
255
|
id,
|
|
318
256
|
isDisabled,
|
|
@@ -321,8 +259,8 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
321
259
|
children
|
|
322
260
|
}) : renderOptionLabel;
|
|
323
261
|
};
|
|
324
|
-
|
|
325
|
-
|
|
262
|
+
let optionProps = {
|
|
263
|
+
// passthrough props
|
|
326
264
|
...(0, _omitProps.omitProps)(option.props, [..._Option.Option.allowedProps, ..._Options.Options.Item.allowedProps]),
|
|
327
265
|
// props from selectable
|
|
328
266
|
...getOptionProps({
|
|
@@ -331,47 +269,44 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
331
269
|
// Options.Item props
|
|
332
270
|
renderBeforeLabel: getRenderOptionLabel(renderBeforeLabel),
|
|
333
271
|
renderAfterLabel: getRenderOptionLabel(renderAfterLabel)
|
|
334
|
-
};
|
|
335
|
-
|
|
272
|
+
};
|
|
273
|
+
// should option be treated as highlighted or selected
|
|
336
274
|
if (isSelected) {
|
|
337
275
|
optionProps.variant = 'selected';
|
|
338
276
|
} else if (isHighlighted) {
|
|
339
277
|
optionProps.variant = 'highlighted';
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
|
|
278
|
+
}
|
|
279
|
+
// should option be treated as disabled
|
|
343
280
|
if (isDisabled) {
|
|
344
281
|
optionProps.variant = 'disabled';
|
|
345
|
-
optionProps = {
|
|
282
|
+
optionProps = {
|
|
283
|
+
...optionProps,
|
|
346
284
|
...getDisabledOptionProps()
|
|
347
285
|
};
|
|
348
286
|
} else {
|
|
349
287
|
// track as valid option if not disabled
|
|
350
288
|
this._optionIds.push(id);
|
|
351
289
|
}
|
|
352
|
-
|
|
353
290
|
return (0, _emotion.jsx)(_Options.Options.Item, optionProps, children);
|
|
354
291
|
}
|
|
355
|
-
|
|
356
292
|
renderGroup(group, data) {
|
|
357
293
|
const getOptionProps = data.getOptionProps,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
294
|
+
getDisabledOptionProps = data.getDisabledOptionProps,
|
|
295
|
+
isFirstChild = data.isFirstChild,
|
|
296
|
+
isLastChild = data.isLastChild,
|
|
297
|
+
afterGroup = data.afterGroup;
|
|
362
298
|
const _group$props = group.props,
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
const groupChildren = [];
|
|
368
|
-
|
|
299
|
+
id = _group$props.id,
|
|
300
|
+
renderLabel = _group$props.renderLabel,
|
|
301
|
+
children = _group$props.children,
|
|
302
|
+
rest = (0, _objectWithoutProperties2.default)(_group$props, _excluded);
|
|
303
|
+
const groupChildren = [];
|
|
304
|
+
// add a separator above
|
|
369
305
|
if (!isFirstChild && !afterGroup) {
|
|
370
306
|
groupChildren.push(_Options$Separator || (_Options$Separator = (0, _emotion.jsx)(_Options.Options.Separator, null)));
|
|
371
|
-
}
|
|
307
|
+
}
|
|
308
|
+
// create a sublist as a group
|
|
372
309
|
// a wrapping listitem will be created by Options
|
|
373
|
-
|
|
374
|
-
|
|
375
310
|
groupChildren.push((0, _emotion.jsx)(_Options.Options, Object.assign({
|
|
376
311
|
id: id,
|
|
377
312
|
as: "ul",
|
|
@@ -382,25 +317,23 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
382
317
|
getOptionProps,
|
|
383
318
|
getDisabledOptionProps
|
|
384
319
|
});
|
|
385
|
-
})));
|
|
386
|
-
|
|
320
|
+
})));
|
|
321
|
+
// add a separator below
|
|
387
322
|
if (!isLastChild) {
|
|
388
323
|
groupChildren.push(_Options$Separator2 || (_Options$Separator2 = (0, _emotion.jsx)(_Options.Options.Separator, null)));
|
|
389
324
|
}
|
|
390
|
-
|
|
391
325
|
return groupChildren;
|
|
392
326
|
}
|
|
393
|
-
|
|
394
327
|
renderList(data) {
|
|
395
328
|
const getListProps = data.getListProps,
|
|
396
|
-
|
|
397
|
-
|
|
329
|
+
getOptionProps = data.getOptionProps,
|
|
330
|
+
getDisabledOptionProps = data.getDisabledOptionProps;
|
|
398
331
|
const _this$props6 = this.props,
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
332
|
+
isShowingOptions = _this$props6.isShowingOptions,
|
|
333
|
+
optionsMaxWidth = _this$props6.optionsMaxWidth,
|
|
334
|
+
optionsMaxHeight = _this$props6.optionsMaxHeight,
|
|
335
|
+
visibleOptionsCount = _this$props6.visibleOptionsCount,
|
|
336
|
+
children = _this$props6.children;
|
|
404
337
|
let lastWasGroup = false;
|
|
405
338
|
const viewProps = isShowingOptions ? {
|
|
406
339
|
display: 'block',
|
|
@@ -427,7 +360,6 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
427
360
|
getDisabledOptionProps
|
|
428
361
|
});
|
|
429
362
|
}
|
|
430
|
-
|
|
431
363
|
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_Group.Group])) {
|
|
432
364
|
const afterGroup = lastWasGroup;
|
|
433
365
|
lastWasGroup = true;
|
|
@@ -440,15 +372,13 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
440
372
|
afterGroup
|
|
441
373
|
});
|
|
442
374
|
}
|
|
443
|
-
|
|
444
375
|
return;
|
|
445
376
|
}) : null));
|
|
446
377
|
}
|
|
447
|
-
|
|
448
378
|
renderIcon() {
|
|
449
379
|
const _this$props7 = this.props,
|
|
450
|
-
|
|
451
|
-
|
|
380
|
+
styles = _this$props7.styles,
|
|
381
|
+
isShowingOptions = _this$props7.isShowingOptions;
|
|
452
382
|
return (0, _emotion.jsx)("span", {
|
|
453
383
|
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
454
384
|
}, isShowingOptions ? _IconArrowOpenUpLine || (_IconArrowOpenUpLine = (0, _emotion.jsx)(_IconArrowOpenUpLine2.IconArrowOpenUpLine, {
|
|
@@ -457,49 +387,48 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
457
387
|
inline: false
|
|
458
388
|
})));
|
|
459
389
|
}
|
|
460
|
-
|
|
461
390
|
renderInput(data) {
|
|
462
391
|
const getInputProps = data.getInputProps,
|
|
463
|
-
|
|
392
|
+
getTriggerProps = data.getTriggerProps;
|
|
464
393
|
const _this$props8 = this.props,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
394
|
+
renderLabel = _this$props8.renderLabel,
|
|
395
|
+
inputValue = _this$props8.inputValue,
|
|
396
|
+
placeholder = _this$props8.placeholder,
|
|
397
|
+
isRequired = _this$props8.isRequired,
|
|
398
|
+
shouldNotWrap = _this$props8.shouldNotWrap,
|
|
399
|
+
size = _this$props8.size,
|
|
400
|
+
isInline = _this$props8.isInline,
|
|
401
|
+
width = _this$props8.width,
|
|
402
|
+
htmlSize = _this$props8.htmlSize,
|
|
403
|
+
messages = _this$props8.messages,
|
|
404
|
+
renderBeforeInput = _this$props8.renderBeforeInput,
|
|
405
|
+
renderAfterInput = _this$props8.renderAfterInput,
|
|
406
|
+
onFocus = _this$props8.onFocus,
|
|
407
|
+
onBlur = _this$props8.onBlur,
|
|
408
|
+
onInputChange = _this$props8.onInputChange,
|
|
409
|
+
onRequestHideOptions = _this$props8.onRequestHideOptions,
|
|
410
|
+
rest = (0, _objectWithoutProperties2.default)(_this$props8, _excluded2);
|
|
482
411
|
const interaction = this.interaction;
|
|
483
412
|
const passthroughProps = (0, _omitProps.omitProps)(rest, Select.allowedProps);
|
|
413
|
+
const _getTriggerProps = getTriggerProps({
|
|
414
|
+
...passthroughProps
|
|
415
|
+
}),
|
|
416
|
+
ref = _getTriggerProps.ref,
|
|
417
|
+
triggerProps = (0, _objectWithoutProperties2.default)(_getTriggerProps, _excluded3);
|
|
418
|
+
const isEditable = typeof onInputChange !== 'undefined';
|
|
484
419
|
|
|
485
|
-
|
|
486
|
-
}),
|
|
487
|
-
ref = _getTriggerProps.ref,
|
|
488
|
-
triggerProps = (0, _objectWithoutProperties2.default)(_getTriggerProps, _excluded3);
|
|
489
|
-
|
|
490
|
-
const isEditable = typeof onInputChange !== 'undefined'; // props to ensure screen readers treat uneditable selects as accessible
|
|
420
|
+
// props to ensure screen readers treat uneditable selects as accessible
|
|
491
421
|
// popup buttons rather than comboboxes.
|
|
492
|
-
|
|
493
422
|
const overrideProps = !isEditable ? {
|
|
494
423
|
role: 'button',
|
|
495
424
|
title: inputValue,
|
|
496
425
|
'aria-autocomplete': void 0
|
|
497
|
-
} : {};
|
|
426
|
+
} : {};
|
|
498
427
|
|
|
428
|
+
// backdoor to autocomplete attr to work around chrome autofill issues
|
|
499
429
|
if (passthroughProps['autoComplete']) {
|
|
500
430
|
overrideProps.autoComplete = passthroughProps['autoComplete'];
|
|
501
431
|
}
|
|
502
|
-
|
|
503
432
|
const inputProps = {
|
|
504
433
|
id: this.id,
|
|
505
434
|
renderLabel,
|
|
@@ -529,16 +458,15 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
529
458
|
};
|
|
530
459
|
return (0, _emotion.jsx)(_TextInput.TextInput, Object.assign({}, triggerProps, getInputProps(inputProps)));
|
|
531
460
|
}
|
|
532
|
-
|
|
533
461
|
render() {
|
|
534
462
|
const _this$props9 = this.props,
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
463
|
+
constrain = _this$props9.constrain,
|
|
464
|
+
placement = _this$props9.placement,
|
|
465
|
+
mountNode = _this$props9.mountNode,
|
|
466
|
+
assistiveText = _this$props9.assistiveText,
|
|
467
|
+
isShowingOptions = _this$props9.isShowingOptions,
|
|
468
|
+
styles = _this$props9.styles;
|
|
469
|
+
// clear temporary option store
|
|
542
470
|
this._optionIds = [];
|
|
543
471
|
const highlightedOptionId = this.highlightedOptionId;
|
|
544
472
|
const selectedOptionId = this.selectedOptionId;
|
|
@@ -548,12 +476,12 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
548
476
|
selectedOptionId: selectedOptionId
|
|
549
477
|
}, this.getEventHandlers()), _ref3 => {
|
|
550
478
|
let getRootProps = _ref3.getRootProps,
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
479
|
+
getInputProps = _ref3.getInputProps,
|
|
480
|
+
getTriggerProps = _ref3.getTriggerProps,
|
|
481
|
+
getListProps = _ref3.getListProps,
|
|
482
|
+
getOptionProps = _ref3.getOptionProps,
|
|
483
|
+
getDisabledOptionProps = _ref3.getDisabledOptionProps,
|
|
484
|
+
getDescriptionProps = _ref3.getDescriptionProps;
|
|
557
485
|
return (0, _emotion.jsx)("span", Object.assign({}, getRootProps({
|
|
558
486
|
css: styles === null || styles === void 0 ? void 0 : styles.select
|
|
559
487
|
}), {
|
|
@@ -578,7 +506,6 @@ let Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0
|
|
|
578
506
|
})));
|
|
579
507
|
});
|
|
580
508
|
}
|
|
581
|
-
|
|
582
509
|
}, _class2.displayName = "Select", _class2.componentId = 'Select', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
583
510
|
inputValue: '',
|
|
584
511
|
isShowingOptions: false,
|
package/lib/Select/locator.js
CHANGED
package/lib/Select/props.js
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
13
|
-
|
|
14
10
|
var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
|
|
15
|
-
|
|
16
11
|
var _PositionPropTypes = require("@instructure/ui-position/lib/PositionPropTypes.js");
|
|
17
|
-
|
|
18
12
|
var _Group = require("./Group");
|
|
19
|
-
|
|
20
13
|
var _Option = require("./Option");
|
|
21
|
-
|
|
22
14
|
/*
|
|
23
15
|
* The MIT License (MIT)
|
|
24
16
|
*
|
|
@@ -42,6 +34,7 @@ var _Option = require("./Option");
|
|
|
42
34
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
43
35
|
* SOFTWARE.
|
|
44
36
|
*/
|
|
37
|
+
|
|
45
38
|
const propTypes = {
|
|
46
39
|
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
47
40
|
inputValue: _propTypes.default.string,
|
package/lib/Select/styles.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -67,6 +66,5 @@ const generateStyle = (componentTheme, props) => {
|
|
|
67
66
|
}
|
|
68
67
|
};
|
|
69
68
|
};
|
|
70
|
-
|
|
71
69
|
var _default = generateStyle;
|
|
72
70
|
exports.default = _default;
|
package/lib/Select/theme.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -36,7 +35,7 @@ exports.default = void 0;
|
|
|
36
35
|
*/
|
|
37
36
|
const generateComponentTheme = theme => {
|
|
38
37
|
const colors = theme.colors,
|
|
39
|
-
|
|
38
|
+
typography = theme.typography;
|
|
40
39
|
const componentVariables = {
|
|
41
40
|
fontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
|
|
42
41
|
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
@@ -47,9 +46,9 @@ const generateComponentTheme = theme => {
|
|
|
47
46
|
color: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
|
|
48
47
|
background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest
|
|
49
48
|
};
|
|
50
|
-
return {
|
|
49
|
+
return {
|
|
50
|
+
...componentVariables
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
-
|
|
54
53
|
var _default = generateComponentTheme;
|
|
55
54
|
exports.default = _default;
|