@instructure/ui-simple-select 10.26.1 → 11.0.1-snapshot-0

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/es/SimpleSelect/Group/index.js +1 -2
  3. package/es/SimpleSelect/Group/props.js +1 -8
  4. package/es/SimpleSelect/Option/index.js +1 -2
  5. package/es/SimpleSelect/Option/props.js +1 -10
  6. package/es/SimpleSelect/index.js +21 -17
  7. package/es/SimpleSelect/props.js +1 -41
  8. package/lib/SimpleSelect/Group/index.js +0 -1
  9. package/lib/SimpleSelect/Group/props.js +1 -9
  10. package/lib/SimpleSelect/Option/index.js +0 -1
  11. package/lib/SimpleSelect/Option/props.js +1 -11
  12. package/lib/SimpleSelect/index.js +20 -16
  13. package/lib/SimpleSelect/props.js +1 -42
  14. package/package.json +13 -16
  15. package/src/SimpleSelect/Group/index.tsx +1 -2
  16. package/src/SimpleSelect/Group/props.ts +2 -16
  17. package/src/SimpleSelect/Option/index.tsx +1 -2
  18. package/src/SimpleSelect/Option/props.ts +2 -17
  19. package/src/SimpleSelect/index.tsx +26 -19
  20. package/src/SimpleSelect/props.ts +2 -46
  21. package/tsconfig.build.json +0 -2
  22. package/tsconfig.build.tsbuildinfo +1 -1
  23. package/types/SimpleSelect/Group/index.d.ts +0 -4
  24. package/types/SimpleSelect/Group/index.d.ts.map +1 -1
  25. package/types/SimpleSelect/Group/props.d.ts +2 -3
  26. package/types/SimpleSelect/Group/props.d.ts.map +1 -1
  27. package/types/SimpleSelect/Option/index.d.ts +0 -8
  28. package/types/SimpleSelect/Option/index.d.ts.map +1 -1
  29. package/types/SimpleSelect/Option/props.d.ts +2 -3
  30. package/types/SimpleSelect/Option/props.d.ts.map +1 -1
  31. package/types/SimpleSelect/index.d.ts +0 -26
  32. package/types/SimpleSelect/index.d.ts.map +1 -1
  33. package/types/SimpleSelect/props.d.ts +2 -3
  34. package/types/SimpleSelect/props.d.ts.map +1 -1
@@ -22,10 +22,15 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import { isValidElement, ComponentElement, Component, Children } from 'react'
25
+ import {
26
+ isValidElement,
27
+ ComponentElement,
28
+ Component,
29
+ Children,
30
+ type ReactElement
31
+ } from 'react'
26
32
 
27
33
  import * as utils from '@instructure/ui-utils'
28
- import { testable } from '@instructure/ui-testable'
29
34
  import {
30
35
  matchComponentTypes,
31
36
  passthroughProps,
@@ -47,7 +52,7 @@ import { Group } from './Group'
47
52
  import type { SimpleSelectGroupProps } from './Group/props'
48
53
 
49
54
  import type { SimpleSelectProps } from './props'
50
- import { allowedProps, propTypes, SimpleSelectState } from './props'
55
+ import { allowedProps, SimpleSelectState } from './props'
51
56
 
52
57
  type OptionChild = ComponentElement<SimpleSelectOptionProps, Option>
53
58
  type GroupChild = ComponentElement<SimpleSelectGroupProps, Group>
@@ -64,7 +69,6 @@ tags: form, field, dropdown
64
69
  ---
65
70
  **/
66
71
  @withDeterministicId()
67
- @testable()
68
72
  class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
69
73
  static readonly componentId = 'SimpleSelect'
70
74
 
@@ -72,7 +76,6 @@ class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
72
76
  static Group = Group
73
77
 
74
78
  static allowedProps = allowedProps
75
- static propTypes = propTypes
76
79
 
77
80
  static defaultProps = {
78
81
  size: 'medium',
@@ -143,7 +146,7 @@ class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
143
146
  const getValues = (children: SimpleSelectProps['children']) =>
144
147
  Children.map(children, (child) => {
145
148
  if (isValidElement(child)) {
146
- return child.props.value
149
+ return (child as ReactElement<any>).props.value
147
150
  }
148
151
  return null
149
152
  })
@@ -424,21 +427,24 @@ class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
424
427
  ...rest
425
428
  } = option.props
426
429
 
427
- const isDisabled = option.props.isDisabled
430
+ 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)
428
431
  const isSelected = id === this.state.selectedOptionId
429
432
  const isHighlighted = id === this.state.highlightedOptionId
430
433
 
431
434
  const getRenderLabel = (renderLabel: RenderSimpleSelectOptionLabel) => {
432
- return typeof renderLabel === 'function' &&
435
+ if (
436
+ typeof renderLabel === 'function' &&
433
437
  !renderLabel?.prototype?.isReactComponent
434
- ? (renderLabel as any).bind(null, {
435
- id,
436
- isDisabled,
437
- isSelected,
438
- isHighlighted,
439
- children
440
- })
441
- : renderLabel
438
+ ) {
439
+ return (renderLabel as any).bind(null, {
440
+ id,
441
+ isDisabled,
442
+ isSelected,
443
+ isHighlighted,
444
+ children
445
+ })
446
+ }
447
+ return renderLabel
442
448
  }
443
449
 
444
450
  return (
@@ -446,9 +452,9 @@ class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
446
452
  id={id}
447
453
  value={value}
448
454
  key={option.key || id}
449
- isHighlighted={id === this.state.highlightedOptionId}
450
- isSelected={id === this.state.selectedOptionId}
451
- isDisabled={option.props.isDisabled}
455
+ isHighlighted={isHighlighted}
456
+ isSelected={isSelected}
457
+ isDisabled={isDisabled}
452
458
  renderBeforeLabel={getRenderLabel(renderBeforeLabel)}
453
459
  renderAfterLabel={getRenderLabel(renderAfterLabel)}
454
460
  {...passthroughProps(rest)}
@@ -541,6 +547,7 @@ class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
541
547
  isOptionContentAppliedToInput={this.props.isOptionContentAppliedToInput}
542
548
  layout={layout}
543
549
  {...passthroughProps(rest)}
550
+ data-cid="SimpleSelect"
544
551
  >
545
552
  {this.renderChildren()}
546
553
  </Select>
@@ -23,20 +23,11 @@
23
23
  */
24
24
 
25
25
  import { InputHTMLAttributes } from 'react'
26
- import PropTypes from 'prop-types'
27
-
28
- import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
29
- import { FormPropTypes } from '@instructure/ui-form-field'
30
- import { PositionPropTypes } from '@instructure/ui-position'
31
-
32
- import { Group } from './Group'
33
- import { Option } from './Option'
34
26
 
35
27
  import type { FormMessage } from '@instructure/ui-form-field'
36
28
  import type {
37
29
  OtherHTMLAttributes,
38
- PickPropsWithExceptions,
39
- PropValidators
30
+ PickPropsWithExceptions
40
31
  } from '@instructure/shared-types'
41
32
  import type {
42
33
  PlacementPropValues,
@@ -272,41 +263,6 @@ type SimpleSelectState = {
272
263
  selectedOptionId?: string
273
264
  }
274
265
 
275
- const propTypes: PropValidators<PropKeys> = {
276
- renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
277
- // TODO: it was using the "controllable" util, in the TS migration mimic that behaviour
278
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
279
- defaultValue: PropTypes.string,
280
- id: PropTypes.string,
281
- size: PropTypes.oneOf(['small', 'medium', 'large']),
282
- assistiveText: PropTypes.string,
283
- placeholder: PropTypes.string,
284
- interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
285
- isRequired: PropTypes.bool,
286
- isInline: PropTypes.bool,
287
- width: PropTypes.string,
288
- visibleOptionsCount: PropTypes.number,
289
- optionsMaxHeight: PropTypes.string,
290
- optionsMaxWidth: PropTypes.string,
291
- messages: PropTypes.arrayOf(FormPropTypes.message),
292
- placement: PositionPropTypes.placement,
293
- constrain: PositionPropTypes.constrain,
294
- mountNode: PositionPropTypes.mountNode,
295
- onChange: PropTypes.func,
296
- onFocus: PropTypes.func,
297
- onBlur: PropTypes.func,
298
- onShowOptions: PropTypes.func,
299
- onHideOptions: PropTypes.func,
300
- inputRef: PropTypes.func,
301
- listRef: PropTypes.func,
302
- renderEmptyOption: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
303
- renderBeforeInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
304
- renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
305
- children: ChildrenPropTypes.oneOf([Group, Option]),
306
- isOptionContentAppliedToInput: PropTypes.bool,
307
- layout: PropTypes.oneOf(['stacked', 'inline'])
308
- }
309
-
310
266
  const allowedProps: AllowedPropKeys = [
311
267
  'renderLabel',
312
268
  'value',
@@ -341,4 +297,4 @@ const allowedProps: AllowedPropKeys = [
341
297
  ]
342
298
 
343
299
  export type { SimpleSelectProps, SimpleSelectState }
344
- export { propTypes, allowedProps }
300
+ export { allowedProps }
@@ -10,10 +10,8 @@
10
10
  { "path": "../console/tsconfig.build.json" },
11
11
  { "path": "../ui-form-field/tsconfig.build.json" },
12
12
  { "path": "../ui-position/tsconfig.build.json" },
13
- { "path": "../ui-prop-types/tsconfig.build.json" },
14
13
  { "path": "../ui-react-utils/tsconfig.build.json" },
15
14
  { "path": "../ui-select/tsconfig.build.json" },
16
- { "path": "../ui-testable/tsconfig.build.json" },
17
15
  { "path": "../ui-babel-preset/tsconfig.build.json" },
18
16
  { "path": "../ui-color-utils/tsconfig.build.json" },
19
17
  { "path": "../ui-icons/tsconfig.build.json" },