@instructure/ui-simple-select 8.8.1-snapshot.8 → 8.9.1

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 (46) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/es/SimpleSelect/Group/index.js +4 -15
  3. package/{src/SimpleSelect/Group/types.ts → es/SimpleSelect/Group/props.js} +15 -3
  4. package/es/SimpleSelect/Option/index.js +4 -35
  5. package/es/SimpleSelect/Option/props.js +57 -0
  6. package/es/SimpleSelect/index.js +3 -175
  7. package/es/SimpleSelect/props.js +192 -0
  8. package/lib/SimpleSelect/Group/index.js +3 -18
  9. package/{src/SimpleSelect/Option/types.ts → lib/SimpleSelect/Group/props.js} +28 -7
  10. package/lib/SimpleSelect/Option/index.js +3 -36
  11. package/lib/SimpleSelect/Option/props.js +68 -0
  12. package/lib/SimpleSelect/index.js +3 -178
  13. package/lib/SimpleSelect/props.js +208 -0
  14. package/package.json +15 -16
  15. package/src/SimpleSelect/Group/index.tsx +4 -16
  16. package/src/SimpleSelect/{types.ts → Group/props.ts} +31 -35
  17. package/src/SimpleSelect/Option/index.tsx +4 -31
  18. package/src/SimpleSelect/Option/props.ts +80 -0
  19. package/src/SimpleSelect/index.tsx +5 -149
  20. package/src/SimpleSelect/props.ts +247 -0
  21. package/src/index.ts +3 -3
  22. package/types/SimpleSelect/Group/index.d.ts +9 -15
  23. package/types/SimpleSelect/Group/index.d.ts.map +1 -1
  24. package/types/SimpleSelect/Group/props.d.ts +14 -0
  25. package/types/SimpleSelect/Group/props.d.ts.map +1 -0
  26. package/types/SimpleSelect/Option/index.d.ts +17 -30
  27. package/types/SimpleSelect/Option/index.d.ts.map +1 -1
  28. package/types/SimpleSelect/Option/props.d.ts +18 -0
  29. package/types/SimpleSelect/Option/props.d.ts.map +1 -0
  30. package/types/SimpleSelect/index.d.ts +61 -150
  31. package/types/SimpleSelect/index.d.ts.map +1 -1
  32. package/types/SimpleSelect/{types.d.ts → props.d.ts} +11 -2
  33. package/types/SimpleSelect/props.d.ts.map +1 -0
  34. package/types/index.d.ts +3 -3
  35. package/LICENSE.md +0 -27
  36. package/es/SimpleSelect/Group/types.js +0 -1
  37. package/es/SimpleSelect/Option/types.js +0 -1
  38. package/es/SimpleSelect/types.js +0 -1
  39. package/lib/SimpleSelect/Group/types.js +0 -1
  40. package/lib/SimpleSelect/Option/types.js +0 -1
  41. package/lib/SimpleSelect/types.js +0 -1
  42. package/types/SimpleSelect/Group/types.d.ts +0 -5
  43. package/types/SimpleSelect/Group/types.d.ts.map +0 -1
  44. package/types/SimpleSelect/Option/types.d.ts +0 -9
  45. package/types/SimpleSelect/Option/types.d.ts.map +0 -1
  46. package/types/SimpleSelect/types.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-simple-select",
3
- "version": "8.8.1-snapshot.8+7b83164f4",
3
+ "version": "8.9.1",
4
4
  "description": "A component for standard select element behavior.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "type": "commonjs",
@@ -25,22 +25,22 @@
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
27
  "@babel/runtime": "^7.13.10",
28
- "@instructure/console": "8.8.1-snapshot.8+7b83164f4",
29
- "@instructure/ui-form-field": "8.8.1-snapshot.8+7b83164f4",
30
- "@instructure/ui-position": "8.8.1-snapshot.8+7b83164f4",
31
- "@instructure/ui-prop-types": "8.8.1-snapshot.8+7b83164f4",
32
- "@instructure/ui-react-utils": "8.8.1-snapshot.8+7b83164f4",
33
- "@instructure/ui-select": "8.8.1-snapshot.8+7b83164f4",
34
- "@instructure/ui-testable": "8.8.1-snapshot.8+7b83164f4",
35
- "@instructure/uid": "8.8.1-snapshot.8+7b83164f4",
28
+ "@instructure/console": "8.9.1",
29
+ "@instructure/ui-form-field": "8.9.1",
30
+ "@instructure/ui-position": "8.9.1",
31
+ "@instructure/ui-prop-types": "8.9.1",
32
+ "@instructure/ui-react-utils": "8.9.1",
33
+ "@instructure/ui-select": "8.9.1",
34
+ "@instructure/ui-testable": "8.9.1",
35
+ "@instructure/uid": "8.9.1",
36
36
  "prop-types": "^15"
37
37
  },
38
38
  "devDependencies": {
39
- "@instructure/ui-babel-preset": "8.8.1-snapshot.8+7b83164f4",
40
- "@instructure/ui-color-utils": "8.8.1-snapshot.8+7b83164f4",
41
- "@instructure/ui-icons": "8.8.1-snapshot.8+7b83164f4",
42
- "@instructure/ui-test-locator": "8.8.1-snapshot.8+7b83164f4",
43
- "@instructure/ui-test-utils": "8.8.1-snapshot.8+7b83164f4"
39
+ "@instructure/ui-babel-preset": "8.9.1",
40
+ "@instructure/ui-color-utils": "8.9.1",
41
+ "@instructure/ui-icons": "8.9.1",
42
+ "@instructure/ui-test-locator": "8.9.1",
43
+ "@instructure/ui-test-utils": "8.9.1"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "react": ">=16.8 <=17"
@@ -48,6 +48,5 @@
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
- "sideEffects": false,
52
- "gitHead": "7b83164f4c5872f3a217e010563f59bf584ae4fc"
51
+ "sideEffects": false
53
52
  }
@@ -23,11 +23,9 @@
23
23
  */
24
24
 
25
25
  import { Component } from 'react'
26
- import PropTypes from 'prop-types'
27
26
 
28
- import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
29
- import { Option } from '../Option'
30
- import { SimpleSelectGroupProps } from './types'
27
+ import type { SimpleSelectGroupProps } from './props'
28
+ import { allowedProps, propTypes } from './props'
31
29
 
32
30
  /**
33
31
  ---
@@ -37,18 +35,8 @@ id: SimpleSelect.Group
37
35
  **/
38
36
  class Group extends Component<SimpleSelectGroupProps> {
39
37
  static readonly componentId = 'SimpleSelect.Group'
40
-
41
- static propTypes = {
42
- /**
43
- * The label associated with the group options.
44
- */
45
- renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
46
- .isRequired,
47
- /**
48
- * Children of type `<SimpleSelect.Option />` that will be considered part of the group.
49
- */
50
- children: ChildrenPropTypes.oneOf([Option])
51
- }
38
+ static allowedProps = allowedProps
39
+ static propTypes = propTypes
52
40
 
53
41
  static defaultProps = {
54
42
  children: null
@@ -21,41 +21,37 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
-
25
24
  import React from 'react'
26
- import type { FormMessage } from '@instructure/ui-form-field'
27
- import type {
28
- PlacementPropValues,
29
- PositionConstraint,
30
- PositionMountNode
31
- } from '@instructure/ui-position'
32
-
33
- export type SimpleSelectProps = {
25
+ import PropTypes from 'prop-types'
26
+
27
+ import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
28
+
29
+ import { Option } from '../Option'
30
+
31
+ import type { PropValidators } from '@instructure/shared-types'
32
+
33
+ type SimpleSelectGroupOwnProps = {
34
34
  renderLabel: React.ReactNode | ((...args: any[]) => any)
35
- value?: string | number // TODO: it was using the "controllable" util, in the TS migration mimic that behaviour
36
- defaultValue?: string
37
- id?: string
38
- size?: 'small' | 'medium' | 'large'
39
- assistiveText?: string
40
- placeholder?: string
41
- interaction?: 'enabled' | 'disabled' | 'readonly'
42
- isRequired?: boolean
43
- isInline?: boolean
44
- width?: string
45
- optionsMaxWidth?: string
46
- visibleOptionsCount?: number
47
- messages?: FormMessage[]
48
- placement?: PlacementPropValues
49
- constrain?: PositionConstraint
50
- mountNode?: PositionMountNode
51
- onChange?: (...args: any[]) => any
52
- onFocus?: (...args: any[]) => any
53
- onBlur?: (...args: any[]) => any
54
- onShowOptions?: (...args: any[]) => any
55
- onHideOptions?: (...args: any[]) => any
56
- inputRef?: (...args: any[]) => any
57
- listRef?: (...args: any[]) => any
58
- renderEmptyOption?: React.ReactNode | ((...args: any[]) => any)
59
- renderBeforeInput?: React.ReactNode | ((...args: any[]) => any)
60
- renderAfterInput?: React.ReactNode | ((...args: any[]) => any)
35
+ children?: React.ReactNode
61
36
  }
37
+ type PropKeys = keyof SimpleSelectGroupOwnProps
38
+
39
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
40
+
41
+ type SimpleSelectGroupProps = SimpleSelectGroupOwnProps
42
+
43
+ const propTypes: PropValidators<PropKeys> = {
44
+ /**
45
+ * The label associated with the group options.
46
+ */
47
+ renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
48
+ /**
49
+ * Children of type `<SimpleSelect.Option />` that will be considered part of the group.
50
+ */
51
+ children: ChildrenPropTypes.oneOf([Option])
52
+ }
53
+
54
+ const allowedProps: AllowedPropKeys = ['renderLabel', 'children']
55
+
56
+ export type { SimpleSelectGroupProps }
57
+ export { propTypes, allowedProps }
@@ -23,8 +23,8 @@
23
23
  */
24
24
 
25
25
  import { Component } from 'react'
26
- import PropTypes from 'prop-types'
27
- import { SimpleSelectOptionProps } from './types'
26
+ import type { SimpleSelectOptionProps } from './props'
27
+ import { allowedProps, propTypes } from './props'
28
28
 
29
29
  /**
30
30
  ---
@@ -35,37 +35,10 @@ id: SimpleSelect.Option
35
35
  class Option extends Component<SimpleSelectOptionProps> {
36
36
  static readonly componentId = 'SimpleSelect.Option'
37
37
 
38
- static propTypes = {
39
- /**
40
- * The id for the option.
41
- */
42
- id: PropTypes.string.isRequired,
43
- /**
44
- * The value for the option.
45
- */
46
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
47
- /**
48
- * Whether or not this option is disabled.
49
- */
50
- isDisabled: PropTypes.bool,
51
- /**
52
- * Content to display before the option label, such as an icon.
53
- */
54
- renderBeforeLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
55
- /**
56
- * Content to display after the option label, such as an icon.
57
- */
58
- renderAfterLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
59
- /**
60
- * Content to display as the option label.
61
- */
62
- children: PropTypes.string
63
- }
64
-
38
+ static allowedProps = allowedProps
39
+ static propTypes = propTypes
65
40
  static defaultProps = {
66
41
  isDisabled: false,
67
- renderBeforeLabel: undefined,
68
- renderAfterLabel: undefined,
69
42
  children: null
70
43
  }
71
44
 
@@ -0,0 +1,80 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ import React from 'react'
25
+ import PropTypes from 'prop-types'
26
+
27
+ import type { PropValidators } from '@instructure/shared-types'
28
+
29
+ type SimpleSelectOptionOwnProps = {
30
+ id: string
31
+ value: string | number
32
+ isDisabled?: boolean
33
+ renderBeforeLabel?: React.ReactNode | ((...args: any[]) => any)
34
+ renderAfterLabel?: React.ReactNode | ((...args: any[]) => any)
35
+ children?: React.ReactNode
36
+ }
37
+ type PropKeys = keyof SimpleSelectOptionOwnProps
38
+
39
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
40
+
41
+ type SimpleSelectOptionProps = SimpleSelectOptionOwnProps
42
+
43
+ const propTypes: PropValidators<PropKeys> = {
44
+ /**
45
+ * The id for the option.
46
+ */
47
+ id: PropTypes.string.isRequired,
48
+ /**
49
+ * The value for the option.
50
+ */
51
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
52
+ /**
53
+ * Whether or not this option is disabled.
54
+ */
55
+ isDisabled: PropTypes.bool,
56
+ /**
57
+ * Content to display before the option label, such as an icon.
58
+ */
59
+ renderBeforeLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
60
+ /**
61
+ * Content to display after the option label, such as an icon.
62
+ */
63
+ renderAfterLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
64
+ /**
65
+ * Content to display as the option label.
66
+ */
67
+ children: PropTypes.string
68
+ }
69
+
70
+ const allowedProps: AllowedPropKeys = [
71
+ 'id',
72
+ 'value',
73
+ 'isDisabled',
74
+ 'renderBeforeLabel',
75
+ 'renderAfterLabel',
76
+ 'children'
77
+ ]
78
+
79
+ export type { SimpleSelectOptionProps }
80
+ export { propTypes, allowedProps }
@@ -23,11 +23,7 @@
23
23
  */
24
24
 
25
25
  import React, { Component, Children } from 'react'
26
- import PropTypes from 'prop-types'
27
26
 
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
27
  import { testable } from '@instructure/ui-testable'
32
28
  import {
33
29
  matchComponentTypes,
@@ -40,7 +36,8 @@ import { Select } from '@instructure/ui-select'
40
36
 
41
37
  import { Option } from './Option'
42
38
  import { Group } from './Group'
43
- import { SimpleSelectProps } from './types'
39
+ import type { SimpleSelectProps } from './props'
40
+ import { allowedProps, propTypes } from './props'
44
41
 
45
42
  /**
46
43
  ---
@@ -54,158 +51,17 @@ class SimpleSelect extends Component<SimpleSelectProps> {
54
51
 
55
52
  static Option = Option
56
53
  static Group = Group
57
- static propTypes = {
58
- /**
59
- * The form field label.
60
- */
61
- renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
62
- .isRequired,
63
- /**
64
- * The value corresponding to the value of the selected option. If defined,
65
- * the component will act controlled and will not manage its own state.
66
- */
67
- // TODO: it was using the "controllable" util, in the TS migration mimic that behaviour
68
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
69
- /**
70
- * The value of the option to select by default, when uncontrolled.
71
- */
72
- defaultValue: PropTypes.string,
73
- /**
74
- * The id of the text input. One is generated if not supplied.
75
- */
76
- id: PropTypes.string,
77
- /**
78
- * The size of the text input.
79
- */
80
- size: PropTypes.oneOf(['small', 'medium', 'large']),
81
- /**
82
- * Additional helpful text to provide to screen readers about the operation
83
- * of the component. Provided via aria-describedby.
84
- */
85
- assistiveText: PropTypes.string,
86
- /**
87
- * Html placeholder text to display when the input has no value. This should
88
- * be hint text, not a label replacement.
89
- */
90
- placeholder: PropTypes.string,
91
- /**
92
- * Specifies if interaction with the input is enabled, disabled, or readonly.
93
- * When "disabled", the input changes visibly to indicate that it cannot
94
- * receive user interactions. When "readonly" the input still cannot receive
95
- * user interactions but it keeps the same styles as if it were enabled.
96
- */
97
- interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
98
- /**
99
- * Whether or not the text input is required.
100
- */
101
- isRequired: PropTypes.bool,
102
- /**
103
- * Whether the input is rendered inline with other elements or if it
104
- * is rendered as a block level element.
105
- */
106
- isInline: PropTypes.bool,
107
- /**
108
- * The width of the text input.
109
- */
110
- width: PropTypes.string,
111
- /**
112
- * The max width the options list can be before option text wraps. If not
113
- * set, the list will only display as wide as the text input.
114
- */
115
- optionsMaxWidth: PropTypes.string,
116
- /**
117
- * The number of options that should be visible before having to scroll.
118
- */
119
- visibleOptionsCount: PropTypes.number,
120
- /**
121
- * Displays messages and validation for the input. It should be an object
122
- * with the following shape:
123
- * `{
124
- * text: PropTypes.string,
125
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
126
- * }`
127
- */
128
- messages: PropTypes.arrayOf(FormPropTypes.message),
129
- /**
130
- * The placement of the options list.
131
- */
132
- placement: PositionPropTypes.placement,
133
- /**
134
- * The parent in which to constrain the placement.
135
- */
136
- constrain: PositionPropTypes.constrain,
137
- /**
138
- * An element or a function returning an element to use mount the options
139
- * list to in the DOM (defaults to `document.body`)
140
- */
141
- mountNode: PositionPropTypes.mountNode,
142
- /**
143
- * Callback fired when a new option is selected.
144
- * @param {Object} event - the event object
145
- * @param {Object} data - additional data
146
- * @param data.value - the value of selected option
147
- * @param data.id - the id of the selected option
148
- */
149
- onChange: PropTypes.func,
150
- /**
151
- * Callback fired when text input receives focus.
152
- */
153
- onFocus: PropTypes.func,
154
- /**
155
- * Callback fired when text input loses focus.
156
- */
157
- onBlur: PropTypes.func,
158
- /**
159
- * Callback fired when the options list is shown.
160
- */
161
- onShowOptions: PropTypes.func,
162
- /**
163
- * Callback fired when the options list is hidden.
164
- */
165
- onHideOptions: PropTypes.func,
166
- /**
167
- * A ref to the html `input` element.
168
- */
169
- inputRef: PropTypes.func,
170
- /**
171
- * A ref to the html `ul` element.
172
- */
173
- listRef: PropTypes.func,
174
- /**
175
- * Content to display in the list when no options are available.
176
- */
177
- renderEmptyOption: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
178
- /**
179
- * Content to display before the text input. This will commonly be an icon.
180
- */
181
- renderBeforeInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
182
- /**
183
- * Content to display after the text input. This content will replace the
184
- * default arrow icons.
185
- */
186
- renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
187
- /**
188
- * Children of type `<SimpleSelect.Option />` or `<SimpleSelect.Group />`.
189
- */
190
- children: ChildrenPropTypes.oneOf([Group, Option])
191
- }
54
+
55
+ static allowedProps = allowedProps
56
+ static propTypes = propTypes
192
57
 
193
58
  static defaultProps = {
194
- value: undefined,
195
- defaultValue: undefined,
196
- id: undefined,
197
59
  size: 'medium',
198
- assistiveText: undefined,
199
60
  placeholder: null,
200
- interaction: undefined,
201
61
  isRequired: false,
202
62
  isInline: false,
203
- width: undefined,
204
- optionsMaxWidth: undefined,
205
63
  visibleOptionsCount: 8,
206
- messages: undefined,
207
64
  placement: 'bottom stretch',
208
- mountNode: undefined,
209
65
  constrain: 'window',
210
66
  // @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
211
67
  onChange: (event, data) => {},