@instructure/ui-simple-select 11.7.2-snapshot-48 → 11.7.2-snapshot-49

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 (39) hide show
  1. package/CHANGELOG.md +12 -2
  2. package/es/SimpleSelect/v2/Group/index.js +46 -0
  3. package/es/SimpleSelect/v2/Group/props.js +26 -0
  4. package/es/SimpleSelect/v2/Option/index.js +48 -0
  5. package/es/SimpleSelect/v2/Option/props.js +26 -0
  6. package/es/SimpleSelect/v2/index.js +444 -0
  7. package/es/SimpleSelect/v2/props.js +26 -0
  8. package/es/exports/b.js +26 -0
  9. package/lib/SimpleSelect/v2/Group/index.js +52 -0
  10. package/lib/SimpleSelect/v2/Group/props.js +31 -0
  11. package/lib/SimpleSelect/v2/Option/index.js +54 -0
  12. package/lib/SimpleSelect/v2/Option/props.js +31 -0
  13. package/lib/SimpleSelect/v2/index.js +454 -0
  14. package/lib/SimpleSelect/v2/props.js +31 -0
  15. package/lib/exports/b.js +26 -0
  16. package/package.json +21 -21
  17. package/src/SimpleSelect/v2/Group/index.tsx +51 -0
  18. package/src/SimpleSelect/v2/Group/props.ts +49 -0
  19. package/src/SimpleSelect/v2/Option/index.tsx +52 -0
  20. package/src/SimpleSelect/v2/Option/props.ts +83 -0
  21. package/src/SimpleSelect/v2/README.md +157 -0
  22. package/src/SimpleSelect/v2/index.tsx +559 -0
  23. package/src/SimpleSelect/v2/props.ts +300 -0
  24. package/src/exports/b.ts +31 -0
  25. package/tsconfig.build.tsbuildinfo +1 -1
  26. package/types/SimpleSelect/v2/Group/index.d.ts +20 -0
  27. package/types/SimpleSelect/v2/Group/index.d.ts.map +1 -0
  28. package/types/SimpleSelect/v2/Group/props.d.ts +19 -0
  29. package/types/SimpleSelect/v2/Group/props.d.ts.map +1 -0
  30. package/types/SimpleSelect/v2/Option/index.d.ts +26 -0
  31. package/types/SimpleSelect/v2/Option/index.d.ts.map +1 -0
  32. package/types/SimpleSelect/v2/Option/props.d.ts +45 -0
  33. package/types/SimpleSelect/v2/Option/props.d.ts.map +1 -0
  34. package/types/SimpleSelect/v2/index.d.ts +90 -0
  35. package/types/SimpleSelect/v2/index.d.ts.map +1 -0
  36. package/types/SimpleSelect/v2/props.d.ts +180 -0
  37. package/types/SimpleSelect/v2/props.d.ts.map +1 -0
  38. package/types/exports/b.d.ts +7 -0
  39. package/types/exports/b.d.ts.map +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-simple-select",
3
- "version": "11.7.2-snapshot-48",
3
+ "version": "11.7.2-snapshot-49",
4
4
  "description": "A component for standard select element behavior.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -15,22 +15,22 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
- "@instructure/console": "11.7.2-snapshot-48",
19
- "@instructure/shared-types": "11.7.2-snapshot-48",
20
- "@instructure/ui-form-field": "11.7.2-snapshot-48",
21
- "@instructure/ui-position": "11.7.2-snapshot-48",
22
- "@instructure/ui-react-utils": "11.7.2-snapshot-48",
23
- "@instructure/ui-select": "11.7.2-snapshot-48"
18
+ "@instructure/console": "11.7.2-snapshot-49",
19
+ "@instructure/shared-types": "11.7.2-snapshot-49",
20
+ "@instructure/ui-position": "11.7.2-snapshot-49",
21
+ "@instructure/ui-react-utils": "11.7.2-snapshot-49",
22
+ "@instructure/ui-form-field": "11.7.2-snapshot-49",
23
+ "@instructure/ui-select": "11.7.2-snapshot-49"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@testing-library/jest-dom": "^6.6.3",
27
27
  "@testing-library/react": "15.0.7",
28
28
  "@testing-library/user-event": "^14.6.1",
29
29
  "vitest": "^3.2.2",
30
- "@instructure/ui-icons": "11.7.2-snapshot-48",
31
- "@instructure/ui-color-utils": "11.7.2-snapshot-48",
32
- "@instructure/ui-utils": "11.7.2-snapshot-48",
33
- "@instructure/ui-babel-preset": "11.7.2-snapshot-48"
30
+ "@instructure/ui-babel-preset": "11.7.2-snapshot-49",
31
+ "@instructure/ui-color-utils": "11.7.2-snapshot-49",
32
+ "@instructure/ui-icons": "11.7.2-snapshot-49",
33
+ "@instructure/ui-utils": "11.7.2-snapshot-49"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": ">=18 <=19"
@@ -60,18 +60,18 @@
60
60
  "default": "./es/exports/a.js"
61
61
  },
62
62
  "./v11_7": {
63
- "src": "./src/exports/a.ts",
64
- "types": "./types/exports/a.d.ts",
65
- "import": "./es/exports/a.js",
66
- "require": "./lib/exports/a.js",
67
- "default": "./es/exports/a.js"
63
+ "src": "./src/exports/b.ts",
64
+ "types": "./types/exports/b.d.ts",
65
+ "import": "./es/exports/b.js",
66
+ "require": "./lib/exports/b.js",
67
+ "default": "./es/exports/b.js"
68
68
  },
69
69
  "./latest": {
70
- "src": "./src/exports/a.ts",
71
- "types": "./types/exports/a.d.ts",
72
- "import": "./es/exports/a.js",
73
- "require": "./lib/exports/a.js",
74
- "default": "./es/exports/a.js"
70
+ "src": "./src/exports/b.ts",
71
+ "types": "./types/exports/b.d.ts",
72
+ "import": "./es/exports/b.js",
73
+ "require": "./lib/exports/b.js",
74
+ "default": "./es/exports/b.js"
75
75
  }
76
76
  },
77
77
  "scripts": {
@@ -0,0 +1,51 @@
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
+
25
+ import { Component } from 'react'
26
+
27
+ import type { SimpleSelectGroupProps } from './props'
28
+ import { allowedProps } from './props'
29
+
30
+ /**
31
+ ---
32
+ parent: SimpleSelect
33
+ id: SimpleSelect.Group
34
+ ---
35
+ **/
36
+ class Group extends Component<SimpleSelectGroupProps> {
37
+ static readonly componentId = 'SimpleSelect.Group'
38
+
39
+ static allowedProps = allowedProps
40
+ static defaultProps = {}
41
+
42
+ /* istanbul ignore next */
43
+ render() {
44
+ // this component is only used for prop validation. Select.Group children
45
+ // are parsed in Select and rendered as Options components
46
+ return null
47
+ }
48
+ }
49
+
50
+ export default Group
51
+ export { Group }
@@ -0,0 +1,49 @@
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
+
25
+ import React from 'react'
26
+
27
+ import type { OtherHTMLAttributes } from '@instructure/shared-types'
28
+
29
+ type SimpleSelectGroupOwnProps = {
30
+ /**
31
+ * The label associated with the group options.
32
+ */
33
+ renderLabel: React.ReactNode | (() => React.ReactNode)
34
+ /**
35
+ * Children of type `<SimpleSelect.Option />` that will be considered part of the group.
36
+ */
37
+ children?: React.ReactNode // TODO: ChildrenPropTypes.oneOf([Option])
38
+ }
39
+
40
+ type PropKeys = keyof SimpleSelectGroupOwnProps
41
+
42
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
43
+
44
+ type SimpleSelectGroupProps = SimpleSelectGroupOwnProps &
45
+ OtherHTMLAttributes<SimpleSelectGroupOwnProps>
46
+ const allowedProps: AllowedPropKeys = ['renderLabel', 'children']
47
+
48
+ export type { SimpleSelectGroupProps }
49
+ export { allowedProps }
@@ -0,0 +1,52 @@
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
+
25
+ import { Component } from 'react'
26
+ import type { SimpleSelectOptionProps } from './props'
27
+ import { allowedProps } from './props'
28
+
29
+ /**
30
+ ---
31
+ parent: SimpleSelect
32
+ id: SimpleSelect.Option
33
+ ---
34
+ **/
35
+ class Option extends Component<SimpleSelectOptionProps> {
36
+ static readonly componentId = 'SimpleSelect.Option'
37
+
38
+ static allowedProps = allowedProps
39
+ static defaultProps = {
40
+ isDisabled: false
41
+ }
42
+
43
+ /* istanbul ignore next */
44
+ render() {
45
+ // this component is only used for prop validation. SimpleSelect.Option children
46
+ // are parsed in Select and rendered as Options.Item components
47
+ return null
48
+ }
49
+ }
50
+
51
+ export default Option
52
+ export { Option }
@@ -0,0 +1,83 @@
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
+
25
+ import React from 'react'
26
+ import type { OtherHTMLAttributes } from '@instructure/shared-types'
27
+ import { Renderable } from '@instructure/shared-types'
28
+
29
+ type OptionProps = {
30
+ id: SimpleSelectOptionOwnProps['id']
31
+ isDisabled?: SimpleSelectOptionOwnProps['isDisabled']
32
+ isSelected?: boolean
33
+ isHighlighted?: boolean
34
+ children?: React.ReactNode
35
+ }
36
+
37
+ type RenderSimpleSelectOptionLabel = Renderable<OptionProps>
38
+
39
+ type SimpleSelectOptionOwnProps = {
40
+ /**
41
+ * The id for the option. **Must be globally unique**, it will be translated
42
+ * to an `id` prop in the DOM.
43
+ */
44
+ id: string
45
+ /**
46
+ * The value for the option.
47
+ */
48
+ value: string | number
49
+ /**
50
+ * Whether or not this option is disabled.
51
+ */
52
+ isDisabled?: boolean
53
+ /**
54
+ * Content to display as the option label.
55
+ */
56
+ children?: string
57
+ /**
58
+ * Content to display before the option label, such as an icon.
59
+ */
60
+ renderBeforeLabel?: RenderSimpleSelectOptionLabel
61
+ /**
62
+ * Content to display after the option label, such as an icon.
63
+ */
64
+ renderAfterLabel?: RenderSimpleSelectOptionLabel
65
+ }
66
+
67
+ type PropKeys = keyof SimpleSelectOptionOwnProps
68
+
69
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
70
+
71
+ type SimpleSelectOptionProps = SimpleSelectOptionOwnProps &
72
+ OtherHTMLAttributes<SimpleSelectOptionOwnProps>
73
+ const allowedProps: AllowedPropKeys = [
74
+ 'id',
75
+ 'value',
76
+ 'isDisabled',
77
+ 'renderBeforeLabel',
78
+ 'renderAfterLabel',
79
+ 'children'
80
+ ]
81
+
82
+ export type { SimpleSelectOptionProps, RenderSimpleSelectOptionLabel }
83
+ export { allowedProps }
@@ -0,0 +1,157 @@
1
+ ---
2
+ describes: SimpleSelect
3
+ ---
4
+
5
+ `SimpleSelect` is a higher level abstraction of [Select](Select) that closely parallels the functionality of standard HTML `<select>` elements. It does not support autocomplete behavior and is much less configurable than [Select](Select). However, because it is more opinionated, `SimpleSelect` can be implemented with very little boilerplate.
6
+
7
+ > Note: The `id` prop on options must be globally unique, it will be translated to an `id` prop
8
+ > in the DOM.
9
+
10
+ ### Uncontrolled
11
+
12
+ For the most basic implementations, `SimpleSelect` can be uncontrolled. If desired, the `defaultValue` prop can be used to set the initial selection.
13
+
14
+ ```javascript
15
+ ---
16
+ type: example
17
+ ---
18
+ <SimpleSelect renderLabel="Uncontrolled Select">
19
+ <SimpleSelect.Option id="foo" value="foo"
20
+ renderBeforeLabel={(props) => {
21
+ console.log(props)
22
+ return <CheckInstUIIcon />
23
+ }}>
24
+ Foo
25
+ </SimpleSelect.Option>
26
+ <SimpleSelect.Option id="bar" value="bar">
27
+ Bar
28
+ </SimpleSelect.Option>
29
+ <SimpleSelect.Option id="baz" value="baz">
30
+ Baz
31
+ </SimpleSelect.Option>
32
+ </SimpleSelect>
33
+ ```
34
+
35
+ ### Controlled
36
+
37
+ To use `SimpleSelect` controlled, simply provide the `value` prop the string that corresponds to the selected option's `value` prop. The `onChange` callback can be used to update the value stored in state.
38
+
39
+ ```js
40
+ ---
41
+ type: example
42
+ ---
43
+ const Example = ({ options }) => {
44
+ const [value, setValue] = useState('Alaska')
45
+
46
+ const handleSelect = (e, { id, value }) => {
47
+ setValue(value)
48
+ }
49
+
50
+ return (
51
+ <SimpleSelect
52
+ renderLabel="Controlled Select"
53
+ assistiveText="Use arrow keys to navigate options."
54
+ value={value}
55
+ onChange={handleSelect}
56
+ >
57
+ {options.map((opt, index) => (
58
+ <SimpleSelect.Option key={index} id={`opt-${index}`} value={opt}>
59
+ {opt}
60
+ </SimpleSelect.Option>
61
+ ))}
62
+ </SimpleSelect>
63
+ )
64
+ }
65
+
66
+ render(
67
+ <Example
68
+ options={[
69
+ 'Alaska',
70
+ 'American Samoa',
71
+ 'Arizona',
72
+ 'Arkansas',
73
+ 'California',
74
+ 'Colorado',
75
+ 'Connecticut',
76
+ 'Delaware',
77
+ 'District Of Columbia',
78
+ 'Federated States Of Micronesia',
79
+ 'Florida',
80
+ 'Georgia',
81
+ 'Guam',
82
+ 'Hawaii',
83
+ 'Idaho',
84
+ 'Illinois'
85
+ ]}
86
+ />
87
+ )
88
+ ```
89
+
90
+ ### Groups
91
+
92
+ Like a HTML `<select>` element, `SimpleSelect` supports option groups. `SimpleSelect.Group` only requires the `renderLabel` prop be provided.
93
+
94
+ ```javascript
95
+ ---
96
+ type: example
97
+ ---
98
+ <SimpleSelect renderLabel="Select with Groups">
99
+ <SimpleSelect.Group renderLabel="Group one" key="grp1">
100
+ <SimpleSelect.Option id="opt1" value="option-1">
101
+ Option one
102
+ </SimpleSelect.Option>
103
+ </SimpleSelect.Group>
104
+ <SimpleSelect.Group renderLabel="Group two" key="grp2">
105
+ <SimpleSelect.Option id="opt2" value="option-2">
106
+ Option two
107
+ </SimpleSelect.Option>
108
+ <SimpleSelect.Option id="opt3" value="option-3">
109
+ Option three
110
+ </SimpleSelect.Option>
111
+ <SimpleSelect.Option id="opt4" value="option-4">
112
+ Option four
113
+ </SimpleSelect.Option>
114
+ </SimpleSelect.Group>
115
+ </SimpleSelect>
116
+ ```
117
+
118
+ ### Icons
119
+
120
+ To display icons (or other elements) before or after an option, pass it via the `renderBeforeLabel` and `renderAfterLabel` prop to `SimpleSelect.Option`. You can pass a function as well, which will have a `props` parameter, so you can access the properties of that `SimpleSelect.Option` (e.g. if it is currently `isHighlighted`). The available props are: `[ id, isDisabled, isSelected, isHighlighted, children ]` (same as for `Select.Option`).
121
+
122
+ ```javascript
123
+ ---
124
+ type: example
125
+ ---
126
+ <SimpleSelect renderLabel="Option Icons">
127
+ <SimpleSelect.Option
128
+ id="text"
129
+ value="text"
130
+ renderBeforeLabel={'XY'}
131
+ >
132
+ Text
133
+ </SimpleSelect.Option>
134
+ <SimpleSelect.Option
135
+ id="icon"
136
+ value="icon"
137
+ renderBeforeLabel={<CheckInstUIIcon />}
138
+ >
139
+ Icon
140
+ </SimpleSelect.Option>
141
+ <SimpleSelect.Option
142
+ id="coloredIcon"
143
+ value="coloredIcon"
144
+ renderBeforeLabel={(props) => {
145
+ let color = 'infoColor'
146
+ if (props.isHighlighted) color = 'baseColor'
147
+ if (props.isSelected) color = 'inverseColor'
148
+ if (props.isDisabled) color = 'disabledBaseColor'
149
+ return <VerifiedInstUIIcon color={color} />
150
+ }}
151
+ >
152
+ Colored Icon
153
+ </SimpleSelect.Option>
154
+ </SimpleSelect>
155
+ ```
156
+
157
+ > Note: This component uses a native `input` field to render the selected value. When it's included in a native HTML `form`, the text value will be sent to the backend instead of anything specified in the `value` field of the `SimpleSelect.Option`-s. We do not recommend to use this component this way, rather write your own code that collects information and sends it to the backend.