@instructure/ui-select 11.7.3-snapshot-7 → 11.7.3-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/CHANGELOG.md +5 -2
- package/es/Select/v1/Group/index.js +5 -4
- package/es/Select/v1/Option/index.js +9 -8
- package/es/Select/v1/index.js +187 -169
- package/es/Select/v1/styles.js +3 -1
- package/es/Select/v1/theme.js +12 -11
- package/es/Select/v2/Group/index.js +5 -4
- package/es/Select/v2/Option/index.js +9 -8
- package/es/Select/v2/index.js +187 -170
- package/lib/Select/v1/Group/index.js +5 -4
- package/lib/Select/v1/Option/index.js +9 -8
- package/lib/Select/v1/index.js +189 -171
- package/lib/Select/v1/styles.js +3 -1
- package/lib/Select/v1/theme.js +12 -11
- package/lib/Select/v2/Group/index.js +5 -4
- package/lib/Select/v2/Option/index.js +9 -8
- package/lib/Select/v2/index.js +188 -171
- package/package.json +20 -20
- package/tsconfig.build.tsbuildinfo +1 -1
package/lib/Select/v1/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = exports.Select = void 0;
|
|
9
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
9
|
var _react = require("react");
|
|
11
10
|
var utils = _interopRequireWildcard(require("@instructure/ui-utils"));
|
|
12
11
|
var _combineDataCid = require("@instructure/ui-utils/lib/combineDataCid.js");
|
|
@@ -22,7 +21,7 @@ var _v11_2 = require("@instructure/ui-popover/v11_6");
|
|
|
22
21
|
var _v11_3 = require("@instructure/ui-text-input/v11_6");
|
|
23
22
|
var _v11_4 = require("@instructure/ui-options/v11_6");
|
|
24
23
|
var _IconArrowOpenDownLine = require("@instructure/ui-icons/lib/generated/IconArrowOpenDownLine.js");
|
|
25
|
-
var
|
|
24
|
+
var _IconArrowOpenUpLine = require("@instructure/ui-icons/lib/generated/IconArrowOpenUpLine.js");
|
|
26
25
|
var _emotion = require("@instructure/emotion");
|
|
27
26
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
28
27
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
@@ -30,10 +29,7 @@ var _Group = require("./Group");
|
|
|
30
29
|
var _Option = require("./Option");
|
|
31
30
|
var _props = require("./props");
|
|
32
31
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
33
|
-
|
|
34
|
-
_excluded2 = ["renderLabel", "inputValue", "placeholder", "isRequired", "shouldNotWrap", "size", "isInline", "width", "htmlSize", "messages", "renderBeforeInput", "renderAfterInput", "onFocus", "onBlur", "onInputChange", "onRequestHideOptions", "layout"],
|
|
35
|
-
_excluded3 = ["ref"];
|
|
36
|
-
var _dec, _dec2, _class, _Select, _Options$Separator, _Options$Separator2, _IconArrowOpenUpLine, _IconArrowOpenDownLin;
|
|
32
|
+
var _dec, _dec2, _class;
|
|
37
33
|
/*
|
|
38
34
|
* The MIT License (MIT)
|
|
39
35
|
*
|
|
@@ -62,8 +58,10 @@ var _dec, _dec2, _class, _Select, _Options$Separator, _Options$Separator2, _Icon
|
|
|
62
58
|
// because the Select component is re-rendered on every prop change of the <Select.Option>
|
|
63
59
|
// and with a large amount of options, this can cause a lot of unnecessary re-renders.
|
|
64
60
|
const MemoedOption = /*#__PURE__*/(0, _react.memo)(function Opt(props) {
|
|
65
|
-
const
|
|
66
|
-
|
|
61
|
+
const {
|
|
62
|
+
optionsItemProps,
|
|
63
|
+
children
|
|
64
|
+
} = props;
|
|
67
65
|
return (
|
|
68
66
|
// The main <Options> that renders this is always an "ul"
|
|
69
67
|
(0, _jsxRuntime.jsx)(_v11_4.Options.Item, {
|
|
@@ -88,58 +86,50 @@ category: components
|
|
|
88
86
|
tags: autocomplete, typeahead, combobox, dropdown, search, form
|
|
89
87
|
---
|
|
90
88
|
**/
|
|
91
|
-
let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = _dec2(_class =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
this._input = node;
|
|
116
|
-
(_this$props$inputRef = (_this$props = this.props).inputRef) === null || _this$props$inputRef === void 0 ? void 0 : _this$props$inputRef.call(_this$props, node);
|
|
117
|
-
};
|
|
118
|
-
this.handleListRef = node => {
|
|
119
|
-
var _this$props$listRef, _this$props2;
|
|
120
|
-
(_this$props$listRef = (_this$props2 = this.props).listRef) === null || _this$props$listRef === void 0 ? void 0 : _this$props$listRef.call(_this$props2, node);
|
|
121
|
-
|
|
122
|
-
// store option height to calculate list maxHeight
|
|
123
|
-
if (node && node.querySelector('[role="option"]')) {
|
|
124
|
-
this._optionHeight = node.querySelector('[role="option"]').offsetHeight;
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
this.handleInputContainerRef = node => {
|
|
128
|
-
this._inputContainer = node;
|
|
129
|
-
};
|
|
130
|
-
}
|
|
89
|
+
let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = _dec2(_class = class Select extends _react.Component {
|
|
90
|
+
static displayName = "Select";
|
|
91
|
+
static componentId = 'Select';
|
|
92
|
+
SCROLL_TOLERANCE = 0.5;
|
|
93
|
+
static allowedProps = _props.allowedProps;
|
|
94
|
+
static defaultProps = {
|
|
95
|
+
inputValue: '',
|
|
96
|
+
isShowingOptions: false,
|
|
97
|
+
size: 'medium',
|
|
98
|
+
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
99
|
+
interaction: undefined,
|
|
100
|
+
isRequired: false,
|
|
101
|
+
isInline: false,
|
|
102
|
+
visibleOptionsCount: 8,
|
|
103
|
+
placement: 'bottom stretch',
|
|
104
|
+
constrain: 'window',
|
|
105
|
+
shouldNotWrap: false,
|
|
106
|
+
scrollToHighlightedOption: true,
|
|
107
|
+
isOptionContentAppliedToInput: false
|
|
108
|
+
};
|
|
109
|
+
static Option = _Option.Option;
|
|
110
|
+
static Group = _Group.Group;
|
|
131
111
|
componentDidMount() {
|
|
132
|
-
|
|
133
|
-
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
112
|
+
this.props.makeStyles?.();
|
|
134
113
|
}
|
|
135
114
|
componentDidUpdate() {
|
|
136
|
-
|
|
137
|
-
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
115
|
+
this.props.makeStyles?.();
|
|
138
116
|
if (this.props.scrollToHighlightedOption) {
|
|
139
117
|
// scroll option into view if needed
|
|
140
118
|
requestAnimationFrame(() => this.scrollToOption(this.highlightedOptionId));
|
|
141
119
|
}
|
|
142
120
|
}
|
|
121
|
+
state = {
|
|
122
|
+
hasInputRef: false
|
|
123
|
+
};
|
|
124
|
+
ref = null;
|
|
125
|
+
_input = null;
|
|
126
|
+
_defaultId = this.props.deterministicId();
|
|
127
|
+
_inputContainer = null;
|
|
128
|
+
_listView = null;
|
|
129
|
+
// temporarily stores actionable options
|
|
130
|
+
_optionIds = [];
|
|
131
|
+
// best guess for first calculation of list height
|
|
132
|
+
_optionHeight = 36;
|
|
143
133
|
focus() {
|
|
144
134
|
this._input && this._input.focus();
|
|
145
135
|
}
|
|
@@ -159,7 +149,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
159
149
|
return this.props.id || this._defaultId;
|
|
160
150
|
}
|
|
161
151
|
get width() {
|
|
162
|
-
return this._inputContainer ? this._inputContainer.offsetWidth :
|
|
152
|
+
return this._inputContainer ? this._inputContainer.offsetWidth : undefined;
|
|
163
153
|
}
|
|
164
154
|
get interaction() {
|
|
165
155
|
return (0, _getInteraction.getInteraction)({
|
|
@@ -208,10 +198,31 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
208
198
|
return selectedOptionId[0];
|
|
209
199
|
}
|
|
210
200
|
if (selectedOptionId.length === 0) {
|
|
211
|
-
return
|
|
201
|
+
return undefined;
|
|
212
202
|
}
|
|
213
203
|
return selectedOptionId;
|
|
214
204
|
}
|
|
205
|
+
handleInputRef = node => {
|
|
206
|
+
// ensures list is positioned with respect to input if list is open on mount
|
|
207
|
+
if (!this.state.hasInputRef) {
|
|
208
|
+
this.setState({
|
|
209
|
+
hasInputRef: true
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
this._input = node;
|
|
213
|
+
this.props.inputRef?.(node);
|
|
214
|
+
};
|
|
215
|
+
handleListRef = node => {
|
|
216
|
+
this.props.listRef?.(node);
|
|
217
|
+
|
|
218
|
+
// store option height to calculate list maxHeight
|
|
219
|
+
if (node && node.querySelector('[role="option"]')) {
|
|
220
|
+
this._optionHeight = node.querySelector('[role="option"]').offsetHeight;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
handleInputContainerRef = node => {
|
|
224
|
+
this._inputContainer = node;
|
|
225
|
+
};
|
|
215
226
|
scrollToOption(id) {
|
|
216
227
|
if (!this._listView || !id) return;
|
|
217
228
|
const option = this._listView.querySelector(`[id="${CSS.escape(id)}"]`);
|
|
@@ -228,22 +239,25 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
228
239
|
}
|
|
229
240
|
}
|
|
230
241
|
highlightOption(event, id) {
|
|
231
|
-
const
|
|
242
|
+
const {
|
|
243
|
+
onRequestHighlightOption
|
|
244
|
+
} = this.props;
|
|
232
245
|
if (id) {
|
|
233
|
-
onRequestHighlightOption
|
|
246
|
+
onRequestHighlightOption?.(event, {
|
|
234
247
|
id
|
|
235
248
|
});
|
|
236
249
|
}
|
|
237
250
|
}
|
|
238
251
|
getEventHandlers() {
|
|
239
|
-
const
|
|
240
|
-
isShowingOptions
|
|
241
|
-
onRequestShowOptions
|
|
242
|
-
onRequestHideOptions
|
|
243
|
-
onRequestSelectOption
|
|
252
|
+
const {
|
|
253
|
+
isShowingOptions,
|
|
254
|
+
onRequestShowOptions,
|
|
255
|
+
onRequestHideOptions,
|
|
256
|
+
onRequestSelectOption
|
|
257
|
+
} = this.props;
|
|
244
258
|
return this.interaction === 'enabled' ? {
|
|
245
259
|
onRequestShowOptions: event => {
|
|
246
|
-
onRequestShowOptions
|
|
260
|
+
onRequestShowOptions?.(event);
|
|
247
261
|
const selectedOptionId = this.selectedOptionId;
|
|
248
262
|
if (selectedOptionId && !Array.isArray(selectedOptionId)) {
|
|
249
263
|
// highlight selected option on show
|
|
@@ -251,7 +265,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
251
265
|
}
|
|
252
266
|
},
|
|
253
267
|
onRequestHideOptions: event => {
|
|
254
|
-
onRequestHideOptions
|
|
268
|
+
onRequestHideOptions?.(event);
|
|
255
269
|
},
|
|
256
270
|
onRequestHighlightOption: (event, {
|
|
257
271
|
id,
|
|
@@ -260,7 +274,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
260
274
|
if (!isShowingOptions) return;
|
|
261
275
|
const highlightedOptionId = this.highlightedOptionId;
|
|
262
276
|
// if id exists, use that
|
|
263
|
-
let highlightId = this._optionIds.indexOf(id) > -1 ? id :
|
|
277
|
+
let highlightId = this._optionIds.indexOf(id) > -1 ? id : undefined;
|
|
264
278
|
if (!highlightId) {
|
|
265
279
|
if (!highlightedOptionId) {
|
|
266
280
|
// nothing highlighted yet, highlight first option
|
|
@@ -268,7 +282,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
268
282
|
} else {
|
|
269
283
|
// find next id based on direction
|
|
270
284
|
const index = this._optionIds.indexOf(highlightedOptionId);
|
|
271
|
-
highlightId = index > -1 ? this._optionIds[index + direction] :
|
|
285
|
+
highlightId = index > -1 ? this._optionIds[index + direction] : undefined;
|
|
272
286
|
}
|
|
273
287
|
}
|
|
274
288
|
if (highlightId) {
|
|
@@ -287,7 +301,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
287
301
|
}) => {
|
|
288
302
|
if (id && this._optionIds.indexOf(id) !== -1) {
|
|
289
303
|
// only select if id exists as a valid option
|
|
290
|
-
onRequestSelectOption
|
|
304
|
+
onRequestSelectOption?.(event, {
|
|
291
305
|
id
|
|
292
306
|
});
|
|
293
307
|
}
|
|
@@ -295,19 +309,21 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
295
309
|
} : {};
|
|
296
310
|
}
|
|
297
311
|
renderOption(option, data) {
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
312
|
+
const {
|
|
313
|
+
getOptionProps,
|
|
314
|
+
getDisabledOptionProps
|
|
315
|
+
} = data;
|
|
316
|
+
const {
|
|
317
|
+
id,
|
|
318
|
+
isDisabled,
|
|
319
|
+
isHighlighted,
|
|
320
|
+
isSelected,
|
|
321
|
+
renderBeforeLabel,
|
|
322
|
+
renderAfterLabel,
|
|
323
|
+
children
|
|
324
|
+
} = option.props;
|
|
308
325
|
const getRenderOptionLabel = renderOptionLabel => {
|
|
309
|
-
|
|
310
|
-
return typeof renderOptionLabel === 'function' && !(renderOptionLabel !== null && renderOptionLabel !== void 0 && (_renderOptionLabel$pr = renderOptionLabel.prototype) !== null && _renderOptionLabel$pr !== void 0 && _renderOptionLabel$pr.isReactComponent) ? renderOptionLabel.bind(null, {
|
|
326
|
+
return typeof renderOptionLabel === 'function' && !renderOptionLabel?.prototype?.isReactComponent ? renderOptionLabel.bind(null, {
|
|
311
327
|
id,
|
|
312
328
|
isDisabled,
|
|
313
329
|
isSelected,
|
|
@@ -354,20 +370,23 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
354
370
|
});
|
|
355
371
|
}
|
|
356
372
|
renderGroup(group, data) {
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
373
|
+
const {
|
|
374
|
+
getOptionProps,
|
|
375
|
+
getDisabledOptionProps,
|
|
376
|
+
isFirstChild,
|
|
377
|
+
isLastChild,
|
|
378
|
+
afterGroup
|
|
379
|
+
} = data;
|
|
380
|
+
const {
|
|
381
|
+
id,
|
|
382
|
+
renderLabel,
|
|
383
|
+
children,
|
|
384
|
+
...rest
|
|
385
|
+
} = group.props;
|
|
367
386
|
const groupChildren = [];
|
|
368
387
|
// add a separator above
|
|
369
388
|
if (!isFirstChild && !afterGroup) {
|
|
370
|
-
groupChildren.push(
|
|
389
|
+
groupChildren.push((0, _jsxRuntime.jsx)(_v11_4.Options.Separator, {}));
|
|
371
390
|
}
|
|
372
391
|
// create a sublist as a group
|
|
373
392
|
// a wrapping listitem will be created by Options
|
|
@@ -386,20 +405,23 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
386
405
|
}));
|
|
387
406
|
// add a separator below
|
|
388
407
|
if (!isLastChild) {
|
|
389
|
-
groupChildren.push(
|
|
408
|
+
groupChildren.push((0, _jsxRuntime.jsx)(_v11_4.Options.Separator, {}));
|
|
390
409
|
}
|
|
391
410
|
return groupChildren;
|
|
392
411
|
}
|
|
393
412
|
renderList(data) {
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
413
|
+
const {
|
|
414
|
+
getListProps,
|
|
415
|
+
getOptionProps,
|
|
416
|
+
getDisabledOptionProps
|
|
417
|
+
} = data;
|
|
418
|
+
const {
|
|
419
|
+
isShowingOptions,
|
|
420
|
+
optionsMaxWidth,
|
|
421
|
+
optionsMaxHeight,
|
|
422
|
+
visibleOptionsCount,
|
|
423
|
+
children
|
|
424
|
+
} = this.props;
|
|
403
425
|
let lastWasGroup = false;
|
|
404
426
|
const viewProps = isShowingOptions ? {
|
|
405
427
|
display: 'block',
|
|
@@ -450,16 +472,17 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
450
472
|
});
|
|
451
473
|
}
|
|
452
474
|
renderIcon() {
|
|
453
|
-
const
|
|
454
|
-
styles
|
|
455
|
-
isShowingOptions
|
|
475
|
+
const {
|
|
476
|
+
styles,
|
|
477
|
+
isShowingOptions
|
|
478
|
+
} = this.props;
|
|
456
479
|
return (0, _jsxRuntime.jsx)("span", {
|
|
457
|
-
css: styles
|
|
458
|
-
children: isShowingOptions ?
|
|
480
|
+
css: styles?.icon,
|
|
481
|
+
children: isShowingOptions ? (0, _jsxRuntime.jsx)(_IconArrowOpenUpLine.IconArrowOpenUpLine, {
|
|
459
482
|
inline: false
|
|
460
|
-
})
|
|
483
|
+
}) : (0, _jsxRuntime.jsx)(_IconArrowOpenDownLine.IconArrowOpenDownLine, {
|
|
461
484
|
inline: false
|
|
462
|
-
})
|
|
485
|
+
})
|
|
463
486
|
});
|
|
464
487
|
}
|
|
465
488
|
renderContentBeforeOrAfterInput(position) {
|
|
@@ -505,50 +528,58 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
505
528
|
return defaultReturn;
|
|
506
529
|
}
|
|
507
530
|
handleRenderBeforeInput() {
|
|
508
|
-
const
|
|
509
|
-
renderBeforeInput
|
|
510
|
-
inputValue
|
|
511
|
-
isOptionContentAppliedToInput
|
|
531
|
+
const {
|
|
532
|
+
renderBeforeInput,
|
|
533
|
+
inputValue,
|
|
534
|
+
isOptionContentAppliedToInput
|
|
535
|
+
} = this.props;
|
|
512
536
|
return this.handleInputContentRender(renderBeforeInput, inputValue, isOptionContentAppliedToInput, 'before', null // default for before
|
|
513
537
|
);
|
|
514
538
|
}
|
|
515
539
|
handleRenderAfterInput() {
|
|
516
|
-
const
|
|
517
|
-
renderAfterInput
|
|
518
|
-
inputValue
|
|
519
|
-
isOptionContentAppliedToInput
|
|
540
|
+
const {
|
|
541
|
+
renderAfterInput,
|
|
542
|
+
inputValue,
|
|
543
|
+
isOptionContentAppliedToInput
|
|
544
|
+
} = this.props;
|
|
520
545
|
return this.handleInputContentRender(renderAfterInput, inputValue, isOptionContentAppliedToInput, 'after', this.renderIcon() // default for after
|
|
521
546
|
);
|
|
522
547
|
}
|
|
523
548
|
renderInput(data) {
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
549
|
+
const {
|
|
550
|
+
getInputProps,
|
|
551
|
+
getTriggerProps
|
|
552
|
+
} = data;
|
|
553
|
+
const {
|
|
554
|
+
renderLabel,
|
|
555
|
+
inputValue,
|
|
556
|
+
placeholder,
|
|
557
|
+
isRequired,
|
|
558
|
+
shouldNotWrap,
|
|
559
|
+
size,
|
|
560
|
+
isInline,
|
|
561
|
+
width,
|
|
562
|
+
htmlSize,
|
|
563
|
+
messages,
|
|
564
|
+
renderBeforeInput,
|
|
565
|
+
renderAfterInput,
|
|
566
|
+
onFocus,
|
|
567
|
+
onBlur,
|
|
568
|
+
onInputChange,
|
|
569
|
+
onRequestHideOptions,
|
|
570
|
+
layout,
|
|
571
|
+
...rest
|
|
572
|
+
} = this.props;
|
|
573
|
+
const {
|
|
574
|
+
interaction
|
|
575
|
+
} = this;
|
|
546
576
|
const passthroughProps = (0, _omitProps.omitProps)(rest, Select.allowedProps);
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
577
|
+
const {
|
|
578
|
+
ref,
|
|
579
|
+
...triggerProps
|
|
580
|
+
} = getTriggerProps({
|
|
581
|
+
...passthroughProps
|
|
582
|
+
});
|
|
552
583
|
const isEditable = typeof onInputChange !== 'undefined';
|
|
553
584
|
|
|
554
585
|
// props to ensure screen readers treat uneditable selects as accessible
|
|
@@ -563,7 +594,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
563
594
|
// that its 'read-only' and that this is a 'textfield', see INSTUI-4500
|
|
564
595
|
role: utils.isSafari() || utils.isAndroidOrIOS() || interaction === 'disabled' && utils.isChromium() ? 'button' : 'combobox',
|
|
565
596
|
title: inputValue,
|
|
566
|
-
'aria-autocomplete':
|
|
597
|
+
'aria-autocomplete': undefined,
|
|
567
598
|
'aria-readonly': true
|
|
568
599
|
} : interaction === 'disabled' && utils.isChromium() ? {
|
|
569
600
|
role: 'button'
|
|
@@ -594,14 +625,14 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
594
625
|
// On iOS VoiceOver, if there is a custom element instead of the changing up and down arrow button
|
|
595
626
|
// the listbox closes on a swipe, so a DOM change is enforced by the key change
|
|
596
627
|
// that seems to inform VoiceOver to behave the correct way
|
|
597
|
-
renderAfterInput: utils.isAndroidOrIOS() && renderAfterInput !==
|
|
628
|
+
renderAfterInput: utils.isAndroidOrIOS() && renderAfterInput !== undefined ? (0, _jsxRuntime.jsx)("span", {
|
|
598
629
|
children: this.handleRenderAfterInput()
|
|
599
630
|
}, this.props.isShowingOptions ? 'open' : 'closed') : this.handleRenderAfterInput(),
|
|
600
631
|
// If `inputValue` is provided, we need to pass a default onChange handler,
|
|
601
632
|
// because TextInput `value` is a controlled prop,
|
|
602
633
|
// and onChange is not required for Select
|
|
603
634
|
// (before it was handled by TextInput's defaultProp)
|
|
604
|
-
onChange: typeof onInputChange === 'function' ? onInputChange : inputValue ? () => {} :
|
|
635
|
+
onChange: typeof onInputChange === 'function' ? onInputChange : inputValue ? () => {} : undefined,
|
|
605
636
|
onFocus,
|
|
606
637
|
onBlur: utils.createChainedFunction(onBlur, onRequestHideOptions),
|
|
607
638
|
...overrideProps
|
|
@@ -614,13 +645,14 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
614
645
|
});
|
|
615
646
|
}
|
|
616
647
|
render() {
|
|
617
|
-
const
|
|
618
|
-
constrain
|
|
619
|
-
placement
|
|
620
|
-
mountNode
|
|
621
|
-
assistiveText
|
|
622
|
-
isShowingOptions
|
|
623
|
-
styles
|
|
648
|
+
const {
|
|
649
|
+
constrain,
|
|
650
|
+
placement,
|
|
651
|
+
mountNode,
|
|
652
|
+
assistiveText,
|
|
653
|
+
isShowingOptions,
|
|
654
|
+
styles
|
|
655
|
+
} = this.props;
|
|
624
656
|
// clear temporary option store
|
|
625
657
|
this._optionIds = [];
|
|
626
658
|
const highlightedOptionId = this.highlightedOptionId;
|
|
@@ -640,7 +672,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
640
672
|
getDescriptionProps
|
|
641
673
|
}) => (0, _jsxRuntime.jsxs)("span", {
|
|
642
674
|
...getRootProps({
|
|
643
|
-
css: styles
|
|
675
|
+
css: styles?.select
|
|
644
676
|
}),
|
|
645
677
|
ref: el => {
|
|
646
678
|
this.ref = el;
|
|
@@ -651,7 +683,7 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
651
683
|
getTriggerProps
|
|
652
684
|
}), (0, _jsxRuntime.jsx)("span", {
|
|
653
685
|
...getDescriptionProps(),
|
|
654
|
-
css: styles
|
|
686
|
+
css: styles?.assistiveText,
|
|
655
687
|
children: assistiveText
|
|
656
688
|
}), (0, _jsxRuntime.jsx)(_v11_2.Popover, {
|
|
657
689
|
constrain: constrain,
|
|
@@ -660,12 +692,12 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
660
692
|
// in order to be able to navigate through the list items with a swipe.
|
|
661
693
|
// The swipe would result in closing the listbox if mounted elsewhere.
|
|
662
694
|
,
|
|
663
|
-
mountNode: mountNode !==
|
|
695
|
+
mountNode: mountNode !== undefined ? mountNode : utils.isAndroidOrIOS() ? this.ref : undefined,
|
|
664
696
|
positionTarget: this._inputContainer,
|
|
665
697
|
isShowingContent: isShowingOptions,
|
|
666
698
|
shouldReturnFocus: false,
|
|
667
699
|
withArrow: false,
|
|
668
|
-
borderWidth: styles
|
|
700
|
+
borderWidth: styles?.popoverBorderWidth,
|
|
669
701
|
children: this.renderList({
|
|
670
702
|
getListProps,
|
|
671
703
|
getOptionProps,
|
|
@@ -675,19 +707,5 @@ let Select = exports.Select = (_dec = (0, _withDeterministicId.withDeterministic
|
|
|
675
707
|
})
|
|
676
708
|
});
|
|
677
709
|
}
|
|
678
|
-
}
|
|
679
|
-
inputValue: '',
|
|
680
|
-
isShowingOptions: false,
|
|
681
|
-
size: 'medium',
|
|
682
|
-
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
683
|
-
interaction: void 0,
|
|
684
|
-
isRequired: false,
|
|
685
|
-
isInline: false,
|
|
686
|
-
visibleOptionsCount: 8,
|
|
687
|
-
placement: 'bottom stretch',
|
|
688
|
-
constrain: 'window',
|
|
689
|
-
shouldNotWrap: false,
|
|
690
|
-
scrollToHighlightedOption: true,
|
|
691
|
-
isOptionContentAppliedToInput: false
|
|
692
|
-
}, _Select.Option = _Option.Option, _Select.Group = _Group.Group, _Select)) || _class) || _class);
|
|
710
|
+
}) || _class) || _class);
|
|
693
711
|
var _default = exports.default = Select;
|
package/lib/Select/v1/styles.js
CHANGED
|
@@ -36,7 +36,9 @@ exports.default = void 0;
|
|
|
36
36
|
* @return {Object} The final style object, which will be used in the component
|
|
37
37
|
*/
|
|
38
38
|
const generateStyle = (componentTheme, props) => {
|
|
39
|
-
const
|
|
39
|
+
const {
|
|
40
|
+
size
|
|
41
|
+
} = props;
|
|
40
42
|
const iconSizeVariants = {
|
|
41
43
|
small: {
|
|
42
44
|
fontSize: componentTheme.smallIconSize
|
package/lib/Select/v1/theme.js
CHANGED
|
@@ -34,18 +34,19 @@ exports.default = void 0;
|
|
|
34
34
|
* @return {Object} The final theme object with the overrides and component variables
|
|
35
35
|
*/
|
|
36
36
|
const generateComponentTheme = theme => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
typography
|
|
37
|
+
const {
|
|
38
|
+
colors,
|
|
39
|
+
typography
|
|
40
|
+
} = theme;
|
|
40
41
|
const componentVariables = {
|
|
41
|
-
fontSize: typography
|
|
42
|
-
fontFamily: typography
|
|
43
|
-
fontWeight: typography
|
|
44
|
-
smallIconSize: typography
|
|
45
|
-
mediumIconSize: typography
|
|
46
|
-
largeIconSize: typography
|
|
47
|
-
color: colors
|
|
48
|
-
background: colors
|
|
42
|
+
fontSize: typography?.fontSizeMedium,
|
|
43
|
+
fontFamily: typography?.fontFamily,
|
|
44
|
+
fontWeight: typography?.fontWeightNormal,
|
|
45
|
+
smallIconSize: typography?.fontSizeXSmall,
|
|
46
|
+
mediumIconSize: typography?.fontSizeSmall,
|
|
47
|
+
largeIconSize: typography?.fontSizeMedium,
|
|
48
|
+
color: colors?.contrasts?.grey125125,
|
|
49
|
+
background: colors?.contrasts?.white1010,
|
|
49
50
|
popoverBorderWidth: 'small'
|
|
50
51
|
};
|
|
51
52
|
return {
|
|
@@ -38,6 +38,11 @@ id: Select.Group
|
|
|
38
38
|
@module Group
|
|
39
39
|
**/
|
|
40
40
|
class Group extends _react.Component {
|
|
41
|
+
static displayName = "Group";
|
|
42
|
+
static componentId = 'Select.Group';
|
|
43
|
+
static allowedProps = _props.allowedProps;
|
|
44
|
+
static defaultProps = {};
|
|
45
|
+
|
|
41
46
|
/* istanbul ignore next */
|
|
42
47
|
render() {
|
|
43
48
|
// this component is only used for prop validation. Select.Group children
|
|
@@ -46,8 +51,4 @@ class Group extends _react.Component {
|
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
53
|
exports.Group = Group;
|
|
49
|
-
Group.displayName = "Group";
|
|
50
|
-
Group.componentId = 'Select.Group';
|
|
51
|
-
Group.allowedProps = _props.allowedProps;
|
|
52
|
-
Group.defaultProps = {};
|
|
53
54
|
var _default = exports.default = Group;
|
|
@@ -38,6 +38,15 @@ id: Select.Option
|
|
|
38
38
|
@module Option
|
|
39
39
|
**/
|
|
40
40
|
class Option extends _react.Component {
|
|
41
|
+
static displayName = "Option";
|
|
42
|
+
static componentId = 'Select.Option';
|
|
43
|
+
static allowedProps = _props.allowedProps;
|
|
44
|
+
static defaultProps = {
|
|
45
|
+
isHighlighted: false,
|
|
46
|
+
isSelected: false,
|
|
47
|
+
isDisabled: false
|
|
48
|
+
};
|
|
49
|
+
|
|
41
50
|
/* istanbul ignore next */
|
|
42
51
|
render() {
|
|
43
52
|
// this component is only used for prop validation. Select.Option children
|
|
@@ -46,12 +55,4 @@ class Option extends _react.Component {
|
|
|
46
55
|
}
|
|
47
56
|
}
|
|
48
57
|
exports.Option = Option;
|
|
49
|
-
Option.displayName = "Option";
|
|
50
|
-
Option.componentId = 'Select.Option';
|
|
51
|
-
Option.allowedProps = _props.allowedProps;
|
|
52
|
-
Option.defaultProps = {
|
|
53
|
-
isHighlighted: false,
|
|
54
|
-
isSelected: false,
|
|
55
|
-
isDisabled: false
|
|
56
|
-
};
|
|
57
58
|
var _default = exports.default = Option;
|