@instructure/ui-options 11.6.0 → 11.6.1-snapshot-129

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 (149) hide show
  1. package/CHANGELOG.md +36 -294
  2. package/es/Options/{Item → v1/Item}/index.js +1 -1
  3. package/es/Options/{Separator → v1/Separator}/index.js +1 -1
  4. package/es/Options/{index.js → v1/index.js} +2 -2
  5. package/es/Options/v2/Item/index.js +127 -0
  6. package/es/Options/v2/Item/props.js +26 -0
  7. package/es/Options/v2/Item/styles.js +189 -0
  8. package/es/Options/v2/Item/theme.js +72 -0
  9. package/es/Options/v2/Separator/index.js +69 -0
  10. package/es/Options/v2/Separator/props.js +26 -0
  11. package/es/Options/v2/Separator/styles.js +46 -0
  12. package/es/Options/v2/Separator/theme.js +45 -0
  13. package/es/Options/v2/index.js +147 -0
  14. package/es/Options/v2/props.js +26 -0
  15. package/es/Options/v2/styles.js +57 -0
  16. package/es/Options/v2/theme.js +47 -0
  17. package/es/{index.js → exports/a.js} +6 -6
  18. package/es/exports/b.js +29 -0
  19. package/lib/Options/{Item → v1/Item}/index.js +1 -1
  20. package/lib/Options/{Separator → v1/Separator}/index.js +1 -1
  21. package/lib/Options/v1/index.js +153 -0
  22. package/lib/Options/v2/Item/index.js +132 -0
  23. package/lib/Options/v2/Item/props.js +31 -0
  24. package/lib/Options/v2/Item/styles.js +195 -0
  25. package/lib/Options/v2/Item/theme.js +78 -0
  26. package/lib/Options/v2/Separator/index.js +74 -0
  27. package/lib/Options/v2/Separator/props.js +31 -0
  28. package/lib/Options/v2/Separator/styles.js +52 -0
  29. package/lib/Options/v2/Separator/theme.js +51 -0
  30. package/lib/Options/{index.js → v2/index.js} +4 -5
  31. package/lib/Options/v2/props.js +31 -0
  32. package/lib/Options/v2/styles.js +63 -0
  33. package/lib/Options/v2/theme.js +53 -0
  34. package/lib/{index.js → exports/a.js} +7 -7
  35. package/lib/exports/b.js +47 -0
  36. package/package.json +40 -18
  37. package/src/Options/{Item → v1/Item}/index.tsx +1 -1
  38. package/src/Options/{Separator → v1/Separator}/index.tsx +1 -1
  39. package/src/Options/{index.tsx → v1/index.tsx} +2 -2
  40. package/src/Options/v2/Item/index.tsx +180 -0
  41. package/src/Options/v2/Item/props.ts +136 -0
  42. package/src/Options/v2/Item/styles.ts +205 -0
  43. package/src/Options/v2/Item/theme.ts +79 -0
  44. package/src/Options/v2/README.md +409 -0
  45. package/src/Options/v2/Separator/index.tsx +79 -0
  46. package/src/Options/v2/Separator/props.ts +52 -0
  47. package/src/Options/v2/Separator/styles.ts +52 -0
  48. package/src/Options/v2/Separator/theme.ts +48 -0
  49. package/src/Options/v2/index.tsx +188 -0
  50. package/src/Options/v2/props.ts +76 -0
  51. package/src/Options/v2/styles.ts +63 -0
  52. package/src/Options/v2/theme.ts +52 -0
  53. package/src/{index.ts → exports/a.ts} +9 -9
  54. package/src/exports/b.ts +38 -0
  55. package/tsconfig.build.tsbuildinfo +1 -1
  56. package/types/Options/v1/Item/index.d.ts.map +1 -0
  57. package/types/Options/v1/Item/props.d.ts.map +1 -0
  58. package/types/Options/v1/Item/styles.d.ts.map +1 -0
  59. package/types/Options/v1/Item/theme.d.ts.map +1 -0
  60. package/types/Options/v1/Separator/index.d.ts.map +1 -0
  61. package/types/Options/v1/Separator/props.d.ts.map +1 -0
  62. package/types/Options/v1/Separator/styles.d.ts.map +1 -0
  63. package/types/Options/v1/Separator/theme.d.ts.map +1 -0
  64. package/types/Options/v1/index.d.ts.map +1 -0
  65. package/types/Options/v1/props.d.ts.map +1 -0
  66. package/types/Options/v1/styles.d.ts.map +1 -0
  67. package/types/Options/v1/theme.d.ts.map +1 -0
  68. package/types/Options/v2/Item/index.d.ts +31 -0
  69. package/types/Options/v2/Item/index.d.ts.map +1 -0
  70. package/types/Options/v2/Item/props.d.ts +70 -0
  71. package/types/Options/v2/Item/props.d.ts.map +1 -0
  72. package/types/Options/v2/Item/styles.d.ts +15 -0
  73. package/types/Options/v2/Item/styles.d.ts.map +1 -0
  74. package/types/Options/v2/Item/theme.d.ts +11 -0
  75. package/types/Options/v2/Item/theme.d.ts.map +1 -0
  76. package/types/Options/v2/Separator/index.d.ts +22 -0
  77. package/types/Options/v2/Separator/index.d.ts.map +1 -0
  78. package/types/Options/v2/Separator/props.d.ts +17 -0
  79. package/types/Options/v2/Separator/props.d.ts.map +1 -0
  80. package/types/Options/v2/Separator/styles.d.ts +15 -0
  81. package/types/Options/v2/Separator/styles.d.ts.map +1 -0
  82. package/types/Options/v2/Separator/theme.d.ts +11 -0
  83. package/types/Options/v2/Separator/theme.d.ts.map +1 -0
  84. package/types/Options/v2/index.d.ts +43 -0
  85. package/types/Options/v2/index.d.ts.map +1 -0
  86. package/types/Options/v2/props.d.ts +32 -0
  87. package/types/Options/v2/props.d.ts.map +1 -0
  88. package/types/Options/v2/styles.d.ts +15 -0
  89. package/types/Options/v2/styles.d.ts.map +1 -0
  90. package/types/Options/v2/theme.d.ts +11 -0
  91. package/types/Options/v2/theme.d.ts.map +1 -0
  92. package/types/exports/a.d.ts +10 -0
  93. package/types/exports/a.d.ts.map +1 -0
  94. package/types/exports/b.d.ts +10 -0
  95. package/types/exports/b.d.ts.map +1 -0
  96. package/types/Options/Item/index.d.ts.map +0 -1
  97. package/types/Options/Item/props.d.ts.map +0 -1
  98. package/types/Options/Item/styles.d.ts.map +0 -1
  99. package/types/Options/Item/theme.d.ts.map +0 -1
  100. package/types/Options/Separator/index.d.ts.map +0 -1
  101. package/types/Options/Separator/props.d.ts.map +0 -1
  102. package/types/Options/Separator/styles.d.ts.map +0 -1
  103. package/types/Options/Separator/theme.d.ts.map +0 -1
  104. package/types/Options/index.d.ts.map +0 -1
  105. package/types/Options/props.d.ts.map +0 -1
  106. package/types/Options/styles.d.ts.map +0 -1
  107. package/types/Options/theme.d.ts.map +0 -1
  108. package/types/index.d.ts +0 -10
  109. package/types/index.d.ts.map +0 -1
  110. /package/es/Options/{Item → v1/Item}/props.js +0 -0
  111. /package/es/Options/{Item → v1/Item}/styles.js +0 -0
  112. /package/es/Options/{Item → v1/Item}/theme.js +0 -0
  113. /package/es/Options/{Separator → v1/Separator}/props.js +0 -0
  114. /package/es/Options/{Separator → v1/Separator}/styles.js +0 -0
  115. /package/es/Options/{Separator → v1/Separator}/theme.js +0 -0
  116. /package/es/Options/{props.js → v1/props.js} +0 -0
  117. /package/es/Options/{styles.js → v1/styles.js} +0 -0
  118. /package/es/Options/{theme.js → v1/theme.js} +0 -0
  119. /package/lib/Options/{Item → v1/Item}/props.js +0 -0
  120. /package/lib/Options/{Item → v1/Item}/styles.js +0 -0
  121. /package/lib/Options/{Item → v1/Item}/theme.js +0 -0
  122. /package/lib/Options/{Separator → v1/Separator}/props.js +0 -0
  123. /package/lib/Options/{Separator → v1/Separator}/styles.js +0 -0
  124. /package/lib/Options/{Separator → v1/Separator}/theme.js +0 -0
  125. /package/lib/Options/{props.js → v1/props.js} +0 -0
  126. /package/lib/Options/{styles.js → v1/styles.js} +0 -0
  127. /package/lib/Options/{theme.js → v1/theme.js} +0 -0
  128. /package/src/Options/{Item → v1/Item}/props.ts +0 -0
  129. /package/src/Options/{Item → v1/Item}/styles.ts +0 -0
  130. /package/src/Options/{Item → v1/Item}/theme.ts +0 -0
  131. /package/src/Options/{README.md → v1/README.md} +0 -0
  132. /package/src/Options/{Separator → v1/Separator}/props.ts +0 -0
  133. /package/src/Options/{Separator → v1/Separator}/styles.ts +0 -0
  134. /package/src/Options/{Separator → v1/Separator}/theme.ts +0 -0
  135. /package/src/Options/{props.ts → v1/props.ts} +0 -0
  136. /package/src/Options/{styles.ts → v1/styles.ts} +0 -0
  137. /package/src/Options/{theme.ts → v1/theme.ts} +0 -0
  138. /package/types/Options/{Item → v1/Item}/index.d.ts +0 -0
  139. /package/types/Options/{Item → v1/Item}/props.d.ts +0 -0
  140. /package/types/Options/{Item → v1/Item}/styles.d.ts +0 -0
  141. /package/types/Options/{Item → v1/Item}/theme.d.ts +0 -0
  142. /package/types/Options/{Separator → v1/Separator}/index.d.ts +0 -0
  143. /package/types/Options/{Separator → v1/Separator}/props.d.ts +0 -0
  144. /package/types/Options/{Separator → v1/Separator}/styles.d.ts +0 -0
  145. /package/types/Options/{Separator → v1/Separator}/theme.d.ts +0 -0
  146. /package/types/Options/{index.d.ts → v1/index.d.ts} +0 -0
  147. /package/types/Options/{props.d.ts → v1/props.d.ts} +0 -0
  148. /package/types/Options/{styles.d.ts → v1/styles.d.ts} +0 -0
  149. /package/types/Options/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "OptionSeparator", {
18
18
  Object.defineProperty(exports, "Options", {
19
19
  enumerable: true,
20
20
  get: function () {
21
- return _Options.Options;
21
+ return _v.Options;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "optionsItemThemeGenerator", {
@@ -39,9 +39,9 @@ Object.defineProperty(exports, "optionsThemeGenerator", {
39
39
  return _theme.optionsThemeGenerator;
40
40
  }
41
41
  });
42
- var _Options = require("./Options");
43
- var _Item = require("./Options/Item");
44
- var _Separator = require("./Options/Separator");
45
- var _theme = require("./Options/theme");
46
- var _theme2 = require("./Options/Item/theme");
47
- var _theme3 = require("./Options/Separator/theme");
42
+ var _v = require("../Options/v1");
43
+ var _Item = require("../Options/v1/Item");
44
+ var _Separator = require("../Options/v1/Separator");
45
+ var _theme = require("../Options/v1/theme");
46
+ var _theme2 = require("../Options/v1/Item/theme");
47
+ var _theme3 = require("../Options/v1/Separator/theme");
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "OptionItem", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _Item.Item;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "OptionSeparator", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _Separator.Separator;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "Options", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _v.Options;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "optionsItemThemeGenerator", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _theme2.optionsItemThemeGenerator;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "optionsSeparatorThemeGenerator", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _theme3.optionsSeparatorThemeGenerator;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "optionsThemeGenerator", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _theme.optionsThemeGenerator;
40
+ }
41
+ });
42
+ var _v = require("../Options/v2");
43
+ var _Item = require("../Options/v2/Item");
44
+ var _Separator = require("../Options/v2/Separator");
45
+ var _theme = require("../Options/v2/theme");
46
+ var _theme2 = require("../Options/v2/Item/theme");
47
+ var _theme3 = require("../Options/v2/Separator/theme");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-options",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-snapshot-129",
4
4
  "description": "A view-only component for composing interactive lists and menus.",
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/shared-types": "11.6.0",
19
- "@instructure/ui-react-utils": "11.6.0",
20
- "@instructure/emotion": "11.6.0",
21
- "@instructure/ui-icons": "11.6.0",
22
- "@instructure/ui-utils": "11.6.0",
23
- "@instructure/ui-view": "11.6.0"
18
+ "@instructure/shared-types": "11.6.1-snapshot-129",
19
+ "@instructure/ui-icons": "11.6.1-snapshot-129",
20
+ "@instructure/ui-utils": "11.6.1-snapshot-129",
21
+ "@instructure/emotion": "11.6.1-snapshot-129",
22
+ "@instructure/ui-react-utils": "11.6.1-snapshot-129",
23
+ "@instructure/ui-view": "11.6.1-snapshot-129"
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-axe-check": "11.6.0",
31
- "@instructure/ui-babel-preset": "11.6.0",
32
- "@instructure/ui-color-utils": "11.6.0",
33
- "@instructure/ui-themes": "11.6.0"
30
+ "@instructure/ui-axe-check": "11.6.1-snapshot-129",
31
+ "@instructure/ui-color-utils": "11.6.1-snapshot-129",
32
+ "@instructure/ui-themes": "11.6.1-snapshot-129",
33
+ "@instructure/ui-babel-preset": "11.6.1-snapshot-129"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": ">=18 <=19"
@@ -40,17 +40,39 @@
40
40
  },
41
41
  "sideEffects": false,
42
42
  "exports": {
43
- ".": {
44
- "types": "./types/index.d.ts",
45
- "import": "./es/index.js",
46
- "require": "./lib/index.js",
47
- "default": "./es/index.js"
48
- },
49
43
  "./lib/*": "./lib/*",
50
44
  "./es/*": "./es/*",
51
45
  "./types/*": "./types/*",
52
46
  "./package.json": "./package.json",
53
- "./src/*": "./src/*"
47
+ "./src/*": "./src/*",
48
+ ".": {
49
+ "src": "./src/exports/a.ts",
50
+ "types": "./types/exports/a.d.ts",
51
+ "import": "./es/exports/a.js",
52
+ "require": "./lib/exports/a.js",
53
+ "default": "./es/exports/a.js"
54
+ },
55
+ "./v11_6": {
56
+ "src": "./src/exports/a.ts",
57
+ "types": "./types/exports/a.d.ts",
58
+ "import": "./es/exports/a.js",
59
+ "require": "./lib/exports/a.js",
60
+ "default": "./es/exports/a.js"
61
+ },
62
+ "./v11_7": {
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
+ },
69
+ "./latest": {
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
+ }
54
76
  },
55
77
  "scripts": {
56
78
  "lint": "ui-scripts lint",
@@ -31,7 +31,7 @@ import {
31
31
  withDeterministicId
32
32
  } from '@instructure/ui-react-utils'
33
33
 
34
- import { withStyle } from '@instructure/emotion'
34
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
35
35
 
36
36
  import generateStyles from './styles'
37
37
  import generateComponentTheme from './theme'
@@ -26,7 +26,7 @@ import { Component } from 'react'
26
26
 
27
27
  import { getElementType, omitProps } from '@instructure/ui-react-utils'
28
28
 
29
- import { withStyle } from '@instructure/emotion'
29
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
30
30
 
31
31
  import generateStyles from './styles'
32
32
  import generateComponentTheme from './theme'
@@ -32,9 +32,9 @@ import {
32
32
  withDeterministicId
33
33
  } from '@instructure/ui-react-utils'
34
34
 
35
- import { View } from '@instructure/ui-view'
35
+ import { View } from '@instructure/ui-view/v11_6'
36
36
 
37
- import { withStyle } from '@instructure/emotion'
37
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
38
38
 
39
39
  import generateStyles from './styles'
40
40
  import generateComponentTheme from './theme'
@@ -0,0 +1,180 @@
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 {
28
+ omitProps,
29
+ getElementType,
30
+ callRenderProp,
31
+ withDeterministicId
32
+ } from '@instructure/ui-react-utils'
33
+
34
+ import { withStyle } from '@instructure/emotion'
35
+
36
+ import generateStyles from './styles'
37
+ import type { OptionsItemProps, OptionsItemStyle } from './props'
38
+ import { allowedProps } from './props'
39
+
40
+ /**
41
+ ---
42
+ parent: Options
43
+ id: Options.Item
44
+ ---
45
+ **/
46
+ @withDeterministicId()
47
+ @withStyle(generateStyles)
48
+ class Item extends Component<OptionsItemProps> {
49
+ static readonly componentId = 'Options.Item'
50
+
51
+ static allowedProps = allowedProps
52
+
53
+ static defaultProps = {
54
+ as: 'span',
55
+ variant: 'default',
56
+ role: 'listitem',
57
+ voiceoverRoleBugWorkaround: false,
58
+ beforeLabelContentVAlign: 'center',
59
+ afterLabelContentVAlign: 'center',
60
+ isSelected: false
61
+ } as const
62
+
63
+ ref: Element | null = null
64
+
65
+ private readonly _descriptionId: string
66
+
67
+ constructor(props: OptionsItemProps) {
68
+ super(props)
69
+
70
+ this._descriptionId = props.deterministicId!('OptionsItem-description')
71
+ }
72
+
73
+ componentDidMount() {
74
+ this.props.makeStyles?.()
75
+ }
76
+
77
+ componentDidUpdate() {
78
+ this.props.makeStyles?.()
79
+ }
80
+
81
+ renderContent(
82
+ renderLabel:
83
+ | OptionsItemProps['renderBeforeLabel']
84
+ | OptionsItemProps['renderAfterLabel'],
85
+ contentVariant:
86
+ | OptionsItemStyle['contentBefore']
87
+ | OptionsItemStyle['contentAfter']
88
+ ) {
89
+ const { styles, variant, as, role, children } = this.props
90
+
91
+ return (
92
+ <span
93
+ css={[styles?.content, contentVariant]}
94
+ role="presentation"
95
+ aria-hidden="true"
96
+ >
97
+ {callRenderProp(renderLabel, {
98
+ variant,
99
+ as,
100
+ role,
101
+ children
102
+ })}
103
+ </span>
104
+ )
105
+ }
106
+
107
+ render() {
108
+ const {
109
+ as,
110
+ href,
111
+ role,
112
+ styles,
113
+ description,
114
+ descriptionRole,
115
+ renderBeforeLabel,
116
+ renderAfterLabel,
117
+ elementRef,
118
+ children,
119
+ voiceoverRoleBugWorkaround
120
+ } = this.props
121
+
122
+ const ElementType = getElementType(Item, this.props, () => as!)
123
+
124
+ const InnerElementType = href ? 'a' : 'span'
125
+
126
+ const passthroughProps = omitProps(this.props, Item.allowedProps)
127
+
128
+ const childrenContent = callRenderProp(children)
129
+ const descriptionContent = callRenderProp(description)
130
+ const ariaDescribedBy =
131
+ this.props['aria-describedby'] ||
132
+ (descriptionContent ? this._descriptionId : undefined)
133
+
134
+ return (
135
+ <ElementType
136
+ role={voiceoverRoleBugWorkaround ? role : 'none'}
137
+ data-cid="Options.Item"
138
+ css={styles?.item}
139
+ ref={(element: Element | null) => {
140
+ this.ref = element
141
+
142
+ if (typeof elementRef === 'function') {
143
+ elementRef(element)
144
+ }
145
+ }}
146
+ aria-describedby={
147
+ voiceoverRoleBugWorkaround ? ariaDescribedBy : undefined
148
+ }
149
+ >
150
+ <InnerElementType
151
+ {...passthroughProps}
152
+ css={styles?.container}
153
+ role={href || voiceoverRoleBugWorkaround ? undefined : role}
154
+ href={href}
155
+ aria-describedby={
156
+ voiceoverRoleBugWorkaround ? undefined : ariaDescribedBy
157
+ }
158
+ >
159
+ {childrenContent}
160
+ {descriptionContent && (
161
+ <span
162
+ css={styles?.description}
163
+ role={descriptionRole}
164
+ id={this._descriptionId}
165
+ >
166
+ {descriptionContent}
167
+ </span>
168
+ )}
169
+ </InnerElementType>
170
+ {renderBeforeLabel &&
171
+ this.renderContent(renderBeforeLabel, styles?.contentBefore)}
172
+ {renderAfterLabel &&
173
+ this.renderContent(renderAfterLabel, styles?.contentAfter)}
174
+ </ElementType>
175
+ )
176
+ }
177
+ }
178
+
179
+ export default Item
180
+ export { Item }
@@ -0,0 +1,136 @@
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 type {
26
+ AsElementType,
27
+ OptionsItemTheme,
28
+ OtherHTMLAttributes,
29
+ Renderable
30
+ } from '@instructure/shared-types'
31
+ import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
32
+ import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
33
+
34
+ type OptionsItemRenderProps = {
35
+ children?: Renderable
36
+ /**
37
+ * Element type to render as. Will be set to `<a>` if href is provided.
38
+ */
39
+ as?: AsElementType
40
+ /**
41
+ * The style variant of the item
42
+ */
43
+ variant?:
44
+ | 'default'
45
+ | 'highlighted'
46
+ | 'selected'
47
+ | 'disabled'
48
+ | 'highlighted-disabled'
49
+ | 'selected-highlighted'
50
+ /**
51
+ * The ARIA role of the element
52
+ */
53
+ role?: string
54
+ }
55
+
56
+ type OptionsItemOwnProps = OptionsItemRenderProps & {
57
+ /**
58
+ * Content to render before the label
59
+ * (if you pass a function, it has the `props` as its parameter)
60
+ */
61
+ renderBeforeLabel?: Renderable<OptionsItemRenderProps>
62
+ /**
63
+ * Content to render after the label
64
+ * (if you pass a function, it has the `props` as its parameter)
65
+ */
66
+ renderAfterLabel?: Renderable<OptionsItemRenderProps>
67
+ /**
68
+ * Sets the vAlign of renderBeforeLabel content
69
+ */
70
+ beforeLabelContentVAlign?: 'start' | 'center' | 'end'
71
+ /**
72
+ * Sets the vAlign of renderAfterLabel content
73
+ */
74
+ afterLabelContentVAlign?: 'start' | 'center' | 'end'
75
+ /**
76
+ * Additional "secondary" description text
77
+ */
78
+ description?: Renderable
79
+ /**
80
+ * The ARIA role of the description element
81
+ */
82
+ descriptionRole?: string
83
+ /**
84
+ * Providing href will render the option as `<a>`.
85
+ */
86
+ href?: string
87
+ /**
88
+ * Sometimes VoiceOver doesn't announce the role of the highlighted item. This prop forces the role to be on the outer element and should only be used when such an issue arises.
89
+ */
90
+ voiceoverRoleBugWorkaround?: boolean
91
+ /**
92
+ * provides a reference to the underlying html root element
93
+ */
94
+ elementRef?: (element: Element | null) => void
95
+ /**
96
+ * Whether or not this option is selected
97
+ */
98
+ isSelected?: boolean
99
+ }
100
+
101
+ type PropKeys = keyof OptionsItemOwnProps
102
+
103
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
104
+
105
+ type OptionsItemProps = OptionsItemOwnProps &
106
+ WithStyleProps<OptionsItemTheme, OptionsItemStyle> &
107
+ WithDeterministicIdProps &
108
+ OtherHTMLAttributes<OptionsItemOwnProps>
109
+
110
+ type OptionsItemStyle = ComponentStyle<
111
+ | 'item'
112
+ | 'container'
113
+ | 'content'
114
+ | 'contentBefore'
115
+ | 'contentAfter'
116
+ | 'description'
117
+ >
118
+ const allowedProps: AllowedPropKeys = [
119
+ 'as',
120
+ 'variant',
121
+ 'role',
122
+ 'renderBeforeLabel',
123
+ 'renderAfterLabel',
124
+ 'beforeLabelContentVAlign',
125
+ 'afterLabelContentVAlign',
126
+ 'description',
127
+ 'descriptionRole',
128
+ 'voiceoverRoleBugWorkaround',
129
+ 'href',
130
+ 'elementRef',
131
+ 'children',
132
+ 'isSelected'
133
+ ]
134
+
135
+ export type { OptionsItemProps, OptionsItemStyle, OptionsItemRenderProps }
136
+ export { allowedProps }