@instructure/ui-link 8.23.1-snapshot.8 → 8.23.1-snapshot.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/Link/__examples__/Link.examples.js +3 -1
- package/es/Link/index.js +27 -14
- package/es/Link/props.js +3 -1
- package/lib/Link/__examples__/Link.examples.js +3 -1
- package/lib/Link/index.js +27 -14
- package/lib/Link/props.js +3 -1
- package/package.json +18 -18
- package/src/Link/__examples__/Link.examples.ts +3 -1
- package/src/Link/index.tsx +17 -4
- package/src/Link/props.ts +15 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Link/__examples__/Link.examples.d.ts.map +1 -1
- package/types/Link/index.d.ts +6 -0
- package/types/Link/index.d.ts.map +1 -1
- package/types/Link/props.d.ts +9 -0
- package/types/Link/props.d.ts.map +1 -1
package/es/Link/index.js
CHANGED
|
@@ -168,6 +168,19 @@ let Link = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
168
168
|
return hasVisibleChildren(this.props.children);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
get role() {
|
|
172
|
+
const _this$props3 = this.props,
|
|
173
|
+
role = _this$props3.role,
|
|
174
|
+
forceButtonRole = _this$props3.forceButtonRole,
|
|
175
|
+
onClick = _this$props3.onClick;
|
|
176
|
+
|
|
177
|
+
if (forceButtonRole) {
|
|
178
|
+
return onClick && this.element !== 'button' ? 'button' : role;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return role;
|
|
182
|
+
}
|
|
183
|
+
|
|
171
184
|
focus() {
|
|
172
185
|
this.ref && this.ref.focus();
|
|
173
186
|
}
|
|
@@ -185,22 +198,21 @@ let Link = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
185
198
|
render() {
|
|
186
199
|
var _this$props$styles2;
|
|
187
200
|
|
|
188
|
-
const _this$
|
|
189
|
-
children = _this$
|
|
190
|
-
onClick = _this$
|
|
191
|
-
color = _this$
|
|
192
|
-
href = _this$
|
|
193
|
-
margin = _this$
|
|
194
|
-
renderIcon = _this$
|
|
195
|
-
iconPlacement = _this$
|
|
196
|
-
isWithinText = _this$
|
|
197
|
-
props = _objectWithoutProperties(_this$
|
|
201
|
+
const _this$props4 = this.props,
|
|
202
|
+
children = _this$props4.children,
|
|
203
|
+
onClick = _this$props4.onClick,
|
|
204
|
+
color = _this$props4.color,
|
|
205
|
+
href = _this$props4.href,
|
|
206
|
+
margin = _this$props4.margin,
|
|
207
|
+
renderIcon = _this$props4.renderIcon,
|
|
208
|
+
iconPlacement = _this$props4.iconPlacement,
|
|
209
|
+
isWithinText = _this$props4.isWithinText,
|
|
210
|
+
props = _objectWithoutProperties(_this$props4, _excluded);
|
|
198
211
|
|
|
199
212
|
const interaction = this.interaction;
|
|
200
213
|
const isDisabled = interaction === 'disabled';
|
|
201
|
-
const role = onClick && this.element !== 'button' ? 'button' : void 0;
|
|
202
214
|
const type = this.element === 'button' || this.element === 'input' ? 'button' : void 0;
|
|
203
|
-
const tabIndex = role === 'button' && !isDisabled ? 0 : void 0;
|
|
215
|
+
const tabIndex = this.role === 'button' && !isDisabled ? 0 : void 0;
|
|
204
216
|
return jsx(View, Object.assign({}, passthroughProps(props), {
|
|
205
217
|
elementRef: this.handleElementRef,
|
|
206
218
|
as: this.element,
|
|
@@ -211,7 +223,7 @@ let Link = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
211
223
|
onFocus: this.handleFocus,
|
|
212
224
|
onBlur: this.handleBlur,
|
|
213
225
|
"aria-disabled": isDisabled ? 'true' : void 0,
|
|
214
|
-
role: role,
|
|
226
|
+
role: this.role,
|
|
215
227
|
type: type,
|
|
216
228
|
tabIndex: tabIndex,
|
|
217
229
|
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.link
|
|
@@ -223,7 +235,8 @@ let Link = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
223
235
|
interaction: void 0,
|
|
224
236
|
color: 'link',
|
|
225
237
|
iconPlacement: 'start',
|
|
226
|
-
isWithinText: true
|
|
238
|
+
isWithinText: true,
|
|
239
|
+
forceButtonRole: true
|
|
227
240
|
}, _class2)) || _class) || _class);
|
|
228
241
|
export default Link;
|
|
229
242
|
export { Link };
|
package/es/Link/props.js
CHANGED
|
@@ -29,6 +29,8 @@ const propTypes = {
|
|
|
29
29
|
color: PropTypes.oneOf(['link', 'link-inverse']),
|
|
30
30
|
elementRef: PropTypes.func,
|
|
31
31
|
as: PropTypes.elementType,
|
|
32
|
+
role: PropTypes.string,
|
|
33
|
+
forceButtonRole: PropTypes.bool,
|
|
32
34
|
interaction: PropTypes.oneOf(['enabled', 'disabled']),
|
|
33
35
|
margin: ThemeablePropTypes.spacing,
|
|
34
36
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
@@ -39,5 +41,5 @@ const propTypes = {
|
|
|
39
41
|
onFocus: PropTypes.func,
|
|
40
42
|
onBlur: PropTypes.func
|
|
41
43
|
};
|
|
42
|
-
const allowedProps = ['children', 'href', 'color', 'elementRef', 'as', 'interaction', 'margin', 'renderIcon', 'iconPlacement', 'display', 'isWithinText', 'onClick', 'onFocus', 'onBlur'];
|
|
44
|
+
const allowedProps = ['children', 'href', 'color', 'elementRef', 'as', 'role', 'forceButtonRole', 'interaction', 'margin', 'renderIcon', 'iconPlacement', 'display', 'isWithinText', 'onClick', 'onFocus', 'onBlur'];
|
|
43
45
|
export { propTypes, allowedProps };
|
package/lib/Link/index.js
CHANGED
|
@@ -177,6 +177,19 @@ let Link = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
177
177
|
return (0, _hasVisibleChildren.hasVisibleChildren)(this.props.children);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
get role() {
|
|
181
|
+
const _this$props3 = this.props,
|
|
182
|
+
role = _this$props3.role,
|
|
183
|
+
forceButtonRole = _this$props3.forceButtonRole,
|
|
184
|
+
onClick = _this$props3.onClick;
|
|
185
|
+
|
|
186
|
+
if (forceButtonRole) {
|
|
187
|
+
return onClick && this.element !== 'button' ? 'button' : role;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return role;
|
|
191
|
+
}
|
|
192
|
+
|
|
180
193
|
focus() {
|
|
181
194
|
this.ref && this.ref.focus();
|
|
182
195
|
}
|
|
@@ -194,21 +207,20 @@ let Link = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
194
207
|
render() {
|
|
195
208
|
var _this$props$styles2;
|
|
196
209
|
|
|
197
|
-
const _this$
|
|
198
|
-
children = _this$
|
|
199
|
-
onClick = _this$
|
|
200
|
-
color = _this$
|
|
201
|
-
href = _this$
|
|
202
|
-
margin = _this$
|
|
203
|
-
renderIcon = _this$
|
|
204
|
-
iconPlacement = _this$
|
|
205
|
-
isWithinText = _this$
|
|
206
|
-
props = (0, _objectWithoutProperties2.default)(_this$
|
|
210
|
+
const _this$props4 = this.props,
|
|
211
|
+
children = _this$props4.children,
|
|
212
|
+
onClick = _this$props4.onClick,
|
|
213
|
+
color = _this$props4.color,
|
|
214
|
+
href = _this$props4.href,
|
|
215
|
+
margin = _this$props4.margin,
|
|
216
|
+
renderIcon = _this$props4.renderIcon,
|
|
217
|
+
iconPlacement = _this$props4.iconPlacement,
|
|
218
|
+
isWithinText = _this$props4.isWithinText,
|
|
219
|
+
props = (0, _objectWithoutProperties2.default)(_this$props4, _excluded);
|
|
207
220
|
const interaction = this.interaction;
|
|
208
221
|
const isDisabled = interaction === 'disabled';
|
|
209
|
-
const role = onClick && this.element !== 'button' ? 'button' : void 0;
|
|
210
222
|
const type = this.element === 'button' || this.element === 'input' ? 'button' : void 0;
|
|
211
|
-
const tabIndex = role === 'button' && !isDisabled ? 0 : void 0;
|
|
223
|
+
const tabIndex = this.role === 'button' && !isDisabled ? 0 : void 0;
|
|
212
224
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, (0, _passthroughProps.passthroughProps)(props), {
|
|
213
225
|
elementRef: this.handleElementRef,
|
|
214
226
|
as: this.element,
|
|
@@ -219,7 +231,7 @@ let Link = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
219
231
|
onFocus: this.handleFocus,
|
|
220
232
|
onBlur: this.handleBlur,
|
|
221
233
|
"aria-disabled": isDisabled ? 'true' : void 0,
|
|
222
|
-
role: role,
|
|
234
|
+
role: this.role,
|
|
223
235
|
type: type,
|
|
224
236
|
tabIndex: tabIndex,
|
|
225
237
|
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.link
|
|
@@ -231,7 +243,8 @@ let Link = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
231
243
|
interaction: void 0,
|
|
232
244
|
color: 'link',
|
|
233
245
|
iconPlacement: 'start',
|
|
234
|
-
isWithinText: true
|
|
246
|
+
isWithinText: true,
|
|
247
|
+
forceButtonRole: true
|
|
235
248
|
}, _class2)) || _class) || _class);
|
|
236
249
|
exports.Link = Link;
|
|
237
250
|
var _default = Link;
|
package/lib/Link/props.js
CHANGED
|
@@ -40,6 +40,8 @@ const propTypes = {
|
|
|
40
40
|
color: _propTypes.default.oneOf(['link', 'link-inverse']),
|
|
41
41
|
elementRef: _propTypes.default.func,
|
|
42
42
|
as: _propTypes.default.elementType,
|
|
43
|
+
role: _propTypes.default.string,
|
|
44
|
+
forceButtonRole: _propTypes.default.bool,
|
|
43
45
|
interaction: _propTypes.default.oneOf(['enabled', 'disabled']),
|
|
44
46
|
margin: _emotion.ThemeablePropTypes.spacing,
|
|
45
47
|
renderIcon: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
|
|
@@ -51,5 +53,5 @@ const propTypes = {
|
|
|
51
53
|
onBlur: _propTypes.default.func
|
|
52
54
|
};
|
|
53
55
|
exports.propTypes = propTypes;
|
|
54
|
-
const allowedProps = ['children', 'href', 'color', 'elementRef', 'as', 'interaction', 'margin', 'renderIcon', 'iconPlacement', 'display', 'isWithinText', 'onClick', 'onFocus', 'onBlur'];
|
|
56
|
+
const allowedProps = ['children', 'href', 'color', 'elementRef', 'as', 'role', 'forceButtonRole', 'interaction', 'margin', 'renderIcon', 'iconPlacement', 'display', 'isWithinText', 'onClick', 'onFocus', 'onBlur'];
|
|
55
57
|
exports.allowedProps = allowedProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-link",
|
|
3
|
-
"version": "8.23.1-snapshot.
|
|
3
|
+
"version": "8.23.1-snapshot.9+11828d0b3",
|
|
4
4
|
"description": "A component for creating links",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,25 +24,25 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.13.10",
|
|
27
|
-
"@instructure/console": "8.23.1-snapshot.
|
|
28
|
-
"@instructure/emotion": "8.23.1-snapshot.
|
|
29
|
-
"@instructure/shared-types": "8.23.1-snapshot.
|
|
30
|
-
"@instructure/ui-a11y-utils": "8.23.1-snapshot.
|
|
31
|
-
"@instructure/ui-color-utils": "8.23.1-snapshot.
|
|
32
|
-
"@instructure/ui-dom-utils": "8.23.1-snapshot.
|
|
33
|
-
"@instructure/ui-icons": "8.23.1-snapshot.
|
|
34
|
-
"@instructure/ui-prop-types": "8.23.1-snapshot.
|
|
35
|
-
"@instructure/ui-react-utils": "8.23.1-snapshot.
|
|
36
|
-
"@instructure/ui-testable": "8.23.1-snapshot.
|
|
37
|
-
"@instructure/ui-view": "8.23.1-snapshot.
|
|
27
|
+
"@instructure/console": "8.23.1-snapshot.9+11828d0b3",
|
|
28
|
+
"@instructure/emotion": "8.23.1-snapshot.9+11828d0b3",
|
|
29
|
+
"@instructure/shared-types": "8.23.1-snapshot.9+11828d0b3",
|
|
30
|
+
"@instructure/ui-a11y-utils": "8.23.1-snapshot.9+11828d0b3",
|
|
31
|
+
"@instructure/ui-color-utils": "8.23.1-snapshot.9+11828d0b3",
|
|
32
|
+
"@instructure/ui-dom-utils": "8.23.1-snapshot.9+11828d0b3",
|
|
33
|
+
"@instructure/ui-icons": "8.23.1-snapshot.9+11828d0b3",
|
|
34
|
+
"@instructure/ui-prop-types": "8.23.1-snapshot.9+11828d0b3",
|
|
35
|
+
"@instructure/ui-react-utils": "8.23.1-snapshot.9+11828d0b3",
|
|
36
|
+
"@instructure/ui-testable": "8.23.1-snapshot.9+11828d0b3",
|
|
37
|
+
"@instructure/ui-view": "8.23.1-snapshot.9+11828d0b3",
|
|
38
38
|
"prop-types": "^15"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@instructure/ui-babel-preset": "8.23.1-snapshot.
|
|
42
|
-
"@instructure/ui-test-locator": "8.23.1-snapshot.
|
|
43
|
-
"@instructure/ui-test-queries": "8.23.1-snapshot.
|
|
44
|
-
"@instructure/ui-test-utils": "8.23.1-snapshot.
|
|
45
|
-
"@instructure/ui-themes": "8.23.1-snapshot.
|
|
41
|
+
"@instructure/ui-babel-preset": "8.23.1-snapshot.9+11828d0b3",
|
|
42
|
+
"@instructure/ui-test-locator": "8.23.1-snapshot.9+11828d0b3",
|
|
43
|
+
"@instructure/ui-test-queries": "8.23.1-snapshot.9+11828d0b3",
|
|
44
|
+
"@instructure/ui-test-utils": "8.23.1-snapshot.9+11828d0b3",
|
|
45
|
+
"@instructure/ui-themes": "8.23.1-snapshot.9+11828d0b3"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": ">=16.8 <=17"
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"sideEffects": false,
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "11828d0b32844a522d267e189c8bc52aa928843a"
|
|
55
55
|
}
|
package/src/Link/index.tsx
CHANGED
|
@@ -65,7 +65,8 @@ class Link extends Component<LinkProps, LinkState> {
|
|
|
65
65
|
interaction: undefined,
|
|
66
66
|
color: 'link',
|
|
67
67
|
iconPlacement: 'start',
|
|
68
|
-
isWithinText: true
|
|
68
|
+
isWithinText: true,
|
|
69
|
+
forceButtonRole: true
|
|
69
70
|
} as const
|
|
70
71
|
|
|
71
72
|
state = { hasFocus: false }
|
|
@@ -182,6 +183,16 @@ class Link extends Component<LinkProps, LinkState> {
|
|
|
182
183
|
return hasVisibleChildren(this.props.children)
|
|
183
184
|
}
|
|
184
185
|
|
|
186
|
+
get role() {
|
|
187
|
+
const { role, forceButtonRole, onClick } = this.props
|
|
188
|
+
|
|
189
|
+
if (forceButtonRole) {
|
|
190
|
+
return onClick && this.element !== 'button' ? 'button' : role
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return role
|
|
194
|
+
}
|
|
195
|
+
|
|
185
196
|
focus() {
|
|
186
197
|
this.ref && (this.ref as HTMLElement).focus()
|
|
187
198
|
}
|
|
@@ -211,15 +222,17 @@ class Link extends Component<LinkProps, LinkState> {
|
|
|
211
222
|
isWithinText,
|
|
212
223
|
...props
|
|
213
224
|
} = this.props
|
|
225
|
+
|
|
214
226
|
const { interaction } = this
|
|
215
227
|
|
|
216
228
|
const isDisabled = interaction === 'disabled'
|
|
217
|
-
|
|
229
|
+
|
|
218
230
|
const type =
|
|
219
231
|
this.element === 'button' || this.element === 'input'
|
|
220
232
|
? 'button'
|
|
221
233
|
: undefined
|
|
222
|
-
|
|
234
|
+
|
|
235
|
+
const tabIndex = this.role === 'button' && !isDisabled ? 0 : undefined
|
|
223
236
|
|
|
224
237
|
return (
|
|
225
238
|
<View
|
|
@@ -233,7 +246,7 @@ class Link extends Component<LinkProps, LinkState> {
|
|
|
233
246
|
onFocus={this.handleFocus}
|
|
234
247
|
onBlur={this.handleBlur}
|
|
235
248
|
aria-disabled={isDisabled ? 'true' : undefined}
|
|
236
|
-
role={role}
|
|
249
|
+
role={this.role}
|
|
237
250
|
type={type}
|
|
238
251
|
tabIndex={tabIndex}
|
|
239
252
|
css={this.props.styles?.link}
|
package/src/Link/props.ts
CHANGED
|
@@ -67,6 +67,17 @@ type LinkOwnProps = {
|
|
|
67
67
|
*/
|
|
68
68
|
as?: AsElementType
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* The ARIA role of the element.
|
|
72
|
+
*/
|
|
73
|
+
role?: string
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* If the Link has an onClick handler but is not a button element,
|
|
77
|
+
* force ARIA role to be "button".
|
|
78
|
+
*/
|
|
79
|
+
forceButtonRole?: boolean
|
|
80
|
+
|
|
70
81
|
/**
|
|
71
82
|
* Determines if the link is enabled or disabled
|
|
72
83
|
*/
|
|
@@ -142,6 +153,8 @@ const propTypes: PropValidators<PropKeys> = {
|
|
|
142
153
|
color: PropTypes.oneOf(['link', 'link-inverse']),
|
|
143
154
|
elementRef: PropTypes.func,
|
|
144
155
|
as: PropTypes.elementType,
|
|
156
|
+
role: PropTypes.string,
|
|
157
|
+
forceButtonRole: PropTypes.bool,
|
|
145
158
|
interaction: PropTypes.oneOf(['enabled', 'disabled']),
|
|
146
159
|
margin: ThemeablePropTypes.spacing,
|
|
147
160
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
@@ -165,6 +178,8 @@ const allowedProps: AllowedPropKeys = [
|
|
|
165
178
|
'color',
|
|
166
179
|
'elementRef',
|
|
167
180
|
'as',
|
|
181
|
+
'role',
|
|
182
|
+
'forceButtonRole',
|
|
168
183
|
'interaction',
|
|
169
184
|
'margin',
|
|
170
185
|
'renderIcon',
|