@instructure/ui-buttons 8.8.1-snapshot.7 → 8.9.1-snapshot.2
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 +6 -0
- package/es/BaseButton/index.js +12 -133
- package/es/BaseButton/props.js +138 -0
- package/es/Button/index.js +4 -87
- package/es/Button/props.js +107 -0
- package/es/CloseButton/index.js +5 -93
- package/es/CloseButton/props.js +103 -0
- package/es/CondensedButton/index.js +4 -65
- package/es/CondensedButton/props.js +86 -0
- package/es/IconButton/index.js +4 -91
- package/es/IconButton/props.js +111 -0
- package/es/ToggleButton/index.js +2 -77
- package/es/ToggleButton/props.js +100 -0
- package/lib/BaseButton/index.js +12 -133
- package/lib/BaseButton/props.js +150 -0
- package/lib/Button/index.js +4 -87
- package/lib/Button/props.js +119 -0
- package/lib/CloseButton/index.js +5 -93
- package/lib/CloseButton/props.js +115 -0
- package/lib/CondensedButton/index.js +4 -65
- package/lib/CondensedButton/props.js +98 -0
- package/lib/IconButton/index.js +4 -91
- package/lib/IconButton/props.js +123 -0
- package/lib/ToggleButton/index.js +3 -79
- package/lib/ToggleButton/props.js +112 -0
- package/package.json +21 -21
- package/src/BaseButton/index.tsx +15 -120
- package/src/BaseButton/props.ts +192 -0
- package/src/BaseButton/styles.ts +1 -1
- package/src/Button/index.tsx +7 -81
- package/src/Button/props.ts +149 -0
- package/src/CloseButton/index.tsx +8 -82
- package/src/CloseButton/props.ts +137 -0
- package/src/CloseButton/styles.ts +1 -1
- package/src/CondensedButton/index.tsx +7 -57
- package/src/CondensedButton/props.ts +118 -0
- package/src/IconButton/index.tsx +7 -84
- package/src/IconButton/props.ts +154 -0
- package/src/ToggleButton/index.tsx +5 -68
- package/src/ToggleButton/props.ts +140 -0
- package/src/index.ts +6 -6
- package/types/BaseButton/index.d.ts +47 -101
- package/types/BaseButton/index.d.ts.map +1 -1
- package/types/BaseButton/{types.d.ts → props.d.ts} +15 -10
- package/types/BaseButton/props.d.ts.map +1 -0
- package/types/BaseButton/styles.d.ts +1 -1
- package/types/Button/index.d.ts +36 -73
- package/types/Button/index.d.ts.map +1 -1
- package/types/Button/{types.d.ts → props.d.ts} +12 -4
- package/types/Button/props.d.ts.map +1 -0
- package/types/CloseButton/index.d.ts +41 -75
- package/types/CloseButton/index.d.ts.map +1 -1
- package/types/CloseButton/props.d.ts +27 -0
- package/types/CloseButton/props.d.ts.map +1 -0
- package/types/CloseButton/styles.d.ts +1 -1
- package/types/CondensedButton/index.d.ts +28 -55
- package/types/CondensedButton/index.d.ts.map +1 -1
- package/types/CondensedButton/props.d.ts +24 -0
- package/types/CondensedButton/props.d.ts.map +1 -0
- package/types/IconButton/index.d.ts +38 -76
- package/types/IconButton/index.d.ts.map +1 -1
- package/types/IconButton/{types.d.ts → props.d.ts} +11 -3
- package/types/IconButton/props.d.ts.map +1 -0
- package/types/ToggleButton/index.d.ts +34 -65
- package/types/ToggleButton/index.d.ts.map +1 -1
- package/types/ToggleButton/{types.d.ts → props.d.ts} +10 -3
- package/types/ToggleButton/props.d.ts.map +1 -0
- package/types/index.d.ts +6 -6
- package/es/BaseButton/types.js +0 -1
- package/es/Button/types.js +0 -1
- package/es/CloseButton/types.js +0 -1
- package/es/CondensedButton/types.js +0 -1
- package/es/IconButton/types.js +0 -1
- package/es/ToggleButton/types.js +0 -1
- package/lib/BaseButton/types.js +0 -1
- package/lib/Button/types.js +0 -1
- package/lib/CloseButton/types.js +0 -1
- package/lib/CondensedButton/types.js +0 -1
- package/lib/IconButton/types.js +0 -1
- package/lib/ToggleButton/types.js +0 -1
- package/src/BaseButton/types.ts +0 -58
- package/src/Button/types.ts +0 -44
- package/src/CloseButton/types.ts +0 -45
- package/src/CondensedButton/types.ts +0 -40
- package/src/IconButton/types.ts +0 -45
- package/src/ToggleButton/types.ts +0 -48
- package/types/BaseButton/types.d.ts.map +0 -1
- package/types/Button/types.d.ts.map +0 -1
- package/types/CloseButton/types.d.ts +0 -22
- package/types/CloseButton/types.d.ts.map +0 -1
- package/types/CondensedButton/types.d.ts +0 -16
- package/types/CondensedButton/types.d.ts.map +0 -1
- package/types/IconButton/types.d.ts.map +0 -1
- package/types/ToggleButton/types.d.ts.map +0 -1
|
@@ -0,0 +1,192 @@
|
|
|
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 PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { ThemeablePropTypes } from '@instructure/emotion'
|
|
29
|
+
|
|
30
|
+
import type { InteractionType } from '@instructure/ui-react-utils'
|
|
31
|
+
import type { Spacing, WithStyleProps } from '@instructure/emotion'
|
|
32
|
+
import type { AsElementType, PropValidators } from '@instructure/shared-types'
|
|
33
|
+
|
|
34
|
+
type BaseButtonOwnProps = {
|
|
35
|
+
children?: React.ReactNode
|
|
36
|
+
type?: 'button' | 'submit' | 'reset'
|
|
37
|
+
size?: 'small' | 'medium' | 'large'
|
|
38
|
+
elementRef?: (...args: any[]) => any
|
|
39
|
+
as?: AsElementType
|
|
40
|
+
interaction?: InteractionType
|
|
41
|
+
color?: 'primary' | 'primary-inverse' | 'secondary' | 'success' | 'danger'
|
|
42
|
+
focusColor?: 'info' | 'inverse'
|
|
43
|
+
display?: 'inline-block' | 'block'
|
|
44
|
+
textAlign?: 'start' | 'center'
|
|
45
|
+
shape?: 'rectangle' | 'circle'
|
|
46
|
+
withBackground?: boolean
|
|
47
|
+
withBorder?: boolean
|
|
48
|
+
isCondensed?: boolean
|
|
49
|
+
margin?: Spacing
|
|
50
|
+
cursor?: string
|
|
51
|
+
href?: string
|
|
52
|
+
onClick?: (...args: any[]) => any
|
|
53
|
+
onKeyDown?: (...args: any[]) => any
|
|
54
|
+
renderIcon?: React.ReactNode | ((...args: any[]) => any)
|
|
55
|
+
tabIndex?: number | string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type BaseButtonStyleProps = {
|
|
59
|
+
isDisabled: boolean
|
|
60
|
+
hasOnlyIconVisible: boolean
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
type PropKeys = keyof BaseButtonOwnProps
|
|
64
|
+
|
|
65
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
66
|
+
|
|
67
|
+
type BaseButtonProps = BaseButtonOwnProps & WithStyleProps
|
|
68
|
+
|
|
69
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
70
|
+
/**
|
|
71
|
+
* Specifies the `Button` children.
|
|
72
|
+
*/
|
|
73
|
+
children: PropTypes.node,
|
|
74
|
+
/**
|
|
75
|
+
* Specifies the type of the `Button`'s underlying html element.
|
|
76
|
+
*/
|
|
77
|
+
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
78
|
+
/**
|
|
79
|
+
* The size of the `Button`
|
|
80
|
+
*/
|
|
81
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
82
|
+
/**
|
|
83
|
+
* Provides a reference to the `Button`'s underlying html element.
|
|
84
|
+
*/
|
|
85
|
+
elementRef: PropTypes.func,
|
|
86
|
+
/**
|
|
87
|
+
* The element to render as the component root, `Button` by default.
|
|
88
|
+
*/
|
|
89
|
+
as: PropTypes.elementType,
|
|
90
|
+
/**
|
|
91
|
+
* Specifies if interaction with the `Button` is enabled, disabled, or readonly.
|
|
92
|
+
*/
|
|
93
|
+
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
94
|
+
/**
|
|
95
|
+
* Specifies the color for the `Button`.
|
|
96
|
+
*/
|
|
97
|
+
color: PropTypes.oneOf([
|
|
98
|
+
'primary',
|
|
99
|
+
'primary-inverse',
|
|
100
|
+
'secondary',
|
|
101
|
+
'success',
|
|
102
|
+
'danger'
|
|
103
|
+
]),
|
|
104
|
+
/**
|
|
105
|
+
* Override the `Button`'s default focus outline color.
|
|
106
|
+
*/
|
|
107
|
+
focusColor: PropTypes.oneOf(['info', 'inverse']),
|
|
108
|
+
/**
|
|
109
|
+
* The `Button` display property. When set to `inline-block`, the `Button` displays inline with other elements.
|
|
110
|
+
* When set to block, the `Button` expands to fill the width of the container.
|
|
111
|
+
*/
|
|
112
|
+
display: PropTypes.oneOf(['inline-block', 'block']),
|
|
113
|
+
/**
|
|
114
|
+
* Sets the alignment of the `Button` children and/or icon.
|
|
115
|
+
*/
|
|
116
|
+
textAlign: PropTypes.oneOf(['start', 'center']),
|
|
117
|
+
/**
|
|
118
|
+
* Specifies if the `Button` shape should be a circle or rectangle.
|
|
119
|
+
*/
|
|
120
|
+
shape: PropTypes.oneOf(['rectangle', 'circle']),
|
|
121
|
+
/**
|
|
122
|
+
* Specifies if the `Button` should render with a solid background. When false, the background is transparent.
|
|
123
|
+
*/
|
|
124
|
+
withBackground: PropTypes.bool,
|
|
125
|
+
/**
|
|
126
|
+
* Specifies if the `Button` should render with a border.
|
|
127
|
+
*/
|
|
128
|
+
withBorder: PropTypes.bool,
|
|
129
|
+
/**
|
|
130
|
+
* Designates if the `Button` should render without padding. This option should only be set when `withBorder` and
|
|
131
|
+
* `withBackground` are also set to false.
|
|
132
|
+
*/
|
|
133
|
+
isCondensed: PropTypes.bool,
|
|
134
|
+
/**
|
|
135
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
136
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
137
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
138
|
+
*/
|
|
139
|
+
margin: ThemeablePropTypes.spacing,
|
|
140
|
+
/**
|
|
141
|
+
* Specify a mouse cursor to use when hovering over the button.
|
|
142
|
+
* The `pointer` cursor is used by default.
|
|
143
|
+
*/
|
|
144
|
+
cursor: PropTypes.string,
|
|
145
|
+
/**
|
|
146
|
+
* Specifies an href attribute for the `Button`'s underlying html element.
|
|
147
|
+
*/
|
|
148
|
+
href: PropTypes.string,
|
|
149
|
+
/**
|
|
150
|
+
* Callback fired when the `Button` is clicked.
|
|
151
|
+
*/
|
|
152
|
+
onClick: PropTypes.func,
|
|
153
|
+
/**
|
|
154
|
+
* Callback fired when the `Button` receives a keydown event.
|
|
155
|
+
*/
|
|
156
|
+
onKeyDown: PropTypes.func,
|
|
157
|
+
/**
|
|
158
|
+
* An icon, or function that returns an icon.
|
|
159
|
+
*/
|
|
160
|
+
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
161
|
+
/**
|
|
162
|
+
* Specifies the tabindex of the `Button`.
|
|
163
|
+
*/
|
|
164
|
+
tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const allowedProps: AllowedPropKeys = [
|
|
168
|
+
'as',
|
|
169
|
+
'children',
|
|
170
|
+
'color',
|
|
171
|
+
'cursor',
|
|
172
|
+
'display',
|
|
173
|
+
'elementRef',
|
|
174
|
+
'focusColor',
|
|
175
|
+
'href',
|
|
176
|
+
'interaction',
|
|
177
|
+
'isCondensed',
|
|
178
|
+
'margin',
|
|
179
|
+
'onClick',
|
|
180
|
+
'onKeyDown',
|
|
181
|
+
'renderIcon',
|
|
182
|
+
'shape',
|
|
183
|
+
'size',
|
|
184
|
+
'tabIndex',
|
|
185
|
+
'textAlign',
|
|
186
|
+
'type',
|
|
187
|
+
'withBackground',
|
|
188
|
+
'withBorder'
|
|
189
|
+
]
|
|
190
|
+
|
|
191
|
+
export type { BaseButtonProps, BaseButtonStyleProps }
|
|
192
|
+
export { propTypes, allowedProps }
|
package/src/BaseButton/styles.ts
CHANGED
package/src/Button/index.tsx
CHANGED
|
@@ -23,16 +23,17 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React, { Component } from 'react'
|
|
26
|
-
import PropTypes from 'prop-types'
|
|
27
26
|
|
|
28
27
|
import { testable } from '@instructure/ui-testable'
|
|
29
28
|
import { getInteraction, passthroughProps } from '@instructure/ui-react-utils'
|
|
30
29
|
|
|
31
|
-
import { withStyle
|
|
30
|
+
import { withStyle } from '@instructure/emotion'
|
|
32
31
|
|
|
33
32
|
import generateComponentTheme from './theme'
|
|
34
33
|
import { BaseButton } from '../BaseButton'
|
|
35
|
-
|
|
34
|
+
|
|
35
|
+
import { propTypes, allowedProps } from './props'
|
|
36
|
+
import type { ButtonProps } from './props'
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
---
|
|
@@ -45,79 +46,8 @@ category: components
|
|
|
45
46
|
class Button extends Component<ButtonProps> {
|
|
46
47
|
static readonly componentId = 'Button'
|
|
47
48
|
|
|
48
|
-
static propTypes =
|
|
49
|
-
|
|
50
|
-
* Specifies the `Button` children.
|
|
51
|
-
*/
|
|
52
|
-
children: PropTypes.node,
|
|
53
|
-
/**
|
|
54
|
-
* Specifies the type of the `Button`'s underlying html element.
|
|
55
|
-
*/
|
|
56
|
-
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
57
|
-
/**
|
|
58
|
-
* The size of the `Button`
|
|
59
|
-
*/
|
|
60
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
61
|
-
/**
|
|
62
|
-
* Provides a reference to the `Button`'s underlying html element.
|
|
63
|
-
*/
|
|
64
|
-
elementRef: PropTypes.func,
|
|
65
|
-
/**
|
|
66
|
-
* The element to render as the component root, `Button` by default.
|
|
67
|
-
*/
|
|
68
|
-
as: PropTypes.elementType,
|
|
69
|
-
/**
|
|
70
|
-
* Specifies if interaction with the `Button` is enabled, disabled, or readonly.
|
|
71
|
-
*/
|
|
72
|
-
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
73
|
-
/**
|
|
74
|
-
* Specifies the color for the `Button`.
|
|
75
|
-
*/
|
|
76
|
-
color: PropTypes.oneOf([
|
|
77
|
-
'primary',
|
|
78
|
-
'primary-inverse',
|
|
79
|
-
'secondary',
|
|
80
|
-
'success',
|
|
81
|
-
'danger'
|
|
82
|
-
]),
|
|
83
|
-
/**
|
|
84
|
-
* Override the `Button`'s default focus outline color.
|
|
85
|
-
*/
|
|
86
|
-
focusColor: PropTypes.oneOf(['info', 'inverse']),
|
|
87
|
-
/**
|
|
88
|
-
* The `Button` display property. When set to `inline-block`, the `Button` displays inline with other elements.
|
|
89
|
-
* When set to block, the `Button` expands to fill the width of the container.
|
|
90
|
-
*/
|
|
91
|
-
display: PropTypes.oneOf(['inline-block', 'block']),
|
|
92
|
-
/**
|
|
93
|
-
* Sets the alignment of the `Button` children and/or icon.
|
|
94
|
-
*/
|
|
95
|
-
textAlign: PropTypes.oneOf(['start', 'center']),
|
|
96
|
-
/**
|
|
97
|
-
* Specifies if the `Button` should render with a solid background. When false, the background is transparent.
|
|
98
|
-
*/
|
|
99
|
-
withBackground: PropTypes.bool,
|
|
100
|
-
/**
|
|
101
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
102
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
103
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
104
|
-
*/
|
|
105
|
-
margin: ThemeablePropTypes.spacing,
|
|
106
|
-
/**
|
|
107
|
-
* Specify a mouse cursor to use when hovering over the button.
|
|
108
|
-
* The `pointer` cursor is used by default.
|
|
109
|
-
*/
|
|
110
|
-
cursor: PropTypes.string,
|
|
111
|
-
/**
|
|
112
|
-
* Specifies an href attribute for the `Button`'s underlying html element.
|
|
113
|
-
*/
|
|
114
|
-
href: PropTypes.string,
|
|
115
|
-
/**
|
|
116
|
-
* An icon, or function that returns an icon.
|
|
117
|
-
*/
|
|
118
|
-
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
|
119
|
-
}
|
|
120
|
-
|
|
49
|
+
static propTypes = propTypes
|
|
50
|
+
static allowedProps = allowedProps
|
|
121
51
|
static defaultProps = {
|
|
122
52
|
children: null,
|
|
123
53
|
type: 'button',
|
|
@@ -126,16 +56,12 @@ class Button extends Component<ButtonProps> {
|
|
|
126
56
|
elementRef: (el) => {},
|
|
127
57
|
as: 'button',
|
|
128
58
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
129
|
-
interaction: undefined,
|
|
130
59
|
color: 'secondary',
|
|
131
|
-
focusColor: undefined,
|
|
132
60
|
display: 'inline-block',
|
|
133
61
|
textAlign: 'center',
|
|
134
62
|
withBackground: true,
|
|
135
63
|
margin: '0',
|
|
136
|
-
cursor: 'pointer'
|
|
137
|
-
href: undefined,
|
|
138
|
-
renderIcon: undefined
|
|
64
|
+
cursor: 'pointer'
|
|
139
65
|
}
|
|
140
66
|
|
|
141
67
|
_buttonComponent = null
|
|
@@ -0,0 +1,149 @@
|
|
|
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 PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { ThemeablePropTypes } from '@instructure/emotion'
|
|
29
|
+
|
|
30
|
+
import type { Spacing } from '@instructure/emotion'
|
|
31
|
+
import type { AsElementType, PropValidators } from '@instructure/shared-types'
|
|
32
|
+
|
|
33
|
+
type ButtonOwnProps = {
|
|
34
|
+
children?: React.ReactNode
|
|
35
|
+
type?: 'button' | 'submit' | 'reset'
|
|
36
|
+
size?: 'small' | 'medium' | 'large'
|
|
37
|
+
elementRef?: (...args: any[]) => any
|
|
38
|
+
as?: AsElementType
|
|
39
|
+
interaction?: 'enabled' | 'disabled' | 'readonly'
|
|
40
|
+
color?: 'primary' | 'primary-inverse' | 'secondary' | 'success' | 'danger'
|
|
41
|
+
focusColor?: 'info' | 'inverse'
|
|
42
|
+
display?: 'inline-block' | 'block'
|
|
43
|
+
textAlign?: 'start' | 'center'
|
|
44
|
+
withBackground?: boolean
|
|
45
|
+
margin?: Spacing
|
|
46
|
+
cursor?: string
|
|
47
|
+
href?: string
|
|
48
|
+
renderIcon?: React.ReactNode | ((...args: any[]) => any)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type PropKeys = keyof ButtonOwnProps
|
|
52
|
+
|
|
53
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
54
|
+
|
|
55
|
+
type ButtonProps = ButtonOwnProps
|
|
56
|
+
|
|
57
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
58
|
+
/**
|
|
59
|
+
* Specifies the `Button` children.
|
|
60
|
+
*/
|
|
61
|
+
children: PropTypes.node,
|
|
62
|
+
/**
|
|
63
|
+
* Specifies the type of the `Button`'s underlying html element.
|
|
64
|
+
*/
|
|
65
|
+
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
66
|
+
/**
|
|
67
|
+
* The size of the `Button`
|
|
68
|
+
*/
|
|
69
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
70
|
+
/**
|
|
71
|
+
* Provides a reference to the `Button`'s underlying html element.
|
|
72
|
+
*/
|
|
73
|
+
elementRef: PropTypes.func,
|
|
74
|
+
/**
|
|
75
|
+
* The element to render as the component root, `Button` by default.
|
|
76
|
+
*/
|
|
77
|
+
as: PropTypes.elementType,
|
|
78
|
+
/**
|
|
79
|
+
* Specifies if interaction with the `Button` is enabled, disabled, or readonly.
|
|
80
|
+
*/
|
|
81
|
+
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
82
|
+
/**
|
|
83
|
+
* Specifies the color for the `Button`.
|
|
84
|
+
*/
|
|
85
|
+
color: PropTypes.oneOf([
|
|
86
|
+
'primary',
|
|
87
|
+
'primary-inverse',
|
|
88
|
+
'secondary',
|
|
89
|
+
'success',
|
|
90
|
+
'danger'
|
|
91
|
+
]),
|
|
92
|
+
/**
|
|
93
|
+
* Override the `Button`'s default focus outline color.
|
|
94
|
+
*/
|
|
95
|
+
focusColor: PropTypes.oneOf(['info', 'inverse']),
|
|
96
|
+
/**
|
|
97
|
+
* The `Button` display property. When set to `inline-block`, the `Button` displays inline with other elements.
|
|
98
|
+
* When set to block, the `Button` expands to fill the width of the container.
|
|
99
|
+
*/
|
|
100
|
+
display: PropTypes.oneOf(['inline-block', 'block']),
|
|
101
|
+
/**
|
|
102
|
+
* Sets the alignment of the `Button` children and/or icon.
|
|
103
|
+
*/
|
|
104
|
+
textAlign: PropTypes.oneOf(['start', 'center']),
|
|
105
|
+
/**
|
|
106
|
+
* Specifies if the `Button` should render with a solid background. When false, the background is transparent.
|
|
107
|
+
*/
|
|
108
|
+
withBackground: PropTypes.bool,
|
|
109
|
+
/**
|
|
110
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
111
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
112
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
113
|
+
*/
|
|
114
|
+
margin: ThemeablePropTypes.spacing,
|
|
115
|
+
/**
|
|
116
|
+
* Specify a mouse cursor to use when hovering over the button.
|
|
117
|
+
* The `pointer` cursor is used by default.
|
|
118
|
+
*/
|
|
119
|
+
cursor: PropTypes.string,
|
|
120
|
+
/**
|
|
121
|
+
* Specifies an href attribute for the `Button`'s underlying html element.
|
|
122
|
+
*/
|
|
123
|
+
href: PropTypes.string,
|
|
124
|
+
/**
|
|
125
|
+
* An icon, or function that returns an icon.
|
|
126
|
+
*/
|
|
127
|
+
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const allowedProps: AllowedPropKeys = [
|
|
131
|
+
'as',
|
|
132
|
+
'children',
|
|
133
|
+
'color',
|
|
134
|
+
'cursor',
|
|
135
|
+
'display',
|
|
136
|
+
'elementRef',
|
|
137
|
+
'focusColor',
|
|
138
|
+
'href',
|
|
139
|
+
'interaction',
|
|
140
|
+
'margin',
|
|
141
|
+
'renderIcon',
|
|
142
|
+
'size',
|
|
143
|
+
'textAlign',
|
|
144
|
+
'type',
|
|
145
|
+
'withBackground'
|
|
146
|
+
]
|
|
147
|
+
|
|
148
|
+
export type { ButtonProps }
|
|
149
|
+
export { propTypes, allowedProps }
|