@instructure/ui-buttons 10.26.1 → 11.0.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 +24 -1
- package/es/BaseButton/index.js +9 -6
- package/es/BaseButton/props.js +1 -26
- package/es/Button/index.js +6 -6
- package/es/Button/props.js +1 -20
- package/es/CloseButton/index.js +12 -8
- package/es/CloseButton/props.js +1 -18
- package/es/CondensedButton/index.js +6 -6
- package/es/CondensedButton/props.js +1 -17
- package/es/IconButton/index.js +7 -6
- package/es/IconButton/props.js +1 -21
- package/es/ToggleButton/index.js +10 -6
- package/es/ToggleButton/props.js +1 -19
- package/lib/BaseButton/index.js +8 -5
- package/lib/BaseButton/props.js +1 -27
- package/lib/Button/index.js +5 -5
- package/lib/Button/props.js +1 -21
- package/lib/CloseButton/index.js +11 -7
- package/lib/CloseButton/props.js +1 -19
- package/lib/CondensedButton/index.js +5 -5
- package/lib/CondensedButton/props.js +1 -18
- package/lib/IconButton/index.js +6 -5
- package/lib/IconButton/props.js +1 -22
- package/lib/ToggleButton/index.js +10 -5
- package/lib/ToggleButton/props.js +1 -20
- package/package.json +20 -23
- package/src/BaseButton/index.tsx +7 -4
- package/src/BaseButton/props.ts +3 -40
- package/src/Button/index.tsx +6 -5
- package/src/Button/props.ts +2 -33
- package/src/CloseButton/index.tsx +6 -6
- package/src/CloseButton/props.ts +3 -25
- package/src/CondensedButton/index.tsx +2 -4
- package/src/CondensedButton/props.ts +3 -22
- package/src/IconButton/index.tsx +3 -4
- package/src/IconButton/props.ts +2 -33
- package/src/ToggleButton/index.tsx +2 -5
- package/src/ToggleButton/props.ts +2 -31
- package/tsconfig.build.json +0 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/BaseButton/index.d.ts +1 -2
- package/types/BaseButton/index.d.ts.map +1 -1
- package/types/BaseButton/props.d.ts +3 -4
- package/types/BaseButton/props.d.ts.map +1 -1
- package/types/Button/index.d.ts +1 -19
- package/types/Button/index.d.ts.map +1 -1
- package/types/Button/props.d.ts +3 -4
- package/types/Button/props.d.ts.map +1 -1
- package/types/CloseButton/index.d.ts +1 -17
- package/types/CloseButton/index.d.ts.map +1 -1
- package/types/CloseButton/props.d.ts +3 -4
- package/types/CloseButton/props.d.ts.map +1 -1
- package/types/CondensedButton/index.d.ts +1 -16
- package/types/CondensedButton/index.d.ts.map +1 -1
- package/types/CondensedButton/props.d.ts +3 -4
- package/types/CondensedButton/props.d.ts.map +1 -1
- package/types/IconButton/index.d.ts +1 -20
- package/types/IconButton/index.d.ts.map +1 -1
- package/types/IconButton/props.d.ts +3 -4
- package/types/IconButton/props.d.ts.map +1 -1
- package/types/ToggleButton/index.d.ts +0 -16
- package/types/ToggleButton/index.d.ts.map +1 -1
- package/types/ToggleButton/props.d.ts +2 -3
- package/types/ToggleButton/props.d.ts.map +1 -1
package/src/Button/index.tsx
CHANGED
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
|
|
25
25
|
import { Component } from 'react'
|
|
26
26
|
|
|
27
|
-
import { testable } from '@instructure/ui-testable'
|
|
28
27
|
import { getInteraction, passthroughProps } from '@instructure/ui-react-utils'
|
|
29
28
|
|
|
30
29
|
import { withStyle } from '@instructure/emotion'
|
|
@@ -32,7 +31,7 @@ import { withStyle } from '@instructure/emotion'
|
|
|
32
31
|
import generateComponentTheme from './theme'
|
|
33
32
|
import { BaseButton } from '../BaseButton'
|
|
34
33
|
|
|
35
|
-
import {
|
|
34
|
+
import { allowedProps } from './props'
|
|
36
35
|
import type { ButtonProps } from './props'
|
|
37
36
|
|
|
38
37
|
/**
|
|
@@ -42,11 +41,9 @@ category: components
|
|
|
42
41
|
**/
|
|
43
42
|
// needed for listing the available theme variables on docs page
|
|
44
43
|
@withStyle(null, generateComponentTheme)
|
|
45
|
-
@testable()
|
|
46
44
|
class Button extends Component<ButtonProps> {
|
|
47
45
|
static readonly componentId = 'Button'
|
|
48
46
|
|
|
49
|
-
static propTypes = propTypes
|
|
50
47
|
static allowedProps = allowedProps
|
|
51
48
|
static defaultProps = {
|
|
52
49
|
type: 'button',
|
|
@@ -130,7 +127,11 @@ class Button extends Component<ButtonProps> {
|
|
|
130
127
|
themeOverride
|
|
131
128
|
}
|
|
132
129
|
|
|
133
|
-
return
|
|
130
|
+
return (
|
|
131
|
+
<BaseButton {...buttonProps} data-cid="Button">
|
|
132
|
+
{children}
|
|
133
|
+
</BaseButton>
|
|
134
|
+
)
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
|
package/src/Button/props.ts
CHANGED
|
@@ -23,17 +23,14 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
-
import PropTypes from 'prop-types'
|
|
27
|
-
|
|
28
26
|
import type { Spacing, WithStyleProps } from '@instructure/emotion'
|
|
29
27
|
import type {
|
|
30
28
|
ToProp,
|
|
31
29
|
AsElementType,
|
|
32
|
-
PropValidators,
|
|
33
30
|
BaseButtonTheme,
|
|
34
31
|
OtherHTMLAttributes
|
|
35
32
|
} from '@instructure/shared-types'
|
|
36
|
-
import type { Cursor } from '@instructure/
|
|
33
|
+
import type { Cursor } from '@instructure/shared-types'
|
|
37
34
|
import type { ViewProps } from '@instructure/ui-view'
|
|
38
35
|
|
|
39
36
|
type ButtonOwnProps = {
|
|
@@ -139,34 +136,6 @@ type ButtonProps = ButtonOwnProps &
|
|
|
139
136
|
WithStyleProps<BaseButtonTheme, null> &
|
|
140
137
|
OtherHTMLAttributes<ButtonOwnProps> &
|
|
141
138
|
ToProp
|
|
142
|
-
|
|
143
|
-
const propTypes: PropValidators<PropKeys> = {
|
|
144
|
-
children: PropTypes.node,
|
|
145
|
-
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
146
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
147
|
-
elementRef: PropTypes.func,
|
|
148
|
-
as: PropTypes.elementType,
|
|
149
|
-
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
150
|
-
color: PropTypes.oneOf([
|
|
151
|
-
'primary',
|
|
152
|
-
'primary-inverse',
|
|
153
|
-
'secondary',
|
|
154
|
-
'success',
|
|
155
|
-
'danger',
|
|
156
|
-
'ai-primary',
|
|
157
|
-
'ai-secondary'
|
|
158
|
-
]),
|
|
159
|
-
focusColor: PropTypes.oneOf(['info', 'inverse']),
|
|
160
|
-
display: PropTypes.oneOf(['inline-block', 'block']),
|
|
161
|
-
textAlign: PropTypes.oneOf(['start', 'center']),
|
|
162
|
-
withBackground: PropTypes.bool,
|
|
163
|
-
margin: PropTypes.string,
|
|
164
|
-
cursor: PropTypes.string,
|
|
165
|
-
href: PropTypes.string,
|
|
166
|
-
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
167
|
-
onClick: PropTypes.func
|
|
168
|
-
}
|
|
169
|
-
|
|
170
139
|
const allowedProps: AllowedPropKeys = [
|
|
171
140
|
'as',
|
|
172
141
|
'children',
|
|
@@ -187,4 +156,4 @@ const allowedProps: AllowedPropKeys = [
|
|
|
187
156
|
]
|
|
188
157
|
|
|
189
158
|
export type { ButtonProps }
|
|
190
|
-
export {
|
|
159
|
+
export { allowedProps }
|
|
@@ -26,7 +26,6 @@ import { Component } from 'react'
|
|
|
26
26
|
|
|
27
27
|
import { IconXSolid } from '@instructure/ui-icons'
|
|
28
28
|
import { ScreenReaderContent } from '@instructure/ui-a11y-content'
|
|
29
|
-
import { testable } from '@instructure/ui-testable'
|
|
30
29
|
import { getInteraction, passthroughProps } from '@instructure/ui-react-utils'
|
|
31
30
|
|
|
32
31
|
import { withStyle } from '@instructure/emotion'
|
|
@@ -35,7 +34,7 @@ import generateStyle from './styles'
|
|
|
35
34
|
import generateComponentTheme from './theme'
|
|
36
35
|
import { BaseButton } from '../BaseButton'
|
|
37
36
|
|
|
38
|
-
import {
|
|
37
|
+
import { allowedProps } from './props'
|
|
39
38
|
import type { CloseButtonProps } from './props'
|
|
40
39
|
|
|
41
40
|
/**
|
|
@@ -44,11 +43,9 @@ category: components
|
|
|
44
43
|
---
|
|
45
44
|
**/
|
|
46
45
|
@withStyle(generateStyle, generateComponentTheme)
|
|
47
|
-
@testable()
|
|
48
46
|
class CloseButton extends Component<CloseButtonProps> {
|
|
49
47
|
static readonly componentId = 'CloseButton'
|
|
50
48
|
|
|
51
|
-
static propTypes = propTypes
|
|
52
49
|
static allowedProps = allowedProps
|
|
53
50
|
static defaultProps = {
|
|
54
51
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
@@ -111,14 +108,16 @@ class CloseButton extends Component<CloseButtonProps> {
|
|
|
111
108
|
<span
|
|
112
109
|
{...passthroughProps(props)}
|
|
113
110
|
css={styles?.closeButton}
|
|
114
|
-
ref={(el) =>
|
|
111
|
+
ref={(el) => {
|
|
112
|
+
this.ref = el
|
|
113
|
+
}}
|
|
115
114
|
>
|
|
116
115
|
<BaseButton
|
|
117
116
|
renderIcon={IconXSolid}
|
|
118
117
|
elementRef={this.handleRef}
|
|
119
118
|
interaction={this.interaction}
|
|
120
119
|
type={type}
|
|
121
|
-
color
|
|
120
|
+
{...(this.color ? { color: this.color } : {})}
|
|
122
121
|
size={size}
|
|
123
122
|
onClick={onClick}
|
|
124
123
|
margin={margin}
|
|
@@ -128,6 +127,7 @@ class CloseButton extends Component<CloseButtonProps> {
|
|
|
128
127
|
href={href}
|
|
129
128
|
cursor={cursor}
|
|
130
129
|
tabIndex={tabIndex}
|
|
130
|
+
data-cid="CloseButton"
|
|
131
131
|
>
|
|
132
132
|
<ScreenReaderContent>{screenReaderLabel}</ScreenReaderContent>
|
|
133
133
|
</BaseButton>
|
package/src/CloseButton/props.ts
CHANGED
|
@@ -23,8 +23,6 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
-
import PropTypes from 'prop-types'
|
|
27
|
-
|
|
28
26
|
import type {
|
|
29
27
|
Spacing,
|
|
30
28
|
WithStyleProps,
|
|
@@ -34,10 +32,9 @@ import type {
|
|
|
34
32
|
ToProp,
|
|
35
33
|
AsElementType,
|
|
36
34
|
CloseButtonTheme,
|
|
37
|
-
OtherHTMLAttributes
|
|
38
|
-
PropValidators
|
|
35
|
+
OtherHTMLAttributes
|
|
39
36
|
} from '@instructure/shared-types'
|
|
40
|
-
import type { Cursor } from '@instructure/
|
|
37
|
+
import type { Cursor } from '@instructure/shared-types'
|
|
41
38
|
import type { ViewProps } from '@instructure/ui-view'
|
|
42
39
|
|
|
43
40
|
type CloseButtonOwnProps = {
|
|
@@ -130,25 +127,6 @@ type CloseButtonProps = CloseButtonOwnProps &
|
|
|
130
127
|
ToProp
|
|
131
128
|
|
|
132
129
|
type CloseButtonStyle = ComponentStyle<'closeButton'>
|
|
133
|
-
|
|
134
|
-
const propTypes: PropValidators<PropKeys> = {
|
|
135
|
-
screenReaderLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
|
|
136
|
-
.isRequired,
|
|
137
|
-
color: PropTypes.oneOf(['primary', 'primary-inverse']),
|
|
138
|
-
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
139
|
-
elementRef: PropTypes.func,
|
|
140
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
141
|
-
onClick: PropTypes.func,
|
|
142
|
-
margin: PropTypes.string,
|
|
143
|
-
placement: PropTypes.oneOf(['start', 'end', 'static']),
|
|
144
|
-
offset: PropTypes.oneOf(['none', 'x-small', 'small', 'medium']),
|
|
145
|
-
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
146
|
-
as: PropTypes.elementType,
|
|
147
|
-
href: PropTypes.string,
|
|
148
|
-
cursor: PropTypes.string,
|
|
149
|
-
tabIndex: PropTypes.number
|
|
150
|
-
}
|
|
151
|
-
|
|
152
130
|
const allowedProps: AllowedPropKeys = [
|
|
153
131
|
'as',
|
|
154
132
|
'color',
|
|
@@ -167,4 +145,4 @@ const allowedProps: AllowedPropKeys = [
|
|
|
167
145
|
]
|
|
168
146
|
|
|
169
147
|
export type { CloseButtonProps, CloseButtonStyle }
|
|
170
|
-
export {
|
|
148
|
+
export { allowedProps }
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
|
|
25
25
|
import { Component } from 'react'
|
|
26
26
|
|
|
27
|
-
import { testable } from '@instructure/ui-testable'
|
|
28
27
|
import { passthroughProps } from '@instructure/ui-react-utils'
|
|
29
28
|
|
|
30
29
|
import { withStyle } from '@instructure/emotion'
|
|
@@ -32,7 +31,7 @@ import { withStyle } from '@instructure/emotion'
|
|
|
32
31
|
import generateComponentTheme from './theme'
|
|
33
32
|
import { BaseButton } from '../BaseButton'
|
|
34
33
|
|
|
35
|
-
import {
|
|
34
|
+
import { allowedProps } from './props'
|
|
36
35
|
import type { CondensedButtonProps } from './props'
|
|
37
36
|
|
|
38
37
|
/**
|
|
@@ -42,11 +41,9 @@ category: components
|
|
|
42
41
|
**/
|
|
43
42
|
// needed for listing the available theme variables on docs page
|
|
44
43
|
@withStyle(null, generateComponentTheme)
|
|
45
|
-
@testable()
|
|
46
44
|
class CondensedButton extends Component<CondensedButtonProps> {
|
|
47
45
|
static readonly componentId = 'CondensedButton'
|
|
48
46
|
|
|
49
|
-
static propTypes = propTypes
|
|
50
47
|
static allowedProps = allowedProps
|
|
51
48
|
static defaultProps = {
|
|
52
49
|
type: 'button',
|
|
@@ -122,6 +119,7 @@ class CondensedButton extends Component<CondensedButtonProps> {
|
|
|
122
119
|
ref={(component) => {
|
|
123
120
|
this._baseButton = component
|
|
124
121
|
}}
|
|
122
|
+
data-cid="CondensedButton"
|
|
125
123
|
>
|
|
126
124
|
{children}
|
|
127
125
|
</BaseButton>
|
|
@@ -23,17 +23,14 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
-
import PropTypes from 'prop-types'
|
|
27
|
-
|
|
28
26
|
import type { Spacing, WithStyleProps } from '@instructure/emotion'
|
|
29
27
|
import type {
|
|
30
28
|
ToProp,
|
|
31
29
|
AsElementType,
|
|
32
30
|
BaseButtonTheme,
|
|
33
|
-
OtherHTMLAttributes
|
|
34
|
-
PropValidators
|
|
31
|
+
OtherHTMLAttributes
|
|
35
32
|
} from '@instructure/shared-types'
|
|
36
|
-
import type { Cursor } from '@instructure/
|
|
33
|
+
import type { Cursor } from '@instructure/shared-types'
|
|
37
34
|
import type { ViewProps } from '@instructure/ui-view'
|
|
38
35
|
|
|
39
36
|
type CondensedButtonOwnProps = {
|
|
@@ -117,22 +114,6 @@ type CondensedButtonProps = CondensedButtonOwnProps &
|
|
|
117
114
|
OtherHTMLAttributes<CondensedButtonOwnProps> &
|
|
118
115
|
ToProp
|
|
119
116
|
|
|
120
|
-
const propTypes: PropValidators<PropKeys> = {
|
|
121
|
-
children: PropTypes.node,
|
|
122
|
-
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
123
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
124
|
-
elementRef: PropTypes.func,
|
|
125
|
-
as: PropTypes.elementType,
|
|
126
|
-
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
127
|
-
color: PropTypes.oneOf(['primary', 'primary-inverse', 'secondary']),
|
|
128
|
-
margin: PropTypes.string,
|
|
129
|
-
cursor: PropTypes.string,
|
|
130
|
-
href: PropTypes.string,
|
|
131
|
-
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
132
|
-
onClick: PropTypes.func,
|
|
133
|
-
display: PropTypes.oneOf(['inline-block', 'block'])
|
|
134
|
-
}
|
|
135
|
-
|
|
136
117
|
const allowedProps: AllowedPropKeys = [
|
|
137
118
|
'as',
|
|
138
119
|
'children',
|
|
@@ -150,4 +131,4 @@ const allowedProps: AllowedPropKeys = [
|
|
|
150
131
|
]
|
|
151
132
|
|
|
152
133
|
export type { CondensedButtonProps }
|
|
153
|
-
export {
|
|
134
|
+
export { allowedProps }
|
package/src/IconButton/index.tsx
CHANGED
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
|
|
25
25
|
import { Component } from 'react'
|
|
26
26
|
|
|
27
|
-
import { testable } from '@instructure/ui-testable'
|
|
28
27
|
import { passthroughProps } from '@instructure/ui-react-utils'
|
|
29
28
|
import { ScreenReaderContent } from '@instructure/ui-a11y-content'
|
|
29
|
+
import { combineDataCid } from '@instructure/ui-utils'
|
|
30
30
|
|
|
31
31
|
import { withStyle } from '@instructure/emotion'
|
|
32
32
|
|
|
33
33
|
import generateComponentTheme from './theme'
|
|
34
34
|
import { BaseButton } from '../BaseButton'
|
|
35
35
|
|
|
36
|
-
import {
|
|
36
|
+
import { allowedProps } from './props'
|
|
37
37
|
import type { IconButtonProps } from './props'
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -44,11 +44,9 @@ category: components
|
|
|
44
44
|
|
|
45
45
|
// needed for listing the available theme variables on docs page
|
|
46
46
|
@withStyle(null, generateComponentTheme)
|
|
47
|
-
@testable()
|
|
48
47
|
class IconButton extends Component<IconButtonProps> {
|
|
49
48
|
static readonly componentId = 'IconButton'
|
|
50
49
|
|
|
51
|
-
static propTypes = propTypes
|
|
52
50
|
static allowedProps = allowedProps
|
|
53
51
|
static defaultProps = {
|
|
54
52
|
type: 'button',
|
|
@@ -130,6 +128,7 @@ class IconButton extends Component<IconButtonProps> {
|
|
|
130
128
|
ref={(component) => {
|
|
131
129
|
this._baseButton = component
|
|
132
130
|
}}
|
|
131
|
+
data-cid={combineDataCid('IconButton', this.props)}
|
|
133
132
|
>
|
|
134
133
|
<ScreenReaderContent>{screenReaderLabel}</ScreenReaderContent>
|
|
135
134
|
</BaseButton>
|
package/src/IconButton/props.ts
CHANGED
|
@@ -23,18 +23,16 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { ReactNode } from 'react'
|
|
26
|
-
import PropTypes from 'prop-types'
|
|
27
26
|
|
|
28
27
|
import type { Spacing, WithStyleProps } from '@instructure/emotion'
|
|
29
28
|
import type {
|
|
30
29
|
ToProp,
|
|
31
30
|
AsElementType,
|
|
32
|
-
PropValidators,
|
|
33
31
|
BaseButtonTheme,
|
|
34
32
|
OtherHTMLAttributes,
|
|
35
33
|
Renderable
|
|
36
34
|
} from '@instructure/shared-types'
|
|
37
|
-
import type { Cursor } from '@instructure/
|
|
35
|
+
import type { Cursor } from '@instructure/shared-types'
|
|
38
36
|
import type { ViewProps } from '@instructure/ui-view'
|
|
39
37
|
|
|
40
38
|
type IconButtonOwnProps = {
|
|
@@ -144,35 +142,6 @@ type IconButtonProps = IconButtonOwnProps &
|
|
|
144
142
|
WithStyleProps<BaseButtonTheme, null> &
|
|
145
143
|
OtherHTMLAttributes<IconButtonOwnProps> &
|
|
146
144
|
ToProp
|
|
147
|
-
|
|
148
|
-
const propTypes: PropValidators<PropKeys> = {
|
|
149
|
-
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
150
|
-
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
151
|
-
screenReaderLabel: PropTypes.string.isRequired,
|
|
152
|
-
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
153
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
154
|
-
elementRef: PropTypes.func,
|
|
155
|
-
as: PropTypes.elementType,
|
|
156
|
-
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
157
|
-
color: PropTypes.oneOf([
|
|
158
|
-
'primary',
|
|
159
|
-
'primary-inverse',
|
|
160
|
-
'secondary',
|
|
161
|
-
'success',
|
|
162
|
-
'danger',
|
|
163
|
-
'ai-primary',
|
|
164
|
-
'ai-secondary'
|
|
165
|
-
]),
|
|
166
|
-
focusColor: PropTypes.oneOf(['info', 'inverse']),
|
|
167
|
-
shape: PropTypes.oneOf(['rectangle', 'circle']),
|
|
168
|
-
withBackground: PropTypes.bool,
|
|
169
|
-
withBorder: PropTypes.bool,
|
|
170
|
-
margin: PropTypes.string,
|
|
171
|
-
cursor: PropTypes.string,
|
|
172
|
-
href: PropTypes.string,
|
|
173
|
-
onClick: PropTypes.func
|
|
174
|
-
}
|
|
175
|
-
|
|
176
145
|
const allowedProps: AllowedPropKeys = [
|
|
177
146
|
'as',
|
|
178
147
|
'children',
|
|
@@ -194,4 +163,4 @@ const allowedProps: AllowedPropKeys = [
|
|
|
194
163
|
]
|
|
195
164
|
|
|
196
165
|
export type { IconButtonProps }
|
|
197
|
-
export {
|
|
166
|
+
export { allowedProps }
|
|
@@ -24,14 +24,12 @@
|
|
|
24
24
|
|
|
25
25
|
import { Component } from 'react'
|
|
26
26
|
|
|
27
|
-
import { testable } from '@instructure/ui-testable'
|
|
28
|
-
|
|
29
27
|
import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils'
|
|
30
28
|
|
|
31
29
|
import { Tooltip } from '@instructure/ui-tooltip'
|
|
32
30
|
import { IconButton } from '../IconButton'
|
|
33
31
|
|
|
34
|
-
import {
|
|
32
|
+
import { allowedProps } from './props'
|
|
35
33
|
import type { ToggleButtonProps, ToggleButtonState } from './props'
|
|
36
34
|
|
|
37
35
|
/**
|
|
@@ -40,11 +38,9 @@ category: components
|
|
|
40
38
|
---
|
|
41
39
|
**/
|
|
42
40
|
|
|
43
|
-
@testable()
|
|
44
41
|
class ToggleButton extends Component<ToggleButtonProps, ToggleButtonState> {
|
|
45
42
|
static readonly componentId = 'ToggleButton'
|
|
46
43
|
|
|
47
|
-
static propTypes = propTypes
|
|
48
44
|
static allowedProps = allowedProps
|
|
49
45
|
static defaultProps = {
|
|
50
46
|
size: 'medium',
|
|
@@ -125,6 +121,7 @@ class ToggleButton extends Component<ToggleButtonProps, ToggleButtonState> {
|
|
|
125
121
|
onClick={onClick}
|
|
126
122
|
interaction={interaction}
|
|
127
123
|
aria-pressed={status === 'pressed'}
|
|
124
|
+
data-cid="ToggleButton"
|
|
128
125
|
>
|
|
129
126
|
{callRenderProp(renderIcon)}
|
|
130
127
|
</IconButton>
|
|
@@ -23,14 +23,10 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
-
import PropTypes from 'prop-types'
|
|
27
|
-
|
|
28
|
-
import { PositionPropTypes } from '@instructure/ui-position'
|
|
29
26
|
|
|
30
27
|
import type {
|
|
31
28
|
AsElementType,
|
|
32
|
-
OtherHTMLAttributes
|
|
33
|
-
PropValidators
|
|
29
|
+
OtherHTMLAttributes
|
|
34
30
|
} from '@instructure/shared-types'
|
|
35
31
|
import type {
|
|
36
32
|
PlacementPropValues,
|
|
@@ -126,31 +122,6 @@ type ToggleButtonProps = ToggleButtonOwnProps &
|
|
|
126
122
|
type ToggleButtonState = {
|
|
127
123
|
isShowingTooltip: boolean
|
|
128
124
|
}
|
|
129
|
-
|
|
130
|
-
const propTypes: PropValidators<PropKeys> = {
|
|
131
|
-
screenReaderLabel: PropTypes.string.isRequired,
|
|
132
|
-
renderTooltipContent: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
|
133
|
-
.isRequired,
|
|
134
|
-
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
135
|
-
status: PropTypes.oneOf(['pressed', 'unpressed']).isRequired,
|
|
136
|
-
as: PropTypes.elementType,
|
|
137
|
-
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
138
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
139
|
-
elementRef: PropTypes.func,
|
|
140
|
-
onClick: PropTypes.func,
|
|
141
|
-
color: PropTypes.oneOf([
|
|
142
|
-
'primary',
|
|
143
|
-
'primary-inverse',
|
|
144
|
-
'secondary',
|
|
145
|
-
'success',
|
|
146
|
-
'danger'
|
|
147
|
-
]),
|
|
148
|
-
isShowingTooltip: PropTypes.bool,
|
|
149
|
-
mountNode: PositionPropTypes.mountNode,
|
|
150
|
-
placement: PositionPropTypes.placement,
|
|
151
|
-
constrain: PositionPropTypes.constrain
|
|
152
|
-
}
|
|
153
|
-
|
|
154
125
|
const allowedProps: AllowedPropKeys = [
|
|
155
126
|
'as',
|
|
156
127
|
'color',
|
|
@@ -169,4 +140,4 @@ const allowedProps: AllowedPropKeys = [
|
|
|
169
140
|
]
|
|
170
141
|
|
|
171
142
|
export type { ToggleButtonProps, ToggleButtonState }
|
|
172
|
-
export {
|
|
143
|
+
export { allowedProps }
|
package/tsconfig.build.json
CHANGED
|
@@ -17,10 +17,8 @@
|
|
|
17
17
|
{ "path": "../ui-color-utils/tsconfig.build.json" },
|
|
18
18
|
{ "path": "../ui-dom-utils/tsconfig.build.json" },
|
|
19
19
|
{ "path": "../ui-icons/tsconfig.build.json" },
|
|
20
|
-
{ "path": "../ui-prop-types/tsconfig.build.json" },
|
|
21
20
|
{ "path": "../ui-position/tsconfig.build.json" },
|
|
22
21
|
{ "path": "../ui-react-utils/tsconfig.build.json" },
|
|
23
|
-
{ "path": "../ui-testable/tsconfig.build.json" },
|
|
24
22
|
{ "path": "../ui-tooltip/tsconfig.build.json" },
|
|
25
23
|
{ "path": "../ui-utils/tsconfig.build.json" },
|
|
26
24
|
{ "path": "../ui-view/tsconfig.build.json" },
|