@instructure/ui-simple-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 CHANGED
@@ -3,9 +3,12 @@
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
- ## [11.7.3-snapshot-7](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-7) (2026-04-29)
6
+ ## [11.7.3-snapshot-26](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-26) (2026-05-05)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-simple-select
8
+
9
+ ### Bug Fixes
10
+
11
+ * **many:** update dependencies, remove lots of Babel plugins, remove Webpack 4 support ([f916fca](https://github.com/instructure/instructure-ui/commit/f916fcafdddcb2d7de401f93e8ff92cfdfa47bba))
9
12
 
10
13
 
11
14
 
@@ -31,6 +31,11 @@ id: SimpleSelect.Group
31
31
  ---
32
32
  **/
33
33
  class Group extends Component {
34
+ static displayName = "Group";
35
+ static componentId = 'SimpleSelect.Group';
36
+ static allowedProps = allowedProps;
37
+ static defaultProps = {};
38
+
34
39
  /* istanbul ignore next */
35
40
  render() {
36
41
  // this component is only used for prop validation. Select.Group children
@@ -38,9 +43,5 @@ class Group extends Component {
38
43
  return null;
39
44
  }
40
45
  }
41
- Group.displayName = "Group";
42
- Group.componentId = 'SimpleSelect.Group';
43
- Group.allowedProps = allowedProps;
44
- Group.defaultProps = {};
45
46
  export default Group;
46
47
  export { Group };
@@ -31,6 +31,13 @@ id: SimpleSelect.Option
31
31
  ---
32
32
  **/
33
33
  class Option extends Component {
34
+ static displayName = "Option";
35
+ static componentId = 'SimpleSelect.Option';
36
+ static allowedProps = allowedProps;
37
+ static defaultProps = {
38
+ isDisabled: false
39
+ };
40
+
34
41
  /* istanbul ignore next */
35
42
  render() {
36
43
  // this component is only used for prop validation. SimpleSelect.Option children
@@ -38,11 +45,5 @@ class Option extends Component {
38
45
  return null;
39
46
  }
40
47
  }
41
- Option.displayName = "Option";
42
- Option.componentId = 'SimpleSelect.Option';
43
- Option.allowedProps = allowedProps;
44
- Option.defaultProps = {
45
- isDisabled: false
46
- };
47
48
  export default Option;
48
49
  export { Option };
@@ -1,8 +1,4 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- const _excluded = ["id", "value", "children", "renderBeforeLabel", "renderAfterLabel"],
3
- _excluded2 = ["id", "renderLabel", "children"],
4
- _excluded3 = ["renderLabel", "value", "defaultValue", "id", "size", "assistiveText", "placeholder", "interaction", "isRequired", "isInline", "width", "optionsMaxWidth", "optionsMaxHeight", "visibleOptionsCount", "messages", "placement", "constrain", "mountNode", "inputRef", "listRef", "renderEmptyOption", "renderBeforeInput", "renderAfterInput", "onFocus", "onBlur", "onShowOptions", "onHideOptions", "children", "layout"];
5
- var _dec, _class, _SimpleSelect;
1
+ var _dec, _class;
6
2
  /*
7
3
  * The MIT License (MIT)
8
4
  *
@@ -41,137 +37,32 @@ category: components
41
37
  tags: form, field, dropdown
42
38
  ---
43
39
  **/
44
- let SimpleSelect = (_dec = withDeterministicId(), _dec(_class = (_SimpleSelect = class SimpleSelect extends Component {
40
+ let SimpleSelect = (_dec = withDeterministicId(), _dec(_class = class SimpleSelect extends Component {
41
+ static displayName = "SimpleSelect";
42
+ static componentId = 'SimpleSelect';
43
+ static Option = Option;
44
+ static Group = Group;
45
+ static allowedProps = allowedProps;
46
+ static defaultProps = {
47
+ size: 'medium',
48
+ isRequired: false,
49
+ isInline: false,
50
+ visibleOptionsCount: 8,
51
+ placement: 'bottom stretch',
52
+ constrain: 'window',
53
+ renderEmptyOption: '---',
54
+ isOptionContentAppliedToInput: false
55
+ };
56
+ ref = null;
57
+ _emptyOptionId;
45
58
  constructor(props) {
46
59
  super(props);
47
- this.ref = null;
48
- this._emptyOptionId = void 0;
49
- this.getOption = (field, value) => {
50
- const children = Children.toArray(this.props.children);
51
- let match;
52
- for (let i = 0; i < children.length; ++i) {
53
- const child = children[i];
54
- if (matchComponentTypes(child, [Option])) {
55
- if (child.props[field] === value) {
56
- match = child;
57
- }
58
- } else if (matchComponentTypes(child, [Group])) {
59
- const groupChildren = Children.toArray(child.props.children);
60
- for (let j = 0; j < groupChildren.length; ++j) {
61
- const groupChild = groupChildren[j];
62
- if (groupChild.props[field] === value) {
63
- match = groupChild;
64
- break;
65
- }
66
- }
67
- }
68
- if (match) break;
69
- }
70
- return match;
71
- };
72
- this.handleRef = node => {
73
- this.ref = node;
74
- };
75
- this.handleBlur = event => {
76
- this.setState({
77
- highlightedOptionId: void 0
78
- });
79
- if (typeof this.props.onBlur === 'function') {
80
- this.props.onBlur(event);
81
- }
82
- };
83
- this.handleShowOptions = event => {
84
- this.setState({
85
- isShowingOptions: true
86
- });
87
- if (typeof this.props.onShowOptions === 'function') {
88
- this.props.onShowOptions(event);
89
- }
90
- if (event.type.startsWith('key')) {
91
- const keyboardEvent = event;
92
- const children = Children.toArray(this.props.children);
93
- if (!this.state.inputValue && children.length > 0) {
94
- const position = keyboardEvent.key === 'ArrowDown' ? 'first' : keyboardEvent.key === 'ArrowUp' ? 'last' : void 0;
95
- if (position) {
96
- var _this$getOptionByPosi;
97
- const optionId = (_this$getOptionByPosi = this.getOptionByPosition(position)) === null || _this$getOptionByPosi === void 0 ? void 0 : _this$getOptionByPosi.props.id;
98
- optionId && this.setState({
99
- highlightedOptionId: optionId
100
- });
101
- }
102
- }
103
- }
104
- };
105
- this.handleHideOptions = event => {
106
- this.setState(state => {
107
- const option = this.getOption('id', state.selectedOptionId);
108
- return {
109
- isShowingOptions: false,
110
- highlightedOptionId: void 0,
111
- inputValue: option ? option.props.children : ''
112
- };
113
- });
114
- if (typeof this.props.onHideOptions === 'function') {
115
- this.props.onHideOptions(event);
116
- }
117
- };
118
- this.handleHighlightOption = (_event, {
119
- id
120
- }) => {
121
- if (id === this._emptyOptionId) return;
122
- this.setState({
123
- highlightedOptionId: id,
124
- inputValue: this.state.inputValue
125
- });
126
- };
127
- this.handleSelectOption = (event, {
128
- id
129
- }) => {
130
- if (id === this._emptyOptionId) {
131
- // selected option is the empty option
132
- this.setState({
133
- isShowingOptions: false
134
- });
135
- return;
136
- }
137
- const option = this.getOption('id', id);
138
- const value = option && option.props.value;
139
-
140
- // Focus needs to be reapplied to input
141
- // after selecting an item to make sure VoiceOver behaves correctly on iOS
142
- if (utils.isAndroidOrIOS()) {
143
- this.blur();
144
- this.focus();
145
- }
146
- if (this.isControlled) {
147
- this.setState({
148
- isShowingOptions: false
149
- });
150
- } else {
151
- this.setState(state => ({
152
- isShowingOptions: false,
153
- selectedOptionId: id,
154
- inputValue: option ? option.props.children : state.inputValue
155
- }));
156
- }
157
- // fire onChange if selected option changed
158
- if (option && typeof this.props.onChange === 'function') {
159
- this.props.onChange(event, {
160
- value,
161
- id
162
- });
163
- }
164
- // hide options list whenever selection is made
165
- if (typeof this.props.onHideOptions === 'function') {
166
- this.props.onHideOptions(event);
167
- }
168
- };
169
- const _option = this.getInitialOption(props);
60
+ const option = this.getInitialOption(props);
170
61
  this.state = {
171
- inputValue: _option ? _option.props.children : '',
62
+ inputValue: option ? option.props.children : '',
172
63
  isShowingOptions: false,
173
- highlightedOptionId: void 0,
174
- selectedOptionId: _option ? _option.props.id : void 0
64
+ highlightedOptionId: undefined,
65
+ selectedOptionId: option ? option.props.id : undefined
175
66
  };
176
67
  this._emptyOptionId = props.deterministicId('Select-EmptyOption');
177
68
  }
@@ -188,7 +79,7 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec(_class = (_SimpleSelect =
188
79
  return this.ref ? this.ref.focused : false;
189
80
  }
190
81
  get id() {
191
- return this.ref ? this.ref.id : void 0;
82
+ return this.ref ? this.ref.id : undefined;
192
83
  }
193
84
  get isControlled() {
194
85
  return typeof this.props.value !== 'undefined';
@@ -215,7 +106,7 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec(_class = (_SimpleSelect =
215
106
  // state.inputValue
216
107
  const option = this.getOption('children', this.state.inputValue);
217
108
  this.setState({
218
- inputValue: option ? option.props.children : void 0,
109
+ inputValue: option ? option.props.children : undefined,
219
110
  selectedOptionId: option ? option.props.id : ''
220
111
  });
221
112
  }
@@ -234,8 +125,10 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec(_class = (_SimpleSelect =
234
125
  }
235
126
  }
236
127
  getInitialOption(props) {
237
- const value = props.value,
238
- defaultValue = props.defaultValue;
128
+ const {
129
+ value,
130
+ defaultValue
131
+ } = props;
239
132
  const initialValue = value || defaultValue;
240
133
  if (typeof initialValue === 'string' || typeof initialValue === 'number') {
241
134
  // get option based on value or defaultValue, if provided
@@ -265,6 +158,29 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec(_class = (_SimpleSelect =
265
158
  }
266
159
  return match;
267
160
  }
161
+ getOption = (field, value) => {
162
+ const children = Children.toArray(this.props.children);
163
+ let match;
164
+ for (let i = 0; i < children.length; ++i) {
165
+ const child = children[i];
166
+ if (matchComponentTypes(child, [Option])) {
167
+ if (child.props[field] === value) {
168
+ match = child;
169
+ }
170
+ } else if (matchComponentTypes(child, [Group])) {
171
+ const groupChildren = Children.toArray(child.props.children);
172
+ for (let j = 0; j < groupChildren.length; ++j) {
173
+ const groupChild = groupChildren[j];
174
+ if (groupChild.props[field] === value) {
175
+ match = groupChild;
176
+ break;
177
+ }
178
+ }
179
+ }
180
+ if (match) break;
181
+ }
182
+ return match;
183
+ };
268
184
  getOptionByPosition(position) {
269
185
  const children = Children.toArray(this.props.children);
270
186
 
@@ -273,7 +189,7 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec(_class = (_SimpleSelect =
273
189
 
274
190
  // Check if child is an option or group
275
191
  const child = children[index];
276
- if (!child) return void 0;
192
+ if (!child) return undefined;
277
193
 
278
194
  // If it's a regular option, return it
279
195
  if (matchComponentTypes(child, [Option])) {
@@ -286,8 +202,104 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec(_class = (_SimpleSelect =
286
202
  const groupIndex = position === 'first' ? 0 : groupOptions.length - 1;
287
203
  return groupOptions[groupIndex];
288
204
  }
289
- return void 0;
205
+ return undefined;
290
206
  }
207
+ handleRef = node => {
208
+ this.ref = node;
209
+ };
210
+ handleBlur = event => {
211
+ this.setState({
212
+ highlightedOptionId: undefined
213
+ });
214
+ if (typeof this.props.onBlur === 'function') {
215
+ this.props.onBlur(event);
216
+ }
217
+ };
218
+ handleShowOptions = event => {
219
+ this.setState({
220
+ isShowingOptions: true
221
+ });
222
+ if (typeof this.props.onShowOptions === 'function') {
223
+ this.props.onShowOptions(event);
224
+ }
225
+ if (event.type.startsWith('key')) {
226
+ const keyboardEvent = event;
227
+ const children = Children.toArray(this.props.children);
228
+ if (!this.state.inputValue && children.length > 0) {
229
+ const position = keyboardEvent.key === 'ArrowDown' ? 'first' : keyboardEvent.key === 'ArrowUp' ? 'last' : undefined;
230
+ if (position) {
231
+ const optionId = this.getOptionByPosition(position)?.props.id;
232
+ optionId && this.setState({
233
+ highlightedOptionId: optionId
234
+ });
235
+ }
236
+ }
237
+ }
238
+ };
239
+ handleHideOptions = event => {
240
+ this.setState(state => {
241
+ const option = this.getOption('id', state.selectedOptionId);
242
+ return {
243
+ isShowingOptions: false,
244
+ highlightedOptionId: undefined,
245
+ inputValue: option ? option.props.children : ''
246
+ };
247
+ });
248
+ if (typeof this.props.onHideOptions === 'function') {
249
+ this.props.onHideOptions(event);
250
+ }
251
+ };
252
+ handleHighlightOption = (_event, {
253
+ id
254
+ }) => {
255
+ if (id === this._emptyOptionId) return;
256
+ this.setState({
257
+ highlightedOptionId: id,
258
+ inputValue: this.state.inputValue
259
+ });
260
+ };
261
+ handleSelectOption = (event, {
262
+ id
263
+ }) => {
264
+ if (id === this._emptyOptionId) {
265
+ // selected option is the empty option
266
+ this.setState({
267
+ isShowingOptions: false
268
+ });
269
+ return;
270
+ }
271
+ const option = this.getOption('id', id);
272
+ const value = option && option.props.value;
273
+
274
+ // Focus needs to be reapplied to input
275
+ // after selecting an item to make sure VoiceOver behaves correctly on iOS
276
+ if (utils.isAndroidOrIOS()) {
277
+ this.blur();
278
+ this.focus();
279
+ }
280
+ if (this.isControlled) {
281
+ this.setState({
282
+ isShowingOptions: false
283
+ });
284
+ } else {
285
+ this.setState(state => ({
286
+ isShowingOptions: false,
287
+ selectedOptionId: id,
288
+ inputValue: option ? option.props.children : state.inputValue
289
+ }));
290
+ }
291
+ // fire onChange if selected option changed
292
+ if (option && typeof this.props.onChange === 'function') {
293
+ this.props.onChange(event, {
294
+ value,
295
+ id
296
+ });
297
+ }
298
+ // hide options list whenever selection is made
299
+ if (typeof this.props.onHideOptions === 'function') {
300
+ this.props.onHideOptions(event);
301
+ }
302
+ };
291
303
  renderChildren() {
292
304
  let children = Children.toArray(this.props.children);
293
305
  children = Children.map(children, child => {
@@ -313,20 +325,19 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec(_class = (_SimpleSelect =
313
325
  });
314
326
  }
315
327
  renderOption(option) {
316
- var _option$props$isDisab;
317
- const _option$props = option.props,
318
- id = _option$props.id,
319
- value = _option$props.value,
320
- children = _option$props.children,
321
- renderBeforeLabel = _option$props.renderBeforeLabel,
322
- renderAfterLabel = _option$props.renderAfterLabel,
323
- rest = _objectWithoutProperties(_option$props, _excluded);
324
- const isDisabled = (_option$props$isDisab = option.props.isDisabled) !== null && _option$props$isDisab !== void 0 ? _option$props$isDisab : false; // after the react 19 upgrade `isDisabled` is undefined instead of defaulting to false if not specified (but only in vitest env for some reason)
328
+ const {
329
+ id,
330
+ value,
331
+ children,
332
+ renderBeforeLabel,
333
+ renderAfterLabel,
334
+ ...rest
335
+ } = option.props;
336
+ const isDisabled = option.props.isDisabled ?? false; // after the react 19 upgrade `isDisabled` is undefined instead of defaulting to false if not specified (but only in vitest env for some reason)
325
337
  const isSelected = id === this.state.selectedOptionId;
326
338
  const isHighlighted = id === this.state.highlightedOptionId;
327
339
  const getRenderLabel = renderLabel => {
328
- var _renderLabel$prototyp;
329
- if (typeof renderLabel === 'function' && !(renderLabel !== null && renderLabel !== void 0 && (_renderLabel$prototyp = renderLabel.prototype) !== null && _renderLabel$prototyp !== void 0 && _renderLabel$prototyp.isReactComponent)) {
340
+ if (typeof renderLabel === 'function' && !renderLabel?.prototype?.isReactComponent) {
330
341
  return renderLabel.bind(null, {
331
342
  id,
332
343
  isDisabled,
@@ -350,11 +361,12 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec(_class = (_SimpleSelect =
350
361
  }, option.key || id);
351
362
  }
352
363
  renderGroup(group) {
353
- const _group$props = group.props,
354
- id = _group$props.id,
355
- renderLabel = _group$props.renderLabel,
356
- children = _group$props.children,
357
- rest = _objectWithoutProperties(_group$props, _excluded2);
364
+ const {
365
+ id,
366
+ renderLabel,
367
+ children,
368
+ ...rest
369
+ } = group.props;
358
370
  return _jsx(Select.Group, {
359
371
  renderLabel: renderLabel,
360
372
  ...passthroughProps(rest),
@@ -362,37 +374,38 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec(_class = (_SimpleSelect =
362
374
  }, group.key || id);
363
375
  }
364
376
  render() {
365
- const _this$props = this.props,
366
- renderLabel = _this$props.renderLabel,
367
- value = _this$props.value,
368
- defaultValue = _this$props.defaultValue,
369
- id = _this$props.id,
370
- size = _this$props.size,
371
- assistiveText = _this$props.assistiveText,
372
- placeholder = _this$props.placeholder,
373
- interaction = _this$props.interaction,
374
- isRequired = _this$props.isRequired,
375
- isInline = _this$props.isInline,
376
- width = _this$props.width,
377
- optionsMaxWidth = _this$props.optionsMaxWidth,
378
- optionsMaxHeight = _this$props.optionsMaxHeight,
379
- visibleOptionsCount = _this$props.visibleOptionsCount,
380
- messages = _this$props.messages,
381
- placement = _this$props.placement,
382
- constrain = _this$props.constrain,
383
- mountNode = _this$props.mountNode,
384
- inputRef = _this$props.inputRef,
385
- listRef = _this$props.listRef,
386
- renderEmptyOption = _this$props.renderEmptyOption,
387
- renderBeforeInput = _this$props.renderBeforeInput,
388
- renderAfterInput = _this$props.renderAfterInput,
389
- onFocus = _this$props.onFocus,
390
- onBlur = _this$props.onBlur,
391
- onShowOptions = _this$props.onShowOptions,
392
- onHideOptions = _this$props.onHideOptions,
393
- children = _this$props.children,
394
- layout = _this$props.layout,
395
- rest = _objectWithoutProperties(_this$props, _excluded3);
377
+ const {
378
+ renderLabel,
379
+ value,
380
+ defaultValue,
381
+ id,
382
+ size,
383
+ assistiveText,
384
+ placeholder,
385
+ interaction,
386
+ isRequired,
387
+ isInline,
388
+ width,
389
+ optionsMaxWidth,
390
+ optionsMaxHeight,
391
+ visibleOptionsCount,
392
+ messages,
393
+ placement,
394
+ constrain,
395
+ mountNode,
396
+ inputRef,
397
+ listRef,
398
+ renderEmptyOption,
399
+ renderBeforeInput,
400
+ renderAfterInput,
401
+ onFocus,
402
+ onBlur,
403
+ onShowOptions,
404
+ onHideOptions,
405
+ children,
406
+ layout,
407
+ ...rest
408
+ } = this.props;
396
409
  return _jsx(Select, {
397
410
  renderLabel: renderLabel,
398
411
  inputValue: this.state.inputValue,
@@ -430,15 +443,6 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec(_class = (_SimpleSelect =
430
443
  children: this.renderChildren()
431
444
  });
432
445
  }
433
- }, _SimpleSelect.displayName = "SimpleSelect", _SimpleSelect.componentId = 'SimpleSelect', _SimpleSelect.Option = Option, _SimpleSelect.Group = Group, _SimpleSelect.allowedProps = allowedProps, _SimpleSelect.defaultProps = {
434
- size: 'medium',
435
- isRequired: false,
436
- isInline: false,
437
- visibleOptionsCount: 8,
438
- placement: 'bottom stretch',
439
- constrain: 'window',
440
- renderEmptyOption: '---',
441
- isOptionContentAppliedToInput: false
442
- }, _SimpleSelect)) || _class);
446
+ }) || _class);
443
447
  export { SimpleSelect };
444
448
  export default SimpleSelect;
@@ -31,6 +31,11 @@ id: SimpleSelect.Group
31
31
  ---
32
32
  **/
33
33
  class Group extends Component {
34
+ static displayName = "Group";
35
+ static componentId = 'SimpleSelect.Group';
36
+ static allowedProps = allowedProps;
37
+ static defaultProps = {};
38
+
34
39
  /* istanbul ignore next */
35
40
  render() {
36
41
  // this component is only used for prop validation. Select.Group children
@@ -38,9 +43,5 @@ class Group extends Component {
38
43
  return null;
39
44
  }
40
45
  }
41
- Group.displayName = "Group";
42
- Group.componentId = 'SimpleSelect.Group';
43
- Group.allowedProps = allowedProps;
44
- Group.defaultProps = {};
45
46
  export default Group;
46
47
  export { Group };
@@ -31,6 +31,13 @@ id: SimpleSelect.Option
31
31
  ---
32
32
  **/
33
33
  class Option extends Component {
34
+ static displayName = "Option";
35
+ static componentId = 'SimpleSelect.Option';
36
+ static allowedProps = allowedProps;
37
+ static defaultProps = {
38
+ isDisabled: false
39
+ };
40
+
34
41
  /* istanbul ignore next */
35
42
  render() {
36
43
  // this component is only used for prop validation. SimpleSelect.Option children
@@ -38,11 +45,5 @@ class Option extends Component {
38
45
  return null;
39
46
  }
40
47
  }
41
- Option.displayName = "Option";
42
- Option.componentId = 'SimpleSelect.Option';
43
- Option.allowedProps = allowedProps;
44
- Option.defaultProps = {
45
- isDisabled: false
46
- };
47
48
  export default Option;
48
49
  export { Option };