@semcore/link 5.44.4-prerelease.0 → 16.0.0-prerelease.0
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 +7 -1
- package/lib/cjs/Link.js +95 -97
- package/lib/cjs/Link.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/cjs/style/link.shadow.css +1 -10
- package/lib/es6/Link.js +96 -95
- package/lib/es6/Link.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/es6/style/link.shadow.css +1 -10
- package/lib/esm/Link.mjs +70 -71
- package/lib/esm/style/link.shadow.css +1 -10
- package/lib/types/index.d.ts +26 -28
- package/package.json +5 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## [16.0.0] - 2025-05-19
|
|
6
|
+
|
|
7
|
+
### Break
|
|
8
|
+
|
|
9
|
+
- `keyboardFocusEnhance` to css `:focus-visible` property.
|
|
10
|
+
|
|
5
11
|
## [5.44.4] - 2025-05-13
|
|
6
12
|
|
|
7
13
|
### Changed
|
|
@@ -793,7 +799,7 @@ CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangel
|
|
|
793
799
|
|
|
794
800
|
- Added repository field to package.json file.
|
|
795
801
|
|
|
796
|
-
## [3.4.1] - 2021-
|
|
802
|
+
## [3.4.1] - 2021-8-26
|
|
797
803
|
|
|
798
804
|
### Changed
|
|
799
805
|
|
package/lib/cjs/Link.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
@@ -13,32 +12,30 @@ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
13
12
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
13
|
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
15
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
var
|
|
17
|
-
var _core = _interopRequireWildcard(require("@semcore/core"));
|
|
15
|
+
var _core = require("@semcore/core");
|
|
18
16
|
var _react = _interopRequireDefault(require("react"));
|
|
19
17
|
var _typography = require("@semcore/typography");
|
|
20
18
|
var _flexBox = require("@semcore/flex-box");
|
|
21
19
|
var _tooltip = require("@semcore/tooltip");
|
|
22
|
-
var _keyboardFocusEnhance = _interopRequireDefault(require("@semcore/
|
|
23
|
-
var _addonTextChildren = _interopRequireDefault(require("@semcore/
|
|
24
|
-
var _logger = _interopRequireDefault(require("@semcore/
|
|
25
|
-
var _hasLabels = _interopRequireDefault(require("@semcore/
|
|
26
|
-
var _resolveColorEnhance = _interopRequireDefault(require("@semcore/
|
|
20
|
+
var _keyboardFocusEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhances/keyboardFocusEnhance"));
|
|
21
|
+
var _addonTextChildren = _interopRequireDefault(require("@semcore/core/lib/utils/addonTextChildren"));
|
|
22
|
+
var _logger = _interopRequireDefault(require("@semcore/core/lib/utils/logger"));
|
|
23
|
+
var _hasLabels = _interopRequireDefault(require("@semcore/core/lib/utils/hasLabels"));
|
|
24
|
+
var _resolveColorEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhances/resolveColorEnhance"));
|
|
27
25
|
/*!__reshadow-styles__:"./style/link.shadow.css"*/
|
|
28
|
-
var style = ( /*__reshadow_css_start__*/
|
|
26
|
+
var style = ( /*__reshadow_css_start__*/_core.sstyled.insert( /*__inner_css_start__*/".___SLink_ypsez_gg_{display:inline-block;font-family:inherit;color:var(--intergalactic-text-link, #006dca);line-height:normal;position:relative;cursor:pointer;border:0;padding:0;margin:0;box-shadow:none;-webkit-tap-highlight-color:transparent;background:0 0;transition:color .15s ease-in-out}.___SLink_ypsez_gg_,.___SLink_ypsez_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SLink_ypsez_gg_:hover{-webkit-text-decoration:none;text-decoration:none}}.___SLink_ypsez_gg_::-moz-focus-inner{border:0;padding:0}.___SLink_ypsez_gg_.__active_ypsez_gg_,.___SLink_ypsez_gg_:active{color:var(--intergalactic-text-link-hover-active, #044792)}@media (hover:hover){.___SLink_ypsez_gg_:hover{color:var(--intergalactic-text-link-hover-active, #044792)}}.___SLink_ypsez_gg_.__active_ypsez_gg_ .___SText_ypsez_gg_,.___SLink_ypsez_gg_:active .___SText_ypsez_gg_{border-color:currentColor}@media (hover:hover){.___SLink_ypsez_gg_:hover .___SText_ypsez_gg_{border-color:currentColor}}.___SLink_ypsez_gg_.__enableVisited_ypsez_gg_:visited{color:var(--intergalactic-text-link-visited, #8649e1)}@media (hover:hover){.___SLink_ypsez_gg_.__enableVisited_ypsez_gg_:visited:hover{color:var(--intergalactic-text-link-visited, #8649e1)}}.___SLink_ypsez_gg_.__visually-disabled_ypsez_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SLink_ypsez_gg_.__noWrapText_ypsez_gg_{white-space:nowrap}.___SLink_ypsez_gg_.__inline_ypsez_gg_{display:inline}.___SAddon_ypsez_gg_{display:inline-flex;justify-content:center;align-items:center;margin-bottom:var(--intergalactic-spacing-05x, 2px);vertical-align:middle;pointer-events:none}.___SLink_ypsez_gg_ .___SAddon_ypsez_gg_:not(:only-child):first-child{margin-right:var(--intergalactic-spacing-1x, 4px)}.___SLink_ypsez_gg_ .___SAddon_ypsez_gg_:not(:only-child):last-child{margin-left:var(--intergalactic-spacing-1x, 4px)}.___SText_ypsez_gg_{border-bottom-width:1px;border-bottom-style:solid;border-color:transparent;transition:border-bottom-color .15s ease-in-out}.___SLink_ypsez_gg_.__text-color_ypsez_gg_{color:var(--text-color_ypsez)}.___SLink_ypsez_gg_.__text-color_ypsez_gg_.__active_ypsez_gg_,.___SLink_ypsez_gg_.__text-color_ypsez_gg_:active{color:var(--text-color_ypsez);filter:brightness(.8)}@media (hover:hover){.___SLink_ypsez_gg_.__text-color_ypsez_gg_:hover{color:var(--text-color_ypsez);filter:brightness(.8)}}@media (prefers-reduced-motion){.___SLink_ypsez_gg_,.___SText_ypsez_gg_{transition:none}}", /*__inner_css_end__*/"ypsez_gg_"),
|
|
29
27
|
/*__reshadow_css_end__*/
|
|
30
28
|
{
|
|
31
|
-
"__SLink": "
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"--text-color": "--text-color_1slzv"
|
|
29
|
+
"__SLink": "___SLink_ypsez_gg_",
|
|
30
|
+
"_visually-disabled": "__visually-disabled_ypsez_gg_",
|
|
31
|
+
"_noWrapText": "__noWrapText_ypsez_gg_",
|
|
32
|
+
"_inline": "__inline_ypsez_gg_",
|
|
33
|
+
"__SAddon": "___SAddon_ypsez_gg_",
|
|
34
|
+
"__SText": "___SText_ypsez_gg_",
|
|
35
|
+
"_active": "__active_ypsez_gg_",
|
|
36
|
+
"_enableVisited": "__enableVisited_ypsez_gg_",
|
|
37
|
+
"_text-color": "__text-color_ypsez_gg_",
|
|
38
|
+
"--text-color": "--text-color_ypsez"
|
|
42
39
|
});
|
|
43
40
|
var RootLink = /*#__PURE__*/function (_Component) {
|
|
44
41
|
(0, _inherits2["default"])(RootLink, _Component);
|
|
@@ -52,18 +49,7 @@ var RootLink = /*#__PURE__*/function (_Component) {
|
|
|
52
49
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
53
50
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "containerRef", /*#__PURE__*/_react["default"].createRef());
|
|
54
51
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
55
|
-
ariaLabelledByContent: ''
|
|
56
|
-
visibleHint: false
|
|
57
|
-
});
|
|
58
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleMouseEnterOnlyAddon", function () {
|
|
59
|
-
_this.setState({
|
|
60
|
-
visibleHint: true
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleMouseLeaveOnlyAddon", function () {
|
|
64
|
-
_this.setState({
|
|
65
|
-
visibleHint: false
|
|
66
|
-
});
|
|
52
|
+
ariaLabelledByContent: ''
|
|
67
53
|
});
|
|
68
54
|
return _this;
|
|
69
55
|
}
|
|
@@ -84,68 +70,80 @@ var RootLink = /*#__PURE__*/function (_Component) {
|
|
|
84
70
|
}
|
|
85
71
|
}
|
|
86
72
|
}, {
|
|
87
|
-
key: "
|
|
88
|
-
value: function
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return
|
|
96
|
-
tag: AddonLeft
|
|
97
|
-
}) : null, (0, _addonTextChildren["default"])(Children, Link.Text, Link.Addon), AddonRight ? /*#__PURE__*/_react["default"].createElement(Link.Addon, {
|
|
98
|
-
tag: AddonRight
|
|
99
|
-
}) : null);
|
|
73
|
+
key: "renderLink",
|
|
74
|
+
value: function renderLink(_ref10) {
|
|
75
|
+
var _ref = this.asProps,
|
|
76
|
+
_ref5;
|
|
77
|
+
var linkProps = _ref10.linkProps,
|
|
78
|
+
children = _ref10.children;
|
|
79
|
+
var styles = this.asProps.styles;
|
|
80
|
+
var SLink = _typography.Text;
|
|
81
|
+
return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SLink, _ref5.cn("SLink", (0, _objectSpread2["default"])({}, (0, _core.assignProps)((0, _objectSpread2["default"])({}, linkProps), _ref))), children);
|
|
100
82
|
}
|
|
101
83
|
}, {
|
|
102
|
-
key: "
|
|
103
|
-
value: function
|
|
104
|
-
var
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
var visibleHint = this.state.visibleHint;
|
|
113
|
-
var hintContent = (_ref9 = (_ref10 = title !== null && title !== void 0 ? title : ariaLabel) !== null && _ref10 !== void 0 ? _ref10 : this.state.ariaLabelledByContent) !== null && _ref9 !== void 0 ? _ref9 : '';
|
|
114
|
-
return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(Link.Addon, {
|
|
115
|
-
tag: _tooltip.Hint,
|
|
116
|
-
title: hintContent,
|
|
117
|
-
timeout: [250, 50],
|
|
118
|
-
visible: keyboardFocused || visibleHint
|
|
119
|
-
}, AddonLeft && /*#__PURE__*/_react["default"].createElement(AddonLeft, _ref5.cn("AddonLeft", {})), AddonRight && /*#__PURE__*/_react["default"].createElement(AddonRight, _ref5.cn("AddonRight", {})));
|
|
84
|
+
key: "renderLinkWithHint",
|
|
85
|
+
value: function renderLinkWithHint(_ref11) {
|
|
86
|
+
var _ref2 = this.asProps,
|
|
87
|
+
_ref6;
|
|
88
|
+
var linkProps = _ref11.linkProps,
|
|
89
|
+
children = _ref11.children,
|
|
90
|
+
hintProps = _ref11.hintProps;
|
|
91
|
+
var styles = this.asProps.styles;
|
|
92
|
+
var SLink = _tooltip.Hint;
|
|
93
|
+
return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SLink, _ref6.cn("SLink", (0, _objectSpread2["default"])({}, (0, _core.assignProps)((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, linkProps), hintProps), _ref2))), children);
|
|
120
94
|
}
|
|
121
95
|
}, {
|
|
122
96
|
key: "render",
|
|
123
97
|
value: function render() {
|
|
124
|
-
var
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
98
|
+
var _ref7, _ref12, _ref13;
|
|
99
|
+
var _this$asProps = this.asProps,
|
|
100
|
+
styles = _this$asProps.styles,
|
|
101
|
+
noWrap = _this$asProps.noWrap,
|
|
102
|
+
color = _this$asProps.color,
|
|
103
|
+
resolveColor = _this$asProps.resolveColor,
|
|
104
|
+
disabled = _this$asProps.disabled,
|
|
105
|
+
href = _this$asProps.href,
|
|
106
|
+
hasChildren = _this$asProps.children,
|
|
107
|
+
AddonLeft = _this$asProps.addonLeft,
|
|
108
|
+
AddonRight = _this$asProps.addonRight,
|
|
109
|
+
Children = _this$asProps.Children,
|
|
110
|
+
title = _this$asProps.title,
|
|
111
|
+
ariaLabel = _this$asProps['aria-label'],
|
|
112
|
+
hintPlacement = _this$asProps.hintPlacement;
|
|
113
|
+
// @ts-ignore
|
|
114
|
+
var Link = this[_core.CORE_INSTANCE];
|
|
115
|
+
var children = (_ref7 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, AddonLeft ? /*#__PURE__*/_react["default"].createElement(Link.Addon, null, /*#__PURE__*/_react["default"].createElement(AddonLeft, _ref7.cn("AddonLeft", {}))) : null, (0, _addonTextChildren["default"])(Children, Link.Text, Link.Addon), AddonRight ? /*#__PURE__*/_react["default"].createElement(Link.Addon, null, /*#__PURE__*/_react["default"].createElement(AddonRight, _ref7.cn("AddonRight", {}))) : null));
|
|
116
|
+
var hintContent = (_ref12 = (_ref13 = title !== null && title !== void 0 ? title : ariaLabel) !== null && _ref13 !== void 0 ? _ref13 : this.state.ariaLabelledByContent) !== null && _ref12 !== void 0 ? _ref12 : '';
|
|
117
|
+
var linkProps = {
|
|
118
|
+
role: 'link',
|
|
119
|
+
tabIndex: disabled ? -1 : 0,
|
|
120
|
+
'use:href': disabled ? undefined : href,
|
|
121
|
+
'visually-disabled': disabled,
|
|
122
|
+
render: _typography.Text,
|
|
123
|
+
'text-color': resolveColor(color),
|
|
124
|
+
tag: 'a',
|
|
125
|
+
noWrapText: noWrap,
|
|
126
|
+
'use:noWrap': false,
|
|
127
|
+
ref: this.containerRef,
|
|
128
|
+
__excludeProps: ['disabled', 'aria-disabled']
|
|
129
|
+
};
|
|
130
|
+
var hintProps = {
|
|
131
|
+
title: hintContent,
|
|
132
|
+
timeout: [250, 50],
|
|
133
|
+
placement: hintPlacement,
|
|
134
|
+
__excludeProps: []
|
|
135
|
+
};
|
|
136
|
+
if (hasChildren === undefined || title) {
|
|
137
|
+
return this.renderLinkWithHint({
|
|
138
|
+
linkProps: linkProps,
|
|
139
|
+
hintProps: hintProps,
|
|
140
|
+
children: children
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return this.renderLink({
|
|
144
|
+
linkProps: linkProps,
|
|
145
|
+
children: children
|
|
146
|
+
});
|
|
149
147
|
}
|
|
150
148
|
}]);
|
|
151
149
|
return RootLink;
|
|
@@ -157,24 +155,24 @@ var RootLink = /*#__PURE__*/function (_Component) {
|
|
|
157
155
|
(0, _defineProperty2["default"])(RootLink, "style", style);
|
|
158
156
|
(0, _defineProperty2["default"])(RootLink, "enhance", [(0, _keyboardFocusEnhance["default"])(), (0, _resolveColorEnhance["default"])()]);
|
|
159
157
|
function LinkText(props) {
|
|
160
|
-
var
|
|
161
|
-
|
|
158
|
+
var _ref3 = arguments[0],
|
|
159
|
+
_ref8;
|
|
162
160
|
var SText = _flexBox.Box;
|
|
163
161
|
var styles = props.styles;
|
|
164
|
-
return
|
|
162
|
+
return _ref8 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SText, _ref8.cn("SText", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
165
163
|
"tag": 'span'
|
|
166
|
-
},
|
|
164
|
+
}, _ref3))));
|
|
167
165
|
}
|
|
168
166
|
function Addon(props) {
|
|
169
|
-
var
|
|
170
|
-
|
|
167
|
+
var _ref4 = arguments[0],
|
|
168
|
+
_ref9;
|
|
171
169
|
var SAddon = _flexBox.Box;
|
|
172
170
|
var styles = props.styles;
|
|
173
|
-
return
|
|
171
|
+
return _ref9 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref9.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
174
172
|
"tag": 'span'
|
|
175
|
-
},
|
|
173
|
+
}, _ref4))));
|
|
176
174
|
}
|
|
177
|
-
var Link = (0, _core
|
|
175
|
+
var Link = (0, _core.createComponent)(RootLink, {
|
|
178
176
|
Text: LinkText,
|
|
179
177
|
Addon: Addon
|
|
180
178
|
});
|
package/lib/cjs/Link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","names":["_core","_interopRequireWildcard","require","_react","_interopRequireDefault","_typography","_flexBox","_tooltip","_keyboardFocusEnhance","_addonTextChildren","_logger","_hasLabels","_resolveColorEnhance","style","_index","sstyled","insert","RootLink","_Component","_inherits2","_super","_createSuper2","_this","_classCallCheck2","_len","arguments","length","args","Array","_key","call","apply","concat","_defineProperty2","_assertThisInitialized2","React","createRef","ariaLabelledByContent","visibleHint","setState","_createClass2","key","value","componentDidMount","_this2","process","env","NODE_ENV","logger","warn","containerRef","current","hasLabels","asProps","displayName","setTimeout","_document$getElementB","_document$getElementB2","document","getElementById","textContent","renderChildren","_ref4","_this$asProps","Children","styles","AddonLeft","addonLeft","AddonRight","addonRight","createElement","Fragment","Link","Addon","tag","addonTextChildren","Text","renderOnlyAddons","_ref5","_ref9","_ref10","_this$asProps2","title","ariaLabel","keyboardFocused","state","hintContent","Hint","timeout","visible","cn","render","_ref","_ref6","SLink","_this$asProps3","noWrap","color","resolveColor","disabled","href","hasChildren","children","_objectSpread2","assignProps","undefined","handleMouseEnterOnlyAddon","handleMouseLeaveOnlyAddon","Component","keyboardFocusEnhance","resolveColorEnhance","LinkText","props","_ref2","arguments[0]","_ref7","SText","Box","_ref3","_ref8","SAddon","createComponent","_default","exports"],"sources":["../../src/Link.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, Root, sstyled } from '@semcore/core';\nimport { Text } from '@semcore/typography';\nimport { Box } from '@semcore/flex-box';\nimport { Hint } from '@semcore/tooltip';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\nimport logger from '@semcore/utils/lib/logger';\nimport hasLabels from '@semcore/utils/lib/hasLabels';\nimport resolveColorEnhance from '@semcore/utils/lib/enhances/resolveColorEnhance';\n\nimport style from './style/link.shadow.css';\n\nclass RootLink extends Component {\n static displayName = 'Link';\n static defaultProps = {\n noWrap: true,\n };\n static style = style;\n static enhance = [keyboardFocusEnhance(), resolveColorEnhance()];\n containerRef = React.createRef();\n\n state = {\n ariaLabelledByContent: '',\n visibleHint: false,\n };\n\n componentDidMount() {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n this.containerRef.current && !hasLabels(this.containerRef.current),\n `'title' or 'aria-label' or 'aria-labelledby' are required props for links without text content`,\n this.asProps['data-ui-name'] || RootLink.displayName,\n );\n }\n\n if (this.asProps['aria-labelledby']) {\n setTimeout(() => {\n this.setState({\n ariaLabelledByContent:\n document.getElementById(this.asProps['aria-labelledby'])?.textContent ?? '',\n });\n }, 0);\n }\n }\n\n handleMouseEnterOnlyAddon = () => {\n this.setState({ visibleHint: true });\n };\n handleMouseLeaveOnlyAddon = () => {\n this.setState({ visibleHint: false });\n };\n\n renderChildren() {\n const { Children, styles, addonLeft: AddonLeft, addonRight: AddonRight } = this.asProps;\n\n return sstyled(styles)(\n <>\n {AddonLeft ? <Link.Addon tag={AddonLeft} /> : null}\n {addonTextChildren(Children, Link.Text, Link.Addon)}\n {AddonRight ? <Link.Addon tag={AddonRight} /> : null}\n </>,\n );\n }\n\n renderOnlyAddons() {\n const {\n styles,\n addonLeft: AddonLeft,\n addonRight: AddonRight,\n title,\n ['aria-label']: ariaLabel,\n keyboardFocused,\n } = this.asProps;\n const { visibleHint } = this.state;\n\n const hintContent = title ?? ariaLabel ?? this.state.ariaLabelledByContent ?? '';\n\n return sstyled(styles)(\n <Link.Addon\n tag={Hint}\n title={hintContent}\n timeout={[250, 50]}\n visible={keyboardFocused || visibleHint}\n >\n {AddonLeft && <AddonLeft />}\n {AddonRight && <AddonRight />}\n </Link.Addon>,\n );\n }\n\n render() {\n const SLink = Root;\n const {\n styles,\n noWrap,\n color,\n resolveColor,\n disabled,\n href,\n children: hasChildren,\n } = this.asProps;\n\n return sstyled(styles)(\n <SLink\n role='link'\n tabIndex={disabled ? -1 : 0}\n use:href={disabled ? undefined : href}\n visually-disabled={disabled}\n render={Text}\n text-color={resolveColor(color)}\n tag='a'\n noWrapText={noWrap}\n use:noWrap={false}\n ref={this.containerRef}\n __excludeProps={['disabled', 'aria-disabled']}\n onMouseEnter={this.handleMouseEnterOnlyAddon}\n onMouseLeave={this.handleMouseLeaveOnlyAddon}\n >\n {hasChildren !== undefined ? this.renderChildren() : this.renderOnlyAddons()}\n </SLink>,\n );\n }\n}\n\nfunction LinkText(props) {\n const SText = Root;\n const { styles } = props;\n return sstyled(styles)(<SText render={Box} tag='span' />);\n}\n\nfunction Addon(props) {\n const SAddon = Root;\n const { styles } = props;\n return sstyled(styles)(<SAddon render={Box} tag='span' />);\n}\n\nconst Link = createComponent(RootLink, {\n Text: LinkText,\n Addon,\n});\n\nexport default Link;\n"],"mappings":";;;;;;;;;;;;;;;;AACA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AADA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAE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AA,GAAO,IAAAxG,aAAO,EAACkD,MAAM,CAAC,eAAC9D,MAAA,YAAAmE,aAAA,CAACkD,MAAM,EAAAD,KAAA,CAAA7B,EAAA,eAAAa,cAAA,qBAAAvG,KAAA,CAAAwG,WAAA;IAAA,OAAkB;EAAM,GAAAc,KAAA,IAAG;AAC3D;AAEA,IAAM9C,IAAI,GAAG,IAAAiD,gBAAe,EAACxG,QAAQ,EAAE;EACrC2D,IAAI,EAAEmC,QAAQ;EACdtC,KAAK,EAALA;AACF,CAAC,CAAC;AAAC,IAAAiD,QAAA,GAEYlD,IAAI;AAAAmD,OAAA,cAAAD,QAAA"}
|
|
1
|
+
{"version":3,"file":"Link.js","names":["_core","require","_react","_interopRequireDefault","_typography","_flexBox","_tooltip","_keyboardFocusEnhance","_addonTextChildren","_logger","_hasLabels","_resolveColorEnhance","style","sstyled","insert","RootLink","_Component","_inherits2","_super","_createSuper2","_this","_classCallCheck2","_len","arguments","length","args","Array","_key","call","apply","concat","_defineProperty2","_assertThisInitialized2","React","createRef","ariaLabelledByContent","_createClass2","key","value","componentDidMount","_this2","process","env","NODE_ENV","logger","warn","containerRef","current","hasLabels","asProps","displayName","setTimeout","_document$getElementB","_document$getElementB2","setState","document","getElementById","textContent","renderLink","_ref10","_ref","_ref5","linkProps","children","styles","SLink","Text","createElement","cn","_objectSpread2","assignProps","renderLinkWithHint","_ref11","_ref2","_ref6","hintProps","Hint","render","_ref7","_ref12","_ref13","_this$asProps","noWrap","color","resolveColor","disabled","href","hasChildren","AddonLeft","addonLeft","AddonRight","addonRight","Children","title","ariaLabel","hintPlacement","Link","CORE_INSTANCE","Fragment","Addon","addonTextChildren","hintContent","state","role","tabIndex","undefined","tag","noWrapText","ref","__excludeProps","timeout","placement","Component","keyboardFocusEnhance","resolveColorEnhance","LinkText","props","_ref3","arguments[0]","_ref8","SText","Box","_ref4","_ref9","SAddon","createComponent","_default","exports"],"sources":["../../src/Link.jsx"],"sourcesContent":["import React from 'react';\nimport { createComponent, Component, Root, sstyled, CORE_INSTANCE } from '@semcore/core';\nimport { Text } from '@semcore/typography';\nimport { Box } from '@semcore/flex-box';\nimport { Hint } from '@semcore/tooltip';\nimport keyboardFocusEnhance from '@semcore/core/lib/utils/enhances/keyboardFocusEnhance';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport logger from '@semcore/core/lib/utils/logger';\nimport hasLabels from '@semcore/core/lib/utils/hasLabels';\nimport resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';\n\nimport style from './style/link.shadow.css';\n\nclass RootLink extends Component {\n static displayName = 'Link';\n static defaultProps = {\n noWrap: true,\n };\n static style = style;\n static enhance = [keyboardFocusEnhance(), resolveColorEnhance()];\n containerRef = React.createRef();\n\n state = {\n ariaLabelledByContent: '',\n };\n\n componentDidMount() {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n this.containerRef.current && !hasLabels(this.containerRef.current),\n `'title' or 'aria-label' or 'aria-labelledby' are required props for links without text content`,\n this.asProps['data-ui-name'] || RootLink.displayName,\n );\n }\n\n if (this.asProps['aria-labelledby']) {\n setTimeout(() => {\n this.setState({\n ariaLabelledByContent:\n document.getElementById(this.asProps['aria-labelledby'])?.textContent ?? '',\n });\n }, 0);\n }\n }\n\n renderLink({ linkProps, children }) {\n const { styles } = this.asProps;\n const SLink = Root;\n\n return sstyled(styles)(\n <SLink render={Text} {...linkProps}>\n {children}\n </SLink>,\n );\n }\n\n renderLinkWithHint({ linkProps, children, hintProps }) {\n const { styles } = this.asProps;\n const SLink = Root;\n\n return sstyled(styles)(\n <SLink render={Hint} {...linkProps} {...hintProps}>\n {children}\n </SLink>,\n );\n }\n\n render() {\n const {\n styles,\n noWrap,\n color,\n resolveColor,\n disabled,\n href,\n children: hasChildren,\n addonLeft: AddonLeft,\n addonRight: AddonRight,\n Children,\n title,\n ['aria-label']: ariaLabel,\n hintPlacement,\n } = this.asProps;\n // @ts-ignore\n const Link = this[CORE_INSTANCE];\n\n const children = sstyled(styles)(\n <>\n {AddonLeft ? (\n <Link.Addon>\n <AddonLeft />\n </Link.Addon>\n ) : null}\n {addonTextChildren(Children, Link.Text, Link.Addon)}\n {AddonRight ? (\n <Link.Addon>\n <AddonRight />\n </Link.Addon>\n ) : null}\n </>,\n );\n\n const hintContent = title ?? ariaLabel ?? this.state.ariaLabelledByContent ?? '';\n\n const linkProps = {\n role: 'link',\n tabIndex: disabled ? -1 : 0,\n 'use:href': disabled ? undefined : href,\n 'visually-disabled': disabled,\n render: Text,\n 'text-color': resolveColor(color),\n tag: 'a',\n noWrapText: noWrap,\n 'use:noWrap': false,\n ref: this.containerRef,\n __excludeProps: ['disabled', 'aria-disabled'],\n };\n\n const hintProps = {\n title: hintContent,\n timeout: [250, 50],\n placement: hintPlacement,\n __excludeProps: [],\n };\n\n if (hasChildren === undefined || title) {\n return this.renderLinkWithHint({ linkProps, hintProps, children });\n }\n\n return this.renderLink({ linkProps, children });\n }\n}\n\nfunction LinkText(props) {\n const SText = Root;\n const { styles } = props;\n return sstyled(styles)(<SText render={Box} tag='span' />);\n}\n\nfunction Addon(props) {\n const SAddon = Root;\n const { styles } = props;\n return sstyled(styles)(<SAddon render={Box} tag='span' />);\n}\n\nconst Link = createComponent(RootLink, {\n Text: LinkText,\n Addon,\n});\n\nexport default Link;\n"],"mappings":";;;;;;;;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AADA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,kBAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,OAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,UAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,oBAAA,GAAAR,sBAAA,CAAA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D,EAAA,eAAAC,cAAA,qBAAArE,KAAA,CAAAsE,WAAA;IAAA,OAAkB;EAAM,GAAAoD,KAAA,IAAG;AAC3D;AAEA,IAAM1B,IAAI,GAAG,IAAA6B,qBAAe,EAAC9G,QAAQ,EAAE;EACrCmD,IAAI,EAAEiD,QAAQ;EACdhB,KAAK,EAALA;AACF,CAAC,CAAC;AAAC,IAAA2B,QAAA,GAEY9B,IAAI;AAAA+B,OAAA,cAAAD,QAAA"}
|
package/lib/cjs/index.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { Intergalactic, UnknownProperties } from '@semcore/core';\nimport { TextProps } from '@semcore/typography';\nimport { BoxProps } from '@semcore/flex-box';\
|
|
1
|
+
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { Intergalactic, UnknownProperties } from '@semcore/core';\nimport { TextProps } from '@semcore/typography';\nimport { BoxProps } from '@semcore/flex-box';\n\n/** @deprecated */\nexport interface ILinkProps extends LinkProps, UnknownProperties {}\nexport type LinkProps = TextProps & {\n /**\n * CSS property of the display link (inline|inline-block)\n * @default false\n */\n inline?: boolean;\n /**\n * Sets the link to the disabled state\n */\n disabled?: boolean;\n /**\n * Sets the link to the active state\n */\n active?: boolean;\n /** This flag enables highlighting of the visited link\n */\n enableVisited?: boolean;\n /** The text will not be moved to a new line\n * @default true\n */\n noWrap?: boolean;\n /** Left addon tag */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n};\n\ndeclare const Link: Intergalactic.Component<'a', LinkProps> & {\n Text: Intergalactic.Component<'span', TextProps>;\n Addon: Intergalactic.Component<'span', BoxProps>;\n};\n\nexport default Link;\n"],"mappings":""}
|
|
@@ -11,14 +11,11 @@ SLink {
|
|
|
11
11
|
margin: 0;
|
|
12
12
|
box-shadow: none;
|
|
13
13
|
-webkit-tap-highlight-color: transparent;
|
|
14
|
-
outline: 0;
|
|
15
14
|
background: none;
|
|
16
15
|
transition: color 0.15s ease-in-out;
|
|
17
16
|
|
|
18
17
|
&:active,
|
|
19
|
-
&:hover
|
|
20
|
-
&:focus {
|
|
21
|
-
outline: 0;
|
|
18
|
+
&:hover {
|
|
22
19
|
text-decoration: none;
|
|
23
20
|
}
|
|
24
21
|
|
|
@@ -43,12 +40,6 @@ SLink {
|
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
42
|
|
|
46
|
-
SLink[keyboardFocused] {
|
|
47
|
-
outline-color: var(--intergalactic-keyboard-focus-outline, rgba(0, 143, 248, 0.5));
|
|
48
|
-
outline-style: solid;
|
|
49
|
-
outline-width: 3px;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
43
|
SLink[visually-disabled] {
|
|
53
44
|
opacity: var(--intergalactic-disabled-opacity, 0.3);
|
|
54
45
|
cursor: default;
|
package/lib/es6/Link.js
CHANGED
|
@@ -5,35 +5,35 @@ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized
|
|
|
5
5
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
import { sstyled as _sstyled } from "@semcore/
|
|
8
|
+
import { sstyled as _sstyled } from "@semcore/core";
|
|
9
|
+
import { assignProps as _assignProps4 } from "@semcore/core";
|
|
9
10
|
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
10
11
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
11
12
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
12
13
|
import React from 'react';
|
|
13
|
-
import createComponent,
|
|
14
|
+
import { createComponent, Component, Root, sstyled, CORE_INSTANCE } from '@semcore/core';
|
|
14
15
|
import { Text } from '@semcore/typography';
|
|
15
16
|
import { Box } from '@semcore/flex-box';
|
|
16
17
|
import { Hint } from '@semcore/tooltip';
|
|
17
|
-
import keyboardFocusEnhance from '@semcore/
|
|
18
|
-
import addonTextChildren from '@semcore/
|
|
19
|
-
import logger from '@semcore/
|
|
20
|
-
import hasLabels from '@semcore/
|
|
21
|
-
import resolveColorEnhance from '@semcore/
|
|
18
|
+
import keyboardFocusEnhance from '@semcore/core/lib/utils/enhances/keyboardFocusEnhance';
|
|
19
|
+
import addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';
|
|
20
|
+
import logger from '@semcore/core/lib/utils/logger';
|
|
21
|
+
import hasLabels from '@semcore/core/lib/utils/hasLabels';
|
|
22
|
+
import resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';
|
|
22
23
|
/*!__reshadow-styles__:"./style/link.shadow.css"*/
|
|
23
|
-
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".
|
|
24
|
+
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SLink_ypsez_gg_{display:inline-block;font-family:inherit;color:var(--intergalactic-text-link, #006dca);line-height:normal;position:relative;cursor:pointer;border:0;padding:0;margin:0;box-shadow:none;-webkit-tap-highlight-color:transparent;background:0 0;transition:color .15s ease-in-out}.___SLink_ypsez_gg_,.___SLink_ypsez_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SLink_ypsez_gg_:hover{-webkit-text-decoration:none;text-decoration:none}}.___SLink_ypsez_gg_::-moz-focus-inner{border:0;padding:0}.___SLink_ypsez_gg_.__active_ypsez_gg_,.___SLink_ypsez_gg_:active{color:var(--intergalactic-text-link-hover-active, #044792)}@media (hover:hover){.___SLink_ypsez_gg_:hover{color:var(--intergalactic-text-link-hover-active, #044792)}}.___SLink_ypsez_gg_.__active_ypsez_gg_ .___SText_ypsez_gg_,.___SLink_ypsez_gg_:active .___SText_ypsez_gg_{border-color:currentColor}@media (hover:hover){.___SLink_ypsez_gg_:hover .___SText_ypsez_gg_{border-color:currentColor}}.___SLink_ypsez_gg_.__enableVisited_ypsez_gg_:visited{color:var(--intergalactic-text-link-visited, #8649e1)}@media (hover:hover){.___SLink_ypsez_gg_.__enableVisited_ypsez_gg_:visited:hover{color:var(--intergalactic-text-link-visited, #8649e1)}}.___SLink_ypsez_gg_.__visually-disabled_ypsez_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SLink_ypsez_gg_.__noWrapText_ypsez_gg_{white-space:nowrap}.___SLink_ypsez_gg_.__inline_ypsez_gg_{display:inline}.___SAddon_ypsez_gg_{display:inline-flex;justify-content:center;align-items:center;margin-bottom:var(--intergalactic-spacing-05x, 2px);vertical-align:middle;pointer-events:none}.___SLink_ypsez_gg_ .___SAddon_ypsez_gg_:not(:only-child):first-child{margin-right:var(--intergalactic-spacing-1x, 4px)}.___SLink_ypsez_gg_ .___SAddon_ypsez_gg_:not(:only-child):last-child{margin-left:var(--intergalactic-spacing-1x, 4px)}.___SText_ypsez_gg_{border-bottom-width:1px;border-bottom-style:solid;border-color:transparent;transition:border-bottom-color .15s ease-in-out}.___SLink_ypsez_gg_.__text-color_ypsez_gg_{color:var(--text-color_ypsez)}.___SLink_ypsez_gg_.__text-color_ypsez_gg_.__active_ypsez_gg_,.___SLink_ypsez_gg_.__text-color_ypsez_gg_:active{color:var(--text-color_ypsez);filter:brightness(.8)}@media (hover:hover){.___SLink_ypsez_gg_.__text-color_ypsez_gg_:hover{color:var(--text-color_ypsez);filter:brightness(.8)}}@media (prefers-reduced-motion){.___SLink_ypsez_gg_,.___SText_ypsez_gg_{transition:none}}", /*__inner_css_end__*/"ypsez_gg_"),
|
|
24
25
|
/*__reshadow_css_end__*/
|
|
25
26
|
{
|
|
26
|
-
"__SLink": "
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"--text-color": "--text-color_1slzv"
|
|
27
|
+
"__SLink": "___SLink_ypsez_gg_",
|
|
28
|
+
"_visually-disabled": "__visually-disabled_ypsez_gg_",
|
|
29
|
+
"_noWrapText": "__noWrapText_ypsez_gg_",
|
|
30
|
+
"_inline": "__inline_ypsez_gg_",
|
|
31
|
+
"__SAddon": "___SAddon_ypsez_gg_",
|
|
32
|
+
"__SText": "___SText_ypsez_gg_",
|
|
33
|
+
"_active": "__active_ypsez_gg_",
|
|
34
|
+
"_enableVisited": "__enableVisited_ypsez_gg_",
|
|
35
|
+
"_text-color": "__text-color_ypsez_gg_",
|
|
36
|
+
"--text-color": "--text-color_ypsez"
|
|
37
37
|
});
|
|
38
38
|
var RootLink = /*#__PURE__*/function (_Component) {
|
|
39
39
|
_inherits(RootLink, _Component);
|
|
@@ -47,18 +47,7 @@ var RootLink = /*#__PURE__*/function (_Component) {
|
|
|
47
47
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
48
48
|
_defineProperty(_assertThisInitialized(_this), "containerRef", /*#__PURE__*/React.createRef());
|
|
49
49
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
50
|
-
ariaLabelledByContent: ''
|
|
51
|
-
visibleHint: false
|
|
52
|
-
});
|
|
53
|
-
_defineProperty(_assertThisInitialized(_this), "handleMouseEnterOnlyAddon", function () {
|
|
54
|
-
_this.setState({
|
|
55
|
-
visibleHint: true
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
_defineProperty(_assertThisInitialized(_this), "handleMouseLeaveOnlyAddon", function () {
|
|
59
|
-
_this.setState({
|
|
60
|
-
visibleHint: false
|
|
61
|
-
});
|
|
50
|
+
ariaLabelledByContent: ''
|
|
62
51
|
});
|
|
63
52
|
return _this;
|
|
64
53
|
}
|
|
@@ -79,68 +68,80 @@ var RootLink = /*#__PURE__*/function (_Component) {
|
|
|
79
68
|
}
|
|
80
69
|
}
|
|
81
70
|
}, {
|
|
82
|
-
key: "
|
|
83
|
-
value: function
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return
|
|
91
|
-
tag: AddonLeft
|
|
92
|
-
}) : null, addonTextChildren(Children, Link.Text, Link.Addon), AddonRight ? /*#__PURE__*/React.createElement(Link.Addon, {
|
|
93
|
-
tag: AddonRight
|
|
94
|
-
}) : null);
|
|
71
|
+
key: "renderLink",
|
|
72
|
+
value: function renderLink(_ref10) {
|
|
73
|
+
var _ref = this.asProps,
|
|
74
|
+
_ref5;
|
|
75
|
+
var linkProps = _ref10.linkProps,
|
|
76
|
+
children = _ref10.children;
|
|
77
|
+
var styles = this.asProps.styles;
|
|
78
|
+
var SLink = Text;
|
|
79
|
+
return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(SLink, _ref5.cn("SLink", _objectSpread({}, _assignProps(_objectSpread({}, linkProps), _ref))), children);
|
|
95
80
|
}
|
|
96
81
|
}, {
|
|
97
|
-
key: "
|
|
98
|
-
value: function
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
var visibleHint = this.state.visibleHint;
|
|
108
|
-
var hintContent = (_ref9 = (_ref10 = title !== null && title !== void 0 ? title : ariaLabel) !== null && _ref10 !== void 0 ? _ref10 : this.state.ariaLabelledByContent) !== null && _ref9 !== void 0 ? _ref9 : '';
|
|
109
|
-
return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(Link.Addon, {
|
|
110
|
-
tag: Hint,
|
|
111
|
-
title: hintContent,
|
|
112
|
-
timeout: [250, 50],
|
|
113
|
-
visible: keyboardFocused || visibleHint
|
|
114
|
-
}, AddonLeft && /*#__PURE__*/React.createElement(AddonLeft, _ref5.cn("AddonLeft", {})), AddonRight && /*#__PURE__*/React.createElement(AddonRight, _ref5.cn("AddonRight", {})));
|
|
82
|
+
key: "renderLinkWithHint",
|
|
83
|
+
value: function renderLinkWithHint(_ref11) {
|
|
84
|
+
var _ref2 = this.asProps,
|
|
85
|
+
_ref6;
|
|
86
|
+
var linkProps = _ref11.linkProps,
|
|
87
|
+
children = _ref11.children,
|
|
88
|
+
hintProps = _ref11.hintProps;
|
|
89
|
+
var styles = this.asProps.styles;
|
|
90
|
+
var SLink = Hint;
|
|
91
|
+
return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(SLink, _ref6.cn("SLink", _objectSpread({}, _assignProps2(_objectSpread(_objectSpread({}, linkProps), hintProps), _ref2))), children);
|
|
115
92
|
}
|
|
116
93
|
}, {
|
|
117
94
|
key: "render",
|
|
118
95
|
value: function render() {
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
96
|
+
var _ref7, _ref12, _ref13;
|
|
97
|
+
var _this$asProps = this.asProps,
|
|
98
|
+
styles = _this$asProps.styles,
|
|
99
|
+
noWrap = _this$asProps.noWrap,
|
|
100
|
+
color = _this$asProps.color,
|
|
101
|
+
resolveColor = _this$asProps.resolveColor,
|
|
102
|
+
disabled = _this$asProps.disabled,
|
|
103
|
+
href = _this$asProps.href,
|
|
104
|
+
hasChildren = _this$asProps.children,
|
|
105
|
+
AddonLeft = _this$asProps.addonLeft,
|
|
106
|
+
AddonRight = _this$asProps.addonRight,
|
|
107
|
+
Children = _this$asProps.Children,
|
|
108
|
+
title = _this$asProps.title,
|
|
109
|
+
ariaLabel = _this$asProps['aria-label'],
|
|
110
|
+
hintPlacement = _this$asProps.hintPlacement;
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
var Link = this[CORE_INSTANCE];
|
|
113
|
+
var children = (_ref7 = sstyled(styles), /*#__PURE__*/React.createElement(React.Fragment, null, AddonLeft ? /*#__PURE__*/React.createElement(Link.Addon, null, /*#__PURE__*/React.createElement(AddonLeft, _ref7.cn("AddonLeft", {}))) : null, addonTextChildren(Children, Link.Text, Link.Addon), AddonRight ? /*#__PURE__*/React.createElement(Link.Addon, null, /*#__PURE__*/React.createElement(AddonRight, _ref7.cn("AddonRight", {}))) : null));
|
|
114
|
+
var hintContent = (_ref12 = (_ref13 = title !== null && title !== void 0 ? title : ariaLabel) !== null && _ref13 !== void 0 ? _ref13 : this.state.ariaLabelledByContent) !== null && _ref12 !== void 0 ? _ref12 : '';
|
|
115
|
+
var linkProps = {
|
|
116
|
+
role: 'link',
|
|
117
|
+
tabIndex: disabled ? -1 : 0,
|
|
118
|
+
'use:href': disabled ? undefined : href,
|
|
119
|
+
'visually-disabled': disabled,
|
|
120
|
+
render: Text,
|
|
121
|
+
'text-color': resolveColor(color),
|
|
122
|
+
tag: 'a',
|
|
123
|
+
noWrapText: noWrap,
|
|
124
|
+
'use:noWrap': false,
|
|
125
|
+
ref: this.containerRef,
|
|
126
|
+
__excludeProps: ['disabled', 'aria-disabled']
|
|
127
|
+
};
|
|
128
|
+
var hintProps = {
|
|
129
|
+
title: hintContent,
|
|
130
|
+
timeout: [250, 50],
|
|
131
|
+
placement: hintPlacement,
|
|
132
|
+
__excludeProps: []
|
|
133
|
+
};
|
|
134
|
+
if (hasChildren === undefined || title) {
|
|
135
|
+
return this.renderLinkWithHint({
|
|
136
|
+
linkProps: linkProps,
|
|
137
|
+
hintProps: hintProps,
|
|
138
|
+
children: children
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return this.renderLink({
|
|
142
|
+
linkProps: linkProps,
|
|
143
|
+
children: children
|
|
144
|
+
});
|
|
144
145
|
}
|
|
145
146
|
}]);
|
|
146
147
|
return RootLink;
|
|
@@ -152,22 +153,22 @@ _defineProperty(RootLink, "defaultProps", {
|
|
|
152
153
|
_defineProperty(RootLink, "style", style);
|
|
153
154
|
_defineProperty(RootLink, "enhance", [keyboardFocusEnhance(), resolveColorEnhance()]);
|
|
154
155
|
function LinkText(props) {
|
|
155
|
-
var
|
|
156
|
-
|
|
156
|
+
var _ref3 = arguments[0],
|
|
157
|
+
_ref8;
|
|
157
158
|
var SText = Box;
|
|
158
159
|
var styles = props.styles;
|
|
159
|
-
return
|
|
160
|
+
return _ref8 = sstyled(styles), /*#__PURE__*/React.createElement(SText, _ref8.cn("SText", _objectSpread({}, _assignProps3({
|
|
160
161
|
"tag": 'span'
|
|
161
|
-
},
|
|
162
|
+
}, _ref3))));
|
|
162
163
|
}
|
|
163
164
|
function Addon(props) {
|
|
164
|
-
var
|
|
165
|
-
|
|
165
|
+
var _ref4 = arguments[0],
|
|
166
|
+
_ref9;
|
|
166
167
|
var SAddon = Box;
|
|
167
168
|
var styles = props.styles;
|
|
168
|
-
return
|
|
169
|
+
return _ref9 = sstyled(styles), /*#__PURE__*/React.createElement(SAddon, _ref9.cn("SAddon", _objectSpread({}, _assignProps4({
|
|
169
170
|
"tag": 'span'
|
|
170
|
-
},
|
|
171
|
+
}, _ref4))));
|
|
171
172
|
}
|
|
172
173
|
var Link = createComponent(RootLink, {
|
|
173
174
|
Text: LinkText,
|
package/lib/es6/Link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","names":["React","createComponent","Component","Root","sstyled","Text","Box","Hint","keyboardFocusEnhance","addonTextChildren","logger","hasLabels","resolveColorEnhance","style","_sstyled","insert","RootLink","_Component","_inherits","_super","_createSuper","_this","_classCallCheck","_len","arguments","length","args","Array","_key","call","apply","concat","_defineProperty","_assertThisInitialized","createRef","ariaLabelledByContent","visibleHint","setState","_createClass","key","value","componentDidMount","_this2","process","env","NODE_ENV","warn","containerRef","current","asProps","displayName","setTimeout","_document$getElementB","_document$getElementB2","document","getElementById","textContent","renderChildren","_ref4","_this$asProps","Children","styles","AddonLeft","addonLeft","AddonRight","addonRight","createElement","Fragment","Link","Addon","tag","renderOnlyAddons","_ref5","_ref9","_ref10","_this$asProps2","title","ariaLabel","keyboardFocused","state","hintContent","timeout","visible","cn","render","_ref","_ref6","SLink","_this$asProps3","noWrap","color","resolveColor","disabled","href","hasChildren","children","_objectSpread","_assignProps","undefined","handleMouseEnterOnlyAddon","handleMouseLeaveOnlyAddon","LinkText","props","_ref2","arguments[0]","_ref7","SText","_assignProps2","_ref3","_ref8","SAddon","_assignProps3"],"sources":["../../src/Link.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, Root, sstyled } from '@semcore/core';\nimport { Text } from '@semcore/typography';\nimport { Box } from '@semcore/flex-box';\nimport { Hint } from '@semcore/tooltip';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\nimport logger from '@semcore/utils/lib/logger';\nimport hasLabels from '@semcore/utils/lib/hasLabels';\nimport resolveColorEnhance from '@semcore/utils/lib/enhances/resolveColorEnhance';\n\nimport style from './style/link.shadow.css';\n\nclass RootLink extends Component {\n static displayName = 'Link';\n static defaultProps = {\n noWrap: true,\n };\n static style = style;\n static enhance = [keyboardFocusEnhance(), resolveColorEnhance()];\n containerRef = React.createRef();\n\n state = {\n ariaLabelledByContent: '',\n visibleHint: false,\n };\n\n componentDidMount() {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n this.containerRef.current && !hasLabels(this.containerRef.current),\n `'title' or 'aria-label' or 'aria-labelledby' are required props for links without text content`,\n this.asProps['data-ui-name'] || RootLink.displayName,\n );\n }\n\n if (this.asProps['aria-labelledby']) {\n setTimeout(() => {\n this.setState({\n ariaLabelledByContent:\n document.getElementById(this.asProps['aria-labelledby'])?.textContent ?? '',\n });\n }, 0);\n }\n }\n\n handleMouseEnterOnlyAddon = () => {\n this.setState({ visibleHint: true });\n };\n handleMouseLeaveOnlyAddon = () => {\n this.setState({ visibleHint: false });\n };\n\n renderChildren() {\n const { Children, styles, addonLeft: AddonLeft, addonRight: AddonRight } = this.asProps;\n\n return sstyled(styles)(\n <>\n {AddonLeft ? <Link.Addon tag={AddonLeft} /> : null}\n {addonTextChildren(Children, Link.Text, Link.Addon)}\n {AddonRight ? <Link.Addon tag={AddonRight} /> : null}\n </>,\n );\n }\n\n renderOnlyAddons() {\n const {\n styles,\n addonLeft: AddonLeft,\n addonRight: AddonRight,\n title,\n ['aria-label']: ariaLabel,\n keyboardFocused,\n } = this.asProps;\n const { visibleHint } = this.state;\n\n const hintContent = title ?? ariaLabel ?? this.state.ariaLabelledByContent ?? '';\n\n return sstyled(styles)(\n <Link.Addon\n tag={Hint}\n title={hintContent}\n timeout={[250, 50]}\n visible={keyboardFocused || visibleHint}\n >\n {AddonLeft && <AddonLeft />}\n {AddonRight && <AddonRight />}\n </Link.Addon>,\n );\n }\n\n render() {\n const SLink = Root;\n const {\n styles,\n noWrap,\n color,\n resolveColor,\n disabled,\n href,\n children: hasChildren,\n } = this.asProps;\n\n return sstyled(styles)(\n <SLink\n role='link'\n tabIndex={disabled ? -1 : 0}\n use:href={disabled ? undefined : href}\n visually-disabled={disabled}\n render={Text}\n text-color={resolveColor(color)}\n tag='a'\n noWrapText={noWrap}\n use:noWrap={false}\n ref={this.containerRef}\n __excludeProps={['disabled', 'aria-disabled']}\n onMouseEnter={this.handleMouseEnterOnlyAddon}\n onMouseLeave={this.handleMouseLeaveOnlyAddon}\n >\n {hasChildren !== undefined ? this.renderChildren() : this.renderOnlyAddons()}\n </SLink>,\n );\n }\n}\n\nfunction LinkText(props) {\n const SText = Root;\n const { styles } = props;\n return sstyled(styles)(<SText render={Box} tag='span' />);\n}\n\nfunction Addon(props) {\n const SAddon = Root;\n const { styles } = props;\n return sstyled(styles)(<SAddon render={Box} tag='span' />);\n}\n\nconst Link = createComponent(RootLink, {\n Text: LinkText,\n Addon,\n});\n\nexport default Link;\n"],"mappings":";;;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAA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,KAAA,IAAG;AAC3D;AAEA,IAAMxC,IAAI,GAAGnE,eAAe,CAACe,QAAQ,EAAE;EACrCX,IAAI,EAAEgG,QAAQ;EACdhC,KAAK,EAALA;AACF,CAAC,CAAC;AAEF,eAAeD,IAAI"}
|
|
1
|
+
{"version":3,"file":"Link.js","names":["React","createComponent","Component","Root","sstyled","CORE_INSTANCE","Text","Box","Hint","keyboardFocusEnhance","addonTextChildren","logger","hasLabels","resolveColorEnhance","style","_sstyled","insert","RootLink","_Component","_inherits","_super","_createSuper","_this","_classCallCheck","_len","arguments","length","args","Array","_key","call","apply","concat","_defineProperty","_assertThisInitialized","createRef","ariaLabelledByContent","_createClass","key","value","componentDidMount","_this2","process","env","NODE_ENV","warn","containerRef","current","asProps","displayName","setTimeout","_document$getElementB","_document$getElementB2","setState","document","getElementById","textContent","renderLink","_ref10","_ref","_ref5","linkProps","children","styles","SLink","createElement","cn","_objectSpread","_assignProps","renderLinkWithHint","_ref11","_ref2","_ref6","hintProps","_assignProps2","render","_ref7","_ref12","_ref13","_this$asProps","noWrap","color","resolveColor","disabled","href","hasChildren","AddonLeft","addonLeft","AddonRight","addonRight","Children","title","ariaLabel","hintPlacement","Link","Fragment","Addon","hintContent","state","role","tabIndex","undefined","tag","noWrapText","ref","__excludeProps","timeout","placement","LinkText","props","_ref3","arguments[0]","_ref8","SText","_assignProps3","_ref4","_ref9","SAddon","_assignProps4"],"sources":["../../src/Link.jsx"],"sourcesContent":["import React from 'react';\nimport { createComponent, Component, Root, sstyled, CORE_INSTANCE } from '@semcore/core';\nimport { Text } from '@semcore/typography';\nimport { Box } from '@semcore/flex-box';\nimport { Hint } from '@semcore/tooltip';\nimport keyboardFocusEnhance from '@semcore/core/lib/utils/enhances/keyboardFocusEnhance';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport logger from '@semcore/core/lib/utils/logger';\nimport hasLabels from '@semcore/core/lib/utils/hasLabels';\nimport resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';\n\nimport style from './style/link.shadow.css';\n\nclass RootLink extends Component {\n static displayName = 'Link';\n static defaultProps = {\n noWrap: true,\n };\n static style = style;\n static enhance = [keyboardFocusEnhance(), resolveColorEnhance()];\n containerRef = React.createRef();\n\n state = {\n ariaLabelledByContent: '',\n };\n\n componentDidMount() {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n this.containerRef.current && !hasLabels(this.containerRef.current),\n `'title' or 'aria-label' or 'aria-labelledby' are required props for links without text content`,\n this.asProps['data-ui-name'] || RootLink.displayName,\n );\n }\n\n if (this.asProps['aria-labelledby']) {\n setTimeout(() => {\n this.setState({\n ariaLabelledByContent:\n document.getElementById(this.asProps['aria-labelledby'])?.textContent ?? '',\n });\n }, 0);\n }\n }\n\n renderLink({ linkProps, children }) {\n const { styles } = this.asProps;\n const SLink = Root;\n\n return sstyled(styles)(\n <SLink render={Text} {...linkProps}>\n {children}\n </SLink>,\n );\n }\n\n renderLinkWithHint({ linkProps, children, hintProps }) {\n const { styles } = this.asProps;\n const SLink = Root;\n\n return sstyled(styles)(\n <SLink render={Hint} {...linkProps} {...hintProps}>\n {children}\n </SLink>,\n );\n }\n\n render() {\n const {\n styles,\n noWrap,\n color,\n resolveColor,\n disabled,\n href,\n children: hasChildren,\n addonLeft: AddonLeft,\n addonRight: AddonRight,\n Children,\n title,\n ['aria-label']: ariaLabel,\n hintPlacement,\n } = this.asProps;\n // @ts-ignore\n const Link = this[CORE_INSTANCE];\n\n const children = sstyled(styles)(\n <>\n {AddonLeft ? (\n <Link.Addon>\n <AddonLeft />\n </Link.Addon>\n ) : null}\n {addonTextChildren(Children, Link.Text, Link.Addon)}\n {AddonRight ? (\n <Link.Addon>\n <AddonRight />\n </Link.Addon>\n ) : null}\n </>,\n );\n\n const hintContent = title ?? ariaLabel ?? this.state.ariaLabelledByContent ?? '';\n\n const linkProps = {\n role: 'link',\n tabIndex: disabled ? -1 : 0,\n 'use:href': disabled ? undefined : href,\n 'visually-disabled': disabled,\n render: Text,\n 'text-color': resolveColor(color),\n tag: 'a',\n noWrapText: noWrap,\n 'use:noWrap': false,\n ref: this.containerRef,\n __excludeProps: ['disabled', 'aria-disabled'],\n };\n\n const hintProps = {\n title: hintContent,\n timeout: [250, 50],\n placement: hintPlacement,\n __excludeProps: [],\n };\n\n if (hasChildren === undefined || title) {\n return this.renderLinkWithHint({ linkProps, hintProps, children });\n }\n\n return this.renderLink({ linkProps, children });\n }\n}\n\nfunction LinkText(props) {\n const SText = Root;\n const { styles } = props;\n return sstyled(styles)(<SText render={Box} tag='span' />);\n}\n\nfunction Addon(props) {\n const SAddon = Root;\n const { styles } = props;\n return sstyled(styles)(<SAddon render={Box} tag='span' />);\n}\n\nconst Link = createComponent(RootLink, {\n Text: LinkText,\n Addon,\n});\n\nexport default Link;\n"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,eAAe,EAAEC,SAAS,EAAEC,IAAI,EAAEC,OAAO,EAAEC,aAAa,QAAQ,eAAe;AACxF,SAASC,IAAI,QAAQ,qBAAqB;AAC1C,SAASC,GAAG,QAAQ,mBAAmB;AACvC,SAASC,IAAI,QAAQ,kBAAkB;AACvC,OAAOC,oBAAoB,MAAM,uDAAuD;AACxF,OAAOC,iBAAiB,MAAM,2CAA2C;AACzE,OAAOC,MAAM,MAAM,gCAAgC;AACnD,OAAOC,SAAS,MAAM,mCAAmC;AACzD,OAAOC,mBAAmB,MAAM,sDAAsD;AAAC;AAAA,IAAAC,KAAA,+BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA,IAIjFC,QAAQ,0BAAAC,UAAA;EAAAC,SAAA,CAAAF,QAAA,EAAAC,UAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,QAAA;EAAA,SAAAA,SAAA;IAAA,IAAAK,KAAA;IAAAC,eAAA,OAAAN,QA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CALhBhB,QAAQ,aAMK,CAACR,oBAAoB,EAAE,EAAEI,mBAAmB,EAAE,CAAC;AAkHlE,SAAS+F,QAAQA,CAACC,KAAK,EAAE;EAAA,IAAAC,KAAA,GAAAC,YAAA;IAAAC,KAAA;EACvB,IAAMC,KAAK,GAE2B1G,GAAG;EADzC,IAAQwD,MAAM,GAAK8C,KAAK,CAAhB9C,MAAM;EACd,OAAAiD,KAAA,GAAO5G,OAAO,CAAC2D,MAAM,CAAC,eAAC/D,KAAA,CAAAiE,aAAA,CAACgD,KAAK,EAAAD,KAAA,CAAA9C,EAAA,UAAAC,aAAA,KAAA+C,aAAA;IAAA,OAAkB;EAAM,GAAAJ,KAAA,IAAG;AAC1D;AAEA,SAASd,KAAKA,CAACa,KAAK,EAAE;EAAA,IAAAM,KAAA,GAAAJ,YAAA;IAAAK,KAAA;EACpB,IAAMC,MAAM,GAE2B9G,GAAG;EAD1C,IAAQwD,MAAM,GAAK8C,KAAK,CAAhB9C,MAAM;EACd,OAAAqD,KAAA,GAAOhH,OAAO,CAAC2D,MAAM,CAAC,eAAC/D,KAAA,CAAAiE,aAAA,CAACoD,MAAM,EAAAD,KAAA,CAAAlD,EAAA,WAAAC,aAAA,KAAAmD,aAAA;IAAA,OAAkB;EAAM,GAAAH,KAAA,IAAG;AAC3D;AAEA,IAAMrB,IAAI,GAAG7F,eAAe,CAACgB,QAAQ,EAAE;EACrCX,IAAI,EAAEsG,QAAQ;EACdZ,KAAK,EAALA;AACF,CAAC,CAAC;AAEF,eAAeF,IAAI"}
|
package/lib/es6/index.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { Intergalactic, UnknownProperties } from '@semcore/core';\nimport { TextProps } from '@semcore/typography';\nimport { BoxProps } from '@semcore/flex-box';\
|
|
1
|
+
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { Intergalactic, UnknownProperties } from '@semcore/core';\nimport { TextProps } from '@semcore/typography';\nimport { BoxProps } from '@semcore/flex-box';\n\n/** @deprecated */\nexport interface ILinkProps extends LinkProps, UnknownProperties {}\nexport type LinkProps = TextProps & {\n /**\n * CSS property of the display link (inline|inline-block)\n * @default false\n */\n inline?: boolean;\n /**\n * Sets the link to the disabled state\n */\n disabled?: boolean;\n /**\n * Sets the link to the active state\n */\n active?: boolean;\n /** This flag enables highlighting of the visited link\n */\n enableVisited?: boolean;\n /** The text will not be moved to a new line\n * @default true\n */\n noWrap?: boolean;\n /** Left addon tag */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n};\n\ndeclare const Link: Intergalactic.Component<'a', LinkProps> & {\n Text: Intergalactic.Component<'span', TextProps>;\n Addon: Intergalactic.Component<'span', BoxProps>;\n};\n\nexport default Link;\n"],"mappings":""}
|
|
@@ -11,14 +11,11 @@ SLink {
|
|
|
11
11
|
margin: 0;
|
|
12
12
|
box-shadow: none;
|
|
13
13
|
-webkit-tap-highlight-color: transparent;
|
|
14
|
-
outline: 0;
|
|
15
14
|
background: none;
|
|
16
15
|
transition: color 0.15s ease-in-out;
|
|
17
16
|
|
|
18
17
|
&:active,
|
|
19
|
-
&:hover
|
|
20
|
-
&:focus {
|
|
21
|
-
outline: 0;
|
|
18
|
+
&:hover {
|
|
22
19
|
text-decoration: none;
|
|
23
20
|
}
|
|
24
21
|
|
|
@@ -43,12 +40,6 @@ SLink {
|
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
42
|
|
|
46
|
-
SLink[keyboardFocused] {
|
|
47
|
-
outline-color: var(--intergalactic-keyboard-focus-outline, rgba(0, 143, 248, 0.5));
|
|
48
|
-
outline-style: solid;
|
|
49
|
-
outline-width: 3px;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
43
|
SLink[visually-disabled] {
|
|
53
44
|
opacity: var(--intergalactic-disabled-opacity, 0.3);
|
|
54
45
|
cursor: default;
|
package/lib/esm/Link.mjs
CHANGED
|
@@ -5,38 +5,36 @@ import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitial
|
|
|
5
5
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
6
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
-
import { sstyled } from "@semcore/
|
|
9
|
-
import createComponent, { sstyled as sstyled$1, assignProps, Component } from "@semcore/core";
|
|
8
|
+
import { sstyled, createComponent, assignProps, CORE_INSTANCE, Component } from "@semcore/core";
|
|
10
9
|
import React from "react";
|
|
11
10
|
import { Text } from "@semcore/typography";
|
|
12
11
|
import { Box } from "@semcore/flex-box";
|
|
13
12
|
import { Hint } from "@semcore/tooltip";
|
|
14
|
-
import keyboardFocusEnhance from "@semcore/
|
|
15
|
-
import addonTextChildren from "@semcore/
|
|
16
|
-
import logger from "@semcore/
|
|
17
|
-
import hasLabels from "@semcore/
|
|
18
|
-
import resolveColorEnhance from "@semcore/
|
|
13
|
+
import keyboardFocusEnhance from "@semcore/core/lib/utils/enhances/keyboardFocusEnhance";
|
|
14
|
+
import addonTextChildren from "@semcore/core/lib/utils/addonTextChildren";
|
|
15
|
+
import logger from "@semcore/core/lib/utils/logger";
|
|
16
|
+
import hasLabels from "@semcore/core/lib/utils/hasLabels";
|
|
17
|
+
import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
|
|
19
18
|
/*!__reshadow-styles__:"./style/link.shadow.css"*/
|
|
20
19
|
var style = (
|
|
21
20
|
/*__reshadow_css_start__*/
|
|
22
21
|
(sstyled.insert(
|
|
23
22
|
/*__inner_css_start__*/
|
|
24
|
-
".
|
|
23
|
+
".___SLink_ypsez_gg_{display:inline-block;font-family:inherit;color:var(--intergalactic-text-link, #006dca);line-height:normal;position:relative;cursor:pointer;border:0;padding:0;margin:0;box-shadow:none;-webkit-tap-highlight-color:transparent;background:0 0;transition:color .15s ease-in-out}.___SLink_ypsez_gg_,.___SLink_ypsez_gg_:active{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SLink_ypsez_gg_:hover{-webkit-text-decoration:none;text-decoration:none}}.___SLink_ypsez_gg_::-moz-focus-inner{border:0;padding:0}.___SLink_ypsez_gg_.__active_ypsez_gg_,.___SLink_ypsez_gg_:active{color:var(--intergalactic-text-link-hover-active, #044792)}@media (hover:hover){.___SLink_ypsez_gg_:hover{color:var(--intergalactic-text-link-hover-active, #044792)}}.___SLink_ypsez_gg_.__active_ypsez_gg_ .___SText_ypsez_gg_,.___SLink_ypsez_gg_:active .___SText_ypsez_gg_{border-color:currentColor}@media (hover:hover){.___SLink_ypsez_gg_:hover .___SText_ypsez_gg_{border-color:currentColor}}.___SLink_ypsez_gg_.__enableVisited_ypsez_gg_:visited{color:var(--intergalactic-text-link-visited, #8649e1)}@media (hover:hover){.___SLink_ypsez_gg_.__enableVisited_ypsez_gg_:visited:hover{color:var(--intergalactic-text-link-visited, #8649e1)}}.___SLink_ypsez_gg_.__visually-disabled_ypsez_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}.___SLink_ypsez_gg_.__noWrapText_ypsez_gg_{white-space:nowrap}.___SLink_ypsez_gg_.__inline_ypsez_gg_{display:inline}.___SAddon_ypsez_gg_{display:inline-flex;justify-content:center;align-items:center;margin-bottom:var(--intergalactic-spacing-05x, 2px);vertical-align:middle;pointer-events:none}.___SLink_ypsez_gg_ .___SAddon_ypsez_gg_:not(:only-child):first-child{margin-right:var(--intergalactic-spacing-1x, 4px)}.___SLink_ypsez_gg_ .___SAddon_ypsez_gg_:not(:only-child):last-child{margin-left:var(--intergalactic-spacing-1x, 4px)}.___SText_ypsez_gg_{border-bottom-width:1px;border-bottom-style:solid;border-color:transparent;transition:border-bottom-color .15s ease-in-out}.___SLink_ypsez_gg_.__text-color_ypsez_gg_{color:var(--text-color_ypsez)}.___SLink_ypsez_gg_.__text-color_ypsez_gg_.__active_ypsez_gg_,.___SLink_ypsez_gg_.__text-color_ypsez_gg_:active{color:var(--text-color_ypsez);filter:brightness(.8)}@media (hover:hover){.___SLink_ypsez_gg_.__text-color_ypsez_gg_:hover{color:var(--text-color_ypsez);filter:brightness(.8)}}@media (prefers-reduced-motion){.___SLink_ypsez_gg_,.___SText_ypsez_gg_{transition:none}}",
|
|
25
24
|
/*__inner_css_end__*/
|
|
26
|
-
"
|
|
25
|
+
"ypsez_gg_"
|
|
27
26
|
), /*__reshadow_css_end__*/
|
|
28
27
|
{
|
|
29
|
-
"__SLink": "
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"--text-color": "--text-color_1slzv"
|
|
28
|
+
"__SLink": "___SLink_ypsez_gg_",
|
|
29
|
+
"_visually-disabled": "__visually-disabled_ypsez_gg_",
|
|
30
|
+
"_noWrapText": "__noWrapText_ypsez_gg_",
|
|
31
|
+
"_inline": "__inline_ypsez_gg_",
|
|
32
|
+
"__SAddon": "___SAddon_ypsez_gg_",
|
|
33
|
+
"__SText": "___SText_ypsez_gg_",
|
|
34
|
+
"_active": "__active_ypsez_gg_",
|
|
35
|
+
"_enableVisited": "__enableVisited_ypsez_gg_",
|
|
36
|
+
"_text-color": "__text-color_ypsez_gg_",
|
|
37
|
+
"--text-color": "--text-color_ypsez"
|
|
40
38
|
})
|
|
41
39
|
);
|
|
42
40
|
var RootLink = /* @__PURE__ */ function(_Component) {
|
|
@@ -51,18 +49,7 @@ var RootLink = /* @__PURE__ */ function(_Component) {
|
|
|
51
49
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
52
50
|
_defineProperty(_assertThisInitialized(_this), "containerRef", /* @__PURE__ */ React.createRef());
|
|
53
51
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
54
|
-
ariaLabelledByContent: ""
|
|
55
|
-
visibleHint: false
|
|
56
|
-
});
|
|
57
|
-
_defineProperty(_assertThisInitialized(_this), "handleMouseEnterOnlyAddon", function() {
|
|
58
|
-
_this.setState({
|
|
59
|
-
visibleHint: true
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
_defineProperty(_assertThisInitialized(_this), "handleMouseLeaveOnlyAddon", function() {
|
|
63
|
-
_this.setState({
|
|
64
|
-
visibleHint: false
|
|
65
|
-
});
|
|
52
|
+
ariaLabelledByContent: ""
|
|
66
53
|
});
|
|
67
54
|
return _this;
|
|
68
55
|
}
|
|
@@ -83,49 +70,61 @@ var RootLink = /* @__PURE__ */ function(_Component) {
|
|
|
83
70
|
}
|
|
84
71
|
}
|
|
85
72
|
}, {
|
|
86
|
-
key: "
|
|
87
|
-
value: function
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}) : null);
|
|
73
|
+
key: "renderLink",
|
|
74
|
+
value: function renderLink(_ref10) {
|
|
75
|
+
var _ref = this.asProps, _ref5;
|
|
76
|
+
var linkProps = _ref10.linkProps, children = _ref10.children;
|
|
77
|
+
var styles = this.asProps.styles;
|
|
78
|
+
var SLink = Text;
|
|
79
|
+
return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(SLink, _ref5.cn("SLink", _objectSpread({}, assignProps(_objectSpread({}, linkProps), _ref))), children);
|
|
94
80
|
}
|
|
95
81
|
}, {
|
|
96
|
-
key: "
|
|
97
|
-
value: function
|
|
98
|
-
var
|
|
99
|
-
var
|
|
100
|
-
var
|
|
101
|
-
var
|
|
102
|
-
return
|
|
103
|
-
tag: Hint,
|
|
104
|
-
title: hintContent,
|
|
105
|
-
timeout: [250, 50],
|
|
106
|
-
visible: keyboardFocused || visibleHint
|
|
107
|
-
}, AddonLeft && /* @__PURE__ */ React.createElement(AddonLeft, _ref5.cn("AddonLeft", {})), AddonRight && /* @__PURE__ */ React.createElement(AddonRight, _ref5.cn("AddonRight", {})));
|
|
82
|
+
key: "renderLinkWithHint",
|
|
83
|
+
value: function renderLinkWithHint(_ref11) {
|
|
84
|
+
var _ref2 = this.asProps, _ref6;
|
|
85
|
+
var linkProps = _ref11.linkProps, children = _ref11.children, hintProps = _ref11.hintProps;
|
|
86
|
+
var styles = this.asProps.styles;
|
|
87
|
+
var SLink = Hint;
|
|
88
|
+
return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SLink, _ref6.cn("SLink", _objectSpread({}, assignProps(_objectSpread(_objectSpread({}, linkProps), hintProps), _ref2))), children);
|
|
108
89
|
}
|
|
109
90
|
}, {
|
|
110
91
|
key: "render",
|
|
111
92
|
value: function render() {
|
|
112
|
-
var
|
|
113
|
-
var
|
|
114
|
-
var
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
93
|
+
var _ref7, _ref12, _ref13;
|
|
94
|
+
var _this$asProps = this.asProps, styles = _this$asProps.styles, noWrap = _this$asProps.noWrap, color = _this$asProps.color, resolveColor = _this$asProps.resolveColor, disabled = _this$asProps.disabled, href = _this$asProps.href, hasChildren = _this$asProps.children, AddonLeft = _this$asProps.addonLeft, AddonRight = _this$asProps.addonRight, Children = _this$asProps.Children, title = _this$asProps.title, ariaLabel = _this$asProps["aria-label"], hintPlacement = _this$asProps.hintPlacement;
|
|
95
|
+
var Link2 = this[CORE_INSTANCE];
|
|
96
|
+
var children = (_ref7 = sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, AddonLeft ? /* @__PURE__ */ React.createElement(Link2.Addon, null, /* @__PURE__ */ React.createElement(AddonLeft, _ref7.cn("AddonLeft", {}))) : null, addonTextChildren(Children, Link2.Text, Link2.Addon), AddonRight ? /* @__PURE__ */ React.createElement(Link2.Addon, null, /* @__PURE__ */ React.createElement(AddonRight, _ref7.cn("AddonRight", {}))) : null));
|
|
97
|
+
var hintContent = (_ref12 = (_ref13 = title !== null && title !== void 0 ? title : ariaLabel) !== null && _ref13 !== void 0 ? _ref13 : this.state.ariaLabelledByContent) !== null && _ref12 !== void 0 ? _ref12 : "";
|
|
98
|
+
var linkProps = {
|
|
99
|
+
role: "link",
|
|
100
|
+
tabIndex: disabled ? -1 : 0,
|
|
118
101
|
"use:href": disabled ? void 0 : href,
|
|
119
102
|
"visually-disabled": disabled,
|
|
103
|
+
render: Text,
|
|
120
104
|
"text-color": resolveColor(color),
|
|
121
|
-
|
|
122
|
-
|
|
105
|
+
tag: "a",
|
|
106
|
+
noWrapText: noWrap,
|
|
123
107
|
"use:noWrap": false,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
108
|
+
ref: this.containerRef,
|
|
109
|
+
__excludeProps: ["disabled", "aria-disabled"]
|
|
110
|
+
};
|
|
111
|
+
var hintProps = {
|
|
112
|
+
title: hintContent,
|
|
113
|
+
timeout: [250, 50],
|
|
114
|
+
placement: hintPlacement,
|
|
115
|
+
__excludeProps: []
|
|
116
|
+
};
|
|
117
|
+
if (hasChildren === void 0 || title) {
|
|
118
|
+
return this.renderLinkWithHint({
|
|
119
|
+
linkProps,
|
|
120
|
+
hintProps,
|
|
121
|
+
children
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return this.renderLink({
|
|
125
|
+
linkProps,
|
|
126
|
+
children
|
|
127
|
+
});
|
|
129
128
|
}
|
|
130
129
|
}]);
|
|
131
130
|
return RootLink2;
|
|
@@ -137,20 +136,20 @@ _defineProperty(RootLink, "defaultProps", {
|
|
|
137
136
|
_defineProperty(RootLink, "style", style);
|
|
138
137
|
_defineProperty(RootLink, "enhance", [keyboardFocusEnhance(), resolveColorEnhance()]);
|
|
139
138
|
function LinkText(props) {
|
|
140
|
-
var
|
|
139
|
+
var _ref3 = arguments[0], _ref8;
|
|
141
140
|
var SText = Box;
|
|
142
141
|
var styles = props.styles;
|
|
143
|
-
return
|
|
142
|
+
return _ref8 = sstyled(styles), /* @__PURE__ */ React.createElement(SText, _ref8.cn("SText", _objectSpread({}, assignProps({
|
|
144
143
|
"tag": "span"
|
|
145
|
-
},
|
|
144
|
+
}, _ref3))));
|
|
146
145
|
}
|
|
147
146
|
function Addon(props) {
|
|
148
|
-
var
|
|
147
|
+
var _ref4 = arguments[0], _ref9;
|
|
149
148
|
var SAddon = Box;
|
|
150
149
|
var styles = props.styles;
|
|
151
|
-
return
|
|
150
|
+
return _ref9 = sstyled(styles), /* @__PURE__ */ React.createElement(SAddon, _ref9.cn("SAddon", _objectSpread({}, assignProps({
|
|
152
151
|
"tag": "span"
|
|
153
|
-
},
|
|
152
|
+
}, _ref4))));
|
|
154
153
|
}
|
|
155
154
|
var Link = createComponent(RootLink, {
|
|
156
155
|
Text: LinkText,
|
|
@@ -11,14 +11,11 @@ SLink {
|
|
|
11
11
|
margin: 0;
|
|
12
12
|
box-shadow: none;
|
|
13
13
|
-webkit-tap-highlight-color: transparent;
|
|
14
|
-
outline: 0;
|
|
15
14
|
background: none;
|
|
16
15
|
transition: color 0.15s ease-in-out;
|
|
17
16
|
|
|
18
17
|
&:active,
|
|
19
|
-
&:hover
|
|
20
|
-
&:focus {
|
|
21
|
-
outline: 0;
|
|
18
|
+
&:hover {
|
|
22
19
|
text-decoration: none;
|
|
23
20
|
}
|
|
24
21
|
|
|
@@ -43,12 +40,6 @@ SLink {
|
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
42
|
|
|
46
|
-
SLink[keyboardFocused] {
|
|
47
|
-
outline-color: var(--intergalactic-keyboard-focus-outline, rgba(0, 143, 248, 0.5));
|
|
48
|
-
outline-style: solid;
|
|
49
|
-
outline-width: 3px;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
43
|
SLink[visually-disabled] {
|
|
53
44
|
opacity: var(--intergalactic-disabled-opacity, 0.3);
|
|
54
45
|
cursor: default;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2,37 +2,35 @@ import React from 'react';
|
|
|
2
2
|
import { Intergalactic, UnknownProperties } from '@semcore/core';
|
|
3
3
|
import { TextProps } from '@semcore/typography';
|
|
4
4
|
import { BoxProps } from '@semcore/flex-box';
|
|
5
|
-
import { KeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
|
|
6
5
|
|
|
7
6
|
/** @deprecated */
|
|
8
7
|
export interface ILinkProps extends LinkProps, UnknownProperties {}
|
|
9
|
-
export type LinkProps = TextProps &
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
8
|
+
export type LinkProps = TextProps & {
|
|
9
|
+
/**
|
|
10
|
+
* CSS property of the display link (inline|inline-block)
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
inline?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Sets the link to the disabled state
|
|
16
|
+
*/
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Sets the link to the active state
|
|
20
|
+
*/
|
|
21
|
+
active?: boolean;
|
|
22
|
+
/** This flag enables highlighting of the visited link
|
|
23
|
+
*/
|
|
24
|
+
enableVisited?: boolean;
|
|
25
|
+
/** The text will not be moved to a new line
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
noWrap?: boolean;
|
|
29
|
+
/** Left addon tag */
|
|
30
|
+
addonLeft?: React.ElementType;
|
|
31
|
+
/** Right addon tag */
|
|
32
|
+
addonRight?: React.ElementType;
|
|
33
|
+
};
|
|
36
34
|
|
|
37
35
|
declare const Link: Intergalactic.Component<'a', LinkProps> & {
|
|
38
36
|
Text: Intergalactic.Component<'span', TextProps>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/link",
|
|
3
3
|
"description": "Semrush Link Component",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "16.0.0-prerelease.0",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,15 +14,12 @@
|
|
|
14
14
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/
|
|
18
|
-
"@semcore/
|
|
19
|
-
"@semcore/flex-box": "
|
|
20
|
-
"@semcore/tooltip": "6.49.4-prerelease.0"
|
|
17
|
+
"@semcore/typography": "16.0.0-prerelease.0",
|
|
18
|
+
"@semcore/tooltip": "16.0.0-prerelease.0",
|
|
19
|
+
"@semcore/flex-box": "16.0.0-prerelease.0"
|
|
21
20
|
},
|
|
22
21
|
"peerDependencies": {
|
|
23
|
-
"@semcore/
|
|
24
|
-
"react": "16.8 - 18",
|
|
25
|
-
"react-dom": "16.8 - 18"
|
|
22
|
+
"@semcore/base-components": "^16.0.0-prerelease.0"
|
|
26
23
|
},
|
|
27
24
|
"repository": {
|
|
28
25
|
"type": "git",
|