@instructure/ui-link 11.7.3-snapshot-7 → 11.7.3-snapshot-26
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 +5 -2
- package/es/Link/v1/index.js +95 -88
- package/es/Link/v1/styles.js +12 -8
- package/es/Link/v1/theme.js +21 -20
- package/es/Link/v2/index.js +122 -113
- package/es/Link/v2/styles.js +12 -11
- package/lib/Link/v1/index.js +95 -88
- package/lib/Link/v1/styles.js +12 -8
- package/lib/Link/v1/theme.js +21 -20
- package/lib/Link/v2/index.js +122 -113
- package/lib/Link/v2/styles.js +12 -11
- package/package.json +15 -15
- package/tsconfig.build.tsbuildinfo +1 -1
package/es/Link/v2/styles.js
CHANGED
|
@@ -35,17 +35,18 @@ import { calcFocusOutlineStyles, calcSpacingFromShorthand } from '@instructure/e
|
|
|
35
35
|
* @return {Object} The final style object, which will be used in the component
|
|
36
36
|
*/
|
|
37
37
|
const generateStyle = (componentTheme, props, sharedTokens, state = {}) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
color
|
|
43
|
-
margin
|
|
38
|
+
const {
|
|
39
|
+
renderIcon,
|
|
40
|
+
iconPlacement = 'start',
|
|
41
|
+
// TODO workaround needed for react 19 where defaultprops doesn't apply for some reasong
|
|
42
|
+
color,
|
|
43
|
+
margin
|
|
44
|
+
} = props;
|
|
44
45
|
|
|
45
46
|
// Get size and variant from state (passed from makeStyleProps) or fall back to props
|
|
46
|
-
const size =
|
|
47
|
-
const variant =
|
|
48
|
-
const hasVisibleChildren =
|
|
47
|
+
const size = state.size ?? props.size;
|
|
48
|
+
const variant = state.variant ?? props.variant;
|
|
49
|
+
const hasVisibleChildren = state.hasVisibleChildren ?? false;
|
|
49
50
|
const isInverseStyle = color === 'link-inverse';
|
|
50
51
|
const inlineLinkSizeStyles = {
|
|
51
52
|
small: {
|
|
@@ -116,7 +117,7 @@ const generateStyle = (componentTheme, props, sharedTokens, state = {}) => {
|
|
|
116
117
|
variantStyles = {
|
|
117
118
|
fontSize: 'inherit',
|
|
118
119
|
lineHeight: 'inherit',
|
|
119
|
-
textDecoration:
|
|
120
|
+
textDecoration: undefined,
|
|
120
121
|
gap: componentTheme.gapMd // Default gap for icons when no size is specified
|
|
121
122
|
};
|
|
122
123
|
}
|
|
@@ -216,7 +217,7 @@ const generateStyle = (componentTheme, props, sharedTokens, state = {}) => {
|
|
|
216
217
|
}),
|
|
217
218
|
...calcFocusOutlineStyles(sharedTokens.focusOutline, isInverseStyle ? {
|
|
218
219
|
focusColor: 'inverse'
|
|
219
|
-
} :
|
|
220
|
+
} : undefined),
|
|
220
221
|
// NOTE: needs separate groups for `:is()` and `:-webkit-any()` because of css selector group validation (see https://www.w3.org/TR/selectors-3/#grouping)
|
|
221
222
|
'&:is(a), &:is(button)': isClickableStyles,
|
|
222
223
|
'&:-webkit-any(a), &:-webkit-any(button)': isClickableStyles,
|
package/lib/Link/v1/index.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.Link = void 0;
|
|
8
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
8
|
var _react = require("react");
|
|
10
9
|
var _v11_ = require("@instructure/ui-view/v11_6");
|
|
11
10
|
var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
|
|
@@ -23,8 +22,7 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
23
22
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
24
23
|
var _props = require("./props");
|
|
25
24
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
26
|
-
|
|
27
|
-
var _dec, _class, _Link;
|
|
25
|
+
var _dec, _class;
|
|
28
26
|
/*
|
|
29
27
|
* The MIT License (MIT)
|
|
30
28
|
*
|
|
@@ -53,64 +51,76 @@ var _dec, _class, _Link;
|
|
|
53
51
|
category: components
|
|
54
52
|
---
|
|
55
53
|
**/
|
|
56
|
-
let Link = exports.Link = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.ref = el;
|
|
72
|
-
if (typeof elementRef === 'function') {
|
|
73
|
-
elementRef(el);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
this.handleClick = event => {
|
|
77
|
-
const onClick = this.props.onClick;
|
|
78
|
-
const interaction = this.interaction;
|
|
79
|
-
if (interaction === 'disabled') {
|
|
80
|
-
event.preventDefault();
|
|
81
|
-
event.stopPropagation();
|
|
82
|
-
} else if (typeof onClick === 'function') {
|
|
83
|
-
onClick(event);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
this.handleFocus = event => {
|
|
87
|
-
this.setState({
|
|
88
|
-
hasFocus: true
|
|
89
|
-
});
|
|
90
|
-
if (typeof this.props.onFocus === 'function') {
|
|
91
|
-
this.props.onFocus(event);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
this.handleBlur = event => {
|
|
95
|
-
this.setState({
|
|
96
|
-
hasFocus: false
|
|
97
|
-
});
|
|
98
|
-
if (typeof this.props.onBlur === 'function') {
|
|
99
|
-
this.props.onBlur(event);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
}
|
|
54
|
+
let Link = exports.Link = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = class Link extends _react.Component {
|
|
55
|
+
static displayName = "Link";
|
|
56
|
+
static componentId = 'Link';
|
|
57
|
+
static allowedProps = _props.allowedProps;
|
|
58
|
+
static defaultProps = {
|
|
59
|
+
// Leave interaction default undefined so that `disabled` can also be supplied
|
|
60
|
+
interaction: undefined,
|
|
61
|
+
color: 'link',
|
|
62
|
+
iconPlacement: 'start',
|
|
63
|
+
isWithinText: true,
|
|
64
|
+
forceButtonRole: true
|
|
65
|
+
};
|
|
66
|
+
state = {
|
|
67
|
+
hasFocus: false
|
|
68
|
+
};
|
|
103
69
|
get _link() {
|
|
104
70
|
return this.ref;
|
|
105
71
|
}
|
|
72
|
+
ref = null;
|
|
106
73
|
componentDidMount() {
|
|
107
|
-
|
|
108
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStyleProps());
|
|
74
|
+
this.props.makeStyles?.(this.makeStyleProps());
|
|
109
75
|
}
|
|
110
76
|
componentDidUpdate() {
|
|
111
|
-
|
|
112
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStyleProps());
|
|
77
|
+
this.props.makeStyles?.(this.makeStyleProps());
|
|
113
78
|
}
|
|
79
|
+
makeStyleProps = () => {
|
|
80
|
+
return {
|
|
81
|
+
containsTruncateText: this.containsTruncateText,
|
|
82
|
+
hasVisibleChildren: this.hasVisibleChildren
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
handleElementRef = el => {
|
|
86
|
+
const {
|
|
87
|
+
elementRef
|
|
88
|
+
} = this.props;
|
|
89
|
+
this.ref = el;
|
|
90
|
+
if (typeof elementRef === 'function') {
|
|
91
|
+
elementRef(el);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
handleClick = event => {
|
|
95
|
+
const {
|
|
96
|
+
onClick
|
|
97
|
+
} = this.props;
|
|
98
|
+
const {
|
|
99
|
+
interaction
|
|
100
|
+
} = this;
|
|
101
|
+
if (interaction === 'disabled') {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
event.stopPropagation();
|
|
104
|
+
} else if (typeof onClick === 'function') {
|
|
105
|
+
onClick(event);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
handleFocus = event => {
|
|
109
|
+
this.setState({
|
|
110
|
+
hasFocus: true
|
|
111
|
+
});
|
|
112
|
+
if (typeof this.props.onFocus === 'function') {
|
|
113
|
+
this.props.onFocus(event);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
handleBlur = event => {
|
|
117
|
+
this.setState({
|
|
118
|
+
hasFocus: false
|
|
119
|
+
});
|
|
120
|
+
if (typeof this.props.onBlur === 'function') {
|
|
121
|
+
this.props.onBlur(event);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
114
124
|
get containsTruncateText() {
|
|
115
125
|
let truncateText = false;
|
|
116
126
|
_react.Children.forEach(this.props.children, child => {
|
|
@@ -120,14 +130,16 @@ let Link = exports.Link = (_dec = (0, _emotion.withStyleLegacy)(_styles.default,
|
|
|
120
130
|
});
|
|
121
131
|
(0, _console.logWarn)(
|
|
122
132
|
// if display prop is used, warn about icon or TruncateText
|
|
123
|
-
!truncateText || this.props.display ===
|
|
133
|
+
!truncateText || this.props.display === undefined, '[Link] Using the display property with TruncateText may cause layout issues.');
|
|
124
134
|
return truncateText;
|
|
125
135
|
}
|
|
126
136
|
get display() {
|
|
127
137
|
if (this.props.display) {
|
|
128
138
|
return this.props.display; // user-entered display property
|
|
129
139
|
}
|
|
130
|
-
const
|
|
140
|
+
const {
|
|
141
|
+
containsTruncateText
|
|
142
|
+
} = this;
|
|
131
143
|
if (this.props.renderIcon) {
|
|
132
144
|
return containsTruncateText ? 'inline-flex' : 'inline-block';
|
|
133
145
|
} else {
|
|
@@ -153,10 +165,11 @@ let Link = exports.Link = (_dec = (0, _emotion.withStyleLegacy)(_styles.default,
|
|
|
153
165
|
return (0, _hasVisibleChildren.hasVisibleChildren)(this.props.children);
|
|
154
166
|
}
|
|
155
167
|
get role() {
|
|
156
|
-
const
|
|
157
|
-
role
|
|
158
|
-
forceButtonRole
|
|
159
|
-
onClick
|
|
168
|
+
const {
|
|
169
|
+
role,
|
|
170
|
+
forceButtonRole,
|
|
171
|
+
onClick
|
|
172
|
+
} = this.props;
|
|
160
173
|
if (forceButtonRole) {
|
|
161
174
|
return onClick && this.element !== 'button' ? 'button' : role;
|
|
162
175
|
}
|
|
@@ -166,32 +179,33 @@ let Link = exports.Link = (_dec = (0, _emotion.withStyleLegacy)(_styles.default,
|
|
|
166
179
|
this.ref && this.ref.focus();
|
|
167
180
|
}
|
|
168
181
|
renderIcon() {
|
|
169
|
-
var _this$props$styles;
|
|
170
182
|
(0, _console.logWarn)(
|
|
171
183
|
// if display prop is used, warn about icon or TruncateText
|
|
172
|
-
this.props.display ===
|
|
184
|
+
this.props.display === undefined, '[Link] Using the display property with an icon may cause layout issues.');
|
|
173
185
|
return (0, _jsxRuntime.jsx)("span", {
|
|
174
|
-
css:
|
|
186
|
+
css: this.props.styles?.icon,
|
|
175
187
|
children: (0, _callRenderProp.callRenderProp)(this.props.renderIcon)
|
|
176
188
|
});
|
|
177
189
|
}
|
|
178
190
|
render() {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const
|
|
191
|
+
const {
|
|
192
|
+
children,
|
|
193
|
+
onClick,
|
|
194
|
+
onMouseEnter,
|
|
195
|
+
color,
|
|
196
|
+
href,
|
|
197
|
+
margin,
|
|
198
|
+
renderIcon,
|
|
199
|
+
iconPlacement,
|
|
200
|
+
isWithinText,
|
|
201
|
+
...props
|
|
202
|
+
} = this.props;
|
|
203
|
+
const {
|
|
204
|
+
interaction
|
|
205
|
+
} = this;
|
|
192
206
|
const isDisabled = interaction === 'disabled';
|
|
193
|
-
const type = this.element === 'button' || this.element === 'input' ? 'button' :
|
|
194
|
-
const tabIndex = this.role === 'button' && !isDisabled ? 0 :
|
|
207
|
+
const type = this.element === 'button' || this.element === 'input' ? 'button' : undefined;
|
|
208
|
+
const tabIndex = this.role === 'button' && !isDisabled ? 0 : undefined;
|
|
195
209
|
return (0, _jsxRuntime.jsxs)(_v11_.View, {
|
|
196
210
|
...(0, _passthroughProps.passthroughProps)(props),
|
|
197
211
|
elementRef: this.handleElementRef,
|
|
@@ -203,21 +217,14 @@ let Link = exports.Link = (_dec = (0, _emotion.withStyleLegacy)(_styles.default,
|
|
|
203
217
|
onClick: this.handleClick,
|
|
204
218
|
onFocus: this.handleFocus,
|
|
205
219
|
onBlur: this.handleBlur,
|
|
206
|
-
"aria-disabled": isDisabled ? 'true' :
|
|
220
|
+
"aria-disabled": isDisabled ? 'true' : undefined,
|
|
207
221
|
role: this.role,
|
|
208
222
|
type: type,
|
|
209
223
|
tabIndex: tabIndex,
|
|
210
|
-
css:
|
|
224
|
+
css: this.props.styles?.link,
|
|
211
225
|
"data-cid": (0, _combineDataCid.combineDataCid)('Link', this.props),
|
|
212
226
|
children: [renderIcon && iconPlacement === 'start' ? this.renderIcon() : null, children, renderIcon && iconPlacement === 'end' ? this.renderIcon() : null]
|
|
213
227
|
});
|
|
214
228
|
}
|
|
215
|
-
}
|
|
216
|
-
// Leave interaction default undefined so that `disabled` can also be supplied
|
|
217
|
-
interaction: void 0,
|
|
218
|
-
color: 'link',
|
|
219
|
-
iconPlacement: 'start',
|
|
220
|
-
isWithinText: true,
|
|
221
|
-
forceButtonRole: true
|
|
222
|
-
}, _Link)) || _class);
|
|
229
|
+
}) || _class);
|
|
223
230
|
var _default = exports.default = Link;
|
package/lib/Link/v1/styles.js
CHANGED
|
@@ -39,14 +39,18 @@ exports.default = void 0;
|
|
|
39
39
|
* @return {Object} The final style object, which will be used in the component
|
|
40
40
|
*/
|
|
41
41
|
const generateStyle = (componentTheme, props, state) => {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
iconPlacement =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
const {
|
|
43
|
+
isWithinText,
|
|
44
|
+
renderIcon,
|
|
45
|
+
iconPlacement = 'start',
|
|
46
|
+
// TODO workaround needed for react 19 where defaultprops doesn't apply for some reasong
|
|
47
|
+
color,
|
|
48
|
+
variant
|
|
49
|
+
} = props;
|
|
50
|
+
const {
|
|
51
|
+
containsTruncateText,
|
|
52
|
+
hasVisibleChildren
|
|
53
|
+
} = state;
|
|
50
54
|
const inverseStyle = color === 'link-inverse';
|
|
51
55
|
const variantStyles = {
|
|
52
56
|
inline: {
|
package/lib/Link/v1/theme.js
CHANGED
|
@@ -35,12 +35,13 @@ var _darken = require("@instructure/ui-color-utils/lib/darken.js");
|
|
|
35
35
|
* @return {Object} The final theme object with the overrides and component variables
|
|
36
36
|
*/
|
|
37
37
|
const generateComponentTheme = theme => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
borders
|
|
41
|
-
typography
|
|
42
|
-
spacing
|
|
43
|
-
themeName
|
|
38
|
+
const {
|
|
39
|
+
colors,
|
|
40
|
+
borders,
|
|
41
|
+
typography,
|
|
42
|
+
spacing,
|
|
43
|
+
key: themeName
|
|
44
|
+
} = theme;
|
|
44
45
|
|
|
45
46
|
// if any styling should depend on the theme itself,
|
|
46
47
|
// this object should specify it
|
|
@@ -58,24 +59,24 @@ const generateComponentTheme = theme => {
|
|
|
58
59
|
|
|
59
60
|
// maps the theme variables to component specific style variables
|
|
60
61
|
const componentVariables = {
|
|
61
|
-
fontFamily: typography
|
|
62
|
-
fontWeight: typography
|
|
63
|
-
fontSize: typography
|
|
64
|
-
lineHeight: typography
|
|
65
|
-
fontSizeSmall: typography
|
|
66
|
-
color: colors
|
|
62
|
+
fontFamily: typography?.fontFamily,
|
|
63
|
+
fontWeight: typography?.fontWeightNormal,
|
|
64
|
+
fontSize: typography?.content,
|
|
65
|
+
lineHeight: typography?.lineHeight150,
|
|
66
|
+
fontSizeSmall: typography?.contentSmall,
|
|
67
|
+
color: colors?.contrasts?.blue5782,
|
|
67
68
|
textDecorationWithinText: 'underline',
|
|
68
69
|
hoverTextDecorationWithinText: 'none',
|
|
69
70
|
textDecorationOutsideText: 'none',
|
|
70
71
|
hoverTextDecorationOutsideText: 'underline',
|
|
71
|
-
focusOutlineWidth: borders
|
|
72
|
-
focusOutlineColor: colors
|
|
73
|
-
focusOutlineStyle: borders
|
|
74
|
-
focusOutlineBorderRadius: borders
|
|
75
|
-
hoverColor: (0, _darken.darken)(colors
|
|
76
|
-
colorInverse: colors
|
|
77
|
-
focusInverseOutlineColor: colors
|
|
78
|
-
focusInverseIconOutlineColor: colors
|
|
72
|
+
focusOutlineWidth: borders?.widthMedium,
|
|
73
|
+
focusOutlineColor: colors?.contrasts?.blue4570,
|
|
74
|
+
focusOutlineStyle: borders?.style,
|
|
75
|
+
focusOutlineBorderRadius: borders?.radiusSmall,
|
|
76
|
+
hoverColor: (0, _darken.darken)(colors?.contrasts?.blue5782, 10),
|
|
77
|
+
colorInverse: colors?.contrasts?.grey1111,
|
|
78
|
+
focusInverseOutlineColor: colors?.contrasts?.white1010,
|
|
79
|
+
focusInverseIconOutlineColor: colors?.contrasts?.white1010,
|
|
79
80
|
iconSize: '1.125em',
|
|
80
81
|
// make icon slightly larger than inherited font-size,
|
|
81
82
|
iconPlusTextMargin: spacing.space4,
|