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