@instructure/ui-link 8.8.1-snapshot.7 → 8.9.1-snapshot.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 +6 -0
- package/es/Link/index.js +10 -92
- package/es/Link/props.js +101 -0
- package/lib/Link/index.js +10 -92
- package/lib/Link/props.js +113 -0
- package/package.json +18 -18
- package/src/Link/index.tsx +9 -88
- package/src/Link/props.ts +147 -0
- package/src/Link/styles.ts +1 -1
- package/src/index.ts +1 -1
- package/types/Link/index.d.ts +34 -75
- package/types/Link/index.d.ts.map +1 -1
- package/types/Link/{types.d.ts → props.d.ts} +12 -6
- package/types/Link/props.d.ts.map +1 -0
- package/types/Link/styles.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/es/Link/types.js +0 -1
- package/lib/Link/types.js +0 -1
- package/src/Link/types.ts +0 -50
- package/types/Link/types.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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.9.0](https://github.com/instructure/instructure-ui/compare/v8.8.0...v8.9.0) (2021-09-15)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- fix shared-types TS errors ([7b83164](https://github.com/instructure/instructure-ui/commit/7b83164f4c5872f3a217e010563f59bf584ae4fc))
|
|
11
|
+
|
|
6
12
|
# [8.8.0](https://github.com/instructure/instructure-ui/compare/v8.7.0...v8.8.0) (2021-08-27)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @instructure/ui-link
|
package/es/Link/index.js
CHANGED
|
@@ -29,16 +29,16 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
29
29
|
|
|
30
30
|
/** @jsx jsx */
|
|
31
31
|
import React, { Component } from 'react';
|
|
32
|
-
import PropTypes from 'prop-types';
|
|
33
32
|
import { View } from '@instructure/ui-view';
|
|
34
33
|
import { hasVisibleChildren } from '@instructure/ui-a11y-utils';
|
|
35
34
|
import { isActiveElement, findFocusable } from '@instructure/ui-dom-utils';
|
|
36
35
|
import { getElementType, getInteraction, matchComponentTypes, passthroughProps, callRenderProp } from '@instructure/ui-react-utils';
|
|
37
36
|
import { logWarn as warn } from '@instructure/console';
|
|
38
37
|
import { testable } from '@instructure/ui-testable';
|
|
39
|
-
import { withStyle, jsx
|
|
38
|
+
import { withStyle, jsx } from '@instructure/emotion';
|
|
40
39
|
import generateStyle from './styles';
|
|
41
40
|
import generateComponentTheme from './theme';
|
|
41
|
+
import { propTypes, allowedProps } from './props';
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
---
|
|
@@ -160,14 +160,18 @@ let Link = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
renderIcon() {
|
|
163
|
+
var _this$props$styles;
|
|
164
|
+
|
|
163
165
|
warn( // if display prop is used, warn about icon or TruncateText
|
|
164
166
|
this.props.display === void 0, '[Link] Using the display property with an icon may cause layout issues.');
|
|
165
167
|
return jsx("span", {
|
|
166
|
-
css: this.props.styles.icon
|
|
168
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.icon
|
|
167
169
|
}, callRenderProp(this.props.renderIcon));
|
|
168
170
|
}
|
|
169
171
|
|
|
170
172
|
render() {
|
|
173
|
+
var _this$props$styles2;
|
|
174
|
+
|
|
171
175
|
const _this$props = this.props,
|
|
172
176
|
children = _this$props.children,
|
|
173
177
|
onClick = _this$props.onClick,
|
|
@@ -197,102 +201,16 @@ let Link = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
197
201
|
role: role,
|
|
198
202
|
type: type,
|
|
199
203
|
tabIndex: tabIndex,
|
|
200
|
-
css: this.props.styles.link
|
|
204
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.link
|
|
201
205
|
}), renderIcon && iconPlacement === 'start' && this.renderIcon(), children, renderIcon && iconPlacement === 'end' && this.renderIcon());
|
|
202
206
|
}
|
|
203
207
|
|
|
204
|
-
}, _class2.displayName = "Link", _class2.componentId = 'Link', _class2.propTypes = {
|
|
205
|
-
/**
|
|
206
|
-
* The text and/or icon displayed by the link
|
|
207
|
-
*/
|
|
208
|
-
children: PropTypes.node.isRequired,
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Sets the link's `href` attribute
|
|
212
|
-
*/
|
|
213
|
-
href: PropTypes.string,
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Designates Link's text color to accommodate light and dark backgrounds
|
|
217
|
-
*/
|
|
218
|
-
color: PropTypes.oneOf(['link', 'link-inverse']),
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Provides a reference to the underlying HTML element
|
|
222
|
-
*/
|
|
223
|
-
elementRef: PropTypes.func,
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* The element type to render as (will default to `<a>` if href is provided)
|
|
227
|
-
*/
|
|
228
|
-
as: PropTypes.elementType,
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Determines if the link is enabled or disabled
|
|
232
|
-
*/
|
|
233
|
-
interaction: PropTypes.oneOf(['enabled', 'disabled']),
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
237
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
238
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
239
|
-
*/
|
|
240
|
-
margin: ThemeablePropTypes.spacing,
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Add an SVG icon to the Link. Do not add icons directly as
|
|
244
|
-
* children.
|
|
245
|
-
*/
|
|
246
|
-
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Place the icon before or after the text in the Link.
|
|
250
|
-
*/
|
|
251
|
-
iconPlacement: PropTypes.oneOf(['start', 'end']),
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Set the CSS display property of the Link element. 'auto' sets no display property.
|
|
255
|
-
*/
|
|
256
|
-
display: PropTypes.oneOf(['auto', 'block', 'inline-block', 'flex', 'inline-flex']),
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Set `false` to remove default underline if Link does not appear inline with text
|
|
260
|
-
*/
|
|
261
|
-
isWithinText: PropTypes.bool,
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Fires when the Link is clicked
|
|
265
|
-
*/
|
|
266
|
-
onClick: PropTypes.func,
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Fires when the Link gains focus
|
|
270
|
-
*/
|
|
271
|
-
onFocus: PropTypes.func,
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Fires when the Link loses focus
|
|
275
|
-
*/
|
|
276
|
-
onBlur: PropTypes.func,
|
|
277
|
-
// eslint-disable-next-line react/require-default-props
|
|
278
|
-
makeStyles: PropTypes.func,
|
|
279
|
-
// eslint-disable-next-line react/require-default-props
|
|
280
|
-
styles: PropTypes.object
|
|
281
|
-
}, _class2.defaultProps = {
|
|
282
|
-
href: void 0,
|
|
283
|
-
elementRef: void 0,
|
|
208
|
+
}, _class2.displayName = "Link", _class2.componentId = 'Link', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
284
209
|
// Leave interaction default undefined so that `disabled` can also be supplied
|
|
285
210
|
interaction: void 0,
|
|
286
|
-
margin: void 0,
|
|
287
|
-
renderIcon: void 0,
|
|
288
|
-
display: void 0,
|
|
289
211
|
color: 'link',
|
|
290
|
-
as: void 0,
|
|
291
212
|
iconPlacement: 'start',
|
|
292
|
-
isWithinText: true
|
|
293
|
-
onClick: void 0,
|
|
294
|
-
onFocus: void 0,
|
|
295
|
-
onBlur: void 0
|
|
213
|
+
isWithinText: true
|
|
296
214
|
}, _temp)) || _class) || _class);
|
|
297
215
|
export default Link;
|
|
298
216
|
export { Link };
|
package/es/Link/props.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import PropTypes from 'prop-types';
|
|
25
|
+
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
26
|
+
const propTypes = {
|
|
27
|
+
/**
|
|
28
|
+
* The text and/or icon displayed by the link
|
|
29
|
+
*/
|
|
30
|
+
children: PropTypes.node.isRequired,
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Sets the link's `href` attribute
|
|
34
|
+
*/
|
|
35
|
+
href: PropTypes.string,
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Designates Link's text color to accommodate light and dark backgrounds
|
|
39
|
+
*/
|
|
40
|
+
color: PropTypes.oneOf(['link', 'link-inverse']),
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Provides a reference to the underlying HTML element
|
|
44
|
+
*/
|
|
45
|
+
elementRef: PropTypes.func,
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The element type to render as (will default to `<a>` if href is provided)
|
|
49
|
+
*/
|
|
50
|
+
as: PropTypes.elementType,
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Determines if the link is enabled or disabled
|
|
54
|
+
*/
|
|
55
|
+
interaction: PropTypes.oneOf(['enabled', 'disabled']),
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
59
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
60
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
61
|
+
*/
|
|
62
|
+
margin: ThemeablePropTypes.spacing,
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Add an SVG icon to the Link. Do not add icons directly as
|
|
66
|
+
* children.
|
|
67
|
+
*/
|
|
68
|
+
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Place the icon before or after the text in the Link.
|
|
72
|
+
*/
|
|
73
|
+
iconPlacement: PropTypes.oneOf(['start', 'end']),
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Set the CSS display property of the Link element. 'auto' sets no display property.
|
|
77
|
+
*/
|
|
78
|
+
display: PropTypes.oneOf(['auto', 'block', 'inline-block', 'flex', 'inline-flex']),
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Set `false` to remove default underline if Link does not appear inline with text
|
|
82
|
+
*/
|
|
83
|
+
isWithinText: PropTypes.bool,
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Fires when the Link is clicked
|
|
87
|
+
*/
|
|
88
|
+
onClick: PropTypes.func,
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Fires when the Link gains focus
|
|
92
|
+
*/
|
|
93
|
+
onFocus: PropTypes.func,
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Fires when the Link loses focus
|
|
97
|
+
*/
|
|
98
|
+
onBlur: PropTypes.func
|
|
99
|
+
};
|
|
100
|
+
const allowedProps = ['children', 'href', 'color', 'elementRef', 'as', 'interaction', 'margin', 'renderIcon', 'iconPlacement', 'display', 'isWithinText', 'onClick', 'onFocus', 'onBlur'];
|
|
101
|
+
export { propTypes, allowedProps };
|
package/lib/Link/index.js
CHANGED
|
@@ -13,8 +13,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
13
13
|
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
|
|
16
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
16
|
var _View = require("@instructure/ui-view/lib/View");
|
|
19
17
|
|
|
20
18
|
var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
|
|
@@ -43,6 +41,8 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
43
41
|
|
|
44
42
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
45
43
|
|
|
44
|
+
var _props = require("./props");
|
|
45
|
+
|
|
46
46
|
const _excluded = ["children", "onClick", "color", "href", "margin", "renderIcon", "iconPlacement", "isWithinText"];
|
|
47
47
|
|
|
48
48
|
var _dec, _dec2, _class, _class2, _temp;
|
|
@@ -169,14 +169,18 @@ let Link = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
renderIcon() {
|
|
172
|
+
var _this$props$styles;
|
|
173
|
+
|
|
172
174
|
(0, _console.logWarn)( // if display prop is used, warn about icon or TruncateText
|
|
173
175
|
this.props.display === void 0, '[Link] Using the display property with an icon may cause layout issues.');
|
|
174
176
|
return (0, _emotion.jsx)("span", {
|
|
175
|
-
css: this.props.styles.icon
|
|
177
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.icon
|
|
176
178
|
}, (0, _callRenderProp.callRenderProp)(this.props.renderIcon));
|
|
177
179
|
}
|
|
178
180
|
|
|
179
181
|
render() {
|
|
182
|
+
var _this$props$styles2;
|
|
183
|
+
|
|
180
184
|
const _this$props = this.props,
|
|
181
185
|
children = _this$props.children,
|
|
182
186
|
onClick = _this$props.onClick,
|
|
@@ -205,102 +209,16 @@ let Link = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
205
209
|
role: role,
|
|
206
210
|
type: type,
|
|
207
211
|
tabIndex: tabIndex,
|
|
208
|
-
css: this.props.styles.link
|
|
212
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.link
|
|
209
213
|
}), renderIcon && iconPlacement === 'start' && this.renderIcon(), children, renderIcon && iconPlacement === 'end' && this.renderIcon());
|
|
210
214
|
}
|
|
211
215
|
|
|
212
|
-
}, _class2.displayName = "Link", _class2.componentId = 'Link', _class2.propTypes = {
|
|
213
|
-
/**
|
|
214
|
-
* The text and/or icon displayed by the link
|
|
215
|
-
*/
|
|
216
|
-
children: _propTypes.default.node.isRequired,
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Sets the link's `href` attribute
|
|
220
|
-
*/
|
|
221
|
-
href: _propTypes.default.string,
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Designates Link's text color to accommodate light and dark backgrounds
|
|
225
|
-
*/
|
|
226
|
-
color: _propTypes.default.oneOf(['link', 'link-inverse']),
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Provides a reference to the underlying HTML element
|
|
230
|
-
*/
|
|
231
|
-
elementRef: _propTypes.default.func,
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* The element type to render as (will default to `<a>` if href is provided)
|
|
235
|
-
*/
|
|
236
|
-
as: _propTypes.default.elementType,
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Determines if the link is enabled or disabled
|
|
240
|
-
*/
|
|
241
|
-
interaction: _propTypes.default.oneOf(['enabled', 'disabled']),
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
245
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
246
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
247
|
-
*/
|
|
248
|
-
margin: _emotion.ThemeablePropTypes.spacing,
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Add an SVG icon to the Link. Do not add icons directly as
|
|
252
|
-
* children.
|
|
253
|
-
*/
|
|
254
|
-
renderIcon: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Place the icon before or after the text in the Link.
|
|
258
|
-
*/
|
|
259
|
-
iconPlacement: _propTypes.default.oneOf(['start', 'end']),
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Set the CSS display property of the Link element. 'auto' sets no display property.
|
|
263
|
-
*/
|
|
264
|
-
display: _propTypes.default.oneOf(['auto', 'block', 'inline-block', 'flex', 'inline-flex']),
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Set `false` to remove default underline if Link does not appear inline with text
|
|
268
|
-
*/
|
|
269
|
-
isWithinText: _propTypes.default.bool,
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Fires when the Link is clicked
|
|
273
|
-
*/
|
|
274
|
-
onClick: _propTypes.default.func,
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Fires when the Link gains focus
|
|
278
|
-
*/
|
|
279
|
-
onFocus: _propTypes.default.func,
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Fires when the Link loses focus
|
|
283
|
-
*/
|
|
284
|
-
onBlur: _propTypes.default.func,
|
|
285
|
-
// eslint-disable-next-line react/require-default-props
|
|
286
|
-
makeStyles: _propTypes.default.func,
|
|
287
|
-
// eslint-disable-next-line react/require-default-props
|
|
288
|
-
styles: _propTypes.default.object
|
|
289
|
-
}, _class2.defaultProps = {
|
|
290
|
-
href: void 0,
|
|
291
|
-
elementRef: void 0,
|
|
216
|
+
}, _class2.displayName = "Link", _class2.componentId = 'Link', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
292
217
|
// Leave interaction default undefined so that `disabled` can also be supplied
|
|
293
218
|
interaction: void 0,
|
|
294
|
-
margin: void 0,
|
|
295
|
-
renderIcon: void 0,
|
|
296
|
-
display: void 0,
|
|
297
219
|
color: 'link',
|
|
298
|
-
as: void 0,
|
|
299
220
|
iconPlacement: 'start',
|
|
300
|
-
isWithinText: true
|
|
301
|
-
onClick: void 0,
|
|
302
|
-
onFocus: void 0,
|
|
303
|
-
onBlur: void 0
|
|
221
|
+
isWithinText: true
|
|
304
222
|
}, _temp)) || _class) || _class);
|
|
305
223
|
exports.Link = Link;
|
|
306
224
|
var _default = Link;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.allowedProps = exports.propTypes = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _emotion = require("@instructure/emotion");
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* The MIT License (MIT)
|
|
16
|
+
*
|
|
17
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
18
|
+
*
|
|
19
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
20
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
21
|
+
* in the Software without restriction, including without limitation the rights
|
|
22
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
24
|
+
* furnished to do so, subject to the following conditions:
|
|
25
|
+
*
|
|
26
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
27
|
+
* copies or substantial portions of the Software.
|
|
28
|
+
*
|
|
29
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
30
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
31
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
32
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
33
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
34
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
|
+
* SOFTWARE.
|
|
36
|
+
*/
|
|
37
|
+
const propTypes = {
|
|
38
|
+
/**
|
|
39
|
+
* The text and/or icon displayed by the link
|
|
40
|
+
*/
|
|
41
|
+
children: _propTypes.default.node.isRequired,
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Sets the link's `href` attribute
|
|
45
|
+
*/
|
|
46
|
+
href: _propTypes.default.string,
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Designates Link's text color to accommodate light and dark backgrounds
|
|
50
|
+
*/
|
|
51
|
+
color: _propTypes.default.oneOf(['link', 'link-inverse']),
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Provides a reference to the underlying HTML element
|
|
55
|
+
*/
|
|
56
|
+
elementRef: _propTypes.default.func,
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The element type to render as (will default to `<a>` if href is provided)
|
|
60
|
+
*/
|
|
61
|
+
as: _propTypes.default.elementType,
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Determines if the link is enabled or disabled
|
|
65
|
+
*/
|
|
66
|
+
interaction: _propTypes.default.oneOf(['enabled', 'disabled']),
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
70
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
71
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
72
|
+
*/
|
|
73
|
+
margin: _emotion.ThemeablePropTypes.spacing,
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Add an SVG icon to the Link. Do not add icons directly as
|
|
77
|
+
* children.
|
|
78
|
+
*/
|
|
79
|
+
renderIcon: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Place the icon before or after the text in the Link.
|
|
83
|
+
*/
|
|
84
|
+
iconPlacement: _propTypes.default.oneOf(['start', 'end']),
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Set the CSS display property of the Link element. 'auto' sets no display property.
|
|
88
|
+
*/
|
|
89
|
+
display: _propTypes.default.oneOf(['auto', 'block', 'inline-block', 'flex', 'inline-flex']),
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Set `false` to remove default underline if Link does not appear inline with text
|
|
93
|
+
*/
|
|
94
|
+
isWithinText: _propTypes.default.bool,
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Fires when the Link is clicked
|
|
98
|
+
*/
|
|
99
|
+
onClick: _propTypes.default.func,
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Fires when the Link gains focus
|
|
103
|
+
*/
|
|
104
|
+
onFocus: _propTypes.default.func,
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Fires when the Link loses focus
|
|
108
|
+
*/
|
|
109
|
+
onBlur: _propTypes.default.func
|
|
110
|
+
};
|
|
111
|
+
exports.propTypes = propTypes;
|
|
112
|
+
const allowedProps = ['children', 'href', 'color', 'elementRef', 'as', 'interaction', 'margin', 'renderIcon', 'iconPlacement', 'display', 'isWithinText', 'onClick', 'onFocus', 'onBlur'];
|
|
113
|
+
exports.allowedProps = allowedProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-link",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.1-snapshot.2+7f5faa3df",
|
|
4
4
|
"description": "A component for creating links",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -25,25 +25,25 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/runtime": "^7.13.10",
|
|
28
|
-
"@instructure/console": "8.
|
|
29
|
-
"@instructure/emotion": "8.
|
|
30
|
-
"@instructure/
|
|
31
|
-
"@instructure/ui-
|
|
32
|
-
"@instructure/ui-
|
|
33
|
-
"@instructure/ui-
|
|
34
|
-
"@instructure/ui-
|
|
35
|
-
"@instructure/ui-
|
|
36
|
-
"@instructure/ui-
|
|
37
|
-
"@instructure/ui-
|
|
28
|
+
"@instructure/console": "8.9.1-snapshot.2+7f5faa3df",
|
|
29
|
+
"@instructure/emotion": "8.9.1-snapshot.2+7f5faa3df",
|
|
30
|
+
"@instructure/shared-types": "8.9.1-snapshot.2+7f5faa3df",
|
|
31
|
+
"@instructure/ui-a11y-utils": "8.9.1-snapshot.2+7f5faa3df",
|
|
32
|
+
"@instructure/ui-color-utils": "8.9.1-snapshot.2+7f5faa3df",
|
|
33
|
+
"@instructure/ui-dom-utils": "8.9.1-snapshot.2+7f5faa3df",
|
|
34
|
+
"@instructure/ui-icons": "8.9.1-snapshot.2+7f5faa3df",
|
|
35
|
+
"@instructure/ui-prop-types": "8.9.1-snapshot.2+7f5faa3df",
|
|
36
|
+
"@instructure/ui-react-utils": "8.9.1-snapshot.2+7f5faa3df",
|
|
37
|
+
"@instructure/ui-testable": "8.9.1-snapshot.2+7f5faa3df",
|
|
38
|
+
"@instructure/ui-view": "8.9.1-snapshot.2+7f5faa3df",
|
|
38
39
|
"prop-types": "^15"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@instructure/
|
|
42
|
-
"@instructure/ui-
|
|
43
|
-
"@instructure/ui-test-
|
|
44
|
-
"@instructure/ui-test-
|
|
45
|
-
"@instructure/ui-
|
|
46
|
-
"@instructure/ui-themes": "8.8.1-snapshot.7+90b251d58"
|
|
42
|
+
"@instructure/ui-babel-preset": "8.9.1-snapshot.2+7f5faa3df",
|
|
43
|
+
"@instructure/ui-test-locator": "8.9.1-snapshot.2+7f5faa3df",
|
|
44
|
+
"@instructure/ui-test-queries": "8.9.1-snapshot.2+7f5faa3df",
|
|
45
|
+
"@instructure/ui-test-utils": "8.9.1-snapshot.2+7f5faa3df",
|
|
46
|
+
"@instructure/ui-themes": "8.9.1-snapshot.2+7f5faa3df"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"react": ">=16.8 <=17"
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"sideEffects": false,
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "7f5faa3df83667636304e0901ef1008d98dffc9a"
|
|
56
56
|
}
|
package/src/Link/index.tsx
CHANGED
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
import React, { Component } from 'react'
|
|
27
|
-
import PropTypes from 'prop-types'
|
|
28
27
|
|
|
29
28
|
import { View } from '@instructure/ui-view'
|
|
30
29
|
import { hasVisibleChildren } from '@instructure/ui-a11y-utils'
|
|
@@ -39,10 +38,12 @@ import {
|
|
|
39
38
|
import { logWarn as warn } from '@instructure/console'
|
|
40
39
|
import { testable } from '@instructure/ui-testable'
|
|
41
40
|
|
|
42
|
-
import { withStyle, jsx
|
|
41
|
+
import { withStyle, jsx } from '@instructure/emotion'
|
|
43
42
|
import generateStyle from './styles'
|
|
44
43
|
import generateComponentTheme from './theme'
|
|
45
|
-
|
|
44
|
+
|
|
45
|
+
import { propTypes, allowedProps } from './props'
|
|
46
|
+
import type { LinkProps, LinkStyleProps } from './props'
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
49
|
---
|
|
@@ -54,94 +55,14 @@ category: components
|
|
|
54
55
|
class Link extends Component<LinkProps> {
|
|
55
56
|
static readonly componentId = 'Link'
|
|
56
57
|
|
|
57
|
-
static propTypes =
|
|
58
|
-
|
|
59
|
-
* The text and/or icon displayed by the link
|
|
60
|
-
*/
|
|
61
|
-
children: PropTypes.node.isRequired,
|
|
62
|
-
/**
|
|
63
|
-
* Sets the link's `href` attribute
|
|
64
|
-
*/
|
|
65
|
-
href: PropTypes.string,
|
|
66
|
-
/**
|
|
67
|
-
* Designates Link's text color to accommodate light and dark backgrounds
|
|
68
|
-
*/
|
|
69
|
-
color: PropTypes.oneOf(['link', 'link-inverse']),
|
|
70
|
-
/**
|
|
71
|
-
* Provides a reference to the underlying HTML element
|
|
72
|
-
*/
|
|
73
|
-
elementRef: PropTypes.func,
|
|
74
|
-
/**
|
|
75
|
-
* The element type to render as (will default to `<a>` if href is provided)
|
|
76
|
-
*/
|
|
77
|
-
as: PropTypes.elementType,
|
|
78
|
-
/**
|
|
79
|
-
* Determines if the link is enabled or disabled
|
|
80
|
-
*/
|
|
81
|
-
interaction: PropTypes.oneOf(['enabled', 'disabled']),
|
|
82
|
-
/**
|
|
83
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
84
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
85
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
86
|
-
*/
|
|
87
|
-
margin: ThemeablePropTypes.spacing,
|
|
88
|
-
/**
|
|
89
|
-
* Add an SVG icon to the Link. Do not add icons directly as
|
|
90
|
-
* children.
|
|
91
|
-
*/
|
|
92
|
-
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
93
|
-
/**
|
|
94
|
-
* Place the icon before or after the text in the Link.
|
|
95
|
-
*/
|
|
96
|
-
iconPlacement: PropTypes.oneOf(['start', 'end']),
|
|
97
|
-
/**
|
|
98
|
-
* Set the CSS display property of the Link element. 'auto' sets no display property.
|
|
99
|
-
*/
|
|
100
|
-
display: PropTypes.oneOf([
|
|
101
|
-
'auto',
|
|
102
|
-
'block',
|
|
103
|
-
'inline-block',
|
|
104
|
-
'flex',
|
|
105
|
-
'inline-flex'
|
|
106
|
-
]),
|
|
107
|
-
/**
|
|
108
|
-
* Set `false` to remove default underline if Link does not appear inline with text
|
|
109
|
-
*/
|
|
110
|
-
isWithinText: PropTypes.bool,
|
|
111
|
-
/**
|
|
112
|
-
* Fires when the Link is clicked
|
|
113
|
-
*/
|
|
114
|
-
onClick: PropTypes.func,
|
|
115
|
-
/**
|
|
116
|
-
* Fires when the Link gains focus
|
|
117
|
-
*/
|
|
118
|
-
onFocus: PropTypes.func,
|
|
119
|
-
/**
|
|
120
|
-
* Fires when the Link loses focus
|
|
121
|
-
*/
|
|
122
|
-
onBlur: PropTypes.func,
|
|
123
|
-
|
|
124
|
-
// eslint-disable-next-line react/require-default-props
|
|
125
|
-
makeStyles: PropTypes.func,
|
|
126
|
-
// eslint-disable-next-line react/require-default-props
|
|
127
|
-
styles: PropTypes.object
|
|
128
|
-
} as const
|
|
129
|
-
|
|
58
|
+
static propTypes = propTypes
|
|
59
|
+
static allowedProps = allowedProps
|
|
130
60
|
static defaultProps = {
|
|
131
|
-
href: undefined,
|
|
132
|
-
elementRef: undefined,
|
|
133
61
|
// Leave interaction default undefined so that `disabled` can also be supplied
|
|
134
62
|
interaction: undefined,
|
|
135
|
-
margin: undefined,
|
|
136
|
-
renderIcon: undefined,
|
|
137
|
-
display: undefined,
|
|
138
63
|
color: 'link',
|
|
139
|
-
as: undefined,
|
|
140
64
|
iconPlacement: 'start',
|
|
141
|
-
isWithinText: true
|
|
142
|
-
onClick: undefined,
|
|
143
|
-
onFocus: undefined,
|
|
144
|
-
onBlur: undefined
|
|
65
|
+
isWithinText: true
|
|
145
66
|
} as const
|
|
146
67
|
|
|
147
68
|
state = { hasFocus: false }
|
|
@@ -268,7 +189,7 @@ class Link extends Component<LinkProps> {
|
|
|
268
189
|
'[Link] Using the display property with an icon may cause layout issues.'
|
|
269
190
|
)
|
|
270
191
|
return (
|
|
271
|
-
<span css={this.props.styles
|
|
192
|
+
<span css={this.props.styles?.icon}>
|
|
272
193
|
{callRenderProp(this.props.renderIcon)}
|
|
273
194
|
</span>
|
|
274
195
|
)
|
|
@@ -313,7 +234,7 @@ class Link extends Component<LinkProps> {
|
|
|
313
234
|
type={type}
|
|
314
235
|
//@ts-expect-error fix to be number
|
|
315
236
|
tabIndex={tabIndex}
|
|
316
|
-
css={this.props.styles
|
|
237
|
+
css={this.props.styles?.link}
|
|
317
238
|
>
|
|
318
239
|
{renderIcon && iconPlacement === 'start' && this.renderIcon()}
|
|
319
240
|
{children}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { ThemeablePropTypes } from '@instructure/emotion'
|
|
29
|
+
|
|
30
|
+
import type { AsElementType, PropValidators } from '@instructure/shared-types'
|
|
31
|
+
import type { Spacing, WithStyleProps } from '@instructure/emotion'
|
|
32
|
+
|
|
33
|
+
type LinkOwnProps = {
|
|
34
|
+
children: React.ReactNode
|
|
35
|
+
href?: string
|
|
36
|
+
color?: 'link' | 'link-inverse'
|
|
37
|
+
elementRef?: (...args: any[]) => any
|
|
38
|
+
as?: AsElementType
|
|
39
|
+
interaction?: 'enabled' | 'disabled'
|
|
40
|
+
margin?: Spacing
|
|
41
|
+
renderIcon?: ((...args: any[]) => any) | React.ReactNode
|
|
42
|
+
iconPlacement?: 'start' | 'end'
|
|
43
|
+
display?: 'auto' | 'block' | 'inline-block' | 'flex' | 'inline-flex'
|
|
44
|
+
isWithinText?: boolean
|
|
45
|
+
onClick?: (...args: any[]) => any
|
|
46
|
+
onFocus?: (...args: any[]) => any
|
|
47
|
+
onBlur?: (...args: any[]) => any
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type LinkStyleProps = {
|
|
51
|
+
containsTruncateText: boolean
|
|
52
|
+
hasVisibleChildren: boolean
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type PropKeys = keyof LinkOwnProps
|
|
56
|
+
|
|
57
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
58
|
+
|
|
59
|
+
type LinkProps = LinkOwnProps & WithStyleProps
|
|
60
|
+
|
|
61
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
62
|
+
/**
|
|
63
|
+
* The text and/or icon displayed by the link
|
|
64
|
+
*/
|
|
65
|
+
children: PropTypes.node.isRequired,
|
|
66
|
+
/**
|
|
67
|
+
* Sets the link's `href` attribute
|
|
68
|
+
*/
|
|
69
|
+
href: PropTypes.string,
|
|
70
|
+
/**
|
|
71
|
+
* Designates Link's text color to accommodate light and dark backgrounds
|
|
72
|
+
*/
|
|
73
|
+
color: PropTypes.oneOf(['link', 'link-inverse']),
|
|
74
|
+
/**
|
|
75
|
+
* Provides a reference to the underlying HTML element
|
|
76
|
+
*/
|
|
77
|
+
elementRef: PropTypes.func,
|
|
78
|
+
/**
|
|
79
|
+
* The element type to render as (will default to `<a>` if href is provided)
|
|
80
|
+
*/
|
|
81
|
+
as: PropTypes.elementType,
|
|
82
|
+
/**
|
|
83
|
+
* Determines if the link is enabled or disabled
|
|
84
|
+
*/
|
|
85
|
+
interaction: PropTypes.oneOf(['enabled', 'disabled']),
|
|
86
|
+
/**
|
|
87
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
88
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
89
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
90
|
+
*/
|
|
91
|
+
margin: ThemeablePropTypes.spacing,
|
|
92
|
+
/**
|
|
93
|
+
* Add an SVG icon to the Link. Do not add icons directly as
|
|
94
|
+
* children.
|
|
95
|
+
*/
|
|
96
|
+
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
97
|
+
/**
|
|
98
|
+
* Place the icon before or after the text in the Link.
|
|
99
|
+
*/
|
|
100
|
+
iconPlacement: PropTypes.oneOf(['start', 'end']),
|
|
101
|
+
/**
|
|
102
|
+
* Set the CSS display property of the Link element. 'auto' sets no display property.
|
|
103
|
+
*/
|
|
104
|
+
display: PropTypes.oneOf([
|
|
105
|
+
'auto',
|
|
106
|
+
'block',
|
|
107
|
+
'inline-block',
|
|
108
|
+
'flex',
|
|
109
|
+
'inline-flex'
|
|
110
|
+
]),
|
|
111
|
+
/**
|
|
112
|
+
* Set `false` to remove default underline if Link does not appear inline with text
|
|
113
|
+
*/
|
|
114
|
+
isWithinText: PropTypes.bool,
|
|
115
|
+
/**
|
|
116
|
+
* Fires when the Link is clicked
|
|
117
|
+
*/
|
|
118
|
+
onClick: PropTypes.func,
|
|
119
|
+
/**
|
|
120
|
+
* Fires when the Link gains focus
|
|
121
|
+
*/
|
|
122
|
+
onFocus: PropTypes.func,
|
|
123
|
+
/**
|
|
124
|
+
* Fires when the Link loses focus
|
|
125
|
+
*/
|
|
126
|
+
onBlur: PropTypes.func
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const allowedProps: AllowedPropKeys = [
|
|
130
|
+
'children',
|
|
131
|
+
'href',
|
|
132
|
+
'color',
|
|
133
|
+
'elementRef',
|
|
134
|
+
'as',
|
|
135
|
+
'interaction',
|
|
136
|
+
'margin',
|
|
137
|
+
'renderIcon',
|
|
138
|
+
'iconPlacement',
|
|
139
|
+
'display',
|
|
140
|
+
'isWithinText',
|
|
141
|
+
'onClick',
|
|
142
|
+
'onFocus',
|
|
143
|
+
'onBlur'
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
export type { LinkProps }
|
|
147
|
+
export { propTypes, allowedProps }
|
package/src/Link/styles.ts
CHANGED
package/src/index.ts
CHANGED
package/types/Link/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { Component } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
2
|
+
import React, { Component } from 'react';
|
|
4
3
|
import { jsx } from '@instructure/emotion';
|
|
5
|
-
import { LinkProps, LinkStyleProps } from './
|
|
4
|
+
import type { LinkProps, LinkStyleProps } from './props';
|
|
6
5
|
/**
|
|
7
6
|
---
|
|
8
7
|
category: components
|
|
@@ -10,83 +9,43 @@ category: components
|
|
|
10
9
|
**/
|
|
11
10
|
declare class Link extends Component<LinkProps> {
|
|
12
11
|
static readonly componentId = "Link";
|
|
13
|
-
static propTypes: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* Add an SVG icon to the Link. Do not add icons directly as
|
|
46
|
-
* children.
|
|
47
|
-
*/
|
|
48
|
-
readonly renderIcon: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
|
49
|
-
/**
|
|
50
|
-
* Place the icon before or after the text in the Link.
|
|
51
|
-
*/
|
|
52
|
-
readonly iconPlacement: PropTypes.Requireable<string>;
|
|
53
|
-
/**
|
|
54
|
-
* Set the CSS display property of the Link element. 'auto' sets no display property.
|
|
55
|
-
*/
|
|
56
|
-
readonly display: PropTypes.Requireable<string>;
|
|
57
|
-
/**
|
|
58
|
-
* Set `false` to remove default underline if Link does not appear inline with text
|
|
59
|
-
*/
|
|
60
|
-
readonly isWithinText: PropTypes.Requireable<boolean>;
|
|
61
|
-
/**
|
|
62
|
-
* Fires when the Link is clicked
|
|
63
|
-
*/
|
|
64
|
-
readonly onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
65
|
-
/**
|
|
66
|
-
* Fires when the Link gains focus
|
|
67
|
-
*/
|
|
68
|
-
readonly onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
69
|
-
/**
|
|
70
|
-
* Fires when the Link loses focus
|
|
71
|
-
*/
|
|
72
|
-
readonly onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
73
|
-
readonly makeStyles: PropTypes.Requireable<(...args: any[]) => any>;
|
|
74
|
-
readonly styles: PropTypes.Requireable<object>;
|
|
75
|
-
};
|
|
12
|
+
static propTypes: import("@instructure/shared-types/types/UtilityTypes").PropValidators<keyof {
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
href?: string | undefined;
|
|
15
|
+
color?: "link" | "link-inverse" | undefined;
|
|
16
|
+
elementRef?: ((...args: any[]) => any) | undefined;
|
|
17
|
+
as?: import("@instructure/shared-types/types/CommonProps").AsElementType | undefined;
|
|
18
|
+
interaction?: "enabled" | "disabled" | undefined;
|
|
19
|
+
margin?: import("@instructure/emotion/types/styleUtils/ThemeablePropValues").Spacing | undefined;
|
|
20
|
+
renderIcon?: React.ReactNode | ((...args: any[]) => any);
|
|
21
|
+
iconPlacement?: "start" | "end" | undefined;
|
|
22
|
+
display?: "auto" | "block" | "inline-block" | "flex" | "inline-flex" | undefined;
|
|
23
|
+
isWithinText?: boolean | undefined;
|
|
24
|
+
onClick?: ((...args: any[]) => any) | undefined;
|
|
25
|
+
onFocus?: ((...args: any[]) => any) | undefined;
|
|
26
|
+
onBlur?: ((...args: any[]) => any) | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
static allowedProps: readonly (keyof {
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
href?: string | undefined;
|
|
31
|
+
color?: "link" | "link-inverse" | undefined;
|
|
32
|
+
elementRef?: ((...args: any[]) => any) | undefined;
|
|
33
|
+
as?: import("@instructure/shared-types/types/CommonProps").AsElementType | undefined;
|
|
34
|
+
interaction?: "enabled" | "disabled" | undefined;
|
|
35
|
+
margin?: import("@instructure/emotion/types/styleUtils/ThemeablePropValues").Spacing | undefined;
|
|
36
|
+
renderIcon?: React.ReactNode | ((...args: any[]) => any);
|
|
37
|
+
iconPlacement?: "start" | "end" | undefined;
|
|
38
|
+
display?: "auto" | "block" | "inline-block" | "flex" | "inline-flex" | undefined;
|
|
39
|
+
isWithinText?: boolean | undefined;
|
|
40
|
+
onClick?: ((...args: any[]) => any) | undefined;
|
|
41
|
+
onFocus?: ((...args: any[]) => any) | undefined;
|
|
42
|
+
onBlur?: ((...args: any[]) => any) | undefined;
|
|
43
|
+
})[];
|
|
76
44
|
static defaultProps: {
|
|
77
|
-
readonly href: undefined;
|
|
78
|
-
readonly elementRef: undefined;
|
|
79
45
|
readonly interaction: undefined;
|
|
80
|
-
readonly margin: undefined;
|
|
81
|
-
readonly renderIcon: undefined;
|
|
82
|
-
readonly display: undefined;
|
|
83
46
|
readonly color: "link";
|
|
84
|
-
readonly as: undefined;
|
|
85
47
|
readonly iconPlacement: "start";
|
|
86
48
|
readonly isWithinText: true;
|
|
87
|
-
readonly onClick: undefined;
|
|
88
|
-
readonly onFocus: undefined;
|
|
89
|
-
readonly onBlur: undefined;
|
|
90
49
|
};
|
|
91
50
|
state: {
|
|
92
51
|
hasFocus: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Link/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Link/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAexC,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAKrD,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExD;;;;GAIG;AACH,cAEM,IAAK,SAAQ,SAAS,CAAC,SAAS,CAAC;IACrC,MAAM,CAAC,QAAQ,CAAC,WAAW,UAAS;IAEpC,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;OAAY;IAC5B,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;SAAe;IAClC,MAAM,CAAC,YAAY;;;;;MAMT;IAEV,KAAK;;MAAsB;IAE3B,iBAAiB;IAMjB,kBAAkB,CAAC,SAAS,KAAA,EAAE,SAAS,KAAA,EAAE,QAAQ,KAAA;IAKjD,cAAc,QAAO,cAAc,CAKlC;IAGD,gBAAgB,oBAMf;IAGD,WAAW,uBAUV;IAGD,WAAW,uBAKV;IAGD,UAAU,uBAKT;IAED,IAAI,oBAAoB,YAgBvB;IAED,IAAI,OAAO,+DAYV;IAED,IAAI,WAAW,0DAEd;IAED,IAAI,OAAO,wEAEV;IAED,IAAI,OAAO,YAGV;IAED,IAAI,SAAS,cAGZ;IAED,IAAI,kBAAkB,YAErB;IAED,KAAK;IAKL,UAAU;IAaV,MAAM;CA+CP;AAED,eAAe,IAAI,CAAA;AACnB,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { AsElementType } from '@instructure/shared-types';
|
|
2
|
-
import type { Spacing } from '@instructure/emotion';
|
|
3
1
|
import React from 'react';
|
|
4
|
-
|
|
2
|
+
import type { AsElementType, PropValidators } from '@instructure/shared-types';
|
|
3
|
+
import type { Spacing, WithStyleProps } from '@instructure/emotion';
|
|
4
|
+
declare type LinkOwnProps = {
|
|
5
|
+
children: React.ReactNode;
|
|
5
6
|
href?: string;
|
|
6
7
|
color?: 'link' | 'link-inverse';
|
|
7
8
|
elementRef?: (...args: any[]) => any;
|
|
@@ -15,11 +16,16 @@ export declare type LinkProps = {
|
|
|
15
16
|
onClick?: (...args: any[]) => any;
|
|
16
17
|
onFocus?: (...args: any[]) => any;
|
|
17
18
|
onBlur?: (...args: any[]) => any;
|
|
18
|
-
makeStyles?: (...args: any[]) => any;
|
|
19
|
-
styles?: any;
|
|
20
19
|
};
|
|
21
20
|
export declare type LinkStyleProps = {
|
|
22
21
|
containsTruncateText: boolean;
|
|
23
22
|
hasVisibleChildren: boolean;
|
|
24
23
|
};
|
|
25
|
-
|
|
24
|
+
declare type PropKeys = keyof LinkOwnProps;
|
|
25
|
+
declare type AllowedPropKeys = Readonly<Array<PropKeys>>;
|
|
26
|
+
declare type LinkProps = LinkOwnProps & WithStyleProps;
|
|
27
|
+
declare const propTypes: PropValidators<PropKeys>;
|
|
28
|
+
declare const allowedProps: AllowedPropKeys;
|
|
29
|
+
export type { LinkProps };
|
|
30
|
+
export { propTypes, allowedProps };
|
|
31
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/Link/props.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAEnE,aAAK,YAAY,GAAG;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,cAAc,CAAA;IAC/B,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IACpC,EAAE,CAAC,EAAE,aAAa,CAAA;IAClB,WAAW,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;IACpC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,SAAS,CAAA;IACxD,aAAa,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;IAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,cAAc,GAAG,MAAM,GAAG,aAAa,CAAA;IACpE,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IACjC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IACjC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;CACjC,CAAA;AAED,oBAAY,cAAc,GAAG;IAC3B,oBAAoB,EAAE,OAAO,CAAA;IAC7B,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,aAAK,QAAQ,GAAG,MAAM,YAAY,CAAA;AAElC,aAAK,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEhD,aAAK,SAAS,GAAG,YAAY,GAAG,cAAc,CAAA;AAE9C,QAAA,MAAM,SAAS,EAAE,cAAc,CAAC,QAAQ,CAkEvC,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,eAenB,CAAA;AAED,YAAY,EAAE,SAAS,EAAE,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAA"}
|
package/types/Link/styles.d.ts
CHANGED
package/types/index.d.ts
CHANGED
package/es/Link/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/Link/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/src/Link/types.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import { AsElementType } from '@instructure/shared-types'
|
|
26
|
-
import type { Spacing } from '@instructure/emotion'
|
|
27
|
-
import React from 'react'
|
|
28
|
-
|
|
29
|
-
export type LinkProps = {
|
|
30
|
-
href?: string
|
|
31
|
-
color?: 'link' | 'link-inverse'
|
|
32
|
-
elementRef?: (...args: any[]) => any
|
|
33
|
-
as?: AsElementType
|
|
34
|
-
interaction?: 'enabled' | 'disabled'
|
|
35
|
-
margin?: Spacing
|
|
36
|
-
renderIcon?: ((...args: any[]) => any) | React.ReactNode
|
|
37
|
-
iconPlacement?: 'start' | 'end'
|
|
38
|
-
display?: 'auto' | 'block' | 'inline-block' | 'flex' | 'inline-flex'
|
|
39
|
-
isWithinText?: boolean
|
|
40
|
-
onClick?: (...args: any[]) => any
|
|
41
|
-
onFocus?: (...args: any[]) => any
|
|
42
|
-
onBlur?: (...args: any[]) => any
|
|
43
|
-
makeStyles?: (...args: any[]) => any
|
|
44
|
-
styles?: any
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export type LinkStyleProps = {
|
|
48
|
-
containsTruncateText: boolean
|
|
49
|
-
hasVisibleChildren: boolean
|
|
50
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/Link/types.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,oBAAY,SAAS,GAAG;IACtB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,cAAc,CAAA;IAC/B,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IACpC,EAAE,CAAC,EAAE,aAAa,CAAA;IAClB,WAAW,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;IACpC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,SAAS,CAAA;IACxD,aAAa,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;IAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,cAAc,GAAG,MAAM,GAAG,aAAa,CAAA;IACpE,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IACjC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IACjC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IAChC,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IACpC,MAAM,CAAC,EAAE,GAAG,CAAA;CACb,CAAA;AAED,oBAAY,cAAc,GAAG;IAC3B,oBAAoB,EAAE,OAAO,CAAA;IAC7B,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAA"}
|