@instructure/ui-buttons 8.13.1-snapshot.9 → 8.14.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 +4 -0
- package/es/BaseButton/index.js +64 -43
- package/es/BaseButton/props.js +2 -88
- package/es/BaseButton/theme.js +1 -1
- package/es/Button/index.js +2 -2
- package/es/Button/props.js +3 -65
- package/es/CloseButton/index.js +23 -18
- package/es/CloseButton/props.js +2 -60
- package/es/CondensedButton/index.js +2 -2
- package/es/CondensedButton/props.js +3 -48
- package/es/IconButton/index.js +2 -2
- package/es/IconButton/props.js +3 -68
- package/es/ToggleButton/index.js +4 -5
- package/es/ToggleButton/props.js +1 -58
- package/lib/BaseButton/index.js +67 -43
- package/lib/BaseButton/props.js +2 -88
- package/lib/BaseButton/theme.js +1 -1
- package/lib/Button/index.js +2 -2
- package/lib/Button/props.js +3 -65
- package/lib/CloseButton/index.js +23 -18
- package/lib/CloseButton/props.js +2 -60
- package/lib/CondensedButton/index.js +2 -2
- package/lib/CondensedButton/props.js +3 -48
- package/lib/IconButton/index.js +2 -2
- package/lib/IconButton/props.js +3 -68
- package/lib/ToggleButton/index.js +4 -5
- package/lib/ToggleButton/props.js +1 -58
- package/package.json +21 -22
- package/src/BaseButton/index.tsx +35 -27
- package/src/BaseButton/props.ts +103 -72
- package/src/BaseButton/theme.ts +1 -6
- package/src/Button/index.tsx +4 -8
- package/src/Button/props.ts +74 -48
- package/src/CloseButton/index.tsx +4 -6
- package/src/CloseButton/props.ts +67 -41
- package/src/CondensedButton/index.tsx +3 -7
- package/src/CondensedButton/props.ts +56 -34
- package/src/IconButton/index.tsx +3 -7
- package/src/IconButton/props.ts +77 -50
- package/src/ToggleButton/index.tsx +8 -15
- package/src/ToggleButton/props.ts +65 -39
- package/tsconfig.build.json +25 -2
- package/tsconfig.build.tsbuildinfo +1 -0
- package/types/BaseButton/BaseButtonLocator.d.ts +57 -56
- package/types/BaseButton/BaseButtonLocator.d.ts.map +1 -1
- package/types/BaseButton/index.d.ts +16 -15
- package/types/BaseButton/index.d.ts.map +1 -1
- package/types/BaseButton/props.d.ts +76 -5
- package/types/BaseButton/props.d.ts.map +1 -1
- package/types/BaseButton/theme.d.ts.map +1 -1
- package/types/Button/ButtonLocator.d.ts +57 -56
- package/types/Button/ButtonLocator.d.ts.map +1 -1
- package/types/Button/index.d.ts +10 -7
- package/types/Button/index.d.ts.map +1 -1
- package/types/Button/locator.d.ts +52 -52
- package/types/Button/props.d.ts +57 -3
- package/types/Button/props.d.ts.map +1 -1
- package/types/CloseButton/CloseButtonLocator.d.ts +52 -52
- package/types/CloseButton/index.d.ts +4 -3
- package/types/CloseButton/index.d.ts.map +1 -1
- package/types/CloseButton/props.d.ts +55 -5
- package/types/CloseButton/props.d.ts.map +1 -1
- package/types/CondensedButton/CondensedButtonLocator.d.ts +57 -56
- package/types/CondensedButton/CondensedButtonLocator.d.ts.map +1 -1
- package/types/CondensedButton/index.d.ts +9 -6
- package/types/CondensedButton/index.d.ts.map +1 -1
- package/types/CondensedButton/props.d.ts +44 -3
- package/types/CondensedButton/props.d.ts.map +1 -1
- package/types/IconButton/IconButtonLocator.d.ts +57 -56
- package/types/IconButton/IconButtonLocator.d.ts.map +1 -1
- package/types/IconButton/index.d.ts +11 -8
- package/types/IconButton/index.d.ts.map +1 -1
- package/types/IconButton/props.d.ts +60 -4
- package/types/IconButton/props.d.ts.map +1 -1
- package/types/ToggleButton/ToggleButtonLocator.d.ts +57 -56
- package/types/ToggleButton/ToggleButtonLocator.d.ts.map +1 -1
- package/types/ToggleButton/index.d.ts +12 -13
- package/types/ToggleButton/index.d.ts.map +1 -1
- package/types/ToggleButton/props.d.ts +52 -4
- package/types/ToggleButton/props.d.ts.map +1 -1
- package/LICENSE.md +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [8.14.0](https://github.com/instructure/instructure-ui/compare/v8.13.0...v8.14.0) (2021-12-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-buttons
|
|
9
|
+
|
|
6
10
|
# [8.13.0](https://github.com/instructure/instructure-ui/compare/v8.12.0...v8.13.0) (2021-12-01)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @instructure/ui-buttons
|
package/es/BaseButton/index.js
CHANGED
|
@@ -28,8 +28,9 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
/** @jsx jsx */
|
|
31
|
-
import { Component } from 'react';
|
|
31
|
+
import React, { Component } from 'react';
|
|
32
32
|
import keycode from 'keycode';
|
|
33
|
+
import { warn } from '@instructure/console';
|
|
33
34
|
import { testable } from '@instructure/ui-testable';
|
|
34
35
|
import { getElementType, getInteraction, passthroughProps, callRenderProp } from '@instructure/ui-react-utils';
|
|
35
36
|
import { isActiveElement } from '@instructure/ui-dom-utils';
|
|
@@ -44,6 +45,7 @@ import { propTypes, allowedProps } from './props';
|
|
|
44
45
|
---
|
|
45
46
|
category: components/utilities
|
|
46
47
|
---
|
|
48
|
+
@tsProps
|
|
47
49
|
**/
|
|
48
50
|
let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class BaseButton extends Component {
|
|
49
51
|
constructor() {
|
|
@@ -80,7 +82,11 @@ let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
80
82
|
onKeyDown = _this$props.onKeyDown,
|
|
81
83
|
href = _this$props.href;
|
|
82
84
|
const interaction = this.interaction;
|
|
83
|
-
|
|
85
|
+
|
|
86
|
+
if (typeof onKeyDown === 'function') {
|
|
87
|
+
onKeyDown(event);
|
|
88
|
+
} // behave like a button when space key is pressed
|
|
89
|
+
|
|
84
90
|
|
|
85
91
|
const _keycode$codes = keycode.codes,
|
|
86
92
|
space = _keycode$codes.space,
|
|
@@ -102,11 +108,15 @@ let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
componentDidMount() {
|
|
105
|
-
|
|
111
|
+
var _this$props$makeStyle, _this$props2;
|
|
112
|
+
|
|
113
|
+
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2, this.makeStylesVariables);
|
|
106
114
|
}
|
|
107
115
|
|
|
108
|
-
componentDidUpdate(
|
|
109
|
-
|
|
116
|
+
componentDidUpdate() {
|
|
117
|
+
var _this$props$makeStyle2, _this$props3;
|
|
118
|
+
|
|
119
|
+
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3, this.makeStylesVariables);
|
|
110
120
|
}
|
|
111
121
|
|
|
112
122
|
get _rootElement() {
|
|
@@ -121,9 +131,9 @@ let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
121
131
|
}
|
|
122
132
|
|
|
123
133
|
get hasOnlyIconVisible() {
|
|
124
|
-
const _this$
|
|
125
|
-
children = _this$
|
|
126
|
-
renderIcon = _this$
|
|
134
|
+
const _this$props4 = this.props,
|
|
135
|
+
children = _this$props4.children,
|
|
136
|
+
renderIcon = _this$props4.renderIcon;
|
|
127
137
|
return !!(renderIcon && !hasVisibleChildren(children));
|
|
128
138
|
}
|
|
129
139
|
|
|
@@ -147,13 +157,25 @@ let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
147
157
|
|
|
148
158
|
get isEnabled() {
|
|
149
159
|
return this.interaction === 'enabled';
|
|
160
|
+
} // TODO: delete once the type of tabIndex is changed to number only
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
get tabIndex() {
|
|
164
|
+
const tabIndex = this.props.tabIndex;
|
|
165
|
+
|
|
166
|
+
if (typeof tabIndex === 'string') {
|
|
167
|
+
warn(false, 'The `string` value for `tabIndex` is deprecated. Only `number` type will be accepted from V9.0.0.');
|
|
168
|
+
return parseInt(tabIndex);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return tabIndex;
|
|
150
172
|
}
|
|
151
173
|
|
|
152
174
|
get focusColor() {
|
|
153
|
-
const _this$
|
|
154
|
-
color = _this$
|
|
155
|
-
focusColor = _this$
|
|
156
|
-
withBackground = _this$
|
|
175
|
+
const _this$props5 = this.props,
|
|
176
|
+
color = _this$props5.color,
|
|
177
|
+
focusColor = _this$props5.focusColor,
|
|
178
|
+
withBackground = _this$props5.withBackground; // Give user specified focusColor preference
|
|
157
179
|
|
|
158
180
|
if (focusColor) {
|
|
159
181
|
return focusColor;
|
|
@@ -179,10 +201,10 @@ let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
179
201
|
}
|
|
180
202
|
|
|
181
203
|
renderChildren() {
|
|
182
|
-
const _this$
|
|
183
|
-
renderIcon = _this$
|
|
184
|
-
children = _this$
|
|
185
|
-
styles = _this$
|
|
204
|
+
const _this$props6 = this.props,
|
|
205
|
+
renderIcon = _this$props6.renderIcon,
|
|
206
|
+
children = _this$props6.children,
|
|
207
|
+
styles = _this$props6.styles;
|
|
186
208
|
const wrappedChildren = jsx("span", {
|
|
187
209
|
css: styles === null || styles === void 0 ? void 0 : styles.children
|
|
188
210
|
}, children);
|
|
@@ -210,32 +232,33 @@ let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
210
232
|
}
|
|
211
233
|
|
|
212
234
|
render() {
|
|
213
|
-
const _this$
|
|
214
|
-
type = _this$
|
|
215
|
-
size = _this$
|
|
216
|
-
elementRef = _this$
|
|
217
|
-
as = _this$
|
|
218
|
-
href = _this$
|
|
219
|
-
color = _this$
|
|
220
|
-
focusColor = _this$
|
|
221
|
-
textAlign = _this$
|
|
222
|
-
shape = _this$
|
|
223
|
-
display = _this$
|
|
224
|
-
withBackground = _this$
|
|
225
|
-
withBorder = _this$
|
|
226
|
-
isCondensed = _this$
|
|
227
|
-
margin = _this$
|
|
228
|
-
cursor = _this$
|
|
229
|
-
onClick = _this$
|
|
230
|
-
renderIcon = _this$
|
|
231
|
-
tabIndex = _this$
|
|
232
|
-
styles = _this$
|
|
233
|
-
makeStyles = _this$
|
|
234
|
-
props = _objectWithoutProperties(_this$
|
|
235
|
+
const _this$props7 = this.props,
|
|
236
|
+
type = _this$props7.type,
|
|
237
|
+
size = _this$props7.size,
|
|
238
|
+
elementRef = _this$props7.elementRef,
|
|
239
|
+
as = _this$props7.as,
|
|
240
|
+
href = _this$props7.href,
|
|
241
|
+
color = _this$props7.color,
|
|
242
|
+
focusColor = _this$props7.focusColor,
|
|
243
|
+
textAlign = _this$props7.textAlign,
|
|
244
|
+
shape = _this$props7.shape,
|
|
245
|
+
display = _this$props7.display,
|
|
246
|
+
withBackground = _this$props7.withBackground,
|
|
247
|
+
withBorder = _this$props7.withBorder,
|
|
248
|
+
isCondensed = _this$props7.isCondensed,
|
|
249
|
+
margin = _this$props7.margin,
|
|
250
|
+
cursor = _this$props7.cursor,
|
|
251
|
+
onClick = _this$props7.onClick,
|
|
252
|
+
renderIcon = _this$props7.renderIcon,
|
|
253
|
+
tabIndex = _this$props7.tabIndex,
|
|
254
|
+
styles = _this$props7.styles,
|
|
255
|
+
makeStyles = _this$props7.makeStyles,
|
|
256
|
+
props = _objectWithoutProperties(_this$props7, _excluded);
|
|
235
257
|
|
|
236
258
|
const isDisabled = this.isDisabled,
|
|
237
259
|
isEnabled = this.isEnabled,
|
|
238
260
|
isReadOnly = this.isReadOnly;
|
|
261
|
+
const tabIndexNumber = this.tabIndex;
|
|
239
262
|
return jsx(View, Object.assign({}, passthroughProps(props), {
|
|
240
263
|
as: this.elementType,
|
|
241
264
|
focusColor: this.focusColor,
|
|
@@ -254,7 +277,7 @@ let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
254
277
|
onClick: this.handleClick,
|
|
255
278
|
onKeyDown: this.handleKeyDown,
|
|
256
279
|
role: onClick && as !== 'button' ? 'button' : void 0,
|
|
257
|
-
tabIndex: onClick && as ?
|
|
280
|
+
tabIndex: onClick && as ? tabIndexNumber || 0 : tabIndexNumber,
|
|
258
281
|
disabled: isDisabled || isReadOnly,
|
|
259
282
|
css: isEnabled ? styles === null || styles === void 0 ? void 0 : styles.baseButton : null
|
|
260
283
|
}), jsx("span", {
|
|
@@ -263,12 +286,11 @@ let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
263
286
|
}
|
|
264
287
|
|
|
265
288
|
}, _class2.displayName = "BaseButton", _class2.componentId = 'BaseButton', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
266
|
-
children: null,
|
|
267
289
|
type: 'button',
|
|
268
290
|
size: 'medium',
|
|
269
|
-
elementRef: el => {},
|
|
270
291
|
as: 'button',
|
|
271
292
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
293
|
+
interaction: void 0,
|
|
272
294
|
color: 'secondary',
|
|
273
295
|
shape: 'rectangle',
|
|
274
296
|
display: 'inline-block',
|
|
@@ -277,8 +299,7 @@ let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
277
299
|
withBorder: true,
|
|
278
300
|
isCondensed: false,
|
|
279
301
|
margin: '0',
|
|
280
|
-
cursor: 'pointer'
|
|
281
|
-
onKeyDown: event => {}
|
|
302
|
+
cursor: 'pointer'
|
|
282
303
|
}, _temp)) || _class) || _class);
|
|
283
304
|
export { BaseButton };
|
|
284
305
|
export default BaseButton;
|
package/es/BaseButton/props.js
CHANGED
|
@@ -24,114 +24,28 @@
|
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
26
26
|
const propTypes = {
|
|
27
|
-
/**
|
|
28
|
-
* Specifies the `Button` children.
|
|
29
|
-
*/
|
|
30
27
|
children: PropTypes.node,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Specifies the type of the `Button`'s underlying html element.
|
|
34
|
-
*/
|
|
35
28
|
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The size of the `Button`
|
|
39
|
-
*/
|
|
40
29
|
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Provides a reference to the `Button`'s underlying html element.
|
|
44
|
-
*/
|
|
45
30
|
elementRef: PropTypes.func,
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The element to render as the component root, `Button` by default.
|
|
49
|
-
*/
|
|
50
31
|
as: PropTypes.elementType,
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Specifies if interaction with the `Button` is enabled, disabled, or readonly.
|
|
54
|
-
*/
|
|
55
32
|
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Specifies the color for the `Button`.
|
|
59
|
-
*/
|
|
60
33
|
color: PropTypes.oneOf(['primary', 'primary-inverse', 'secondary', 'success', 'danger']),
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Override the `Button`'s default focus outline color.
|
|
64
|
-
*/
|
|
65
34
|
focusColor: PropTypes.oneOf(['info', 'inverse']),
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* The `Button` display property. When set to `inline-block`, the `Button` displays inline with other elements.
|
|
69
|
-
* When set to block, the `Button` expands to fill the width of the container.
|
|
70
|
-
*/
|
|
71
35
|
display: PropTypes.oneOf(['inline-block', 'block']),
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Sets the alignment of the `Button` children and/or icon.
|
|
75
|
-
*/
|
|
76
36
|
textAlign: PropTypes.oneOf(['start', 'center']),
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Specifies if the `Button` shape should be a circle or rectangle.
|
|
80
|
-
*/
|
|
81
37
|
shape: PropTypes.oneOf(['rectangle', 'circle']),
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Specifies if the `Button` should render with a solid background. When false, the background is transparent.
|
|
85
|
-
*/
|
|
86
38
|
withBackground: PropTypes.bool,
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Specifies if the `Button` should render with a border.
|
|
90
|
-
*/
|
|
91
39
|
withBorder: PropTypes.bool,
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Designates if the `Button` should render without padding. This option should only be set when `withBorder` and
|
|
95
|
-
* `withBackground` are also set to false.
|
|
96
|
-
*/
|
|
97
40
|
isCondensed: PropTypes.bool,
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
101
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
102
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
103
|
-
*/
|
|
104
41
|
margin: ThemeablePropTypes.spacing,
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Specify a mouse cursor to use when hovering over the button.
|
|
108
|
-
* The `pointer` cursor is used by default.
|
|
109
|
-
*/
|
|
110
42
|
cursor: PropTypes.string,
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Specifies an href attribute for the `Button`'s underlying html element.
|
|
114
|
-
*/
|
|
115
43
|
href: PropTypes.string,
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Callback fired when the `Button` is clicked.
|
|
119
|
-
*/
|
|
120
44
|
onClick: PropTypes.func,
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Callback fired when the `Button` receives a keydown event.
|
|
124
|
-
*/
|
|
125
45
|
onKeyDown: PropTypes.func,
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* An icon, or function that returns an icon.
|
|
129
|
-
*/
|
|
130
46
|
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
* Specifies the tabindex of the `Button`.
|
|
134
|
-
*/
|
|
47
|
+
// Deprecated `string` tabIndex type
|
|
48
|
+
// TODO: remove string type in v9
|
|
135
49
|
tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
136
50
|
};
|
|
137
51
|
const allowedProps = ['as', 'children', 'color', 'cursor', 'display', 'elementRef', 'focusColor', 'href', 'interaction', 'isCondensed', 'margin', 'onClick', 'onKeyDown', 'renderIcon', 'shape', 'size', 'tabIndex', 'textAlign', 'type', 'withBackground', 'withBorder'];
|
package/es/BaseButton/theme.js
CHANGED
|
@@ -38,7 +38,7 @@ const generateButtonThemeVars = _ref => {
|
|
|
38
38
|
[`${style}Background`]: backgroundColor,
|
|
39
39
|
[`${style}HoverBackground`]: darken(backgroundColor, 10),
|
|
40
40
|
[`${style}ActiveBackground`]: darken(backgroundColor, 10),
|
|
41
|
-
[`${style}ActiveBoxShadow`]: `${activeShadow} ${darken(borderColor, 20
|
|
41
|
+
[`${style}ActiveBoxShadow`]: `${activeShadow} ${darken(borderColor, 20)}`,
|
|
42
42
|
[`${style}GhostColor`]: ghostTextColor,
|
|
43
43
|
[`${style}GhostBorderColor`]: ghostBorderColor,
|
|
44
44
|
[`${style}GhostBackground`]: 'transparent',
|
package/es/Button/index.js
CHANGED
|
@@ -38,6 +38,7 @@ import { propTypes, allowedProps } from './props';
|
|
|
38
38
|
---
|
|
39
39
|
category: components
|
|
40
40
|
---
|
|
41
|
+
@tsProps
|
|
41
42
|
**/
|
|
42
43
|
// needed for listing the available theme variables on docs page
|
|
43
44
|
let Button = (_dec = withStyle(null, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class Button extends Component {
|
|
@@ -111,12 +112,11 @@ let Button = (_dec = withStyle(null, generateComponentTheme), _dec2 = testable()
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
}, _class2.displayName = "Button", _class2.componentId = 'Button', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
114
|
-
children: null,
|
|
115
115
|
type: 'button',
|
|
116
116
|
size: 'medium',
|
|
117
|
-
elementRef: el => {},
|
|
118
117
|
as: 'button',
|
|
119
118
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
119
|
+
interaction: void 0,
|
|
120
120
|
color: 'secondary',
|
|
121
121
|
display: 'inline-block',
|
|
122
122
|
textAlign: 'center',
|
package/es/Button/props.js
CHANGED
|
@@ -24,84 +24,22 @@
|
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
26
26
|
const propTypes = {
|
|
27
|
-
/**
|
|
28
|
-
* Specifies the `Button` children.
|
|
29
|
-
*/
|
|
30
27
|
children: PropTypes.node,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Specifies the type of the `Button`'s underlying html element.
|
|
34
|
-
*/
|
|
35
28
|
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The size of the `Button`
|
|
39
|
-
*/
|
|
40
29
|
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Provides a reference to the `Button`'s underlying html element.
|
|
44
|
-
*/
|
|
45
30
|
elementRef: PropTypes.func,
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The element to render as the component root, `Button` by default.
|
|
49
|
-
*/
|
|
50
31
|
as: PropTypes.elementType,
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Specifies if interaction with the `Button` is enabled, disabled, or readonly.
|
|
54
|
-
*/
|
|
55
32
|
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Specifies the color for the `Button`.
|
|
59
|
-
*/
|
|
60
33
|
color: PropTypes.oneOf(['primary', 'primary-inverse', 'secondary', 'success', 'danger']),
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Override the `Button`'s default focus outline color.
|
|
64
|
-
*/
|
|
65
34
|
focusColor: PropTypes.oneOf(['info', 'inverse']),
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* The `Button` display property. When set to `inline-block`, the `Button` displays inline with other elements.
|
|
69
|
-
* When set to block, the `Button` expands to fill the width of the container.
|
|
70
|
-
*/
|
|
71
35
|
display: PropTypes.oneOf(['inline-block', 'block']),
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Sets the alignment of the `Button` children and/or icon.
|
|
75
|
-
*/
|
|
76
36
|
textAlign: PropTypes.oneOf(['start', 'center']),
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Specifies if the `Button` should render with a solid background. When false, the background is transparent.
|
|
80
|
-
*/
|
|
81
37
|
withBackground: PropTypes.bool,
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
85
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
86
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
87
|
-
*/
|
|
88
38
|
margin: ThemeablePropTypes.spacing,
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Specify a mouse cursor to use when hovering over the button.
|
|
92
|
-
* The `pointer` cursor is used by default.
|
|
93
|
-
*/
|
|
94
39
|
cursor: PropTypes.string,
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Specifies an href attribute for the `Button`'s underlying html element.
|
|
98
|
-
*/
|
|
99
40
|
href: PropTypes.string,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
* An icon, or function that returns an icon.
|
|
103
|
-
*/
|
|
104
|
-
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
|
41
|
+
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
42
|
+
onClick: PropTypes.func
|
|
105
43
|
};
|
|
106
|
-
const allowedProps = ['as', 'children', 'color', 'cursor', 'display', 'elementRef', 'focusColor', 'href', 'interaction', 'margin', 'renderIcon', 'size', 'textAlign', 'type', 'withBackground'];
|
|
44
|
+
const allowedProps = ['as', 'children', 'color', 'cursor', 'display', 'elementRef', 'focusColor', 'href', 'interaction', 'margin', 'renderIcon', 'size', 'textAlign', 'type', 'withBackground', 'onClick'];
|
|
107
45
|
export { propTypes, allowedProps };
|
package/es/CloseButton/index.js
CHANGED
|
@@ -43,6 +43,7 @@ import { propTypes, allowedProps } from './props';
|
|
|
43
43
|
---
|
|
44
44
|
category: components
|
|
45
45
|
---
|
|
46
|
+
@tsProps
|
|
46
47
|
**/
|
|
47
48
|
let CloseButton = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class CloseButton extends Component {
|
|
48
49
|
constructor() {
|
|
@@ -60,11 +61,15 @@ let CloseButton = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
componentDidMount() {
|
|
63
|
-
|
|
64
|
+
var _this$props$makeStyle, _this$props;
|
|
65
|
+
|
|
66
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
componentDidUpdate() {
|
|
67
|
-
|
|
70
|
+
var _this$props$makeStyle2, _this$props2;
|
|
71
|
+
|
|
72
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
get interaction() {
|
|
@@ -79,21 +84,21 @@ let CloseButton = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
render() {
|
|
82
|
-
const _this$
|
|
83
|
-
screenReaderLabel = _this$
|
|
84
|
-
elementRef = _this$
|
|
85
|
-
size = _this$
|
|
86
|
-
onClick = _this$
|
|
87
|
-
margin = _this$
|
|
88
|
-
placement = _this$
|
|
89
|
-
offset = _this$
|
|
90
|
-
type = _this$
|
|
91
|
-
as = _this$
|
|
92
|
-
href = _this$
|
|
93
|
-
cursor = _this$
|
|
94
|
-
tabIndex = _this$
|
|
95
|
-
styles = _this$
|
|
96
|
-
props = _objectWithoutProperties(_this$
|
|
87
|
+
const _this$props3 = this.props,
|
|
88
|
+
screenReaderLabel = _this$props3.screenReaderLabel,
|
|
89
|
+
elementRef = _this$props3.elementRef,
|
|
90
|
+
size = _this$props3.size,
|
|
91
|
+
onClick = _this$props3.onClick,
|
|
92
|
+
margin = _this$props3.margin,
|
|
93
|
+
placement = _this$props3.placement,
|
|
94
|
+
offset = _this$props3.offset,
|
|
95
|
+
type = _this$props3.type,
|
|
96
|
+
as = _this$props3.as,
|
|
97
|
+
href = _this$props3.href,
|
|
98
|
+
cursor = _this$props3.cursor,
|
|
99
|
+
tabIndex = _this$props3.tabIndex,
|
|
100
|
+
styles = _this$props3.styles,
|
|
101
|
+
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
97
102
|
|
|
98
103
|
return jsx("span", Object.assign({}, passthroughProps(props), {
|
|
99
104
|
css: styles === null || styles === void 0 ? void 0 : styles.closeButton
|
|
@@ -116,8 +121,8 @@ let CloseButton = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
}, _class2.displayName = "CloseButton", _class2.componentId = 'CloseButton', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
119
|
-
onClick: event => {},
|
|
120
124
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
125
|
+
interaction: void 0,
|
|
121
126
|
type: 'button',
|
|
122
127
|
placement: 'static',
|
|
123
128
|
offset: 'x-small',
|
package/es/CloseButton/props.js
CHANGED
|
@@ -24,79 +24,21 @@
|
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
26
26
|
const propTypes = {
|
|
27
|
-
/**
|
|
28
|
-
* An accessible label for the `CloseButton` (required)
|
|
29
|
-
*/
|
|
30
27
|
screenReaderLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Specifies the color for the `CloseButton`.
|
|
34
|
-
*/
|
|
35
28
|
color: PropTypes.oneOf(['primary', 'primary-inverse']),
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Specifies if interaction with the `CloseButton` is enabled, disabled, or readonly.
|
|
39
|
-
*/
|
|
40
29
|
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Provides a reference to the `CloseButton`'s underlying html element.
|
|
44
|
-
*/
|
|
45
30
|
elementRef: PropTypes.func,
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The size of the `CloseButton`
|
|
49
|
-
*/
|
|
50
31
|
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Callback fired when the `CloseButton` is clicked.
|
|
54
|
-
*/
|
|
55
32
|
onClick: PropTypes.func,
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
59
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
60
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
61
|
-
*/
|
|
62
33
|
margin: ThemeablePropTypes.spacing,
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Specifies the placement of the `CloseButton`
|
|
66
|
-
*/
|
|
67
34
|
placement: PropTypes.oneOf(['start', 'end', 'static']),
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Specifies the offset distance for the `CloseButton` with respect to both the top and start/end of the container.
|
|
71
|
-
* Note that for this property to have an effect, the `placement` prop must be set to either `start` or `end`. The
|
|
72
|
-
* offset will also be created with respect to a positioned parent. If it does not appear to be working, try setting
|
|
73
|
-
* the `position` of the parent container to `relative`.
|
|
74
|
-
*/
|
|
75
35
|
offset: PropTypes.oneOf(['none', 'x-small', 'small', 'medium']),
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Specifies the type of the `Button`'s underlying html element.
|
|
79
|
-
*/
|
|
80
36
|
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* The element to render as the component root, `CloseButton` by default.
|
|
84
|
-
*/
|
|
85
37
|
as: PropTypes.elementType,
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Specifies an href attribute for the `CloseButton`'s underlying html element.
|
|
89
|
-
*/
|
|
90
38
|
href: PropTypes.string,
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Specify a mouse cursor to use when hovering over the `CloseButton`.
|
|
94
|
-
*/
|
|
95
39
|
cursor: PropTypes.string,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
* Specifies the tabindex of the `CloseButton`.
|
|
99
|
-
*/
|
|
40
|
+
// Deprecated `string` tabIndex type
|
|
41
|
+
// TODO: remove string type in v9
|
|
100
42
|
tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
101
43
|
};
|
|
102
44
|
const allowedProps = ['as', 'color', 'cursor', 'elementRef', 'href', 'interaction', 'margin', 'offset', 'onClick', 'placement', 'screenReaderLabel', 'size', 'tabIndex', 'type'];
|
|
@@ -38,6 +38,7 @@ import { propTypes, allowedProps } from './props';
|
|
|
38
38
|
---
|
|
39
39
|
category: components
|
|
40
40
|
---
|
|
41
|
+
@tsProps
|
|
41
42
|
**/
|
|
42
43
|
// needed for listing the available theme variables on docs page
|
|
43
44
|
let CondensedButton = (_dec = withStyle(null, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class CondensedButton extends Component {
|
|
@@ -102,12 +103,11 @@ let CondensedButton = (_dec = withStyle(null, generateComponentTheme), _dec2 = t
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
}, _class2.displayName = "CondensedButton", _class2.componentId = 'CondensedButton', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
105
|
-
children: null,
|
|
106
106
|
type: 'button',
|
|
107
107
|
size: 'medium',
|
|
108
|
-
elementRef: el => {},
|
|
109
108
|
as: 'button',
|
|
110
109
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
110
|
+
interaction: void 0,
|
|
111
111
|
color: 'primary',
|
|
112
112
|
margin: '0',
|
|
113
113
|
cursor: 'pointer'
|