@instructure/ui-select 11.7.2-snapshot-47 → 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.
- package/CHANGELOG.md +12 -2
- package/es/Select/v2/Group/index.js +47 -0
- package/es/Select/v2/Group/props.js +26 -0
- package/es/Select/v2/Option/index.js +51 -0
- package/es/Select/v2/Option/props.js +26 -0
- package/es/Select/v2/index.js +704 -0
- package/es/Select/v2/props.js +35 -0
- package/es/Select/v2/styles.js +41 -0
- package/es/exports/b.js +26 -0
- package/lib/Select/v2/Group/index.js +53 -0
- package/lib/Select/v2/Group/props.js +31 -0
- package/lib/Select/v2/Option/index.js +57 -0
- package/lib/Select/v2/Option/props.js +31 -0
- package/lib/Select/v2/index.js +714 -0
- package/lib/Select/v2/props.js +40 -0
- package/lib/Select/v2/styles.js +47 -0
- package/lib/exports/b.js +26 -0
- package/package.json +29 -29
- package/src/Select/v2/Group/index.tsx +52 -0
- package/src/Select/v2/Group/props.ts +48 -0
- package/src/Select/v2/Option/index.tsx +56 -0
- package/src/Select/v2/Option/props.ts +82 -0
- package/src/Select/v2/README.md +1342 -0
- package/src/Select/v2/index.tsx +897 -0
- package/src/Select/v2/props.ts +333 -0
- package/src/Select/v2/styles.ts +48 -0
- package/src/exports/b.ts +31 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Select/v2/Group/index.d.ts +21 -0
- package/types/Select/v2/Group/index.d.ts.map +1 -0
- package/types/Select/v2/Group/props.d.ts +19 -0
- package/types/Select/v2/Group/props.d.ts.map +1 -0
- package/types/Select/v2/Option/index.d.ts +28 -0
- package/types/Select/v2/Option/index.d.ts.map +1 -0
- package/types/Select/v2/Option/props.d.ts +43 -0
- package/types/Select/v2/Option/props.d.ts.map +1 -0
- package/types/Select/v2/index.d.ts +138 -0
- package/types/Select/v2/index.d.ts.map +1 -0
- package/types/Select/v2/props.d.ts +206 -0
- package/types/Select/v2/props.d.ts.map +1 -0
- package/types/Select/v2/styles.d.ts +12 -0
- package/types/Select/v2/styles.d.ts.map +1 -0
- package/types/exports/b.d.ts +7 -0
- package/types/exports/b.d.ts.map +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.allowedProps = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
// These props are directly passed to Selectable
|
|
32
|
+
// TODO: import these from Selectable once TS types can be imported
|
|
33
|
+
|
|
34
|
+
// These props are directly passed to TextInput
|
|
35
|
+
// TODO: import these from TextInput once TS types can be imported
|
|
36
|
+
|
|
37
|
+
// These props are directly passed to Popover
|
|
38
|
+
// TODO: import these from Popover once TS types can be imported
|
|
39
|
+
|
|
40
|
+
const allowedProps = exports.allowedProps = ['renderLabel', 'inputValue', 'isShowingOptions', 'id', 'size', 'assistiveText', 'placeholder', 'interaction', 'isRequired', 'isInline', 'width', 'htmlSize', 'visibleOptionsCount', 'isOptionContentAppliedToInput', 'optionsMaxHeight', 'optionsMaxWidth', 'messages', 'placement', 'constrain', 'mountNode', 'onFocus', 'onBlur', 'onInputChange', 'onRequestShowOptions', 'onRequestHideOptions', 'onRequestHighlightOption', 'onRequestSelectOption', 'inputRef', 'listRef', 'renderBeforeInput', 'renderAfterInput', 'children', 'shouldNotWrap', 'scrollToHighlightedOption', 'layout'];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Generates the style object from the theme and provided additional information
|
|
33
|
+
* @param {Object} componentTheme The theme variable object.
|
|
34
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
35
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
36
|
+
* @return {Object} The final style object, which will be used in the component
|
|
37
|
+
*/
|
|
38
|
+
const generateStyle = (componentTheme, _props) => {
|
|
39
|
+
return {
|
|
40
|
+
assistiveText: {
|
|
41
|
+
label: 'select__assistiveText',
|
|
42
|
+
display: 'none'
|
|
43
|
+
},
|
|
44
|
+
popoverBorderWidth: componentTheme.popoverBorderWidth
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
var _default = exports.default = generateStyle;
|
package/lib/exports/b.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Select", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _v.Select;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "SelectGroup", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _Group.Group;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "SelectOption", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _Option.Option;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _v = require("../Select/v2");
|
|
25
|
+
var _Group = require("../Select/v2/Group");
|
|
26
|
+
var _Option = require("../Select/v2/Option");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-select",
|
|
3
|
-
"version": "11.7.2-snapshot-
|
|
3
|
+
"version": "11.7.2-snapshot-49",
|
|
4
4
|
"description": "A component for select and autocomplete behavior.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -15,30 +15,30 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.27.6",
|
|
18
|
-
"@instructure/emotion": "11.7.2-snapshot-
|
|
19
|
-
"@instructure/shared-types": "11.7.2-snapshot-
|
|
20
|
-
"@instructure/ui-
|
|
21
|
-
"@instructure/ui-
|
|
22
|
-
"@instructure/ui-
|
|
23
|
-
"@instructure/ui-
|
|
24
|
-
"@instructure/ui-
|
|
25
|
-
"@instructure/ui-
|
|
26
|
-
"@instructure/ui-
|
|
27
|
-
"@instructure/ui-
|
|
28
|
-
"@instructure/ui-view": "11.7.2-snapshot-
|
|
29
|
-
"@instructure/ui-
|
|
30
|
-
"@instructure/uid": "11.7.2-snapshot-
|
|
31
|
-
"@instructure/ui-selectable": "11.7.2-snapshot-
|
|
18
|
+
"@instructure/emotion": "11.7.2-snapshot-49",
|
|
19
|
+
"@instructure/shared-types": "11.7.2-snapshot-49",
|
|
20
|
+
"@instructure/ui-dom-utils": "11.7.2-snapshot-49",
|
|
21
|
+
"@instructure/ui-icons": "11.7.2-snapshot-49",
|
|
22
|
+
"@instructure/ui-form-field": "11.7.2-snapshot-49",
|
|
23
|
+
"@instructure/ui-popover": "11.7.2-snapshot-49",
|
|
24
|
+
"@instructure/ui-position": "11.7.2-snapshot-49",
|
|
25
|
+
"@instructure/ui-react-utils": "11.7.2-snapshot-49",
|
|
26
|
+
"@instructure/ui-options": "11.7.2-snapshot-49",
|
|
27
|
+
"@instructure/ui-utils": "11.7.2-snapshot-49",
|
|
28
|
+
"@instructure/ui-view": "11.7.2-snapshot-49",
|
|
29
|
+
"@instructure/ui-text-input": "11.7.2-snapshot-49",
|
|
30
|
+
"@instructure/uid": "11.7.2-snapshot-49",
|
|
31
|
+
"@instructure/ui-selectable": "11.7.2-snapshot-49"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@testing-library/jest-dom": "^6.6.3",
|
|
35
35
|
"@testing-library/react": "15.0.7",
|
|
36
36
|
"@testing-library/user-event": "^14.6.1",
|
|
37
37
|
"vitest": "^3.2.2",
|
|
38
|
-
"@instructure/ui-babel-preset": "11.7.2-snapshot-
|
|
39
|
-
"@instructure/ui-
|
|
40
|
-
"@instructure/ui-
|
|
41
|
-
"@instructure/ui-themes": "11.7.2-snapshot-
|
|
38
|
+
"@instructure/ui-babel-preset": "11.7.2-snapshot-49",
|
|
39
|
+
"@instructure/ui-scripts": "11.7.2-snapshot-49",
|
|
40
|
+
"@instructure/ui-color-utils": "11.7.2-snapshot-49",
|
|
41
|
+
"@instructure/ui-themes": "11.7.2-snapshot-49"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=18 <=19"
|
|
@@ -68,18 +68,18 @@
|
|
|
68
68
|
"default": "./es/exports/a.js"
|
|
69
69
|
},
|
|
70
70
|
"./v11_7": {
|
|
71
|
-
"src": "./src/exports/
|
|
72
|
-
"types": "./types/exports/
|
|
73
|
-
"import": "./es/exports/
|
|
74
|
-
"require": "./lib/exports/
|
|
75
|
-
"default": "./es/exports/
|
|
71
|
+
"src": "./src/exports/b.ts",
|
|
72
|
+
"types": "./types/exports/b.d.ts",
|
|
73
|
+
"import": "./es/exports/b.js",
|
|
74
|
+
"require": "./lib/exports/b.js",
|
|
75
|
+
"default": "./es/exports/b.js"
|
|
76
76
|
},
|
|
77
77
|
"./latest": {
|
|
78
|
-
"src": "./src/exports/
|
|
79
|
-
"types": "./types/exports/
|
|
80
|
-
"import": "./es/exports/
|
|
81
|
-
"require": "./lib/exports/
|
|
82
|
-
"default": "./es/exports/
|
|
78
|
+
"src": "./src/exports/b.ts",
|
|
79
|
+
"types": "./types/exports/b.d.ts",
|
|
80
|
+
"import": "./es/exports/b.js",
|
|
81
|
+
"require": "./lib/exports/b.js",
|
|
82
|
+
"default": "./es/exports/b.js"
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
@@ -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 { SelectGroupProps } from './props'
|
|
27
|
+
import { allowedProps } from './props'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
---
|
|
31
|
+
parent: Select
|
|
32
|
+
id: Select.Group
|
|
33
|
+
---
|
|
34
|
+
@module Group
|
|
35
|
+
**/
|
|
36
|
+
class Group extends Component<SelectGroupProps> {
|
|
37
|
+
static readonly componentId = 'Select.Group'
|
|
38
|
+
|
|
39
|
+
static allowedProps = allowedProps
|
|
40
|
+
|
|
41
|
+
static defaultProps = {}
|
|
42
|
+
|
|
43
|
+
/* istanbul ignore next */
|
|
44
|
+
render() {
|
|
45
|
+
// this component is only used for prop validation. Select.Group children
|
|
46
|
+
// are parsed in Select and rendered as Options components
|
|
47
|
+
return null
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default Group
|
|
52
|
+
export { Group }
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
|
|
26
|
+
import type { OtherHTMLAttributes, Renderable } from '@instructure/shared-types'
|
|
27
|
+
|
|
28
|
+
type SelectGroupOwnProps = {
|
|
29
|
+
/**
|
|
30
|
+
* The label associated with the group options.
|
|
31
|
+
*/
|
|
32
|
+
renderLabel: Renderable
|
|
33
|
+
/**
|
|
34
|
+
* Children of type `<SimpleSelect.Option />` that will be considered part of the group.
|
|
35
|
+
*/
|
|
36
|
+
children?: React.ReactNode // TODO: ChildrenPropTypes.oneOf([Option])
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type PropKeys = keyof SelectGroupOwnProps
|
|
40
|
+
|
|
41
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
42
|
+
|
|
43
|
+
type SelectGroupProps = SelectGroupOwnProps &
|
|
44
|
+
OtherHTMLAttributes<SelectGroupOwnProps>
|
|
45
|
+
const allowedProps: AllowedPropKeys = ['renderLabel', 'children']
|
|
46
|
+
|
|
47
|
+
export type { SelectGroupProps }
|
|
48
|
+
export { allowedProps }
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { SelectOptionProps } from './props'
|
|
27
|
+
import { allowedProps } from './props'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
---
|
|
31
|
+
parent: Select
|
|
32
|
+
id: Select.Option
|
|
33
|
+
---
|
|
34
|
+
@module Option
|
|
35
|
+
**/
|
|
36
|
+
class Option extends Component<SelectOptionProps> {
|
|
37
|
+
static readonly componentId = 'Select.Option'
|
|
38
|
+
|
|
39
|
+
static allowedProps = allowedProps
|
|
40
|
+
|
|
41
|
+
static defaultProps = {
|
|
42
|
+
isHighlighted: false,
|
|
43
|
+
isSelected: false,
|
|
44
|
+
isDisabled: false
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* istanbul ignore next */
|
|
48
|
+
render() {
|
|
49
|
+
// this component is only used for prop validation. Select.Option children
|
|
50
|
+
// are parsed in Select and rendered as Options.Item components
|
|
51
|
+
return null
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default Option
|
|
56
|
+
export { Option }
|
|
@@ -0,0 +1,82 @@
|
|
|
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, Renderable } from '@instructure/shared-types'
|
|
27
|
+
|
|
28
|
+
type OptionProps = {
|
|
29
|
+
/**
|
|
30
|
+
* The id for the option. **Must be globally unique**, it will be translated
|
|
31
|
+
* to an `id` prop in the DOM.
|
|
32
|
+
*/
|
|
33
|
+
id: string
|
|
34
|
+
/**
|
|
35
|
+
* Whether or not this option is highlighted.
|
|
36
|
+
*/
|
|
37
|
+
isHighlighted?: boolean
|
|
38
|
+
/**
|
|
39
|
+
* Whether or not this option is selected.
|
|
40
|
+
*/
|
|
41
|
+
isSelected?: boolean
|
|
42
|
+
/**
|
|
43
|
+
* Whether or not this option is disabled.
|
|
44
|
+
*/
|
|
45
|
+
isDisabled?: boolean
|
|
46
|
+
/**
|
|
47
|
+
* Content to display as the option label.
|
|
48
|
+
*/
|
|
49
|
+
children?: React.ReactNode
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type RenderSelectOptionLabel = Renderable<OptionProps>
|
|
53
|
+
|
|
54
|
+
type SelectOptionOwnProps = OptionProps & {
|
|
55
|
+
/**
|
|
56
|
+
* Content to display before the option label, such as an icon.
|
|
57
|
+
*/
|
|
58
|
+
renderBeforeLabel?: RenderSelectOptionLabel
|
|
59
|
+
/**
|
|
60
|
+
* Content to display after the option label, such as an icon.
|
|
61
|
+
*/
|
|
62
|
+
renderAfterLabel?: RenderSelectOptionLabel
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type PropKeys = keyof SelectOptionOwnProps
|
|
66
|
+
|
|
67
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
68
|
+
|
|
69
|
+
type SelectOptionProps = SelectOptionOwnProps &
|
|
70
|
+
OtherHTMLAttributes<SelectOptionOwnProps>
|
|
71
|
+
const allowedProps: AllowedPropKeys = [
|
|
72
|
+
'id',
|
|
73
|
+
'isHighlighted',
|
|
74
|
+
'isSelected',
|
|
75
|
+
'isDisabled',
|
|
76
|
+
'renderBeforeLabel',
|
|
77
|
+
'renderAfterLabel',
|
|
78
|
+
'children'
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
export type { SelectOptionProps, RenderSelectOptionLabel }
|
|
82
|
+
export { allowedProps }
|