Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit ecd337c

Browse files
committed
fix(mixed): add accessibility prop to all components
1 parent 0c316b1 commit ecd337c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+252
-46
lines changed

packages/react/src/components/Accordion/Accordion.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class Accordion extends AutoControlledComponent<ReactProps<AccordionProps>, any>
104104
}),
105105
),
106106
]),
107-
accessibility: PropTypes.func,
107+
accessibility: customPropTypes.accessibility,
108108

109109
renderPanelTitle: PropTypes.func,
110110
renderPanelContent: PropTypes.func,

packages/react/src/components/Attachment/Attachment.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Attachment extends UIComponent<ReactProps<AttachmentProps>, AttachmentStat
7575
...commonPropTypes.createCommon({
7676
content: false,
7777
}),
78-
accessibility: PropTypes.func,
78+
accessibility: customPropTypes.accessibility,
7979
action: customPropTypes.itemShorthand,
8080
actionable: PropTypes.bool,
8181
description: customPropTypes.itemShorthand,

packages/react/src/components/Avatar/Avatar.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import * as React from 'react'
33
import Image from '../Image/Image'
44
import Label from '../Label/Label'
55
import Status, { StatusProps } from '../Status/Status'
6+
import { Accessibility } from '../../lib/accessibility/types'
7+
import { defaultBehavior } from '../../lib/accessibility'
68
import { ReactProps, ShorthandValue } from '../../types'
79
import {
810
createShorthandFactory,
@@ -14,6 +16,12 @@ import {
1416
} from '../../lib'
1517

1618
export interface AvatarProps extends UIComponentProps {
19+
/**
20+
* Accessibility behavior if overridden by the user.
21+
* @default defaultBehavior
22+
*/
23+
accessibility?: Accessibility
24+
1725
/** Shorthand for the image. */
1826
image?: ShorthandValue
1927

@@ -48,6 +56,7 @@ class Avatar extends UIComponent<ReactProps<AvatarProps>, any> {
4856
children: false,
4957
content: false,
5058
}),
59+
accessibility: customPropTypes.accessibility,
5160
name: PropTypes.string,
5261
image: customPropTypes.itemShorthand,
5362
label: customPropTypes.itemShorthand,
@@ -57,6 +66,7 @@ class Avatar extends UIComponent<ReactProps<AvatarProps>, any> {
5766
}
5867

5968
static defaultProps = {
69+
accessibility: defaultBehavior,
6070
size: 'medium',
6171
getInitials(name: string) {
6272
if (!name) {
@@ -81,11 +91,11 @@ class Avatar extends UIComponent<ReactProps<AvatarProps>, any> {
8191
},
8292
} as AvatarProps
8393

84-
renderComponent({ ElementType, classes, unhandledProps, styles, variables }) {
94+
renderComponent({ accessibility, ElementType, classes, unhandledProps, styles, variables }) {
8595
const { name, status, image, label, getInitials, size } = this.props as AvatarProps
8696

8797
return (
88-
<ElementType {...unhandledProps} className={classes.root}>
98+
<ElementType {...accessibility.attributes.root} {...unhandledProps} className={classes.root}>
8999
{Image.create(image, {
90100
defaultProps: {
91101
fluid: true,

packages/react/src/components/Button/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Button extends UIComponent<ReactProps<ButtonProps>, ButtonState> {
106106
primary: customPropTypes.every([customPropTypes.disallow(['secondary']), PropTypes.bool]),
107107
text: PropTypes.bool,
108108
secondary: customPropTypes.every([customPropTypes.disallow(['primary']), PropTypes.bool]),
109-
accessibility: PropTypes.func,
109+
accessibility: customPropTypes.accessibility,
110110
}
111111

112112
public static defaultProps = {

packages/react/src/components/Button/ButtonGroup.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,20 @@ import {
1313
commonPropTypes,
1414
rtlTextContainer,
1515
} from '../../lib'
16+
import { Accessibility } from '../../lib/accessibility/types'
17+
import { defaultBehavior } from '../../lib/accessibility'
1618
import Button from './Button'
1719

1820
export interface ButtonGroupProps
1921
extends UIComponentProps,
2022
ChildrenComponentProps,
2123
ContentComponentProps {
24+
/**
25+
* Accessibility behavior if overridden by the user.
26+
* @default defaultBehavior
27+
*/
28+
accessibility?: Accessibility
29+
2230
/** The buttons contained inside the ButtonGroup. */
2331
buttons?: ShorthandValue[]
2432

@@ -36,12 +44,13 @@ class ButtonGroup extends UIComponent<ReactProps<ButtonGroupProps>, any> {
3644

3745
public static propTypes = {
3846
...commonPropTypes.createCommon(),
39-
accessibility: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
47+
accessibility: customPropTypes.accessibility,
4048
buttons: customPropTypes.collectionShorthand,
4149
circular: PropTypes.bool,
4250
}
4351

4452
public static defaultProps = {
53+
accessibility: defaultBehavior,
4554
as: 'div',
4655
}
4756

packages/react/src/components/Chat/Chat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Chat extends UIComponent<ReactProps<ChatProps>, any> {
3939
...commonPropTypes.createCommon({
4040
content: false,
4141
}),
42-
accessibility: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
42+
accessibility: customPropTypes.accessibility,
4343
items: PropTypes.arrayOf(customPropTypes.itemShorthand),
4444
}
4545

packages/react/src/components/Chat/ChatItem.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
rtlTextContainer,
1515
} from '../../lib'
1616
import Box from '../Box/Box'
17+
import { Accessibility } from '../../lib/accessibility/types'
18+
import { defaultBehavior } from '../../lib/accessibility'
1719
import { ComponentSlotStylesPrepared } from '../../themes/types'
1820

1921
export interface ChatItemSlotClassNames {
@@ -22,6 +24,12 @@ export interface ChatItemSlotClassNames {
2224
}
2325

2426
export interface ChatItemProps extends UIComponentProps, ChildrenComponentProps {
27+
/**
28+
* Accessibility behavior if overridden by the user.
29+
* @default defaultBehavior
30+
*/
31+
accessibility?: Accessibility
32+
2533
/** Controls item's relation to other chat items. */
2634
attached?: boolean | 'top' | 'bottom'
2735

@@ -46,19 +54,22 @@ class ChatItem extends UIComponent<ReactProps<ChatItemProps>, any> {
4654

4755
static propTypes = {
4856
...commonPropTypes.createCommon({ content: false }),
57+
accessibility: customPropTypes.accessibility,
4958
attached: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['top', 'bottom'])]),
5059
gutter: customPropTypes.itemShorthand,
5160
contentPosition: PropTypes.oneOf(['start', 'end']),
5261
message: customPropTypes.itemShorthand,
5362
}
5463

5564
static defaultProps = {
65+
accessibility: defaultBehavior,
5666
as: 'li',
5767
contentPosition: 'start',
5868
attached: false,
5969
}
6070

6171
renderComponent({
72+
accessibility,
6273
ElementType,
6374
classes,
6475
unhandledProps,
@@ -69,6 +80,7 @@ class ChatItem extends UIComponent<ReactProps<ChatItemProps>, any> {
6980
return (
7081
<ElementType
7182
{...rtlTextContainer.getAttributes({ forElements: [children] })}
83+
{...accessibility.attributes.root}
7284
{...unhandledProps}
7385
className={classes.root}
7486
>

packages/react/src/components/Chat/ChatMessage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class ChatMessage extends UIComponent<ReactProps<ChatMessageProps>, ChatMessageS
9696

9797
static propTypes = {
9898
...commonPropTypes.createCommon({ content: 'shorthand' }),
99-
accessibility: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
99+
accessibility: customPropTypes.accessibility,
100100
actionMenu: customPropTypes.itemShorthand,
101101
author: customPropTypes.itemShorthand,
102102
badge: customPropTypes.itemShorthand,

packages/react/src/components/Dialog/Dialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Ref from '../Ref/Ref'
2424
export interface DialogProps extends UIComponentProps, ContentComponentProps, ColorComponentProps {
2525
/**
2626
* Accessibility behavior if overridden by the user.
27-
* @default defaultBehavior
27+
* @default dialogBehavior
2828
*/
2929
accessibility?: Accessibility
3030

@@ -94,7 +94,7 @@ class Dialog extends AutoControlledComponent<ReactProps<DialogProps>, DialogStat
9494
content: true,
9595
}),
9696
actions: customPropTypes.itemShorthand,
97-
accessibility: PropTypes.func,
97+
accessibility: customPropTypes.accessibility,
9898
cancelButton: customPropTypes.itemShorthand,
9999
confirmButton: customPropTypes.itemShorthand,
100100
defaultOpen: PropTypes.bool,

packages/react/src/components/Divider/Divider.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,23 @@ import {
1111
ContentComponentProps,
1212
commonPropTypes,
1313
rtlTextContainer,
14+
customPropTypes,
1415
} from '../../lib'
16+
import { Accessibility } from '../../lib/accessibility/types'
17+
import { defaultBehavior } from '../../lib/accessibility'
1518
import { ReactProps } from '../../types'
1619

1720
export interface DividerProps
1821
extends UIComponentProps,
1922
ChildrenComponentProps,
2023
ColorComponentProps,
2124
ContentComponentProps {
25+
/**
26+
* Accessibility behavior if overridden by the user.
27+
* @default defaultBehavior
28+
*/
29+
accessibility?: Accessibility
30+
2231
/** A divider can be fitted, without any space above or below it. */
2332
fitted?: boolean
2433

@@ -41,21 +50,24 @@ class Divider extends UIComponent<ReactProps<DividerProps>, any> {
4150

4251
static propTypes = {
4352
...commonPropTypes.createCommon({ color: true }),
53+
accessibility: customPropTypes.accessibility,
4454
fitted: PropTypes.bool,
4555
size: PropTypes.number,
4656
important: PropTypes.bool,
4757
}
4858

4959
static defaultProps = {
60+
accessibility: defaultBehavior,
5061
size: 0,
5162
}
5263

53-
renderComponent({ ElementType, classes, unhandledProps }) {
64+
renderComponent({ accessibility, ElementType, classes, unhandledProps }) {
5465
const { children, content } = this.props
5566

5667
return (
5768
<ElementType
5869
{...rtlTextContainer.getAttributes({ forElements: [children, content] })}
70+
{...accessibility.attributes.root}
5971
{...unhandledProps}
6072
className={classes.root}
6173
>

packages/react/src/components/Form/Form.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ import {
1111
commonPropTypes,
1212
rtlTextContainer,
1313
} from '../../lib'
14+
import { Accessibility } from '../../lib/accessibility/types'
15+
import { defaultBehavior } from '../../lib/accessibility'
1416
import { ComponentEventHandler, ReactProps, ShorthandValue } from '../../types'
1517
import FormField from './FormField'
1618

1719
export interface FormProps extends UIComponentProps, ChildrenComponentProps {
20+
/**
21+
* Accessibility behavior if overridden by the user.
22+
* @default defaultBehavior
23+
*/
24+
accessibility?: Accessibility
25+
1826
/** The HTML form action. */
1927
action?: string
2028

@@ -45,25 +53,28 @@ class Form extends UIComponent<ReactProps<FormProps>, any> {
4553
...commonPropTypes.createCommon({
4654
content: false,
4755
}),
56+
accessibility: customPropTypes.accessibility,
4857
action: PropTypes.string,
4958
fields: customPropTypes.collectionShorthand,
5059
onSubmit: PropTypes.func,
5160
}
5261

5362
public static defaultProps = {
63+
accessibility: defaultBehavior,
5464
as: 'form',
5565
}
5666

5767
public static Field = FormField
5868

59-
public renderComponent({ ElementType, classes, unhandledProps }): React.ReactNode {
69+
public renderComponent({ accessibility, ElementType, classes, unhandledProps }): React.ReactNode {
6070
const { action, children } = this.props
6171
return (
6272
<ElementType
6373
className={classes.root}
6474
action={action}
6575
onSubmit={this.handleSubmit}
6676
{...rtlTextContainer.getAttributes({ forElements: [children] })}
77+
{...accessibility.attributes.root}
6778
{...unhandledProps}
6879
>
6980
{childrenExist(children) ? children : this.renderFields()}

packages/react/src/components/Form/FormField.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@ import {
1010
ChildrenComponentProps,
1111
commonPropTypes,
1212
} from '../../lib'
13+
import { Accessibility } from '../../lib/accessibility/types'
14+
import { defaultBehavior } from '../../lib/accessibility'
1315
import { ReactProps, ShorthandValue } from '../../types'
1416
import Text from '../Text/Text'
1517
import Input from '../Input/Input'
1618
import Box from '../Box/Box'
1719

1820
export interface FormFieldProps extends UIComponentProps, ChildrenComponentProps {
21+
/**
22+
* Accessibility behavior if overridden by the user.
23+
* @default defaultBehavior
24+
*/
25+
accessibility?: Accessibility
26+
1927
/** A control for the form field. */
2028
control?: ShorthandValue
2129

@@ -55,6 +63,7 @@ class FormField extends UIComponent<ReactProps<FormFieldProps>, any> {
5563
...commonPropTypes.createCommon({
5664
content: false,
5765
}),
66+
accessibility: customPropTypes.accessibility,
5867
control: customPropTypes.itemShorthand,
5968
id: PropTypes.string,
6069
inline: PropTypes.bool,
@@ -66,6 +75,7 @@ class FormField extends UIComponent<ReactProps<FormFieldProps>, any> {
6675
}
6776

6877
public static defaultProps = {
78+
accessibility: defaultBehavior,
6979
as: 'div',
7080
control: { as: Input },
7181
}
@@ -108,7 +118,7 @@ class FormField extends UIComponent<ReactProps<FormFieldProps>, any> {
108118
)
109119

110120
return (
111-
<ElementType className={classes.root} {...unhandledProps}>
121+
<ElementType className={classes.root} {...accessibility.attributes.root} {...unhandledProps}>
112122
{childrenExist(children) ? children : content}
113123
</ElementType>
114124
)

packages/react/src/components/Grid/Grid.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Grid extends UIComponent<ReactProps<GridProps>, any> {
4848
...commonPropTypes.createCommon({
4949
content: false,
5050
}),
51-
accessibility: PropTypes.func,
51+
accessibility: customPropTypes.accessibility,
5252
columns: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
5353
content: customPropTypes.every([
5454
customPropTypes.disallow(['children']),
@@ -66,6 +66,7 @@ class Grid extends UIComponent<ReactProps<GridProps>, any> {
6666
}
6767

6868
public renderComponent({
69+
accessibility,
6970
ElementType,
7071
classes,
7172
unhandledProps,
@@ -76,6 +77,7 @@ class Grid extends UIComponent<ReactProps<GridProps>, any> {
7677
<ElementType
7778
className={classes.root}
7879
{...rtlTextContainer.getAttributes({ forElements: [children, content] })}
80+
{...accessibility.attributes.root}
7981
{...unhandledProps}
8082
>
8183
{childrenExist(children) ? children : content}

0 commit comments

Comments
 (0)