@instructure/ui-buttons 8.8.1-snapshot.3 → 8.8.1-snapshot.63
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/es/BaseButton/index.js +14 -135
- 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 +14 -135
- 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 +18 -123
- 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 +63 -117
- package/types/BaseButton/index.d.ts.map +1 -1
- package/types/BaseButton/{types.d.ts → props.d.ts} +14 -8
- 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 -57
- 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
package/es/BaseButton/index.js
CHANGED
|
@@ -29,16 +29,16 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
29
29
|
|
|
30
30
|
/** @jsx jsx */
|
|
31
31
|
import { Component } from 'react';
|
|
32
|
-
import PropTypes from 'prop-types';
|
|
33
32
|
import keycode from 'keycode';
|
|
34
33
|
import { testable } from '@instructure/ui-testable';
|
|
35
34
|
import { getElementType, getInteraction, passthroughProps, callRenderProp } from '@instructure/ui-react-utils';
|
|
36
35
|
import { isActiveElement } from '@instructure/ui-dom-utils';
|
|
37
36
|
import { hasVisibleChildren } from '@instructure/ui-a11y-utils';
|
|
38
37
|
import { View } from '@instructure/ui-view';
|
|
39
|
-
import { withStyle, jsx
|
|
38
|
+
import { withStyle, jsx } from '@instructure/emotion';
|
|
40
39
|
import generateStyles from './styles';
|
|
41
40
|
import generateComponentTheme from './theme';
|
|
41
|
+
import { propTypes, allowedProps } from './props';
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
---
|
|
@@ -176,7 +176,7 @@ let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
176
176
|
children = _this$props4.children,
|
|
177
177
|
styles = _this$props4.styles;
|
|
178
178
|
const wrappedChildren = jsx("span", {
|
|
179
|
-
css: styles.children
|
|
179
|
+
css: styles === null || styles === void 0 ? void 0 : styles.children
|
|
180
180
|
}, children);
|
|
181
181
|
|
|
182
182
|
if (!renderIcon) {
|
|
@@ -185,19 +185,19 @@ let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
185
185
|
|
|
186
186
|
const hasOnlyIconVisible = this.hasOnlyIconVisible;
|
|
187
187
|
const wrappedIcon = jsx("span", {
|
|
188
|
-
css: styles.iconSVG
|
|
188
|
+
css: styles === null || styles === void 0 ? void 0 : styles.iconSVG
|
|
189
189
|
}, callRenderProp(renderIcon));
|
|
190
190
|
const flexChildren = hasOnlyIconVisible ? jsx("span", {
|
|
191
|
-
css: styles.iconOnly
|
|
191
|
+
css: styles === null || styles === void 0 ? void 0 : styles.iconOnly
|
|
192
192
|
}, wrappedIcon, children) : [jsx("span", {
|
|
193
193
|
key: "icon",
|
|
194
|
-
css: styles.iconWrapper
|
|
194
|
+
css: styles === null || styles === void 0 ? void 0 : styles.iconWrapper
|
|
195
195
|
}, wrappedIcon), jsx("span", {
|
|
196
196
|
key: "children",
|
|
197
|
-
css: styles.childrenWrapper
|
|
197
|
+
css: styles === null || styles === void 0 ? void 0 : styles.childrenWrapper
|
|
198
198
|
}, wrappedChildren)];
|
|
199
199
|
return jsx("span", {
|
|
200
|
-
css: styles.childrenLayout
|
|
200
|
+
css: styles === null || styles === void 0 ? void 0 : styles.childrenLayout
|
|
201
201
|
}, flexChildren);
|
|
202
202
|
}
|
|
203
203
|
|
|
@@ -241,144 +241,27 @@ let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
241
241
|
margin: margin,
|
|
242
242
|
cursor: isDisabled ? 'not-allowed' : cursor,
|
|
243
243
|
href: href,
|
|
244
|
-
type: href ?
|
|
244
|
+
type: href ? void 0 : type,
|
|
245
245
|
elementRef: this.handleElementRef,
|
|
246
246
|
onClick: this.handleClick,
|
|
247
247
|
onKeyDown: this.handleKeyDown,
|
|
248
|
-
role: onClick && as !== 'button' ? 'button' :
|
|
248
|
+
role: onClick && as !== 'button' ? 'button' : void 0,
|
|
249
249
|
tabIndex: onClick && as ? tabIndex || '0' : tabIndex,
|
|
250
250
|
disabled: isDisabled || isReadOnly,
|
|
251
|
-
css: isEnabled ? styles.baseButton : null
|
|
251
|
+
css: isEnabled ? styles === null || styles === void 0 ? void 0 : styles.baseButton : null
|
|
252
252
|
}), jsx("span", {
|
|
253
|
-
css: styles.content
|
|
253
|
+
css: styles === null || styles === void 0 ? void 0 : styles.content
|
|
254
254
|
}, this.renderChildren()));
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
}, _class2.displayName = "BaseButton", _class2.componentId = 'BaseButton', _class2.propTypes = {
|
|
258
|
-
// eslint-disable-next-line react/require-default-props
|
|
259
|
-
makeStyles: PropTypes.func,
|
|
260
|
-
// eslint-disable-next-line react/require-default-props
|
|
261
|
-
styles: PropTypes.object,
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Specifies the `Button` children.
|
|
265
|
-
*/
|
|
266
|
-
children: PropTypes.node,
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Specifies the type of the `Button`'s underlying html element.
|
|
270
|
-
*/
|
|
271
|
-
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* The size of the `Button`
|
|
275
|
-
*/
|
|
276
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Provides a reference to the `Button`'s underlying html element.
|
|
280
|
-
*/
|
|
281
|
-
elementRef: PropTypes.func,
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* The element to render as the component root, `Button` by default.
|
|
285
|
-
*/
|
|
286
|
-
as: PropTypes.elementType,
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Specifies if interaction with the `Button` is enabled, disabled, or readonly.
|
|
290
|
-
*/
|
|
291
|
-
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Specifies the color for the `Button`.
|
|
295
|
-
*/
|
|
296
|
-
color: PropTypes.oneOf(['primary', 'primary-inverse', 'secondary', 'success', 'danger']),
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Override the `Button`'s default focus outline color.
|
|
300
|
-
*/
|
|
301
|
-
focusColor: PropTypes.oneOf(['info', 'inverse']),
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* The `Button` display property. When set to `inline-block`, the `Button` displays inline with other elements.
|
|
305
|
-
* When set to block, the `Button` expands to fill the width of the container.
|
|
306
|
-
*/
|
|
307
|
-
display: PropTypes.oneOf(['inline-block', 'block']),
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Sets the alignment of the `Button` children and/or icon.
|
|
311
|
-
*/
|
|
312
|
-
textAlign: PropTypes.oneOf(['start', 'center']),
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Specifies if the `Button` shape should be a circle or rectangle.
|
|
316
|
-
*/
|
|
317
|
-
shape: PropTypes.oneOf(['rectangle', 'circle']),
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Specifies if the `Button` should render with a solid background. When false, the background is transparent.
|
|
321
|
-
*/
|
|
322
|
-
withBackground: PropTypes.bool,
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Specifies if the `Button` should render with a border.
|
|
326
|
-
*/
|
|
327
|
-
withBorder: PropTypes.bool,
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Designates if the `Button` should render without padding. This option should only be set when `withBorder` and
|
|
331
|
-
* `withBackground` are also set to false.
|
|
332
|
-
*/
|
|
333
|
-
isCondensed: PropTypes.bool,
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
337
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
338
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
339
|
-
*/
|
|
340
|
-
margin: ThemeablePropTypes.spacing,
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Specify a mouse cursor to use when hovering over the button.
|
|
344
|
-
* The `pointer` cursor is used by default.
|
|
345
|
-
*/
|
|
346
|
-
cursor: PropTypes.string,
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Specifies an href attribute for the `Button`'s underlying html element.
|
|
350
|
-
*/
|
|
351
|
-
href: PropTypes.string,
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Callback fired when the `Button` is clicked.
|
|
355
|
-
*/
|
|
356
|
-
onClick: PropTypes.func,
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Callback fired when the `Button` receives a keydown event.
|
|
360
|
-
*/
|
|
361
|
-
onKeyDown: PropTypes.func,
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* An icon, or function that returns an icon.
|
|
365
|
-
*/
|
|
366
|
-
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Specifies the tabindex of the `Button`.
|
|
370
|
-
*/
|
|
371
|
-
tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
372
|
-
}, _class2.defaultProps = {
|
|
257
|
+
}, _class2.displayName = "BaseButton", _class2.componentId = 'BaseButton', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
373
258
|
children: null,
|
|
374
259
|
type: 'button',
|
|
375
260
|
size: 'medium',
|
|
376
261
|
elementRef: el => {},
|
|
377
262
|
as: 'button',
|
|
378
263
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
379
|
-
interaction: void 0,
|
|
380
264
|
color: 'secondary',
|
|
381
|
-
focusColor: void 0,
|
|
382
265
|
shape: 'rectangle',
|
|
383
266
|
display: 'inline-block',
|
|
384
267
|
textAlign: 'start',
|
|
@@ -387,11 +270,7 @@ let BaseButton = (_dec = withStyle(generateStyles, generateComponentTheme), _dec
|
|
|
387
270
|
isCondensed: false,
|
|
388
271
|
margin: '0',
|
|
389
272
|
cursor: 'pointer',
|
|
390
|
-
|
|
391
|
-
onClick: void 0,
|
|
392
|
-
onKeyDown: event => {},
|
|
393
|
-
renderIcon: void 0,
|
|
394
|
-
tabIndex: void 0
|
|
273
|
+
onKeyDown: event => {}
|
|
395
274
|
}, _temp)) || _class) || _class);
|
|
396
275
|
export { BaseButton };
|
|
397
276
|
export default BaseButton;
|
|
@@ -0,0 +1,138 @@
|
|
|
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
|
+
import PropTypes from 'prop-types';
|
|
25
|
+
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
26
|
+
const propTypes = {
|
|
27
|
+
/**
|
|
28
|
+
* Specifies the `Button` children.
|
|
29
|
+
*/
|
|
30
|
+
children: PropTypes.node,
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Specifies the type of the `Button`'s underlying html element.
|
|
34
|
+
*/
|
|
35
|
+
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The size of the `Button`
|
|
39
|
+
*/
|
|
40
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Provides a reference to the `Button`'s underlying html element.
|
|
44
|
+
*/
|
|
45
|
+
elementRef: PropTypes.func,
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The element to render as the component root, `Button` by default.
|
|
49
|
+
*/
|
|
50
|
+
as: PropTypes.elementType,
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Specifies if interaction with the `Button` is enabled, disabled, or readonly.
|
|
54
|
+
*/
|
|
55
|
+
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Specifies the color for the `Button`.
|
|
59
|
+
*/
|
|
60
|
+
color: PropTypes.oneOf(['primary', 'primary-inverse', 'secondary', 'success', 'danger']),
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Override the `Button`'s default focus outline color.
|
|
64
|
+
*/
|
|
65
|
+
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
|
+
display: PropTypes.oneOf(['inline-block', 'block']),
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Sets the alignment of the `Button` children and/or icon.
|
|
75
|
+
*/
|
|
76
|
+
textAlign: PropTypes.oneOf(['start', 'center']),
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Specifies if the `Button` shape should be a circle or rectangle.
|
|
80
|
+
*/
|
|
81
|
+
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
|
+
withBackground: PropTypes.bool,
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Specifies if the `Button` should render with a border.
|
|
90
|
+
*/
|
|
91
|
+
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
|
+
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
|
+
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
|
+
cursor: PropTypes.string,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Specifies an href attribute for the `Button`'s underlying html element.
|
|
114
|
+
*/
|
|
115
|
+
href: PropTypes.string,
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Callback fired when the `Button` is clicked.
|
|
119
|
+
*/
|
|
120
|
+
onClick: PropTypes.func,
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Callback fired when the `Button` receives a keydown event.
|
|
124
|
+
*/
|
|
125
|
+
onKeyDown: PropTypes.func,
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* An icon, or function that returns an icon.
|
|
129
|
+
*/
|
|
130
|
+
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Specifies the tabindex of the `Button`.
|
|
134
|
+
*/
|
|
135
|
+
tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
136
|
+
};
|
|
137
|
+
const allowedProps = ['as', 'children', 'color', 'cursor', 'display', 'elementRef', 'focusColor', 'href', 'interaction', 'isCondensed', 'margin', 'onClick', 'onKeyDown', 'renderIcon', 'shape', 'size', 'tabIndex', 'textAlign', 'type', 'withBackground', 'withBorder'];
|
|
138
|
+
export { propTypes, allowedProps };
|
package/es/Button/index.js
CHANGED
|
@@ -27,12 +27,12 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
27
27
|
* SOFTWARE.
|
|
28
28
|
*/
|
|
29
29
|
import React, { Component } from 'react';
|
|
30
|
-
import PropTypes from 'prop-types';
|
|
31
30
|
import { testable } from '@instructure/ui-testable';
|
|
32
31
|
import { getInteraction, passthroughProps } from '@instructure/ui-react-utils';
|
|
33
|
-
import { withStyle
|
|
32
|
+
import { withStyle } from '@instructure/emotion';
|
|
34
33
|
import generateComponentTheme from './theme';
|
|
35
34
|
import { BaseButton } from '../BaseButton';
|
|
35
|
+
import { propTypes, allowedProps } from './props';
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
---
|
|
@@ -106,102 +106,19 @@ let Button = (_dec = withStyle(null, generateComponentTheme), _dec2 = testable()
|
|
|
106
106
|
return /*#__PURE__*/React.createElement(BaseButton, buttonProps, children);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
}, _class2.displayName = "Button", _class2.componentId = 'Button', _class2.propTypes = {
|
|
110
|
-
/**
|
|
111
|
-
* Specifies the `Button` children.
|
|
112
|
-
*/
|
|
113
|
-
children: PropTypes.node,
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Specifies the type of the `Button`'s underlying html element.
|
|
117
|
-
*/
|
|
118
|
-
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* The size of the `Button`
|
|
122
|
-
*/
|
|
123
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Provides a reference to the `Button`'s underlying html element.
|
|
127
|
-
*/
|
|
128
|
-
elementRef: PropTypes.func,
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* The element to render as the component root, `Button` by default.
|
|
132
|
-
*/
|
|
133
|
-
as: PropTypes.elementType,
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Specifies if interaction with the `Button` is enabled, disabled, or readonly.
|
|
137
|
-
*/
|
|
138
|
-
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Specifies the color for the `Button`.
|
|
142
|
-
*/
|
|
143
|
-
color: PropTypes.oneOf(['primary', 'primary-inverse', 'secondary', 'success', 'danger']),
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Override the `Button`'s default focus outline color.
|
|
147
|
-
*/
|
|
148
|
-
focusColor: PropTypes.oneOf(['info', 'inverse']),
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* The `Button` display property. When set to `inline-block`, the `Button` displays inline with other elements.
|
|
152
|
-
* When set to block, the `Button` expands to fill the width of the container.
|
|
153
|
-
*/
|
|
154
|
-
display: PropTypes.oneOf(['inline-block', 'block']),
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Sets the alignment of the `Button` children and/or icon.
|
|
158
|
-
*/
|
|
159
|
-
textAlign: PropTypes.oneOf(['start', 'center']),
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Specifies if the `Button` should render with a solid background. When false, the background is transparent.
|
|
163
|
-
*/
|
|
164
|
-
withBackground: PropTypes.bool,
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
168
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
169
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
170
|
-
*/
|
|
171
|
-
margin: ThemeablePropTypes.spacing,
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Specify a mouse cursor to use when hovering over the button.
|
|
175
|
-
* The `pointer` cursor is used by default.
|
|
176
|
-
*/
|
|
177
|
-
cursor: PropTypes.string,
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Specifies an href attribute for the `Button`'s underlying html element.
|
|
181
|
-
*/
|
|
182
|
-
href: PropTypes.string,
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* An icon, or function that returns an icon.
|
|
186
|
-
*/
|
|
187
|
-
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
|
188
|
-
}, _class2.defaultProps = {
|
|
109
|
+
}, _class2.displayName = "Button", _class2.componentId = 'Button', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
189
110
|
children: null,
|
|
190
111
|
type: 'button',
|
|
191
112
|
size: 'medium',
|
|
192
113
|
elementRef: el => {},
|
|
193
114
|
as: 'button',
|
|
194
115
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
195
|
-
interaction: void 0,
|
|
196
116
|
color: 'secondary',
|
|
197
|
-
focusColor: void 0,
|
|
198
117
|
display: 'inline-block',
|
|
199
118
|
textAlign: 'center',
|
|
200
119
|
withBackground: true,
|
|
201
120
|
margin: '0',
|
|
202
|
-
cursor: 'pointer'
|
|
203
|
-
href: void 0,
|
|
204
|
-
renderIcon: void 0
|
|
121
|
+
cursor: 'pointer'
|
|
205
122
|
}, _temp)) || _class) || _class);
|
|
206
123
|
export default Button;
|
|
207
124
|
export { Button };
|