@instructure/ui-buttons 11.7.8 → 11.7.9-pr-snapshot-1792147648392
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 +13 -0
- package/es/BaseButton/v1/index.js +213 -289
- package/es/BaseButton/v1/props.js +24 -26
- package/es/BaseButton/v1/styles.js +399 -450
- package/es/BaseButton/v1/theme.js +140 -177
- package/es/BaseButton/v2/index.js +227 -306
- package/es/BaseButton/v2/props.js +24 -26
- package/es/BaseButton/v2/styles.js +550 -604
- package/es/Button/v1/index.js +78 -116
- package/es/Button/v1/props.js +19 -26
- package/es/Button/v1/theme.js +1 -25
- package/es/Button/v2/index.js +81 -118
- package/es/Button/v2/props.js +19 -26
- package/es/CloseButton/v1/index.js +83 -120
- package/es/CloseButton/v1/props.js +17 -26
- package/es/CloseButton/v1/styles.js +30 -67
- package/es/CloseButton/v1/theme.js +12 -44
- package/es/CloseButton/v2/index.js +88 -124
- package/es/CloseButton/v2/props.js +17 -26
- package/es/CloseButton/v2/styles.js +30 -67
- package/es/CondensedButton/v1/index.js +70 -106
- package/es/CondensedButton/v1/props.js +16 -26
- package/es/CondensedButton/v1/theme.js +1 -25
- package/es/CondensedButton/v2/index.js +73 -108
- package/es/CondensedButton/v2/props.js +16 -26
- package/es/IconButton/v1/index.js +74 -114
- package/es/IconButton/v1/props.js +20 -26
- package/es/IconButton/v1/theme.js +1 -25
- package/es/IconButton/v2/index.js +77 -116
- package/es/IconButton/v2/props.js +20 -26
- package/es/ToggleButton/v1/index.js +74 -112
- package/es/ToggleButton/v1/props.js +17 -26
- package/es/ToggleButton/v2/index.js +75 -114
- package/es/ToggleButton/v2/props.js +18 -26
- package/es/exports/a.js +1 -25
- package/es/exports/b.js +1 -25
- package/package.json +19 -25
- package/src/BaseButton/v1/index.tsx +1 -4
- package/src/BaseButton/v2/index.tsx +1 -4
- package/tsconfig.build.json +0 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/BaseButton/v1/index.d.ts.map +1 -1
- package/types/BaseButton/v2/index.d.ts.map +1 -1
- package/lib/BaseButton/v1/index.js +0 -318
- package/lib/BaseButton/v1/props.js +0 -31
- package/lib/BaseButton/v1/styles.js +0 -465
- package/lib/BaseButton/v1/theme.js +0 -187
- package/lib/BaseButton/v2/index.js +0 -338
- package/lib/BaseButton/v2/props.js +0 -31
- package/lib/BaseButton/v2/styles.js +0 -625
- package/lib/Button/v1/index.js +0 -130
- package/lib/Button/v1/props.js +0 -31
- package/lib/Button/v1/theme.js +0 -13
- package/lib/Button/v2/index.js +0 -130
- package/lib/Button/v2/props.js +0 -31
- package/lib/CloseButton/v1/index.js +0 -137
- package/lib/CloseButton/v1/props.js +0 -31
- package/lib/CloseButton/v1/styles.js +0 -76
- package/lib/CloseButton/v1/theme.js +0 -51
- package/lib/CloseButton/v2/index.js +0 -140
- package/lib/CloseButton/v2/props.js +0 -31
- package/lib/CloseButton/v2/styles.js +0 -76
- package/lib/CondensedButton/v1/index.js +0 -119
- package/lib/CondensedButton/v1/props.js +0 -31
- package/lib/CondensedButton/v1/theme.js +0 -13
- package/lib/CondensedButton/v2/index.js +0 -119
- package/lib/CondensedButton/v2/props.js +0 -31
- package/lib/IconButton/v1/index.js +0 -129
- package/lib/IconButton/v1/props.js +0 -31
- package/lib/IconButton/v1/theme.js +0 -13
- package/lib/IconButton/v2/index.js +0 -129
- package/lib/IconButton/v2/props.js +0 -31
- package/lib/ToggleButton/v1/index.js +0 -129
- package/lib/ToggleButton/v1/props.js +0 -31
- package/lib/ToggleButton/v2/index.js +0 -130
- package/lib/ToggleButton/v2/props.js +0 -31
- package/lib/exports/a.js +0 -47
- package/lib/exports/b.js +0 -47
- package/lib/package.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
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
|
+
## [11.7.9-pr-snapshot-1792147648392](https://github.com/instructure/instructure-ui/compare/v11.7.8...v11.7.9-pr-snapshot-1792147648392) (2026-10-16)
|
|
7
|
+
|
|
8
|
+
### Build System
|
|
9
|
+
|
|
10
|
+
* **many:** replace babel with swc ([7e36c54](https://github.com/instructure/instructure-ui/commit/7e36c54d240b4fa483801c03ab18e7f860f561e2))
|
|
11
|
+
|
|
12
|
+
### BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
* **many:** `@instructure/ui-babel-preset` and
|
|
15
|
+
`@instructure/browserslist-config-instui` are removed and will no longer be
|
|
16
|
+
published. Packages depend on `@swc/helpers` instead of `@babel/runtime`.
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
## [11.7.8](https://github.com/instructure/instructure-ui/compare/v11.7.7...v11.7.8) (2026-10-02)
|
|
7
20
|
|
|
8
21
|
### Features
|
|
@@ -1,310 +1,234 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* The MIT License (MIT)
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
-
*
|
|
7
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
* in the Software without restriction, including without limitation the rights
|
|
10
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
* furnished to do so, subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
* copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
* SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
|
|
1
|
+
import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
26
3
|
import { Component } from 'react';
|
|
27
4
|
import keycode from 'keycode';
|
|
28
5
|
import { getElementType, getInteraction, passthroughProps, callRenderProp } from '@instructure/ui-react-utils';
|
|
29
6
|
import { isActiveElement } from '@instructure/ui-dom-utils';
|
|
30
7
|
import { hasVisibleChildren } from '@instructure/ui-a11y-utils';
|
|
31
8
|
import { View } from '@instructure/ui-view/v11_6';
|
|
32
|
-
|
|
33
|
-
// this bug is very likely caused by `babel-plugin-transform-imports` and can be reverted once it is removed from the codebase
|
|
34
|
-
import { isSafari, safeLinkProps } from '@instructure/ui-utils';
|
|
35
|
-
import { combineDataCid } from '@instructure/ui-utils';
|
|
9
|
+
import { isSafari, safeLinkProps, combineDataCid } from '@instructure/ui-utils';
|
|
36
10
|
import { withStyle } from '@instructure/emotion';
|
|
37
11
|
import generateStyles from './styles.js';
|
|
38
12
|
import generateComponentTheme from './theme.js';
|
|
39
13
|
import { allowedProps } from './props.js';
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return getInteraction({
|
|
92
|
-
props: this.props
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
get isDisabled() {
|
|
96
|
-
return this.interaction === 'disabled';
|
|
97
|
-
}
|
|
98
|
-
get isReadOnly() {
|
|
99
|
-
return this.interaction === 'readonly';
|
|
100
|
-
}
|
|
101
|
-
get isEnabled() {
|
|
102
|
-
return this.interaction === 'enabled';
|
|
103
|
-
}
|
|
104
|
-
get focusColor() {
|
|
105
|
-
const {
|
|
106
|
-
color,
|
|
107
|
-
focusColor,
|
|
108
|
-
withBackground
|
|
109
|
-
} = this.props;
|
|
110
|
-
|
|
111
|
-
// Give user specified focusColor preference
|
|
112
|
-
if (focusColor) {
|
|
113
|
-
return focusColor;
|
|
14
|
+
class BaseButton extends Component {
|
|
15
|
+
static{
|
|
16
|
+
this.displayName = 'BaseButton';
|
|
17
|
+
}
|
|
18
|
+
static{
|
|
19
|
+
this.componentId = 'BaseButton';
|
|
20
|
+
}
|
|
21
|
+
static{
|
|
22
|
+
this.allowedProps = allowedProps;
|
|
23
|
+
}
|
|
24
|
+
static{
|
|
25
|
+
this.defaultProps = {
|
|
26
|
+
type: 'button',
|
|
27
|
+
size: 'medium',
|
|
28
|
+
as: 'button',
|
|
29
|
+
interaction: undefined,
|
|
30
|
+
color: 'secondary',
|
|
31
|
+
shape: 'rectangle',
|
|
32
|
+
display: 'inline-block',
|
|
33
|
+
textAlign: 'start',
|
|
34
|
+
withBackground: true,
|
|
35
|
+
withBorder: true,
|
|
36
|
+
isCondensed: false,
|
|
37
|
+
margin: '0',
|
|
38
|
+
cursor: 'pointer'
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
componentDidMount() {
|
|
42
|
+
this.props.makeStyles?.(this.makeStylesVariables);
|
|
43
|
+
}
|
|
44
|
+
componentDidUpdate() {
|
|
45
|
+
this.props.makeStyles?.(this.makeStylesVariables);
|
|
46
|
+
}
|
|
47
|
+
get makeStylesVariables() {
|
|
48
|
+
return {
|
|
49
|
+
isDisabled: this.isDisabled,
|
|
50
|
+
hasOnlyIconVisible: this.hasOnlyIconVisible,
|
|
51
|
+
isEnabled: this.isEnabled
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
get hasOnlyIconVisible() {
|
|
55
|
+
const { children, renderIcon } = this.props;
|
|
56
|
+
return !!(renderIcon && !hasVisibleChildren(children));
|
|
57
|
+
}
|
|
58
|
+
get elementType() {
|
|
59
|
+
return getElementType(BaseButton, this.props);
|
|
60
|
+
}
|
|
61
|
+
get interaction() {
|
|
62
|
+
return getInteraction({
|
|
63
|
+
props: this.props
|
|
64
|
+
});
|
|
114
65
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// by default since it is replacing the `light` button variant.
|
|
118
|
-
// Override the focus color with info even though it is
|
|
119
|
-
// an inverse color
|
|
120
|
-
if (color === 'primary-inverse' && withBackground) {
|
|
121
|
-
return 'info';
|
|
66
|
+
get isDisabled() {
|
|
67
|
+
return this.interaction === 'disabled';
|
|
122
68
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
get focused() {
|
|
126
|
-
return isActiveElement(this.ref);
|
|
127
|
-
}
|
|
128
|
-
focus() {
|
|
129
|
-
this.ref && this.ref.focus();
|
|
130
|
-
}
|
|
131
|
-
handleElementRef = el => {
|
|
132
|
-
const {
|
|
133
|
-
elementRef
|
|
134
|
-
} = this.props;
|
|
135
|
-
this.ref = el;
|
|
136
|
-
if (typeof elementRef === 'function') {
|
|
137
|
-
elementRef(el);
|
|
69
|
+
get isReadOnly() {
|
|
70
|
+
return this.interaction === 'readonly';
|
|
138
71
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const {
|
|
142
|
-
onClick
|
|
143
|
-
} = this.props;
|
|
144
|
-
const {
|
|
145
|
-
interaction
|
|
146
|
-
} = this;
|
|
147
|
-
if (interaction !== 'enabled') {
|
|
148
|
-
event.preventDefault();
|
|
149
|
-
event.stopPropagation();
|
|
150
|
-
return;
|
|
72
|
+
get isEnabled() {
|
|
73
|
+
return this.interaction === 'enabled';
|
|
151
74
|
}
|
|
152
|
-
|
|
153
|
-
|
|
75
|
+
get focusColor() {
|
|
76
|
+
const { color, focusColor, withBackground } = this.props;
|
|
77
|
+
if (focusColor) {
|
|
78
|
+
return focusColor;
|
|
79
|
+
}
|
|
80
|
+
if (color === 'primary-inverse' && withBackground) {
|
|
81
|
+
return 'info';
|
|
82
|
+
}
|
|
83
|
+
return color.includes('inverse') ? 'inverse' : 'info';
|
|
154
84
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const {
|
|
158
|
-
onClick,
|
|
159
|
-
onKeyDown,
|
|
160
|
-
href
|
|
161
|
-
} = this.props;
|
|
162
|
-
const {
|
|
163
|
-
interaction
|
|
164
|
-
} = this;
|
|
165
|
-
if (typeof onKeyDown === 'function') {
|
|
166
|
-
onKeyDown(event);
|
|
85
|
+
get focused() {
|
|
86
|
+
return isActiveElement(this.ref);
|
|
167
87
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const {
|
|
171
|
-
space,
|
|
172
|
-
enter
|
|
173
|
-
} = keycode.codes;
|
|
174
|
-
if (this.elementType !== 'button' && [space, enter].includes(event.keyCode)) {
|
|
175
|
-
event.preventDefault();
|
|
176
|
-
event.stopPropagation();
|
|
177
|
-
if (typeof onClick === 'function' && interaction === 'enabled') {
|
|
178
|
-
onClick(event);
|
|
179
|
-
}
|
|
180
|
-
if (href) {
|
|
181
|
-
this.ref && this.ref.click();
|
|
182
|
-
}
|
|
88
|
+
focus() {
|
|
89
|
+
this.ref && this.ref.focus();
|
|
183
90
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
91
|
+
renderChildren() {
|
|
92
|
+
const { renderIcon, children, styles } = this.props;
|
|
93
|
+
const wrappedChildren = /*#__PURE__*/ _jsx("span", {
|
|
94
|
+
css: styles?.children,
|
|
95
|
+
children: children
|
|
96
|
+
});
|
|
97
|
+
if (!renderIcon) {
|
|
98
|
+
return wrappedChildren;
|
|
99
|
+
}
|
|
100
|
+
const { hasOnlyIconVisible } = this;
|
|
101
|
+
const wrappedIcon = /*#__PURE__*/ _jsx("span", {
|
|
102
|
+
css: styles?.iconSVG,
|
|
103
|
+
children: callRenderProp(renderIcon)
|
|
104
|
+
});
|
|
105
|
+
const flexChildren = hasOnlyIconVisible ? /*#__PURE__*/ _jsxs("span", {
|
|
106
|
+
css: styles?.iconOnly,
|
|
107
|
+
children: [
|
|
108
|
+
wrappedIcon,
|
|
109
|
+
children
|
|
110
|
+
]
|
|
111
|
+
}) : [
|
|
112
|
+
/*#__PURE__*/ _jsx("span", {
|
|
113
|
+
css: styles?.iconWrapper,
|
|
114
|
+
children: wrappedIcon
|
|
115
|
+
}, "icon"),
|
|
116
|
+
/*#__PURE__*/ _jsx("span", {
|
|
117
|
+
css: styles?.childrenWrapper,
|
|
118
|
+
children: wrappedChildren
|
|
119
|
+
}, "children")
|
|
120
|
+
];
|
|
121
|
+
return /*#__PURE__*/ _jsx("span", {
|
|
122
|
+
css: styles?.childrenLayout,
|
|
123
|
+
children: flexChildren
|
|
124
|
+
});
|
|
197
125
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
// only add 0 tabIndex value if it doesn't have it by default, see
|
|
262
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
|
|
263
|
-
let needsZeroTabIndex = true;
|
|
264
|
-
if (typeof elementType == 'string') {
|
|
265
|
-
if (['button', 'frame', 'iframe', 'input', 'object', 'select', 'textarea', 'summary'].includes(elementType)) {
|
|
266
|
-
needsZeroTabIndex = false;
|
|
267
|
-
}
|
|
268
|
-
if (href && (elementType === 'a' || elementType === 'area')) {
|
|
269
|
-
needsZeroTabIndex = false;
|
|
270
|
-
}
|
|
126
|
+
render() {
|
|
127
|
+
const { type, size, elementRef, as, href: rawHref, color, focusColor, textAlign, shape, display, withBackground, withBorder, isCondensed, margin, cursor, onClick, renderIcon, tabIndex, styles, makeStyles, withFocusOutline, ...props } = this.props;
|
|
128
|
+
const { isDisabled, isReadOnly, elementType } = this;
|
|
129
|
+
const { href, rel } = safeLinkProps({
|
|
130
|
+
tag: typeof elementType == 'string' ? elementType : 'button',
|
|
131
|
+
attr: 'href',
|
|
132
|
+
href: rawHref,
|
|
133
|
+
target: props.target,
|
|
134
|
+
rel: props.rel
|
|
135
|
+
});
|
|
136
|
+
let needsZeroTabIndex = true;
|
|
137
|
+
if (typeof elementType == 'string') {
|
|
138
|
+
if ([
|
|
139
|
+
'button',
|
|
140
|
+
'frame',
|
|
141
|
+
'iframe',
|
|
142
|
+
'input',
|
|
143
|
+
'object',
|
|
144
|
+
'select',
|
|
145
|
+
'textarea',
|
|
146
|
+
'summary'
|
|
147
|
+
].includes(elementType)) {
|
|
148
|
+
needsZeroTabIndex = false;
|
|
149
|
+
}
|
|
150
|
+
if (href && (elementType === 'a' || elementType === 'area')) {
|
|
151
|
+
needsZeroTabIndex = false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
let tabIndexValue = tabIndex;
|
|
155
|
+
if (onClick && as && needsZeroTabIndex || isSafari() && as) {
|
|
156
|
+
tabIndexValue = tabIndex || 0;
|
|
157
|
+
}
|
|
158
|
+
return /*#__PURE__*/ _jsx(View, {
|
|
159
|
+
...passthroughProps(props),
|
|
160
|
+
as: elementType,
|
|
161
|
+
focusColor: this.focusColor,
|
|
162
|
+
position: "relative",
|
|
163
|
+
display: display,
|
|
164
|
+
width: display === 'block' ? '100%' : 'auto',
|
|
165
|
+
borderRadius: shape === 'circle' ? 'circle' : 'medium',
|
|
166
|
+
background: "transparent",
|
|
167
|
+
padding: "none",
|
|
168
|
+
borderWidth: "none",
|
|
169
|
+
margin: margin,
|
|
170
|
+
cursor: isDisabled ? 'not-allowed' : cursor,
|
|
171
|
+
href: href,
|
|
172
|
+
rel: rel,
|
|
173
|
+
type: href ? undefined : type,
|
|
174
|
+
elementRef: this.handleElementRef,
|
|
175
|
+
onClick: this.handleClick,
|
|
176
|
+
onKeyDown: this.handleKeyDown,
|
|
177
|
+
role: onClick && as !== 'button' ? 'button' : undefined,
|
|
178
|
+
tabIndex: tabIndexValue,
|
|
179
|
+
disabled: isDisabled || isReadOnly,
|
|
180
|
+
css: styles?.baseButton,
|
|
181
|
+
withFocusOutline: withFocusOutline,
|
|
182
|
+
"data-cid": combineDataCid('BaseButton', this.props),
|
|
183
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
184
|
+
css: styles?.content,
|
|
185
|
+
children: this.renderChildren()
|
|
186
|
+
})
|
|
187
|
+
});
|
|
271
188
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
189
|
+
constructor(...args){
|
|
190
|
+
super(...args), this.ref = null, this.handleElementRef = (el)=>{
|
|
191
|
+
const { elementRef } = this.props;
|
|
192
|
+
this.ref = el;
|
|
193
|
+
if (typeof elementRef === 'function') {
|
|
194
|
+
elementRef(el);
|
|
195
|
+
}
|
|
196
|
+
}, this.handleClick = (event)=>{
|
|
197
|
+
const { onClick } = this.props;
|
|
198
|
+
const { interaction } = this;
|
|
199
|
+
if (interaction !== 'enabled') {
|
|
200
|
+
event.preventDefault();
|
|
201
|
+
event.stopPropagation();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (typeof onClick === 'function') {
|
|
205
|
+
onClick(event);
|
|
206
|
+
}
|
|
207
|
+
}, this.handleKeyDown = (event)=>{
|
|
208
|
+
const { onClick, onKeyDown, href } = this.props;
|
|
209
|
+
const { interaction } = this;
|
|
210
|
+
if (typeof onKeyDown === 'function') {
|
|
211
|
+
onKeyDown(event);
|
|
212
|
+
}
|
|
213
|
+
const { space, enter } = keycode.codes;
|
|
214
|
+
if (this.elementType !== 'button' && [
|
|
215
|
+
space,
|
|
216
|
+
enter
|
|
217
|
+
].includes(event.keyCode)) {
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
event.stopPropagation();
|
|
220
|
+
if (typeof onClick === 'function' && interaction === 'enabled') {
|
|
221
|
+
onClick(event);
|
|
222
|
+
}
|
|
223
|
+
if (href) {
|
|
224
|
+
this.ref && this.ref.click();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
};
|
|
276
228
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
position: "relative",
|
|
282
|
-
display: display,
|
|
283
|
-
width: display === 'block' ? '100%' : 'auto',
|
|
284
|
-
borderRadius: shape === 'circle' ? 'circle' : 'medium',
|
|
285
|
-
background: "transparent",
|
|
286
|
-
padding: "none",
|
|
287
|
-
borderWidth: "none",
|
|
288
|
-
margin: margin,
|
|
289
|
-
cursor: isDisabled ? 'not-allowed' : cursor,
|
|
290
|
-
href: href,
|
|
291
|
-
rel: rel,
|
|
292
|
-
type: href ? undefined : type,
|
|
293
|
-
elementRef: this.handleElementRef,
|
|
294
|
-
onClick: this.handleClick,
|
|
295
|
-
onKeyDown: this.handleKeyDown,
|
|
296
|
-
role: onClick && as !== 'button' ? 'button' : undefined,
|
|
297
|
-
tabIndex: tabIndexValue,
|
|
298
|
-
disabled: isDisabled || isReadOnly,
|
|
299
|
-
css: styles?.baseButton,
|
|
300
|
-
withFocusOutline: withFocusOutline,
|
|
301
|
-
"data-cid": combineDataCid('BaseButton', this.props),
|
|
302
|
-
children: _jsx("span", {
|
|
303
|
-
css: styles?.content,
|
|
304
|
-
children: this.renderChildren()
|
|
305
|
-
})
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
}) || _class);
|
|
229
|
+
}
|
|
230
|
+
BaseButton = _ts_decorate([
|
|
231
|
+
withStyle(generateStyles, generateComponentTheme)
|
|
232
|
+
], BaseButton);
|
|
309
233
|
export { BaseButton };
|
|
310
|
-
export default BaseButton;
|
|
234
|
+
export default BaseButton;
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const allowedProps = ['as', 'children', 'color', 'cursor', 'display', 'elementRef', 'focusColor', 'href', 'interaction', 'isCondensed', 'margin', 'onClick', 'onKeyDown', 'renderIcon', 'shape', 'size', 'tabIndex', 'textAlign', 'type', 'withBackground', 'withBorder'];
|
|
26
|
-
export { allowedProps };
|
|
1
|
+
const allowedProps = [
|
|
2
|
+
'as',
|
|
3
|
+
'children',
|
|
4
|
+
'color',
|
|
5
|
+
'cursor',
|
|
6
|
+
'display',
|
|
7
|
+
'elementRef',
|
|
8
|
+
'focusColor',
|
|
9
|
+
'href',
|
|
10
|
+
'interaction',
|
|
11
|
+
'isCondensed',
|
|
12
|
+
'margin',
|
|
13
|
+
'onClick',
|
|
14
|
+
'onKeyDown',
|
|
15
|
+
'renderIcon',
|
|
16
|
+
'shape',
|
|
17
|
+
'size',
|
|
18
|
+
'tabIndex',
|
|
19
|
+
'textAlign',
|
|
20
|
+
'type',
|
|
21
|
+
'withBackground',
|
|
22
|
+
'withBorder'
|
|
23
|
+
];
|
|
24
|
+
export { allowedProps };
|