@instructure/ui-options 8.19.1-snapshot.8 → 8.20.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.
- package/CHANGELOG.md +7 -0
- package/es/Options/Item/__examples__/Item.examples.js +5 -0
- package/es/Options/Item/index.js +16 -9
- package/es/Options/Item/props.js +3 -2
- package/es/Options/Item/styles.js +18 -1
- package/es/Options/Item/theme.js +1 -1
- package/es/Options/index.js +2 -2
- package/lib/Options/Item/__examples__/Item.examples.js +5 -0
- package/lib/Options/Item/index.js +15 -8
- package/lib/Options/Item/props.js +3 -2
- package/lib/Options/Item/styles.js +18 -1
- package/lib/Options/Item/theme.js +1 -1
- package/lib/Options/index.js +2 -2
- package/package.json +14 -15
- package/src/Options/Item/__examples__/Item.examples.ts +10 -0
- package/src/Options/Item/index.tsx +31 -4
- package/src/Options/Item/props.ts +22 -3
- package/src/Options/Item/styles.ts +17 -1
- package/src/Options/Item/theme.ts +1 -1
- package/src/Options/README.md +61 -0
- package/src/Options/index.tsx +8 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Options/Item/__examples__/Item.examples.d.ts.map +1 -1
- package/types/Options/Item/index.d.ts +6 -4
- package/types/Options/Item/index.d.ts.map +1 -1
- package/types/Options/Item/props.d.ts +8 -3
- package/types/Options/Item/props.d.ts.map +1 -1
- package/types/Options/Item/styles.d.ts.map +1 -1
- package/types/Options/index.d.ts.map +1 -1
- package/LICENSE.md +0 -27
package/src/Options/README.md
CHANGED
|
@@ -24,6 +24,9 @@ example: true
|
|
|
24
24
|
<Options.Item variant="disabled">
|
|
25
25
|
Disabled option
|
|
26
26
|
</Options.Item>
|
|
27
|
+
<Options.Item variant="highlighted-disabled">
|
|
28
|
+
Highlighted disabled option
|
|
29
|
+
</Options.Item>
|
|
27
30
|
</Options>
|
|
28
31
|
</View>
|
|
29
32
|
```
|
|
@@ -372,3 +375,61 @@ class Example extends React.Component {
|
|
|
372
375
|
|
|
373
376
|
render(<Example />)
|
|
374
377
|
```
|
|
378
|
+
|
|
379
|
+
Providing a `href` prop will render the option as `<a>` link element.
|
|
380
|
+
|
|
381
|
+
**WARNING!** Since `Options` is a view-only component, you have to make sure it is accessible, and if set the variant to disabled, disable the links as well!
|
|
382
|
+
|
|
383
|
+
```js
|
|
384
|
+
---
|
|
385
|
+
render: false
|
|
386
|
+
example: true
|
|
387
|
+
---
|
|
388
|
+
class Example extends React.Component {
|
|
389
|
+
constructor(props) {
|
|
390
|
+
super(props)
|
|
391
|
+
|
|
392
|
+
this.state = {
|
|
393
|
+
highlighted: -1
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
handleMouseOver = (index) => {
|
|
398
|
+
this.setState({ highlighted: index })
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
render() {
|
|
402
|
+
return (
|
|
403
|
+
<View display="block" width="300px">
|
|
404
|
+
<Options onMouseOut={(e) => this.setState({ highlighted: -1 })}>
|
|
405
|
+
<Options.Item
|
|
406
|
+
onMouseOver={(e) => this.handleMouseOver(1)}
|
|
407
|
+
variant={this.state.highlighted === 1 ? 'highlighted' : 'default'}
|
|
408
|
+
href="/"
|
|
409
|
+
>
|
|
410
|
+
Link one
|
|
411
|
+
</Options.Item>
|
|
412
|
+
<Options.Item
|
|
413
|
+
onMouseOver={(e) => this.handleMouseOver(2)}
|
|
414
|
+
variant={this.state.highlighted === 2 ? 'highlighted' : 'default'}
|
|
415
|
+
href="/"
|
|
416
|
+
>
|
|
417
|
+
Link two
|
|
418
|
+
</Options.Item>
|
|
419
|
+
<Options.Item
|
|
420
|
+
onMouseOver={(e) => this.handleMouseOver(3)}
|
|
421
|
+
variant={this.state.highlighted === 3 ? 'highlighted' : 'default'}
|
|
422
|
+
variant="disabled"
|
|
423
|
+
onClick={(e) => { e.preventDefault() }}
|
|
424
|
+
href="/"
|
|
425
|
+
>
|
|
426
|
+
Link three
|
|
427
|
+
</Options.Item>
|
|
428
|
+
</Options>
|
|
429
|
+
</View>
|
|
430
|
+
)
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
render(<Example />)
|
|
435
|
+
```
|
package/src/Options/index.tsx
CHANGED
|
@@ -134,7 +134,7 @@ class Options extends Component<OptionsProps> {
|
|
|
134
134
|
return this.renderSubList(child)
|
|
135
135
|
}
|
|
136
136
|
if (matchComponentTypes(child, ['Item', 'Separator'])) {
|
|
137
|
-
return safeCloneElement(child, { as: this.childAs })
|
|
137
|
+
return safeCloneElement(child, { as: this.childAs || child.props.as })
|
|
138
138
|
}
|
|
139
139
|
return undefined
|
|
140
140
|
})
|
|
@@ -161,7 +161,13 @@ class Options extends Component<OptionsProps> {
|
|
|
161
161
|
margin="none"
|
|
162
162
|
padding="none"
|
|
163
163
|
background="primary"
|
|
164
|
-
aria-labelledby={
|
|
164
|
+
aria-labelledby={
|
|
165
|
+
renderLabel
|
|
166
|
+
? this._labelId
|
|
167
|
+
: this.props['aria-labelledby']
|
|
168
|
+
? this.props['aria-labelledby']
|
|
169
|
+
: undefined
|
|
170
|
+
}
|
|
165
171
|
>
|
|
166
172
|
{this.renderChildren()}
|
|
167
173
|
</View>
|