@instructure/ui-buttons 8.33.1 → 8.33.2-snapshot-5
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 +8 -0
- package/es/BaseButton/BaseButtonLocator.js +3 -2
- package/es/BaseButton/index.js +44 -80
- package/es/BaseButton/locator.js +1 -0
- package/es/BaseButton/props.js +1 -0
- package/es/BaseButton/styles.js +12 -17
- package/es/BaseButton/theme.js +17 -17
- package/es/Button/ButtonLocator.js +2 -2
- package/es/Button/index.js +17 -26
- package/es/Button/props.js +1 -0
- package/es/Button/theme.js +1 -0
- package/es/CloseButton/CloseButtonLocator.js +3 -1
- package/es/CloseButton/index.js +14 -28
- package/es/CloseButton/locator.js +1 -0
- package/es/CloseButton/props.js +1 -0
- package/es/CloseButton/styles.js +3 -5
- package/es/CloseButton/theme.js +3 -3
- package/es/CondensedButton/CondensedButtonLocator.js +2 -2
- package/es/CondensedButton/index.js +13 -22
- package/es/CondensedButton/props.js +1 -0
- package/es/CondensedButton/theme.js +1 -0
- package/es/IconButton/IconButtonLocator.js +2 -2
- package/es/IconButton/index.js +18 -27
- package/es/IconButton/props.js +1 -0
- package/es/IconButton/theme.js +1 -0
- package/es/ToggleButton/ToggleButtonLocator.js +9 -8
- package/es/ToggleButton/index.js +14 -23
- package/es/ToggleButton/props.js +1 -0
- package/es/index.js +1 -0
- package/lib/BaseButton/BaseButtonLocator.js +1 -5
- package/lib/BaseButton/index.js +44 -97
- package/lib/BaseButton/locator.js +0 -2
- package/lib/BaseButton/props.js +1 -4
- package/lib/BaseButton/styles.js +12 -18
- package/lib/BaseButton/theme.js +17 -20
- package/lib/Button/ButtonLocator.js +1 -5
- package/lib/Button/index.js +16 -36
- package/lib/Button/locator.js +0 -2
- package/lib/Button/props.js +1 -4
- package/lib/Button/theme.js +0 -2
- package/lib/CloseButton/CloseButtonLocator.js +1 -3
- package/lib/CloseButton/index.js +14 -40
- package/lib/CloseButton/locator.js +0 -2
- package/lib/CloseButton/props.js +1 -4
- package/lib/CloseButton/styles.js +3 -6
- package/lib/CloseButton/theme.js +3 -4
- package/lib/CondensedButton/CondensedButtonLocator.js +1 -5
- package/lib/CondensedButton/index.js +12 -31
- package/lib/CondensedButton/locator.js +0 -2
- package/lib/CondensedButton/props.js +1 -4
- package/lib/CondensedButton/theme.js +0 -2
- package/lib/IconButton/IconButtonLocator.js +1 -5
- package/lib/IconButton/index.js +17 -37
- package/lib/IconButton/locator.js +0 -2
- package/lib/IconButton/props.js +1 -4
- package/lib/IconButton/theme.js +0 -2
- package/lib/ToggleButton/ToggleButtonLocator.js +5 -10
- package/lib/ToggleButton/index.js +13 -32
- package/lib/ToggleButton/props.js +1 -4
- package/lib/index.js +0 -6
- package/package.json +20 -20
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Button/index.d.ts +2 -2
package/lib/BaseButton/index.js
CHANGED
|
@@ -1,50 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.BaseButton = void 0;
|
|
11
|
-
|
|
12
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
11
|
var _keycode = _interopRequireDefault(require("keycode"));
|
|
17
|
-
|
|
18
12
|
var _console = require("@instructure/console");
|
|
19
|
-
|
|
20
13
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
21
|
-
|
|
22
14
|
var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
|
|
23
|
-
|
|
24
15
|
var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
|
|
25
|
-
|
|
26
16
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
27
|
-
|
|
28
17
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
29
|
-
|
|
30
18
|
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
31
|
-
|
|
32
19
|
var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
|
|
33
|
-
|
|
34
20
|
var _View = require("@instructure/ui-view/lib/View");
|
|
35
|
-
|
|
36
21
|
var _emotion = require("@instructure/emotion");
|
|
37
|
-
|
|
38
22
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
39
|
-
|
|
40
23
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
41
|
-
|
|
42
24
|
var _props = require("./props");
|
|
43
|
-
|
|
44
25
|
const _excluded = ["type", "size", "elementRef", "as", "href", "color", "focusColor", "textAlign", "shape", "display", "withBackground", "withBorder", "isCondensed", "margin", "cursor", "onClick", "renderIcon", "tabIndex", "styles", "makeStyles"];
|
|
45
|
-
|
|
46
26
|
var _dec, _dec2, _class, _class2;
|
|
47
|
-
|
|
48
27
|
/**
|
|
49
28
|
---
|
|
50
29
|
category: components/utilities
|
|
@@ -55,168 +34,138 @@ let BaseButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
55
34
|
constructor() {
|
|
56
35
|
super(...arguments);
|
|
57
36
|
this.ref = null;
|
|
58
|
-
|
|
59
37
|
this.handleElementRef = el => {
|
|
60
38
|
const elementRef = this.props.elementRef;
|
|
61
39
|
this.ref = el;
|
|
62
|
-
|
|
63
40
|
if (typeof elementRef === 'function') {
|
|
64
41
|
elementRef(el);
|
|
65
42
|
}
|
|
66
43
|
};
|
|
67
|
-
|
|
68
44
|
this.handleClick = event => {
|
|
69
45
|
const onClick = this.props.onClick;
|
|
70
46
|
const interaction = this.interaction;
|
|
71
|
-
|
|
72
47
|
if (interaction !== 'enabled') {
|
|
73
48
|
event.preventDefault();
|
|
74
49
|
event.stopPropagation();
|
|
75
50
|
return;
|
|
76
51
|
}
|
|
77
|
-
|
|
78
52
|
if (typeof onClick === 'function') {
|
|
79
53
|
onClick(event);
|
|
80
54
|
}
|
|
81
55
|
};
|
|
82
|
-
|
|
83
56
|
this.handleKeyDown = event => {
|
|
84
57
|
const _this$props = this.props,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
58
|
+
onClick = _this$props.onClick,
|
|
59
|
+
onKeyDown = _this$props.onKeyDown,
|
|
60
|
+
href = _this$props.href;
|
|
88
61
|
const interaction = this.interaction;
|
|
89
|
-
|
|
90
62
|
if (typeof onKeyDown === 'function') {
|
|
91
63
|
onKeyDown(event);
|
|
92
|
-
}
|
|
93
|
-
|
|
64
|
+
}
|
|
94
65
|
|
|
66
|
+
// behave like a button when space key is pressed
|
|
95
67
|
const _keycode$codes = _keycode.default.codes,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
68
|
+
space = _keycode$codes.space,
|
|
69
|
+
enter = _keycode$codes.enter;
|
|
99
70
|
if (this.elementType !== 'button' && [space, enter].includes(event.keyCode)) {
|
|
100
71
|
event.preventDefault();
|
|
101
72
|
event.stopPropagation();
|
|
102
|
-
|
|
103
73
|
if (typeof onClick === 'function' && interaction === 'enabled') {
|
|
104
74
|
onClick(event);
|
|
105
75
|
}
|
|
106
|
-
|
|
107
76
|
if (href) {
|
|
108
77
|
this.ref && this.ref.click();
|
|
109
78
|
}
|
|
110
79
|
}
|
|
111
80
|
};
|
|
112
81
|
}
|
|
113
|
-
|
|
114
82
|
componentDidMount() {
|
|
115
83
|
var _this$props$makeStyle, _this$props2;
|
|
116
|
-
|
|
117
84
|
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2, this.makeStylesVariables);
|
|
118
85
|
}
|
|
119
|
-
|
|
120
86
|
componentDidUpdate() {
|
|
121
87
|
var _this$props$makeStyle2, _this$props3;
|
|
122
|
-
|
|
123
88
|
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3, this.makeStylesVariables);
|
|
124
89
|
}
|
|
125
|
-
|
|
126
90
|
get _rootElement() {
|
|
127
91
|
return this.ref;
|
|
128
92
|
}
|
|
129
|
-
|
|
130
93
|
get makeStylesVariables() {
|
|
131
94
|
return {
|
|
132
95
|
isDisabled: this.isDisabled,
|
|
133
96
|
hasOnlyIconVisible: this.hasOnlyIconVisible
|
|
134
97
|
};
|
|
135
98
|
}
|
|
136
|
-
|
|
137
99
|
get hasOnlyIconVisible() {
|
|
138
100
|
const _this$props4 = this.props,
|
|
139
|
-
|
|
140
|
-
|
|
101
|
+
children = _this$props4.children,
|
|
102
|
+
renderIcon = _this$props4.renderIcon;
|
|
141
103
|
return !!(renderIcon && !(0, _hasVisibleChildren.hasVisibleChildren)(children));
|
|
142
104
|
}
|
|
143
|
-
|
|
144
105
|
get elementType() {
|
|
145
106
|
return (0, _getElementType.getElementType)(BaseButton, this.props);
|
|
146
107
|
}
|
|
147
|
-
|
|
148
108
|
get interaction() {
|
|
149
109
|
return (0, _getInteraction.getInteraction)({
|
|
150
110
|
props: this.props
|
|
151
111
|
});
|
|
152
112
|
}
|
|
153
|
-
|
|
154
113
|
get isDisabled() {
|
|
155
114
|
return this.interaction === 'disabled';
|
|
156
115
|
}
|
|
157
|
-
|
|
158
116
|
get isReadOnly() {
|
|
159
117
|
return this.interaction === 'readonly';
|
|
160
118
|
}
|
|
161
|
-
|
|
162
119
|
get isEnabled() {
|
|
163
120
|
return this.interaction === 'enabled';
|
|
164
|
-
}
|
|
165
|
-
|
|
121
|
+
}
|
|
166
122
|
|
|
123
|
+
// TODO: delete once the type of tabIndex is changed to number only
|
|
167
124
|
get tabIndex() {
|
|
168
125
|
const tabIndex = this.props.tabIndex;
|
|
169
|
-
|
|
170
126
|
if (typeof tabIndex === 'string') {
|
|
171
127
|
(0, _console.warn)(false, 'The `string` value for `tabIndex` is deprecated. Only `number` type will be accepted from V9.0.0.');
|
|
172
128
|
return parseInt(tabIndex);
|
|
173
129
|
}
|
|
174
|
-
|
|
175
130
|
return tabIndex;
|
|
176
131
|
}
|
|
177
|
-
|
|
178
132
|
get focusColor() {
|
|
179
133
|
const _this$props5 = this.props,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
134
|
+
color = _this$props5.color,
|
|
135
|
+
focusColor = _this$props5.focusColor,
|
|
136
|
+
withBackground = _this$props5.withBackground;
|
|
183
137
|
|
|
138
|
+
// Give user specified focusColor preference
|
|
184
139
|
if (focusColor) {
|
|
185
140
|
return focusColor;
|
|
186
|
-
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// The `primary-inverse` background has an info focus outline
|
|
187
144
|
// by default since it is replacing the `light` button variant.
|
|
188
145
|
// Override the focus color with info even though it is
|
|
189
146
|
// an inverse color
|
|
190
|
-
|
|
191
|
-
|
|
192
147
|
if (color === 'primary-inverse' && withBackground) {
|
|
193
148
|
return 'info';
|
|
194
149
|
}
|
|
195
|
-
|
|
196
150
|
return color.includes('inverse') ? 'inverse' : 'info';
|
|
197
151
|
}
|
|
198
|
-
|
|
199
152
|
get focused() {
|
|
200
153
|
return (0, _isActiveElement.isActiveElement)(this.ref);
|
|
201
154
|
}
|
|
202
|
-
|
|
203
155
|
focus() {
|
|
204
156
|
this.ref && this.ref.focus();
|
|
205
157
|
}
|
|
206
|
-
|
|
207
158
|
renderChildren() {
|
|
208
159
|
const _this$props6 = this.props,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
160
|
+
renderIcon = _this$props6.renderIcon,
|
|
161
|
+
children = _this$props6.children,
|
|
162
|
+
styles = _this$props6.styles;
|
|
212
163
|
const wrappedChildren = (0, _emotion.jsx)("span", {
|
|
213
164
|
css: styles === null || styles === void 0 ? void 0 : styles.children
|
|
214
165
|
}, children);
|
|
215
|
-
|
|
216
166
|
if (!renderIcon) {
|
|
217
167
|
return wrappedChildren;
|
|
218
168
|
}
|
|
219
|
-
|
|
220
169
|
const hasOnlyIconVisible = this.hasOnlyIconVisible;
|
|
221
170
|
const wrappedIcon = (0, _emotion.jsx)("span", {
|
|
222
171
|
css: styles === null || styles === void 0 ? void 0 : styles.iconSVG
|
|
@@ -234,33 +183,32 @@ let BaseButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
234
183
|
css: styles === null || styles === void 0 ? void 0 : styles.childrenLayout
|
|
235
184
|
}, flexChildren);
|
|
236
185
|
}
|
|
237
|
-
|
|
238
186
|
render() {
|
|
239
187
|
const _this$props7 = this.props,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
188
|
+
type = _this$props7.type,
|
|
189
|
+
size = _this$props7.size,
|
|
190
|
+
elementRef = _this$props7.elementRef,
|
|
191
|
+
as = _this$props7.as,
|
|
192
|
+
href = _this$props7.href,
|
|
193
|
+
color = _this$props7.color,
|
|
194
|
+
focusColor = _this$props7.focusColor,
|
|
195
|
+
textAlign = _this$props7.textAlign,
|
|
196
|
+
shape = _this$props7.shape,
|
|
197
|
+
display = _this$props7.display,
|
|
198
|
+
withBackground = _this$props7.withBackground,
|
|
199
|
+
withBorder = _this$props7.withBorder,
|
|
200
|
+
isCondensed = _this$props7.isCondensed,
|
|
201
|
+
margin = _this$props7.margin,
|
|
202
|
+
cursor = _this$props7.cursor,
|
|
203
|
+
onClick = _this$props7.onClick,
|
|
204
|
+
renderIcon = _this$props7.renderIcon,
|
|
205
|
+
tabIndex = _this$props7.tabIndex,
|
|
206
|
+
styles = _this$props7.styles,
|
|
207
|
+
makeStyles = _this$props7.makeStyles,
|
|
208
|
+
props = (0, _objectWithoutProperties2.default)(_this$props7, _excluded);
|
|
261
209
|
const isDisabled = this.isDisabled,
|
|
262
|
-
|
|
263
|
-
|
|
210
|
+
isEnabled = this.isEnabled,
|
|
211
|
+
isReadOnly = this.isReadOnly;
|
|
264
212
|
const tabIndexNumber = this.tabIndex;
|
|
265
213
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, (0, _passthroughProps.passthroughProps)(props), {
|
|
266
214
|
as: this.elementType,
|
|
@@ -287,7 +235,6 @@ let BaseButton = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
287
235
|
css: styles === null || styles === void 0 ? void 0 : styles.content
|
|
288
236
|
}, this.renderChildren()));
|
|
289
237
|
}
|
|
290
|
-
|
|
291
238
|
}, _class2.displayName = "BaseButton", _class2.componentId = 'BaseButton', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
292
239
|
type: 'button',
|
|
293
240
|
size: 'medium',
|
package/lib/BaseButton/props.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _emotion = require("@instructure/emotion");
|
|
13
|
-
|
|
14
10
|
/*
|
|
15
11
|
* The MIT License (MIT)
|
|
16
12
|
*
|
|
@@ -34,6 +30,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
34
30
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
31
|
* SOFTWARE.
|
|
36
32
|
*/
|
|
33
|
+
|
|
37
34
|
const propTypes = {
|
|
38
35
|
children: _propTypes.default.node,
|
|
39
36
|
type: _propTypes.default.oneOf(['button', 'submit', 'reset']),
|
package/lib/BaseButton/styles.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -41,14 +40,14 @@ exports.default = void 0;
|
|
|
41
40
|
*/
|
|
42
41
|
const generateStyle = (componentTheme, props, state) => {
|
|
43
42
|
const size = props.size,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
color = props.color,
|
|
44
|
+
textAlign = props.textAlign,
|
|
45
|
+
shape = props.shape,
|
|
46
|
+
withBackground = props.withBackground,
|
|
47
|
+
withBorder = props.withBorder,
|
|
48
|
+
isCondensed = props.isCondensed;
|
|
50
49
|
const isDisabled = state.isDisabled,
|
|
51
|
-
|
|
50
|
+
hasOnlyIconVisible = state.hasOnlyIconVisible;
|
|
52
51
|
const shapeVariants = {
|
|
53
52
|
circle: {
|
|
54
53
|
borderRadius: '50%'
|
|
@@ -258,20 +257,16 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
258
257
|
baseButton: {
|
|
259
258
|
label: 'baseButton',
|
|
260
259
|
appearance: 'none',
|
|
261
|
-
textDecoration: 'none'
|
|
262
|
-
/* for links styled as buttons */
|
|
263
|
-
,
|
|
260
|
+
textDecoration: 'none' /* for links styled as buttons */,
|
|
264
261
|
touchAction: 'manipulation',
|
|
265
262
|
'&::-moz-focus-inner': {
|
|
266
|
-
border: '0'
|
|
267
|
-
/* removes default dotted focus outline in Firefox */
|
|
268
|
-
|
|
263
|
+
border: '0' /* removes default dotted focus outline in Firefox */
|
|
269
264
|
},
|
|
270
|
-
'*': {
|
|
271
|
-
pointerEvents: 'none'
|
|
272
|
-
/* Ensures that button or link is always the event target */
|
|
273
265
|
|
|
266
|
+
'*': {
|
|
267
|
+
pointerEvents: 'none' /* Ensures that button or link is always the event target */
|
|
274
268
|
},
|
|
269
|
+
|
|
275
270
|
'&:active > [class$=-baseButton__content]': colorVariants[color].active,
|
|
276
271
|
'&:hover > [class$=-baseButton__content]': colorVariants[color].hover
|
|
277
272
|
},
|
|
@@ -375,6 +370,5 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
375
370
|
}
|
|
376
371
|
};
|
|
377
372
|
};
|
|
378
|
-
|
|
379
373
|
var _default = generateStyle;
|
|
380
374
|
exports.default = _default;
|
package/lib/BaseButton/theme.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _alpha = require("@instructure/ui-color-utils/lib/alpha.js");
|
|
9
|
-
|
|
10
8
|
var _darken = require("@instructure/ui-color-utils/lib/darken.js");
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,16 +29,16 @@ var _darken = require("@instructure/ui-color-utils/lib/darken.js");
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
35
|
-
const activeShadow = 'inset 0 0 0.1875rem 0.0625rem';
|
|
36
32
|
|
|
33
|
+
const activeShadow = 'inset 0 0 0.1875rem 0.0625rem';
|
|
37
34
|
const generateButtonThemeVars = _ref => {
|
|
38
35
|
let style = _ref.style,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
textColor = _ref.textColor,
|
|
37
|
+
ghostTextColor = _ref.ghostTextColor,
|
|
38
|
+
backgroundColor = _ref.backgroundColor,
|
|
39
|
+
borderColor = _ref.borderColor,
|
|
40
|
+
_ref$ghostBorderColor = _ref.ghostBorderColor,
|
|
41
|
+
ghostBorderColor = _ref$ghostBorderColor === void 0 ? borderColor : _ref$ghostBorderColor;
|
|
45
42
|
return {
|
|
46
43
|
[`${style}Color`]: textColor,
|
|
47
44
|
[`${style}BorderColor`]: (0, _darken.darken)(borderColor, 10),
|
|
@@ -57,22 +54,22 @@ const generateButtonThemeVars = _ref => {
|
|
|
57
54
|
[`${style}GhostActiveBoxShadow`]: `${activeShadow} ${(0, _alpha.alpha)(ghostBorderColor, 28)}`
|
|
58
55
|
};
|
|
59
56
|
};
|
|
57
|
+
|
|
60
58
|
/**
|
|
61
59
|
* Generates the theme object for the component from the theme and provided additional information
|
|
62
60
|
* @param {Object} theme The actual theme object.
|
|
63
61
|
* @return {Object} The final theme object with the overrides and component variables
|
|
64
62
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
63
|
const generateComponentTheme = theme => {
|
|
68
64
|
const borders = theme.borders,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
colors = theme.colors,
|
|
66
|
+
forms = theme.forms,
|
|
67
|
+
spacing = theme.spacing,
|
|
68
|
+
typography = theme.typography,
|
|
69
|
+
themeName = theme.key;
|
|
74
70
|
const themeSpecificStyle = {
|
|
75
|
-
canvas: {
|
|
71
|
+
canvas: {
|
|
72
|
+
...generateButtonThemeVars({
|
|
76
73
|
style: 'primary',
|
|
77
74
|
backgroundColor: theme['ic-brand-button--primary-bgd'],
|
|
78
75
|
borderColor: theme['ic-brand-button--primary-bgd'],
|
|
@@ -171,10 +168,10 @@ const generateComponentTheme = theme => {
|
|
|
171
168
|
// Overrides for ghost hover states to ensure correct color contrast for a11y
|
|
172
169
|
successGhostHoverBackground: (0, _alpha.alpha)(colors === null || colors === void 0 ? void 0 : colors.textSuccess, 1)
|
|
173
170
|
};
|
|
174
|
-
return {
|
|
171
|
+
return {
|
|
172
|
+
...componentVariables,
|
|
175
173
|
...themeSpecificStyle[themeName]
|
|
176
174
|
};
|
|
177
175
|
};
|
|
178
|
-
|
|
179
176
|
var _default = generateComponentTheme;
|
|
180
177
|
exports.default = _default;
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ButtonLocator = void 0;
|
|
7
|
-
|
|
8
7
|
var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
|
|
9
|
-
|
|
10
8
|
var _uiTestQueries = require("@instructure/ui-test-queries");
|
|
11
|
-
|
|
12
9
|
var _index = require("./index");
|
|
13
|
-
|
|
14
10
|
/*
|
|
15
11
|
* The MIT License (MIT)
|
|
16
12
|
*
|
|
@@ -34,13 +30,13 @@ var _index = require("./index");
|
|
|
34
30
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
31
|
* SOFTWARE.
|
|
36
32
|
*/
|
|
33
|
+
|
|
37
34
|
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
38
35
|
const ButtonLocator = (0, _locator.locator)(_index.Button.selector, {
|
|
39
36
|
click: async function (element) {
|
|
40
37
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
41
38
|
args[_key - 1] = arguments[_key];
|
|
42
39
|
}
|
|
43
|
-
|
|
44
40
|
return (await (0, _uiTestQueries.find)(element, 'a,button,[role="button"]')).click(...args);
|
|
45
41
|
}
|
|
46
42
|
});
|
package/lib/Button/index.js
CHANGED
|
@@ -1,36 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.Button = void 0;
|
|
11
|
-
|
|
12
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
11
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
17
|
-
|
|
18
12
|
var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
|
|
19
|
-
|
|
20
13
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
21
|
-
|
|
22
14
|
var _emotion = require("@instructure/emotion");
|
|
23
|
-
|
|
24
15
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
25
|
-
|
|
26
16
|
var _BaseButton = require("../BaseButton");
|
|
27
|
-
|
|
28
17
|
var _props = require("./props");
|
|
29
|
-
|
|
30
18
|
const _excluded = ["children", "type", "size", "as", "color", "focusColor", "display", "textAlign", "withBackground", "margin", "cursor", "href", "renderIcon"];
|
|
31
|
-
|
|
32
19
|
var _dec, _dec2, _class, _class2;
|
|
33
|
-
|
|
34
20
|
/**
|
|
35
21
|
---
|
|
36
22
|
category: components
|
|
@@ -43,50 +29,45 @@ let Button = (_dec = (0, _emotion.withStyle)(null, _theme.default), _dec2 = (0,
|
|
|
43
29
|
super(...arguments);
|
|
44
30
|
this._buttonComponent = null;
|
|
45
31
|
this.ref = null;
|
|
46
|
-
|
|
47
32
|
this.handleElementRef = el => {
|
|
48
33
|
const elementRef = this.props.elementRef;
|
|
49
34
|
this.ref = el;
|
|
50
|
-
|
|
51
35
|
if (typeof elementRef === 'function') {
|
|
52
36
|
elementRef(el);
|
|
53
37
|
}
|
|
54
38
|
};
|
|
55
|
-
|
|
56
39
|
this.handleButtonRef = component => {
|
|
57
40
|
this._buttonComponent = component;
|
|
58
41
|
};
|
|
59
42
|
}
|
|
60
|
-
|
|
61
43
|
get focused() {
|
|
62
44
|
return this._buttonComponent && this._buttonComponent.focused;
|
|
63
45
|
}
|
|
64
|
-
|
|
65
46
|
focus() {
|
|
66
47
|
this._buttonComponent && this._buttonComponent.focus();
|
|
67
48
|
}
|
|
68
|
-
|
|
69
49
|
render() {
|
|
70
50
|
const _this$props = this.props,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
51
|
+
children = _this$props.children,
|
|
52
|
+
type = _this$props.type,
|
|
53
|
+
size = _this$props.size,
|
|
54
|
+
as = _this$props.as,
|
|
55
|
+
color = _this$props.color,
|
|
56
|
+
focusColor = _this$props.focusColor,
|
|
57
|
+
display = _this$props.display,
|
|
58
|
+
textAlign = _this$props.textAlign,
|
|
59
|
+
withBackground = _this$props.withBackground,
|
|
60
|
+
margin = _this$props.margin,
|
|
61
|
+
cursor = _this$props.cursor,
|
|
62
|
+
href = _this$props.href,
|
|
63
|
+
renderIcon = _this$props.renderIcon,
|
|
64
|
+
props = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
|
|
85
65
|
const interaction = (0, _getInteraction.getInteraction)({
|
|
86
66
|
props
|
|
87
67
|
});
|
|
88
68
|
const themeOverride = this.props.themeOverride;
|
|
89
|
-
const buttonProps = {
|
|
69
|
+
const buttonProps = {
|
|
70
|
+
...(0, _passthroughProps.passthroughProps)(props),
|
|
90
71
|
type,
|
|
91
72
|
size,
|
|
92
73
|
elementRef: this.handleElementRef,
|
|
@@ -106,7 +87,6 @@ let Button = (_dec = (0, _emotion.withStyle)(null, _theme.default), _dec2 = (0,
|
|
|
106
87
|
};
|
|
107
88
|
return /*#__PURE__*/_react.default.createElement(_BaseButton.BaseButton, buttonProps, children);
|
|
108
89
|
}
|
|
109
|
-
|
|
110
90
|
}, _class2.displayName = "Button", _class2.componentId = 'Button', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
111
91
|
type: 'button',
|
|
112
92
|
size: 'medium',
|
package/lib/Button/locator.js
CHANGED
package/lib/Button/props.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _emotion = require("@instructure/emotion");
|
|
13
|
-
|
|
14
10
|
/*
|
|
15
11
|
* The MIT License (MIT)
|
|
16
12
|
*
|
|
@@ -34,6 +30,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
34
30
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
31
|
* SOFTWARE.
|
|
36
32
|
*/
|
|
33
|
+
|
|
37
34
|
const propTypes = {
|
|
38
35
|
children: _propTypes.default.node,
|
|
39
36
|
type: _propTypes.default.oneOf(['button', 'submit', 'reset']),
|
package/lib/Button/theme.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -11,5 +10,4 @@ Object.defineProperty(exports, "default", {
|
|
|
11
10
|
return _theme.default;
|
|
12
11
|
}
|
|
13
12
|
});
|
|
14
|
-
|
|
15
13
|
var _theme = _interopRequireDefault(require("../BaseButton/theme"));
|