@instructure/ui-link 11.6.0 → 11.6.1-snapshot-129

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +40 -288
  2. package/es/Link/{index.js → v1/index.js} +2 -2
  3. package/es/Link/v2/index.js +253 -0
  4. package/es/Link/v2/props.js +26 -0
  5. package/es/Link/v2/styles.js +242 -0
  6. package/es/{index.js → exports/a.js} +1 -1
  7. package/{src/index.ts → es/exports/b.js} +1 -3
  8. package/lib/Link/{index.js → v1/index.js} +3 -3
  9. package/lib/Link/v2/index.js +262 -0
  10. package/lib/Link/v2/props.js +31 -0
  11. package/lib/Link/v2/styles.js +248 -0
  12. package/lib/{index.js → exports/a.js} +2 -2
  13. package/lib/exports/b.js +12 -0
  14. package/package.json +43 -21
  15. package/src/Link/{index.tsx → v1/index.tsx} +3 -3
  16. package/src/Link/{props.ts → v1/props.ts} +1 -1
  17. package/src/Link/v2/README.md +261 -0
  18. package/src/Link/v2/index.tsx +321 -0
  19. package/src/Link/v2/props.ts +184 -0
  20. package/src/Link/v2/styles.ts +267 -0
  21. package/src/exports/a.ts +26 -0
  22. package/src/exports/b.ts +26 -0
  23. package/tsconfig.build.tsbuildinfo +1 -1
  24. package/types/Link/{index.d.ts → v1/index.d.ts} +1 -1
  25. package/types/Link/v1/index.d.ts.map +1 -0
  26. package/types/Link/{props.d.ts → v1/props.d.ts} +1 -1
  27. package/types/Link/v1/props.d.ts.map +1 -0
  28. package/types/Link/v1/styles.d.ts.map +1 -0
  29. package/types/Link/v1/theme.d.ts.map +1 -0
  30. package/types/Link/v2/index.d.ts +66 -0
  31. package/types/Link/v2/index.d.ts.map +1 -0
  32. package/types/Link/v2/props.d.ts +105 -0
  33. package/types/Link/v2/props.d.ts.map +1 -0
  34. package/types/Link/v2/styles.d.ts +19 -0
  35. package/types/Link/v2/styles.d.ts.map +1 -0
  36. package/types/exports/a.d.ts +3 -0
  37. package/types/exports/a.d.ts.map +1 -0
  38. package/types/exports/b.d.ts +3 -0
  39. package/types/exports/b.d.ts.map +1 -0
  40. package/types/Link/index.d.ts.map +0 -1
  41. package/types/Link/props.d.ts.map +0 -1
  42. package/types/Link/styles.d.ts.map +0 -1
  43. package/types/Link/theme.d.ts.map +0 -1
  44. package/types/index.d.ts +0 -3
  45. package/types/index.d.ts.map +0 -1
  46. /package/es/Link/{props.js → v1/props.js} +0 -0
  47. /package/es/Link/{styles.js → v1/styles.js} +0 -0
  48. /package/es/Link/{theme.js → v1/theme.js} +0 -0
  49. /package/lib/Link/{props.js → v1/props.js} +0 -0
  50. /package/lib/Link/{styles.js → v1/styles.js} +0 -0
  51. /package/lib/Link/{theme.js → v1/theme.js} +0 -0
  52. /package/src/Link/{README.md → v1/README.md} +0 -0
  53. /package/src/Link/{styles.ts → v1/styles.ts} +0 -0
  54. /package/src/Link/{theme.ts → v1/theme.ts} +0 -0
  55. /package/types/Link/{styles.d.ts → v1/styles.d.ts} +0 -0
  56. /package/types/Link/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,262 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.Link = void 0;
8
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
+ var _react = require("react");
10
+ var _latest = require("@instructure/ui-view/latest");
11
+ var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
12
+ var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
13
+ var _findFocusable = require("@instructure/ui-dom-utils/lib/findFocusable.js");
14
+ var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
15
+ var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
16
+ var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
17
+ var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
18
+ var _combineDataCid = require("@instructure/ui-utils/lib/combineDataCid.js");
19
+ var _console = require("@instructure/console");
20
+ var _renderIconWithProps = require("@instructure/ui-icons/lib/IconPropsProvider/renderIconWithProps.js");
21
+ var _emotion = require("@instructure/emotion");
22
+ var _styles = _interopRequireDefault(require("./styles"));
23
+ var _props = require("./props");
24
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
25
+ const _excluded = ["children", "onClick", "onMouseEnter", "color", "href", "margin", "renderIcon", "iconPlacement"];
26
+ var _dec, _class, _Link;
27
+ /*
28
+ * The MIT License (MIT)
29
+ *
30
+ * Copyright (c) 2015 - present Instructure, Inc.
31
+ *
32
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
33
+ * of this software and associated documentation files (the "Software"), to deal
34
+ * in the Software without restriction, including without limitation the rights
35
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36
+ * copies of the Software, and to permit persons to whom the Software is
37
+ * furnished to do so, subject to the following conditions:
38
+ *
39
+ * The above copyright notice and this permission notice shall be included in all
40
+ * copies or substantial portions of the Software.
41
+ *
42
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
+ * SOFTWARE.
49
+ */
50
+ /**
51
+ ---
52
+ category: components
53
+ ---
54
+ **/
55
+ let Link = exports.Link = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = (_Link = class Link extends _react.Component {
56
+ constructor(...args) {
57
+ super(...args);
58
+ this.state = {
59
+ hasFocus: false
60
+ };
61
+ this.ref = null;
62
+ this.makeStyleProps = () => {
63
+ const _this$props = this.props,
64
+ variantProp = _this$props.variant,
65
+ sizeProp = _this$props.size;
66
+
67
+ // Handle deprecated variant values by mapping them to new variant + size props
68
+ let variant = variantProp;
69
+ let size = sizeProp;
70
+ if (variantProp === 'inline-small' || variantProp === 'standalone-small') {
71
+ (0, _console.logWarn)(false, `[Link] The variant value "${variantProp}" is deprecated. Use variant="${variantProp.replace('-small', '')}" with size="small" instead.`);
72
+ variant = variantProp.replace('-small', '');
73
+ // Only set size from deprecated variant if size prop is not explicitly provided
74
+ if (!sizeProp) {
75
+ size = 'small';
76
+ }
77
+ } else if ((variantProp === 'inline' || variantProp === 'standalone') && !sizeProp) {
78
+ // When using new variant values without explicit size, default to medium
79
+ // This maintains the old behavior where 'inline' and 'standalone' were medium-sized
80
+ size = 'medium';
81
+ }
82
+ return {
83
+ containsTruncateText: this.containsTruncateText,
84
+ hasVisibleChildren: this.hasVisibleChildren,
85
+ variant,
86
+ size
87
+ };
88
+ };
89
+ this.handleElementRef = el => {
90
+ const elementRef = this.props.elementRef;
91
+ this.ref = el;
92
+ if (typeof elementRef === 'function') {
93
+ elementRef(el);
94
+ }
95
+ };
96
+ this.handleClick = event => {
97
+ const onClick = this.props.onClick;
98
+ const interaction = this.interaction;
99
+ if (interaction === 'disabled') {
100
+ event.preventDefault();
101
+ event.stopPropagation();
102
+ } else if (typeof onClick === 'function') {
103
+ onClick(event);
104
+ }
105
+ };
106
+ this.handleFocus = event => {
107
+ this.setState({
108
+ hasFocus: true
109
+ });
110
+ if (typeof this.props.onFocus === 'function') {
111
+ this.props.onFocus(event);
112
+ }
113
+ };
114
+ this.handleBlur = event => {
115
+ this.setState({
116
+ hasFocus: false
117
+ });
118
+ if (typeof this.props.onBlur === 'function') {
119
+ this.props.onBlur(event);
120
+ }
121
+ };
122
+ }
123
+ get _link() {
124
+ return this.ref;
125
+ }
126
+ componentDidMount() {
127
+ var _this$props$makeStyle, _this$props2;
128
+ (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2, this.makeStyleProps());
129
+ }
130
+ componentDidUpdate() {
131
+ var _this$props$makeStyle2, _this$props3;
132
+ (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3, this.makeStyleProps());
133
+ }
134
+ get containsTruncateText() {
135
+ let truncateText = false;
136
+ _react.Children.forEach(this.props.children, child => {
137
+ if (child && (0, _matchComponentTypes.matchComponentTypes)(child, ['TruncateText'])) {
138
+ truncateText = true;
139
+ }
140
+ });
141
+ (0, _console.logWarn)(
142
+ // if display prop is used, warn about icon or TruncateText
143
+ !truncateText || this.props.display === void 0, '[Link] Using the display property with TruncateText may cause layout issues.');
144
+ return truncateText;
145
+ }
146
+ get display() {
147
+ if (this.props.display) {
148
+ return this.props.display; // user-entered display property
149
+ }
150
+ const containsTruncateText = this.containsTruncateText;
151
+ if (this.props.renderIcon) {
152
+ return containsTruncateText ? 'inline-flex' : 'inline-block';
153
+ } else {
154
+ return containsTruncateText ? 'block' : 'auto';
155
+ }
156
+ }
157
+ get interaction() {
158
+ return (0, _getInteraction.getInteraction)({
159
+ props: this.props,
160
+ interactionTypes: ['disabled']
161
+ });
162
+ }
163
+ get element() {
164
+ return (0, _getElementType.getElementType)(Link, this.props);
165
+ }
166
+ get focused() {
167
+ return (0, _isActiveElement.isActiveElement)(this.ref);
168
+ }
169
+ get focusable() {
170
+ return (0, _findFocusable.findFocusable)(this.ref);
171
+ }
172
+ get hasVisibleChildren() {
173
+ return (0, _hasVisibleChildren.hasVisibleChildren)(this.props.children);
174
+ }
175
+ get role() {
176
+ const _this$props4 = this.props,
177
+ role = _this$props4.role,
178
+ forceButtonRole = _this$props4.forceButtonRole,
179
+ onClick = _this$props4.onClick;
180
+ if (forceButtonRole) {
181
+ return onClick && this.element !== 'button' ? 'button' : role;
182
+ }
183
+ return role;
184
+ }
185
+ focus() {
186
+ this.ref && this.ref.focus();
187
+ }
188
+ renderIcon() {
189
+ var _this$props$styles;
190
+ const _this$props5 = this.props,
191
+ display = _this$props5.display,
192
+ renderIcon = _this$props5.renderIcon,
193
+ variantProp = _this$props5.variant,
194
+ sizeProp = _this$props5.size;
195
+ (0, _console.logWarn)(
196
+ // if display prop is used, warn about icon or TruncateText
197
+ display === void 0, '[Link] Using the display property with an icon may cause layout issues.');
198
+
199
+ // Determine the actual size being used (considering deprecated variants)
200
+ let size = sizeProp;
201
+ if (variantProp === 'inline-small' || variantProp === 'standalone-small') {
202
+ size = sizeProp || 'small';
203
+ } else if ((variantProp === 'inline' || variantProp === 'standalone') && !sizeProp) {
204
+ size = 'medium';
205
+ }
206
+
207
+ // Map Link sizes to icon sizes
208
+ const linkSizeToIconSize = {
209
+ small: 'xs',
210
+ medium: 'sm',
211
+ large: 'lg'
212
+ };
213
+ const iconSize = linkSizeToIconSize[size || 'medium'];
214
+ return (0, _jsxRuntime.jsx)("span", {
215
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.icon,
216
+ children: (0, _renderIconWithProps.renderIconWithProps)(renderIcon, iconSize, void 0)
217
+ });
218
+ }
219
+ render() {
220
+ var _this$props$styles2;
221
+ const _this$props6 = this.props,
222
+ children = _this$props6.children,
223
+ onClick = _this$props6.onClick,
224
+ onMouseEnter = _this$props6.onMouseEnter,
225
+ color = _this$props6.color,
226
+ href = _this$props6.href,
227
+ margin = _this$props6.margin,
228
+ renderIcon = _this$props6.renderIcon,
229
+ iconPlacement = _this$props6.iconPlacement,
230
+ props = (0, _objectWithoutProperties2.default)(_this$props6, _excluded);
231
+ const interaction = this.interaction;
232
+ const isDisabled = interaction === 'disabled';
233
+ const type = this.element === 'button' || this.element === 'input' ? 'button' : void 0;
234
+ const tabIndex = this.role === 'button' && !isDisabled ? 0 : void 0;
235
+ return (0, _jsxRuntime.jsxs)(_latest.View, {
236
+ ...(0, _passthroughProps.passthroughProps)(props),
237
+ elementRef: this.handleElementRef,
238
+ as: this.element,
239
+ display: this.display,
240
+ margin: margin,
241
+ href: href,
242
+ onMouseEnter: onMouseEnter,
243
+ onClick: this.handleClick,
244
+ onFocus: this.handleFocus,
245
+ onBlur: this.handleBlur,
246
+ "aria-disabled": isDisabled ? 'true' : void 0,
247
+ role: this.role,
248
+ type: type,
249
+ tabIndex: tabIndex,
250
+ css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.link,
251
+ "data-cid": (0, _combineDataCid.combineDataCid)('Link', this.props),
252
+ children: [renderIcon && iconPlacement === 'start' ? this.renderIcon() : null, children, renderIcon && iconPlacement === 'end' ? this.renderIcon() : null]
253
+ });
254
+ }
255
+ }, _Link.displayName = "Link", _Link.componentId = 'Link', _Link.allowedProps = _props.allowedProps, _Link.defaultProps = {
256
+ // Leave interaction default undefined so that `disabled` can also be supplied
257
+ interaction: void 0,
258
+ color: 'link',
259
+ iconPlacement: 'start',
260
+ forceButtonRole: true
261
+ }, _Link)) || _class);
262
+ var _default = exports.default = Link;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowedProps = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ const allowedProps = exports.allowedProps = ['children', 'href', 'color', 'elementRef', 'as', 'role', 'forceButtonRole', 'interaction', 'margin', 'renderIcon', 'iconPlacement', 'display', 'onBlur', 'onClick', 'onFocus', 'onMouseEnter', 'size', 'variant'];
@@ -0,0 +1,248 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _emotion = require("@instructure/emotion");
8
+ /*
9
+ * The MIT License (MIT)
10
+ *
11
+ * Copyright (c) 2015 - present Instructure, Inc.
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+
32
+ /**
33
+ * ---
34
+ * private: true
35
+ * ---
36
+ * Generates the style object from the theme and provided additional information
37
+ * @param {Object} componentTheme The theme variable object.
38
+ * @param {Object} props the props of the component, the style is applied to
39
+ * @param {Object} sharedTokens Shared token object that stores common values for the theme.
40
+ * @param {Object} state the state of the component, the style is applied to
41
+ * @return {Object} The final style object, which will be used in the component
42
+ */
43
+ const generateStyle = (componentTheme, props, sharedTokens, state = {}) => {
44
+ var _state$size, _state$variant, _state$hasVisibleChil;
45
+ const renderIcon = props.renderIcon,
46
+ _props$iconPlacement = props.iconPlacement,
47
+ iconPlacement = _props$iconPlacement === void 0 ? 'start' : _props$iconPlacement,
48
+ color = props.color,
49
+ margin = props.margin;
50
+
51
+ // Get size and variant from state (passed from makeStyleProps) or fall back to props
52
+ const size = (_state$size = state.size) !== null && _state$size !== void 0 ? _state$size : props.size;
53
+ const variant = (_state$variant = state.variant) !== null && _state$variant !== void 0 ? _state$variant : props.variant;
54
+ const hasVisibleChildren = (_state$hasVisibleChil = state.hasVisibleChildren) !== null && _state$hasVisibleChil !== void 0 ? _state$hasVisibleChil : false;
55
+ const isInverseStyle = color === 'link-inverse';
56
+ const inlineLinkSizeStyles = {
57
+ small: {
58
+ fontFamily: componentTheme.inlineLink.small.fontFamily,
59
+ fontWeight: componentTheme.inlineLink.small.fontWeight,
60
+ fontSize: componentTheme.inlineLink.small.fontSize,
61
+ lineHeight: componentTheme.inlineLink.small.lineHeight,
62
+ textDecoration: componentTheme.inlineLink.small.textDecoration,
63
+ gap: componentTheme.gapSm
64
+ },
65
+ medium: {
66
+ fontFamily: componentTheme.inlineLink.medium.fontFamily,
67
+ fontWeight: componentTheme.inlineLink.medium.fontWeight,
68
+ fontSize: componentTheme.inlineLink.medium.fontSize,
69
+ lineHeight: componentTheme.inlineLink.medium.lineHeight,
70
+ textDecoration: componentTheme.inlineLink.medium.textDecoration,
71
+ gap: componentTheme.gapMd
72
+ },
73
+ large: {
74
+ fontFamily: componentTheme.inlineLink.large.fontFamily,
75
+ fontWeight: componentTheme.inlineLink.large.fontWeight,
76
+ fontSize: componentTheme.inlineLink.large.fontSize,
77
+ lineHeight: componentTheme.inlineLink.large.lineHeight,
78
+ textDecoration: componentTheme.inlineLink.large.textDecoration,
79
+ gap: componentTheme.gapLg
80
+ }
81
+ };
82
+
83
+ // For standalone variant, use the base component theme tokens
84
+ const standaloneLinkSizeStyles = {
85
+ small: {
86
+ fontFamily: componentTheme.fontFamily,
87
+ fontWeight: componentTheme.fontWeight,
88
+ fontSize: componentTheme.fontSizeSm,
89
+ lineHeight: componentTheme.lineHeightSm,
90
+ textDecoration: 'none',
91
+ gap: componentTheme.gapSm
92
+ },
93
+ medium: {
94
+ fontFamily: componentTheme.fontFamily,
95
+ fontWeight: componentTheme.fontWeight,
96
+ fontSize: componentTheme.fontSizeMd,
97
+ lineHeight: componentTheme.lineHeightMd,
98
+ textDecoration: 'none',
99
+ gap: componentTheme.gapMd
100
+ },
101
+ large: {
102
+ fontFamily: componentTheme.fontFamily,
103
+ fontWeight: componentTheme.fontWeight,
104
+ fontSize: componentTheme.fontSizeLg,
105
+ lineHeight: componentTheme.lineHeightLg,
106
+ textDecoration: 'none',
107
+ gap: componentTheme.gapLg
108
+ }
109
+ };
110
+
111
+ // Get proper styles based on variant and size
112
+ let variantStyles;
113
+ if (size && variant === 'inline') {
114
+ variantStyles = inlineLinkSizeStyles[size];
115
+ } else if (size && variant === 'standalone') {
116
+ variantStyles = standaloneLinkSizeStyles[size];
117
+ } else if (size) {
118
+ // Fallback if variant is not specified but size is
119
+ variantStyles = standaloneLinkSizeStyles[size];
120
+ } else {
121
+ // No size provided, use inherit
122
+ variantStyles = {
123
+ fontSize: 'inherit',
124
+ lineHeight: 'inherit',
125
+ textDecoration: void 0,
126
+ gap: componentTheme.gapMd // Default gap for icons when no size is specified
127
+ };
128
+ }
129
+ const baseStyles = {
130
+ boxSizing: 'border-box',
131
+ fontFamily: componentTheme.fontFamily,
132
+ fontWeight: componentTheme.fontWeight,
133
+ verticalAlign: 'baseline',
134
+ fontSize: variantStyles.fontSize,
135
+ lineHeight: variantStyles.lineHeight,
136
+ color: componentTheme.unstyledTextColor,
137
+ // set up focus styles
138
+ borderRadius: '0.125rem',
139
+ // If icon is present, use flex to align icon with text
140
+ // Use 'flex' for standalone variant (block-level), 'inline-flex' for inline variant
141
+ ...(renderIcon && hasVisibleChildren && {
142
+ display: variant === 'standalone' ? 'flex' : 'inline-flex',
143
+ alignItems: 'baseline'
144
+ }),
145
+ '&[aria-disabled]': {
146
+ cursor: 'not-allowed',
147
+ pointerEvents: 'none',
148
+ opacity: '1',
149
+ color: componentTheme.textDisabledColor
150
+ }
151
+ };
152
+
153
+ // If Link is a button or link, it should look clickable
154
+ const isClickableStyles = {
155
+ ...baseStyles,
156
+ cursor: 'pointer',
157
+ color: componentTheme.textColor,
158
+ fontSize: variantStyles.fontSize,
159
+ lineHeight: variantStyles.lineHeight,
160
+ ...(variantStyles.fontFamily && {
161
+ fontFamily: variantStyles.fontFamily
162
+ }),
163
+ ...(variantStyles.fontWeight && {
164
+ fontWeight: variantStyles.fontWeight
165
+ }),
166
+ '&:hover, &:active, &:focus': {
167
+ color: componentTheme.textHoverColor,
168
+ // a11y requirement: interactive links must be underlined on interaction
169
+ textDecoration: 'underline'
170
+ },
171
+ // Use textDecoration from variantStyles if available (from inlineLink token), otherwise fallback
172
+ ...(variantStyles.textDecoration ? {
173
+ textDecoration: variantStyles.textDecoration
174
+ } : {
175
+ textDecoration: 'underline'
176
+ })
177
+ };
178
+ const buttonStyle = {
179
+ appearance: 'none',
180
+ userSelect: 'text',
181
+ background: 'none',
182
+ border: 'none',
183
+ cursor: 'pointer',
184
+ margin: 0,
185
+ padding: 0,
186
+ textAlign: 'inherit',
187
+ fontSize: variantStyles.fontSize,
188
+ lineHeight: variantStyles.lineHeight,
189
+ ...(variantStyles.textDecoration && {
190
+ textDecoration: variantStyles.textDecoration
191
+ })
192
+ };
193
+ const inverseStyles = {
194
+ color: componentTheme.onColorTextColor,
195
+ // TODO remove double (here with the util and in View) focus ring calculations
196
+ // in the future after the View refactor is complete
197
+ // This needs stronger specificity than `View`
198
+ '&&&&&:focus': {
199
+ outlineColor: sharedTokens.focusOutline.onColor
200
+ },
201
+ '&:hover, &:active': {
202
+ color: componentTheme.onColorTextHoverColor
203
+ },
204
+ '&[aria-disabled]': {
205
+ color: componentTheme.onColorTextDisabledColor
206
+ }
207
+ };
208
+
209
+ // Icon styles based on size - use gap from variantStyles
210
+ const iconStyles = {
211
+ paddingInlineStart: iconPlacement === 'start' ? 0 : variantStyles.gap || componentTheme.gapMd,
212
+ paddingInlineEnd: iconPlacement === 'start' ? variantStyles.gap || componentTheme.gapMd : 0
213
+ };
214
+ return {
215
+ link: {
216
+ label: 'link',
217
+ ...baseStyles,
218
+ // TODO handle the merging on tokens inside the util
219
+ margin: (0, _emotion.calcSpacingFromShorthand)(margin, {
220
+ ...sharedTokens.spacing,
221
+ ...sharedTokens.legacy.spacing
222
+ }),
223
+ ...(0, _emotion.calcFocusOutlineStyles)(sharedTokens.focusOutline, isInverseStyle ? {
224
+ focusColor: 'inverse'
225
+ } : void 0),
226
+ // NOTE: needs separate groups for `:is()` and `:-webkit-any()` because of css selector group validation (see https://www.w3.org/TR/selectors-3/#grouping)
227
+ '&:is(a), &:is(button)': isClickableStyles,
228
+ '&:-webkit-any(a), &:-webkit-any(button)': isClickableStyles,
229
+ '&:is(button)': buttonStyle,
230
+ '&:-webkit-any(button)': buttonStyle,
231
+ ...(isInverseStyle && {
232
+ ...inverseStyles,
233
+ '&:is(a):link, &:is(a):visited, &:is(button)': inverseStyles,
234
+ '&:-webkit-any(a):link, &:-webkit-any(a):visited, &:-webkit-any(button)': inverseStyles
235
+ })
236
+ },
237
+ icon: {
238
+ label: 'icon',
239
+ ...(renderIcon && {
240
+ boxSizing: 'border-box',
241
+ display: 'flex',
242
+ alignSelf: 'center',
243
+ ...iconStyles
244
+ })
245
+ }
246
+ };
247
+ };
248
+ var _default = exports.default = generateStyle;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "Link", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _Link.Link;
9
+ return _v.Link;
10
10
  }
11
11
  });
12
- var _Link = require("./Link");
12
+ var _v = require("../Link/v1");
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Link", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _v.Link;
10
+ }
11
+ });
12
+ var _v = require("../Link/v2");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-link",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-snapshot-129",
4
4
  "description": "A component for creating links",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -15,25 +15,25 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
- "@instructure/emotion": "11.6.0",
19
- "@instructure/shared-types": "11.6.0",
20
- "@instructure/ui-a11y-utils": "11.6.0",
21
- "@instructure/ui-color-utils": "11.6.0",
22
- "@instructure/ui-dom-utils": "11.6.0",
23
- "@instructure/console": "11.6.0",
24
- "@instructure/ui-react-utils": "11.6.0",
25
- "@instructure/ui-icons": "11.6.0",
26
- "@instructure/ui-utils": "11.6.0",
27
- "@instructure/ui-view": "11.6.0"
18
+ "@instructure/console": "11.6.1-snapshot-129",
19
+ "@instructure/shared-types": "11.6.1-snapshot-129",
20
+ "@instructure/ui-a11y-utils": "11.6.1-snapshot-129",
21
+ "@instructure/ui-color-utils": "11.6.1-snapshot-129",
22
+ "@instructure/emotion": "11.6.1-snapshot-129",
23
+ "@instructure/ui-dom-utils": "11.6.1-snapshot-129",
24
+ "@instructure/ui-icons": "11.6.1-snapshot-129",
25
+ "@instructure/ui-react-utils": "11.6.1-snapshot-129",
26
+ "@instructure/ui-utils": "11.6.1-snapshot-129",
27
+ "@instructure/ui-view": "11.6.1-snapshot-129"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@testing-library/jest-dom": "^6.6.3",
31
31
  "@testing-library/react": "15.0.7",
32
32
  "@testing-library/user-event": "^14.6.1",
33
33
  "vitest": "^3.2.2",
34
- "@instructure/ui-axe-check": "11.6.0",
35
- "@instructure/ui-themes": "11.6.0",
36
- "@instructure/ui-babel-preset": "11.6.0"
34
+ "@instructure/ui-babel-preset": "11.6.1-snapshot-129",
35
+ "@instructure/ui-axe-check": "11.6.1-snapshot-129",
36
+ "@instructure/ui-themes": "11.6.1-snapshot-129"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": ">=18 <=19"
@@ -43,17 +43,39 @@
43
43
  },
44
44
  "sideEffects": false,
45
45
  "exports": {
46
- ".": {
47
- "types": "./types/index.d.ts",
48
- "import": "./es/index.js",
49
- "require": "./lib/index.js",
50
- "default": "./es/index.js"
51
- },
52
46
  "./lib/*": "./lib/*",
53
47
  "./es/*": "./es/*",
54
48
  "./types/*": "./types/*",
55
49
  "./package.json": "./package.json",
56
- "./src/*": "./src/*"
50
+ "./src/*": "./src/*",
51
+ ".": {
52
+ "src": "./src/exports/a.ts",
53
+ "types": "./types/exports/a.d.ts",
54
+ "import": "./es/exports/a.js",
55
+ "require": "./lib/exports/a.js",
56
+ "default": "./es/exports/a.js"
57
+ },
58
+ "./v11_6": {
59
+ "src": "./src/exports/a.ts",
60
+ "types": "./types/exports/a.d.ts",
61
+ "import": "./es/exports/a.js",
62
+ "require": "./lib/exports/a.js",
63
+ "default": "./es/exports/a.js"
64
+ },
65
+ "./v11_7": {
66
+ "src": "./src/exports/b.ts",
67
+ "types": "./types/exports/b.d.ts",
68
+ "import": "./es/exports/b.js",
69
+ "require": "./lib/exports/b.js",
70
+ "default": "./es/exports/b.js"
71
+ },
72
+ "./latest": {
73
+ "src": "./src/exports/b.ts",
74
+ "types": "./types/exports/b.d.ts",
75
+ "import": "./es/exports/b.js",
76
+ "require": "./lib/exports/b.js",
77
+ "default": "./es/exports/b.js"
78
+ }
57
79
  },
58
80
  "scripts": {
59
81
  "lint": "ui-scripts lint",