@instructure/ui-buttons 10.26.1-snapshot-2 → 10.26.1
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 +1 -24
- package/es/BaseButton/index.js +6 -9
- package/es/BaseButton/props.js +26 -1
- package/es/Button/index.js +6 -6
- package/es/Button/props.js +20 -1
- package/es/CloseButton/index.js +8 -12
- package/es/CloseButton/props.js +18 -1
- package/es/CondensedButton/index.js +6 -6
- package/es/CondensedButton/props.js +17 -1
- package/es/IconButton/index.js +6 -7
- package/es/IconButton/props.js +21 -1
- package/es/ToggleButton/index.js +6 -10
- package/es/ToggleButton/props.js +19 -1
- package/lib/BaseButton/index.js +5 -8
- package/lib/BaseButton/props.js +27 -1
- package/lib/Button/index.js +5 -5
- package/lib/Button/props.js +21 -1
- package/lib/CloseButton/index.js +7 -11
- package/lib/CloseButton/props.js +19 -1
- package/lib/CondensedButton/index.js +5 -5
- package/lib/CondensedButton/props.js +18 -1
- package/lib/IconButton/index.js +5 -6
- package/lib/IconButton/props.js +22 -1
- package/lib/ToggleButton/index.js +5 -10
- package/lib/ToggleButton/props.js +20 -1
- package/package.json +23 -20
- package/src/BaseButton/index.tsx +4 -7
- package/src/BaseButton/props.ts +40 -3
- package/src/Button/index.tsx +5 -6
- package/src/Button/props.ts +33 -2
- package/src/CloseButton/index.tsx +6 -6
- package/src/CloseButton/props.ts +25 -3
- package/src/CondensedButton/index.tsx +4 -2
- package/src/CondensedButton/props.ts +22 -3
- package/src/IconButton/index.tsx +4 -3
- package/src/IconButton/props.ts +33 -2
- package/src/ToggleButton/index.tsx +5 -2
- package/src/ToggleButton/props.ts +31 -2
- package/tsconfig.build.json +2 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/BaseButton/index.d.ts +2 -1
- package/types/BaseButton/index.d.ts.map +1 -1
- package/types/BaseButton/props.d.ts +4 -3
- package/types/BaseButton/props.d.ts.map +1 -1
- package/types/Button/index.d.ts +19 -1
- package/types/Button/index.d.ts.map +1 -1
- package/types/Button/props.d.ts +4 -3
- package/types/Button/props.d.ts.map +1 -1
- package/types/CloseButton/index.d.ts +17 -1
- package/types/CloseButton/index.d.ts.map +1 -1
- package/types/CloseButton/props.d.ts +4 -3
- package/types/CloseButton/props.d.ts.map +1 -1
- package/types/CondensedButton/index.d.ts +16 -1
- package/types/CondensedButton/index.d.ts.map +1 -1
- package/types/CondensedButton/props.d.ts +4 -3
- package/types/CondensedButton/props.d.ts.map +1 -1
- package/types/IconButton/index.d.ts +20 -1
- package/types/IconButton/index.d.ts.map +1 -1
- package/types/IconButton/props.d.ts +4 -3
- package/types/IconButton/props.d.ts.map +1 -1
- package/types/ToggleButton/index.d.ts +16 -0
- package/types/ToggleButton/index.d.ts.map +1 -1
- package/types/ToggleButton/props.d.ts +3 -2
- package/types/ToggleButton/props.d.ts.map +1 -1
package/lib/Button/index.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = exports.Button = void 0;
|
|
8
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
9
|
var _react = require("react");
|
|
10
|
+
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
10
11
|
var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
|
|
11
12
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
12
13
|
var _emotion = require("@instructure/emotion");
|
|
@@ -15,7 +16,7 @@ var _BaseButton = require("../BaseButton");
|
|
|
15
16
|
var _props = require("./props");
|
|
16
17
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
17
18
|
const _excluded = ["children", "type", "size", "as", "color", "focusColor", "display", "textAlign", "withBackground", "margin", "cursor", "href", "renderIcon"];
|
|
18
|
-
var _dec, _class, _Button;
|
|
19
|
+
var _dec, _dec2, _class, _Button;
|
|
19
20
|
/*
|
|
20
21
|
* The MIT License (MIT)
|
|
21
22
|
*
|
|
@@ -45,7 +46,7 @@ category: components
|
|
|
45
46
|
---
|
|
46
47
|
**/
|
|
47
48
|
// needed for listing the available theme variables on docs page
|
|
48
|
-
let Button = exports.Button = (_dec = (0, _emotion.withStyle)(null, _theme.default), _dec(_class = (_Button = class Button extends _react.Component {
|
|
49
|
+
let Button = exports.Button = (_dec = (0, _emotion.withStyle)(null, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_Button = class Button extends _react.Component {
|
|
49
50
|
constructor(...args) {
|
|
50
51
|
super(...args);
|
|
51
52
|
this._buttonComponent = null;
|
|
@@ -108,11 +109,10 @@ let Button = exports.Button = (_dec = (0, _emotion.withStyle)(null, _theme.defau
|
|
|
108
109
|
};
|
|
109
110
|
return (0, _jsxRuntime.jsx)(_BaseButton.BaseButton, {
|
|
110
111
|
...buttonProps,
|
|
111
|
-
"data-cid": "Button",
|
|
112
112
|
children: children
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
}, _Button.displayName = "Button", _Button.componentId = 'Button', _Button.allowedProps = _props.allowedProps, _Button.defaultProps = {
|
|
115
|
+
}, _Button.displayName = "Button", _Button.componentId = 'Button', _Button.propTypes = _props.propTypes, _Button.allowedProps = _props.allowedProps, _Button.defaultProps = {
|
|
116
116
|
type: 'button',
|
|
117
117
|
size: 'medium',
|
|
118
118
|
as: 'button',
|
|
@@ -124,5 +124,5 @@ let Button = exports.Button = (_dec = (0, _emotion.withStyle)(null, _theme.defau
|
|
|
124
124
|
withBackground: true,
|
|
125
125
|
margin: '0',
|
|
126
126
|
cursor: 'pointer'
|
|
127
|
-
}, _Button)) || _class);
|
|
127
|
+
}, _Button)) || _class) || _class);
|
|
128
128
|
var _default = exports.default = Button;
|
package/lib/Button/props.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
|
+
exports.propTypes = exports.allowedProps = void 0;
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
9
|
/*
|
|
8
10
|
* The MIT License (MIT)
|
|
9
11
|
*
|
|
@@ -28,4 +30,22 @@ exports.allowedProps = void 0;
|
|
|
28
30
|
* SOFTWARE.
|
|
29
31
|
*/
|
|
30
32
|
|
|
33
|
+
const propTypes = exports.propTypes = {
|
|
34
|
+
children: _propTypes.default.node,
|
|
35
|
+
type: _propTypes.default.oneOf(['button', 'submit', 'reset']),
|
|
36
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
37
|
+
elementRef: _propTypes.default.func,
|
|
38
|
+
as: _propTypes.default.elementType,
|
|
39
|
+
interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
|
|
40
|
+
color: _propTypes.default.oneOf(['primary', 'primary-inverse', 'secondary', 'success', 'danger', 'ai-primary', 'ai-secondary']),
|
|
41
|
+
focusColor: _propTypes.default.oneOf(['info', 'inverse']),
|
|
42
|
+
display: _propTypes.default.oneOf(['inline-block', 'block']),
|
|
43
|
+
textAlign: _propTypes.default.oneOf(['start', 'center']),
|
|
44
|
+
withBackground: _propTypes.default.bool,
|
|
45
|
+
margin: _propTypes.default.string,
|
|
46
|
+
cursor: _propTypes.default.string,
|
|
47
|
+
href: _propTypes.default.string,
|
|
48
|
+
renderIcon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
49
|
+
onClick: _propTypes.default.func
|
|
50
|
+
};
|
|
31
51
|
const allowedProps = exports.allowedProps = ['as', 'children', 'color', 'cursor', 'display', 'elementRef', 'focusColor', 'href', 'interaction', 'margin', 'renderIcon', 'size', 'textAlign', 'type', 'withBackground', 'onClick'];
|
package/lib/CloseButton/index.js
CHANGED
|
@@ -9,6 +9,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _IconXSolid = require("@instructure/ui-icons/lib/IconXSolid.js");
|
|
11
11
|
var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
|
|
12
|
+
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
12
13
|
var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
|
|
13
14
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
14
15
|
var _emotion = require("@instructure/emotion");
|
|
@@ -18,7 +19,7 @@ var _BaseButton = require("../BaseButton");
|
|
|
18
19
|
var _props = require("./props");
|
|
19
20
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
20
21
|
const _excluded = ["screenReaderLabel", "elementRef", "size", "onClick", "margin", "placement", "offset", "type", "as", "href", "cursor", "tabIndex", "styles"];
|
|
21
|
-
var _dec, _class, _CloseButton;
|
|
22
|
+
var _dec, _dec2, _class, _CloseButton;
|
|
22
23
|
/*
|
|
23
24
|
* The MIT License (MIT)
|
|
24
25
|
*
|
|
@@ -47,7 +48,7 @@ var _dec, _class, _CloseButton;
|
|
|
47
48
|
category: components
|
|
48
49
|
---
|
|
49
50
|
**/
|
|
50
|
-
let CloseButton = exports.CloseButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_CloseButton = class CloseButton extends _react.Component {
|
|
51
|
+
let CloseButton = exports.CloseButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_CloseButton = class CloseButton extends _react.Component {
|
|
51
52
|
constructor(...args) {
|
|
52
53
|
super(...args);
|
|
53
54
|
this.ref = null;
|
|
@@ -94,17 +95,13 @@ let CloseButton = exports.CloseButton = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
94
95
|
return (0, _jsxRuntime.jsx)("span", {
|
|
95
96
|
...(0, _passthroughProps.passthroughProps)(props),
|
|
96
97
|
css: styles === null || styles === void 0 ? void 0 : styles.closeButton,
|
|
97
|
-
ref: el =>
|
|
98
|
-
this.ref = el;
|
|
99
|
-
},
|
|
98
|
+
ref: el => this.ref = el,
|
|
100
99
|
children: (0, _jsxRuntime.jsx)(_BaseButton.BaseButton, {
|
|
101
100
|
renderIcon: _IconXSolid.IconXSolid,
|
|
102
101
|
elementRef: this.handleRef,
|
|
103
102
|
interaction: this.interaction,
|
|
104
103
|
type: type,
|
|
105
|
-
|
|
106
|
-
color: this.color
|
|
107
|
-
} : {}),
|
|
104
|
+
color: this.color,
|
|
108
105
|
size: size,
|
|
109
106
|
onClick: onClick,
|
|
110
107
|
margin: margin,
|
|
@@ -114,14 +111,13 @@ let CloseButton = exports.CloseButton = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
114
111
|
href: href,
|
|
115
112
|
cursor: cursor,
|
|
116
113
|
tabIndex: tabIndex,
|
|
117
|
-
"data-cid": "CloseButton",
|
|
118
114
|
children: (0, _jsxRuntime.jsx)(_ScreenReaderContent.ScreenReaderContent, {
|
|
119
115
|
children: screenReaderLabel
|
|
120
116
|
})
|
|
121
117
|
})
|
|
122
118
|
});
|
|
123
119
|
}
|
|
124
|
-
}, _CloseButton.displayName = "CloseButton", _CloseButton.componentId = 'CloseButton', _CloseButton.allowedProps = _props.allowedProps, _CloseButton.defaultProps = {
|
|
120
|
+
}, _CloseButton.displayName = "CloseButton", _CloseButton.componentId = 'CloseButton', _CloseButton.propTypes = _props.propTypes, _CloseButton.allowedProps = _props.allowedProps, _CloseButton.defaultProps = {
|
|
125
121
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
126
122
|
interaction: void 0,
|
|
127
123
|
type: 'button',
|
|
@@ -131,5 +127,5 @@ let CloseButton = exports.CloseButton = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
131
127
|
margin: '0',
|
|
132
128
|
as: 'button',
|
|
133
129
|
cursor: 'pointer'
|
|
134
|
-
}, _CloseButton)) || _class);
|
|
130
|
+
}, _CloseButton)) || _class) || _class);
|
|
135
131
|
var _default = exports.default = CloseButton;
|
package/lib/CloseButton/props.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
|
+
exports.propTypes = exports.allowedProps = void 0;
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
9
|
/*
|
|
8
10
|
* The MIT License (MIT)
|
|
9
11
|
*
|
|
@@ -28,4 +30,20 @@ exports.allowedProps = void 0;
|
|
|
28
30
|
* SOFTWARE.
|
|
29
31
|
*/
|
|
30
32
|
|
|
33
|
+
const propTypes = exports.propTypes = {
|
|
34
|
+
screenReaderLabel: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]).isRequired,
|
|
35
|
+
color: _propTypes.default.oneOf(['primary', 'primary-inverse']),
|
|
36
|
+
interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
|
|
37
|
+
elementRef: _propTypes.default.func,
|
|
38
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
39
|
+
onClick: _propTypes.default.func,
|
|
40
|
+
margin: _propTypes.default.string,
|
|
41
|
+
placement: _propTypes.default.oneOf(['start', 'end', 'static']),
|
|
42
|
+
offset: _propTypes.default.oneOf(['none', 'x-small', 'small', 'medium']),
|
|
43
|
+
type: _propTypes.default.oneOf(['button', 'submit', 'reset']),
|
|
44
|
+
as: _propTypes.default.elementType,
|
|
45
|
+
href: _propTypes.default.string,
|
|
46
|
+
cursor: _propTypes.default.string,
|
|
47
|
+
tabIndex: _propTypes.default.number
|
|
48
|
+
};
|
|
31
49
|
const allowedProps = exports.allowedProps = ['as', 'color', 'cursor', 'elementRef', 'href', 'interaction', 'margin', 'offset', 'onClick', 'placement', 'screenReaderLabel', 'size', 'tabIndex', 'type'];
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = exports.CondensedButton = void 0;
|
|
8
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
9
|
var _react = require("react");
|
|
10
|
+
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
10
11
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
11
12
|
var _emotion = require("@instructure/emotion");
|
|
12
13
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
@@ -14,7 +15,7 @@ var _BaseButton = require("../BaseButton");
|
|
|
14
15
|
var _props = require("./props");
|
|
15
16
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
16
17
|
const _excluded = ["children", "type", "size", "elementRef", "as", "interaction", "color", "margin", "cursor", "href", "renderIcon", "display"];
|
|
17
|
-
var _dec, _class, _CondensedButton;
|
|
18
|
+
var _dec, _dec2, _class, _CondensedButton;
|
|
18
19
|
/*
|
|
19
20
|
* The MIT License (MIT)
|
|
20
21
|
*
|
|
@@ -44,7 +45,7 @@ category: components
|
|
|
44
45
|
---
|
|
45
46
|
**/
|
|
46
47
|
// needed for listing the available theme variables on docs page
|
|
47
|
-
let CondensedButton = exports.CondensedButton = (_dec = (0, _emotion.withStyle)(null, _theme.default), _dec(_class = (_CondensedButton = class CondensedButton extends _react.Component {
|
|
48
|
+
let CondensedButton = exports.CondensedButton = (_dec = (0, _emotion.withStyle)(null, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_CondensedButton = class CondensedButton extends _react.Component {
|
|
48
49
|
constructor(...args) {
|
|
49
50
|
super(...args);
|
|
50
51
|
this._baseButton = null;
|
|
@@ -99,11 +100,10 @@ let CondensedButton = exports.CondensedButton = (_dec = (0, _emotion.withStyle)(
|
|
|
99
100
|
ref: component => {
|
|
100
101
|
this._baseButton = component;
|
|
101
102
|
},
|
|
102
|
-
"data-cid": "CondensedButton",
|
|
103
103
|
children: children
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
-
}, _CondensedButton.displayName = "CondensedButton", _CondensedButton.componentId = 'CondensedButton', _CondensedButton.allowedProps = _props.allowedProps, _CondensedButton.defaultProps = {
|
|
106
|
+
}, _CondensedButton.displayName = "CondensedButton", _CondensedButton.componentId = 'CondensedButton', _CondensedButton.propTypes = _props.propTypes, _CondensedButton.allowedProps = _props.allowedProps, _CondensedButton.defaultProps = {
|
|
107
107
|
type: 'button',
|
|
108
108
|
size: 'medium',
|
|
109
109
|
as: 'button',
|
|
@@ -113,5 +113,5 @@ let CondensedButton = exports.CondensedButton = (_dec = (0, _emotion.withStyle)(
|
|
|
113
113
|
margin: '0',
|
|
114
114
|
cursor: 'pointer',
|
|
115
115
|
display: 'inline-block'
|
|
116
|
-
}, _CondensedButton)) || _class);
|
|
116
|
+
}, _CondensedButton)) || _class) || _class);
|
|
117
117
|
var _default = exports.default = CondensedButton;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
|
+
exports.propTypes = exports.allowedProps = void 0;
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
9
|
/*
|
|
8
10
|
* The MIT License (MIT)
|
|
9
11
|
*
|
|
@@ -28,4 +30,19 @@ exports.allowedProps = void 0;
|
|
|
28
30
|
* SOFTWARE.
|
|
29
31
|
*/
|
|
30
32
|
|
|
33
|
+
const propTypes = exports.propTypes = {
|
|
34
|
+
children: _propTypes.default.node,
|
|
35
|
+
type: _propTypes.default.oneOf(['button', 'submit', 'reset']),
|
|
36
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
37
|
+
elementRef: _propTypes.default.func,
|
|
38
|
+
as: _propTypes.default.elementType,
|
|
39
|
+
interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
|
|
40
|
+
color: _propTypes.default.oneOf(['primary', 'primary-inverse', 'secondary']),
|
|
41
|
+
margin: _propTypes.default.string,
|
|
42
|
+
cursor: _propTypes.default.string,
|
|
43
|
+
href: _propTypes.default.string,
|
|
44
|
+
renderIcon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
45
|
+
onClick: _propTypes.default.func,
|
|
46
|
+
display: _propTypes.default.oneOf(['inline-block', 'block'])
|
|
47
|
+
};
|
|
31
48
|
const allowedProps = exports.allowedProps = ['as', 'children', 'color', 'cursor', 'elementRef', 'href', 'interaction', 'margin', 'renderIcon', 'size', 'type', 'onClick', 'display'];
|
package/lib/IconButton/index.js
CHANGED
|
@@ -7,16 +7,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = exports.IconButton = void 0;
|
|
8
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
9
|
var _react = require("react");
|
|
10
|
+
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
10
11
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
11
12
|
var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
|
|
12
|
-
var _combineDataCid = require("@instructure/ui-utils/lib/combineDataCid.js");
|
|
13
13
|
var _emotion = require("@instructure/emotion");
|
|
14
14
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
15
15
|
var _BaseButton = require("../BaseButton");
|
|
16
16
|
var _props = require("./props");
|
|
17
17
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
18
18
|
const _excluded = ["children", "renderIcon", "screenReaderLabel", "type", "size", "elementRef", "as", "interaction", "color", "focusColor", "shape", "withBackground", "withBorder", "margin", "cursor", "href"];
|
|
19
|
-
var _dec, _class, _IconButton;
|
|
19
|
+
var _dec, _dec2, _class, _IconButton;
|
|
20
20
|
/*
|
|
21
21
|
* The MIT License (MIT)
|
|
22
22
|
*
|
|
@@ -46,7 +46,7 @@ category: components
|
|
|
46
46
|
---
|
|
47
47
|
**/
|
|
48
48
|
// needed for listing the available theme variables on docs page
|
|
49
|
-
let IconButton = exports.IconButton = (_dec = (0, _emotion.withStyle)(null, _theme.default), _dec(_class = (_IconButton = class IconButton extends _react.Component {
|
|
49
|
+
let IconButton = exports.IconButton = (_dec = (0, _emotion.withStyle)(null, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_IconButton = class IconButton extends _react.Component {
|
|
50
50
|
constructor(...args) {
|
|
51
51
|
super(...args);
|
|
52
52
|
this._baseButton = null;
|
|
@@ -105,13 +105,12 @@ let IconButton = exports.IconButton = (_dec = (0, _emotion.withStyle)(null, _the
|
|
|
105
105
|
ref: component => {
|
|
106
106
|
this._baseButton = component;
|
|
107
107
|
},
|
|
108
|
-
"data-cid": (0, _combineDataCid.combineDataCid)('IconButton', this.props),
|
|
109
108
|
children: (0, _jsxRuntime.jsx)(_ScreenReaderContent.ScreenReaderContent, {
|
|
110
109
|
children: screenReaderLabel
|
|
111
110
|
})
|
|
112
111
|
});
|
|
113
112
|
}
|
|
114
|
-
}, _IconButton.displayName = "IconButton", _IconButton.componentId = 'IconButton', _IconButton.allowedProps = _props.allowedProps, _IconButton.defaultProps = {
|
|
113
|
+
}, _IconButton.displayName = "IconButton", _IconButton.componentId = 'IconButton', _IconButton.propTypes = _props.propTypes, _IconButton.allowedProps = _props.allowedProps, _IconButton.defaultProps = {
|
|
115
114
|
type: 'button',
|
|
116
115
|
size: 'medium',
|
|
117
116
|
as: 'button',
|
|
@@ -123,5 +122,5 @@ let IconButton = exports.IconButton = (_dec = (0, _emotion.withStyle)(null, _the
|
|
|
123
122
|
withBorder: true,
|
|
124
123
|
margin: '0',
|
|
125
124
|
cursor: 'pointer'
|
|
126
|
-
}, _IconButton)) || _class);
|
|
125
|
+
}, _IconButton)) || _class) || _class);
|
|
127
126
|
var _default = exports.default = IconButton;
|
package/lib/IconButton/props.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
|
+
exports.propTypes = exports.allowedProps = void 0;
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
7
9
|
/*
|
|
8
10
|
* The MIT License (MIT)
|
|
9
11
|
*
|
|
@@ -28,4 +30,23 @@ exports.allowedProps = void 0;
|
|
|
28
30
|
* SOFTWARE.
|
|
29
31
|
*/
|
|
30
32
|
|
|
33
|
+
const propTypes = exports.propTypes = {
|
|
34
|
+
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
35
|
+
renderIcon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
36
|
+
screenReaderLabel: _propTypes.default.string.isRequired,
|
|
37
|
+
type: _propTypes.default.oneOf(['button', 'submit', 'reset']),
|
|
38
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
39
|
+
elementRef: _propTypes.default.func,
|
|
40
|
+
as: _propTypes.default.elementType,
|
|
41
|
+
interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
|
|
42
|
+
color: _propTypes.default.oneOf(['primary', 'primary-inverse', 'secondary', 'success', 'danger', 'ai-primary', 'ai-secondary']),
|
|
43
|
+
focusColor: _propTypes.default.oneOf(['info', 'inverse']),
|
|
44
|
+
shape: _propTypes.default.oneOf(['rectangle', 'circle']),
|
|
45
|
+
withBackground: _propTypes.default.bool,
|
|
46
|
+
withBorder: _propTypes.default.bool,
|
|
47
|
+
margin: _propTypes.default.string,
|
|
48
|
+
cursor: _propTypes.default.string,
|
|
49
|
+
href: _propTypes.default.string,
|
|
50
|
+
onClick: _propTypes.default.func
|
|
51
|
+
};
|
|
31
52
|
const allowedProps = exports.allowedProps = ['as', 'children', 'color', 'cursor', 'elementRef', 'focusColor', 'href', 'interaction', 'margin', 'renderIcon', 'screenReaderLabel', 'shape', 'size', 'type', 'withBackground', 'withBorder', 'onClick'];
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = exports.ToggleButton = void 0;
|
|
8
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
9
|
var _react = require("react");
|
|
10
|
+
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
10
11
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
11
12
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
12
13
|
var _Tooltip = require("@instructure/ui-tooltip/lib/Tooltip");
|
|
@@ -14,6 +15,7 @@ var _IconButton = require("../IconButton");
|
|
|
14
15
|
var _props = require("./props");
|
|
15
16
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
16
17
|
const _excluded = ["as", "color", "elementRef", "size", "interaction", "mountNode", "renderIcon", "renderTooltipContent", "screenReaderLabel", "status", "placement", "onClick"];
|
|
18
|
+
var _dec, _class, _ToggleButton;
|
|
17
19
|
/*
|
|
18
20
|
* The MIT License (MIT)
|
|
19
21
|
*
|
|
@@ -42,8 +44,7 @@ const _excluded = ["as", "color", "elementRef", "size", "interaction", "mountNod
|
|
|
42
44
|
category: components
|
|
43
45
|
---
|
|
44
46
|
**/
|
|
45
|
-
|
|
46
|
-
class ToggleButton extends _react.Component {
|
|
47
|
+
let ToggleButton = exports.ToggleButton = (_dec = (0, _testable.testable)(), _dec(_class = (_ToggleButton = class ToggleButton extends _react.Component {
|
|
47
48
|
constructor(props) {
|
|
48
49
|
super(props);
|
|
49
50
|
this.ref = null;
|
|
@@ -105,17 +106,11 @@ class ToggleButton extends _react.Component {
|
|
|
105
106
|
onClick: onClick,
|
|
106
107
|
interaction: interaction,
|
|
107
108
|
"aria-pressed": status === 'pressed',
|
|
108
|
-
"data-cid": "ToggleButton",
|
|
109
109
|
children: (0, _callRenderProp.callRenderProp)(renderIcon)
|
|
110
110
|
})
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
}
|
|
114
|
-
exports.ToggleButton = ToggleButton;
|
|
115
|
-
ToggleButton.displayName = "ToggleButton";
|
|
116
|
-
ToggleButton.componentId = 'ToggleButton';
|
|
117
|
-
ToggleButton.allowedProps = _props.allowedProps;
|
|
118
|
-
ToggleButton.defaultProps = {
|
|
113
|
+
}, _ToggleButton.displayName = "ToggleButton", _ToggleButton.componentId = 'ToggleButton', _ToggleButton.propTypes = _props.propTypes, _ToggleButton.allowedProps = _props.allowedProps, _ToggleButton.defaultProps = {
|
|
119
114
|
size: 'medium',
|
|
120
115
|
as: 'button',
|
|
121
116
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
@@ -124,5 +119,5 @@ ToggleButton.defaultProps = {
|
|
|
124
119
|
color: 'secondary',
|
|
125
120
|
placement: 'top center',
|
|
126
121
|
constrain: 'window'
|
|
127
|
-
};
|
|
122
|
+
}, _ToggleButton)) || _class);
|
|
128
123
|
var _default = exports.default = ToggleButton;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
|
+
exports.propTypes = exports.allowedProps = void 0;
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _PositionPropTypes = require("@instructure/ui-position/lib/PositionPropTypes.js");
|
|
7
10
|
/*
|
|
8
11
|
* The MIT License (MIT)
|
|
9
12
|
*
|
|
@@ -28,4 +31,20 @@ exports.allowedProps = void 0;
|
|
|
28
31
|
* SOFTWARE.
|
|
29
32
|
*/
|
|
30
33
|
|
|
34
|
+
const propTypes = exports.propTypes = {
|
|
35
|
+
screenReaderLabel: _propTypes.default.string.isRequired,
|
|
36
|
+
renderTooltipContent: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
37
|
+
renderIcon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
38
|
+
status: _propTypes.default.oneOf(['pressed', 'unpressed']).isRequired,
|
|
39
|
+
as: _propTypes.default.elementType,
|
|
40
|
+
interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
|
|
41
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
42
|
+
elementRef: _propTypes.default.func,
|
|
43
|
+
onClick: _propTypes.default.func,
|
|
44
|
+
color: _propTypes.default.oneOf(['primary', 'primary-inverse', 'secondary', 'success', 'danger']),
|
|
45
|
+
isShowingTooltip: _propTypes.default.bool,
|
|
46
|
+
mountNode: _PositionPropTypes.PositionPropTypes.mountNode,
|
|
47
|
+
placement: _PositionPropTypes.PositionPropTypes.placement,
|
|
48
|
+
constrain: _PositionPropTypes.PositionPropTypes.constrain
|
|
49
|
+
};
|
|
31
50
|
const allowedProps = exports.allowedProps = ['as', 'color', 'constrain', 'elementRef', 'interaction', 'isShowingTooltip', 'mountNode', 'onClick', 'placement', 'renderIcon', 'renderTooltipContent', 'screenReaderLabel', 'size', 'status'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-buttons",
|
|
3
|
-
"version": "10.26.1
|
|
3
|
+
"version": "10.26.1",
|
|
4
4
|
"description": "Accessible button components",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,33 +23,36 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-axe-check": "10.26.1
|
|
27
|
-
"@instructure/ui-babel-preset": "10.26.1
|
|
28
|
-
"@instructure/ui-themes": "10.26.1
|
|
26
|
+
"@instructure/ui-axe-check": "10.26.1",
|
|
27
|
+
"@instructure/ui-babel-preset": "10.26.1",
|
|
28
|
+
"@instructure/ui-themes": "10.26.1",
|
|
29
29
|
"@testing-library/jest-dom": "^6.6.3",
|
|
30
|
-
"@testing-library/react": "
|
|
30
|
+
"@testing-library/react": "^16.0.1",
|
|
31
31
|
"@testing-library/user-event": "^14.6.1",
|
|
32
32
|
"vitest": "^3.2.2"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/runtime": "^7.27.6",
|
|
36
|
-
"@instructure/console": "10.26.1
|
|
37
|
-
"@instructure/emotion": "10.26.1
|
|
38
|
-
"@instructure/shared-types": "10.26.1
|
|
39
|
-
"@instructure/ui-a11y-content": "10.26.1
|
|
40
|
-
"@instructure/ui-a11y-utils": "10.26.1
|
|
41
|
-
"@instructure/ui-color-utils": "10.26.1
|
|
42
|
-
"@instructure/ui-dom-utils": "10.26.1
|
|
43
|
-
"@instructure/ui-icons": "10.26.1
|
|
44
|
-
"@instructure/ui-position": "10.26.1
|
|
45
|
-
"@instructure/ui-
|
|
46
|
-
"@instructure/ui-
|
|
47
|
-
"@instructure/ui-
|
|
48
|
-
"@instructure/ui-
|
|
49
|
-
"
|
|
36
|
+
"@instructure/console": "10.26.1",
|
|
37
|
+
"@instructure/emotion": "10.26.1",
|
|
38
|
+
"@instructure/shared-types": "10.26.1",
|
|
39
|
+
"@instructure/ui-a11y-content": "10.26.1",
|
|
40
|
+
"@instructure/ui-a11y-utils": "10.26.1",
|
|
41
|
+
"@instructure/ui-color-utils": "10.26.1",
|
|
42
|
+
"@instructure/ui-dom-utils": "10.26.1",
|
|
43
|
+
"@instructure/ui-icons": "10.26.1",
|
|
44
|
+
"@instructure/ui-position": "10.26.1",
|
|
45
|
+
"@instructure/ui-prop-types": "10.26.1",
|
|
46
|
+
"@instructure/ui-react-utils": "10.26.1",
|
|
47
|
+
"@instructure/ui-testable": "10.26.1",
|
|
48
|
+
"@instructure/ui-tooltip": "10.26.1",
|
|
49
|
+
"@instructure/ui-utils": "10.26.1",
|
|
50
|
+
"@instructure/ui-view": "10.26.1",
|
|
51
|
+
"keycode": "^2",
|
|
52
|
+
"prop-types": "^15.8.1"
|
|
50
53
|
},
|
|
51
54
|
"peerDependencies": {
|
|
52
|
-
"react": ">=
|
|
55
|
+
"react": ">=16.14 <=18"
|
|
53
56
|
},
|
|
54
57
|
"publishConfig": {
|
|
55
58
|
"access": "public"
|
package/src/BaseButton/index.tsx
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import { Component } from 'react'
|
|
26
26
|
import keycode from 'keycode'
|
|
27
27
|
|
|
28
|
+
import { testable } from '@instructure/ui-testable'
|
|
28
29
|
import {
|
|
29
30
|
getElementType,
|
|
30
31
|
getInteraction,
|
|
@@ -35,18 +36,14 @@ import { isActiveElement } from '@instructure/ui-dom-utils'
|
|
|
35
36
|
import { hasVisibleChildren } from '@instructure/ui-a11y-utils'
|
|
36
37
|
import { View } from '@instructure/ui-view'
|
|
37
38
|
import type { ViewProps } from '@instructure/ui-view'
|
|
38
|
-
|
|
39
|
-
// TODO these have to be imported in separate lines because otherwise `isSafari` will be missing from the babel build
|
|
40
|
-
// this bug is very likely caused by `babel-plugin-transform-imports` and can be reverted once it is removed from the codebase
|
|
41
39
|
import { isSafari } from '@instructure/ui-utils'
|
|
42
|
-
import { combineDataCid } from '@instructure/ui-utils'
|
|
43
40
|
|
|
44
41
|
import { withStyle } from '@instructure/emotion'
|
|
45
42
|
|
|
46
43
|
import generateStyles from './styles'
|
|
47
44
|
import generateComponentTheme from './theme'
|
|
48
45
|
|
|
49
|
-
import { allowedProps } from './props'
|
|
46
|
+
import { propTypes, allowedProps } from './props'
|
|
50
47
|
import type { BaseButtonProps, BaseButtonStyleProps } from './props'
|
|
51
48
|
|
|
52
49
|
/**
|
|
@@ -56,9 +53,11 @@ category: components/utilities
|
|
|
56
53
|
**/
|
|
57
54
|
|
|
58
55
|
@withStyle(generateStyles, generateComponentTheme)
|
|
56
|
+
@testable()
|
|
59
57
|
class BaseButton extends Component<BaseButtonProps> {
|
|
60
58
|
static readonly componentId = 'BaseButton'
|
|
61
59
|
|
|
60
|
+
static propTypes = propTypes
|
|
62
61
|
static allowedProps = allowedProps
|
|
63
62
|
static defaultProps = {
|
|
64
63
|
type: 'button',
|
|
@@ -286,7 +285,6 @@ class BaseButton extends Component<BaseButtonProps> {
|
|
|
286
285
|
if ((onClick && as && needsZeroTabIndex) || (isSafari() && as)) {
|
|
287
286
|
tabIndexValue = tabIndex || 0
|
|
288
287
|
}
|
|
289
|
-
|
|
290
288
|
return (
|
|
291
289
|
<View
|
|
292
290
|
{...passthroughProps(props)}
|
|
@@ -311,7 +309,6 @@ class BaseButton extends Component<BaseButtonProps> {
|
|
|
311
309
|
disabled={isDisabled || isReadOnly}
|
|
312
310
|
css={styles?.baseButton}
|
|
313
311
|
withFocusOutline={withFocusOutline}
|
|
314
|
-
data-cid={combineDataCid('BaseButton', this.props)}
|
|
315
312
|
>
|
|
316
313
|
<span css={styles?.content}>{this.renderChildren()}</span>
|
|
317
314
|
</View>
|
package/src/BaseButton/props.ts
CHANGED
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
26
28
|
import type { InteractionType } from '@instructure/ui-react-utils'
|
|
27
29
|
import type {
|
|
28
30
|
Spacing,
|
|
@@ -33,9 +35,10 @@ import type {
|
|
|
33
35
|
ToProp,
|
|
34
36
|
AsElementType,
|
|
35
37
|
BaseButtonTheme,
|
|
36
|
-
OtherHTMLAttributes
|
|
38
|
+
OtherHTMLAttributes,
|
|
39
|
+
PropValidators
|
|
37
40
|
} from '@instructure/shared-types'
|
|
38
|
-
import type { Cursor } from '@instructure/
|
|
41
|
+
import type { Cursor } from '@instructure/ui-prop-types'
|
|
39
42
|
import type { ViewProps } from '@instructure/ui-view'
|
|
40
43
|
import { Renderable } from '@instructure/shared-types'
|
|
41
44
|
|
|
@@ -193,6 +196,40 @@ type BaseButtonStyle = ComponentStyle<
|
|
|
193
196
|
| 'iconWrapper'
|
|
194
197
|
| 'childrenWrapper'
|
|
195
198
|
>
|
|
199
|
+
|
|
200
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
201
|
+
children: PropTypes.node,
|
|
202
|
+
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
203
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
204
|
+
elementRef: PropTypes.func,
|
|
205
|
+
as: PropTypes.elementType,
|
|
206
|
+
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
207
|
+
color: PropTypes.oneOf([
|
|
208
|
+
'primary',
|
|
209
|
+
'primary-inverse',
|
|
210
|
+
'secondary',
|
|
211
|
+
'success',
|
|
212
|
+
'danger',
|
|
213
|
+
'ai-primary',
|
|
214
|
+
'ai-secondary'
|
|
215
|
+
]),
|
|
216
|
+
focusColor: PropTypes.oneOf(['info', 'inverse']),
|
|
217
|
+
display: PropTypes.oneOf(['inline-block', 'block']),
|
|
218
|
+
textAlign: PropTypes.oneOf(['start', 'center']),
|
|
219
|
+
shape: PropTypes.oneOf(['rectangle', 'circle']),
|
|
220
|
+
withBackground: PropTypes.bool,
|
|
221
|
+
withBorder: PropTypes.bool,
|
|
222
|
+
isCondensed: PropTypes.bool,
|
|
223
|
+
margin: PropTypes.string,
|
|
224
|
+
cursor: PropTypes.string,
|
|
225
|
+
href: PropTypes.string,
|
|
226
|
+
onClick: PropTypes.func,
|
|
227
|
+
onKeyDown: PropTypes.func,
|
|
228
|
+
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
229
|
+
tabIndex: PropTypes.number,
|
|
230
|
+
withFocusOutline: PropTypes.bool
|
|
231
|
+
}
|
|
232
|
+
|
|
196
233
|
const allowedProps: AllowedPropKeys = [
|
|
197
234
|
'as',
|
|
198
235
|
'children',
|
|
@@ -223,4 +260,4 @@ export type {
|
|
|
223
260
|
BaseButtonStyleProps,
|
|
224
261
|
BaseButtonStyle
|
|
225
262
|
}
|
|
226
|
-
export { allowedProps }
|
|
263
|
+
export { propTypes, allowedProps }
|