@semcore/link 16.0.0-prerelease.4 → 16.0.0-prerelease.7
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/lib/esm/Link.mjs +124 -102
- package/lib/esm/index.mjs +2 -2
- package/package.json +5 -5
package/lib/esm/Link.mjs
CHANGED
|
@@ -1,134 +1,156 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { sstyled
|
|
9
|
-
import
|
|
10
|
-
import { Text
|
|
11
|
-
import { Box
|
|
12
|
-
import { Hint
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
var
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
+
import { sstyled, createComponent, assignProps, Component } from "@semcore/core";
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { Text } from "@semcore/typography";
|
|
11
|
+
import { Box } from "@semcore/flex-box";
|
|
12
|
+
import { Hint } from "@semcore/tooltip";
|
|
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";
|
|
18
|
+
var style = (
|
|
19
19
|
/*__reshadow_css_start__*/
|
|
20
|
-
(
|
|
20
|
+
(sstyled.insert(
|
|
21
21
|
/*__inner_css_start__*/
|
|
22
22
|
".___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}}",
|
|
23
23
|
"ypsez_gg_"
|
|
24
24
|
), {
|
|
25
|
-
__SLink: "___SLink_ypsez_gg_",
|
|
25
|
+
"__SLink": "___SLink_ypsez_gg_",
|
|
26
26
|
"_visually-disabled": "__visually-disabled_ypsez_gg_",
|
|
27
|
-
_noWrapText: "__noWrapText_ypsez_gg_",
|
|
28
|
-
_inline: "__inline_ypsez_gg_",
|
|
29
|
-
__SAddon: "___SAddon_ypsez_gg_",
|
|
30
|
-
__SText: "___SText_ypsez_gg_",
|
|
31
|
-
_active: "__active_ypsez_gg_",
|
|
32
|
-
_enableVisited: "__enableVisited_ypsez_gg_",
|
|
27
|
+
"_noWrapText": "__noWrapText_ypsez_gg_",
|
|
28
|
+
"_inline": "__inline_ypsez_gg_",
|
|
29
|
+
"__SAddon": "___SAddon_ypsez_gg_",
|
|
30
|
+
"__SText": "___SText_ypsez_gg_",
|
|
31
|
+
"_active": "__active_ypsez_gg_",
|
|
32
|
+
"_enableVisited": "__enableVisited_ypsez_gg_",
|
|
33
33
|
"_text-color": "__text-color_ypsez_gg_",
|
|
34
34
|
"--text-color": "--text-color_ypsez"
|
|
35
35
|
})
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
);
|
|
37
|
+
var RootLink = /* @__PURE__ */ function(_Component) {
|
|
38
|
+
_inherits(RootLink2, _Component);
|
|
39
|
+
var _super = _createSuper(RootLink2);
|
|
40
|
+
function RootLink2() {
|
|
41
|
+
var _this;
|
|
42
|
+
_classCallCheck(this, RootLink2);
|
|
43
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
44
|
+
args[_key] = arguments[_key];
|
|
45
|
+
}
|
|
46
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "containerRef", /* @__PURE__ */ React.createRef());
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
45
49
|
ariaLabelledByContent: "",
|
|
46
|
-
visibleHint:
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
visibleHint: false
|
|
51
|
+
});
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "handleMouseEnterOnlyAddon", function() {
|
|
53
|
+
_this.setState({
|
|
54
|
+
visibleHint: true
|
|
50
55
|
});
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
});
|
|
57
|
+
_defineProperty(_assertThisInitialized(_this), "handleMouseLeaveOnlyAddon", function() {
|
|
58
|
+
_this.setState({
|
|
59
|
+
visibleHint: false
|
|
54
60
|
});
|
|
55
|
-
})
|
|
61
|
+
});
|
|
62
|
+
return _this;
|
|
56
63
|
}
|
|
57
|
-
|
|
64
|
+
_createClass(RootLink2, [{
|
|
58
65
|
key: "componentDidMount",
|
|
59
|
-
value: function() {
|
|
60
|
-
var
|
|
61
|
-
process.env.NODE_ENV !== "production"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
value: function componentDidMount() {
|
|
67
|
+
var _this2 = this;
|
|
68
|
+
if (process.env.NODE_ENV !== "production") {
|
|
69
|
+
logger.warn(this.containerRef.current && !hasLabels(this.containerRef.current), "'title' or 'aria-label' or 'aria-labelledby' are required props for links without text content", this.asProps["data-ui-name"] || RootLink2.displayName);
|
|
70
|
+
}
|
|
71
|
+
if (this.asProps["aria-labelledby"]) {
|
|
72
|
+
setTimeout(function() {
|
|
73
|
+
var _document$getElementB, _document$getElementB2;
|
|
74
|
+
_this2.setState({
|
|
75
|
+
ariaLabelledByContent: (_document$getElementB = (_document$getElementB2 = document.getElementById(_this2.asProps["aria-labelledby"])) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.textContent) !== null && _document$getElementB !== void 0 ? _document$getElementB : ""
|
|
76
|
+
});
|
|
77
|
+
}, 0);
|
|
78
|
+
}
|
|
67
79
|
}
|
|
68
80
|
}, {
|
|
69
81
|
key: "renderChildren",
|
|
70
|
-
value: function() {
|
|
71
|
-
var
|
|
72
|
-
return
|
|
73
|
-
tag:
|
|
74
|
-
}) : null,
|
|
75
|
-
tag:
|
|
82
|
+
value: function renderChildren() {
|
|
83
|
+
var _this$asProps = this.asProps, Children = _this$asProps.Children, styles = _this$asProps.styles, AddonLeft = _this$asProps.addonLeft, AddonRight = _this$asProps.addonRight;
|
|
84
|
+
return sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, AddonLeft ? /* @__PURE__ */ React.createElement(Link.Addon, {
|
|
85
|
+
tag: AddonLeft
|
|
86
|
+
}) : null, addonTextChildren(Children, Link.Text, Link.Addon), AddonRight ? /* @__PURE__ */ React.createElement(Link.Addon, {
|
|
87
|
+
tag: AddonRight
|
|
76
88
|
}) : null);
|
|
77
89
|
}
|
|
78
90
|
}, {
|
|
79
91
|
key: "renderOnlyAddons",
|
|
80
|
-
value: function() {
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
value: function renderOnlyAddons() {
|
|
93
|
+
var _ref5, _ref9, _ref10;
|
|
94
|
+
var _this$asProps2 = this.asProps, styles = _this$asProps2.styles, AddonLeft = _this$asProps2.addonLeft, AddonRight = _this$asProps2.addonRight, title = _this$asProps2.title, ariaLabel = _this$asProps2["aria-label"], keyboardFocused = _this$asProps2.keyboardFocused;
|
|
95
|
+
var visibleHint = this.state.visibleHint;
|
|
96
|
+
var hintContent = (_ref9 = (_ref10 = title !== null && title !== void 0 ? title : ariaLabel) !== null && _ref10 !== void 0 ? _ref10 : this.state.ariaLabelledByContent) !== null && _ref9 !== void 0 ? _ref9 : "";
|
|
97
|
+
return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(Link.Addon, {
|
|
98
|
+
tag: Hint,
|
|
99
|
+
title: hintContent,
|
|
85
100
|
timeout: [250, 50],
|
|
86
|
-
visible:
|
|
87
|
-
},
|
|
101
|
+
visible: keyboardFocused || visibleHint
|
|
102
|
+
}, AddonLeft && /* @__PURE__ */ React.createElement(AddonLeft, _ref5.cn("AddonLeft", {})), AddonRight && /* @__PURE__ */ React.createElement(AddonRight, _ref5.cn("AddonRight", {})));
|
|
88
103
|
}
|
|
89
104
|
}, {
|
|
90
105
|
key: "render",
|
|
91
|
-
value: function() {
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
value: function render() {
|
|
107
|
+
var _ref = this.asProps, _ref6;
|
|
108
|
+
var SLink = Text;
|
|
109
|
+
var _this$asProps3 = this.asProps, styles = _this$asProps3.styles, noWrap = _this$asProps3.noWrap, color = _this$asProps3.color, resolveColor = _this$asProps3.resolveColor, disabled = _this$asProps3.disabled, href = _this$asProps3.href, hasChildren = _this$asProps3.children;
|
|
110
|
+
return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SLink, _ref6.cn("SLink", _objectSpread({}, assignProps({
|
|
111
|
+
"role": "link",
|
|
112
|
+
"tabIndex": disabled ? -1 : 0,
|
|
113
|
+
"use:href": disabled ? void 0 : href,
|
|
114
|
+
"visually-disabled": disabled,
|
|
115
|
+
"text-color": resolveColor(color),
|
|
116
|
+
"tag": "a",
|
|
117
|
+
"noWrapText": noWrap,
|
|
118
|
+
"use:noWrap": false,
|
|
119
|
+
"ref": this.containerRef,
|
|
120
|
+
"__excludeProps": ["disabled", "aria-disabled"],
|
|
121
|
+
"onMouseEnter": this.handleMouseEnterOnlyAddon,
|
|
122
|
+
"onMouseLeave": this.handleMouseLeaveOnlyAddon
|
|
123
|
+
}, _ref))), hasChildren !== void 0 ? this.renderChildren() : this.renderOnlyAddons());
|
|
107
124
|
}
|
|
108
|
-
}])
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
125
|
+
}]);
|
|
126
|
+
return RootLink2;
|
|
127
|
+
}(Component);
|
|
128
|
+
_defineProperty(RootLink, "displayName", "Link");
|
|
129
|
+
_defineProperty(RootLink, "defaultProps", {
|
|
130
|
+
noWrap: true
|
|
113
131
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
function
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
},
|
|
132
|
+
_defineProperty(RootLink, "style", style);
|
|
133
|
+
_defineProperty(RootLink, "enhance", [keyboardFocusEnhance(), resolveColorEnhance()]);
|
|
134
|
+
function LinkText(props) {
|
|
135
|
+
var _ref2 = arguments[0], _ref7;
|
|
136
|
+
var SText = Box;
|
|
137
|
+
var styles = props.styles;
|
|
138
|
+
return _ref7 = sstyled(styles), /* @__PURE__ */ React.createElement(SText, _ref7.cn("SText", _objectSpread({}, assignProps({
|
|
139
|
+
"tag": "span"
|
|
140
|
+
}, _ref2))));
|
|
121
141
|
}
|
|
122
|
-
function
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
},
|
|
142
|
+
function Addon(props) {
|
|
143
|
+
var _ref3 = arguments[0], _ref8;
|
|
144
|
+
var SAddon = Box;
|
|
145
|
+
var styles = props.styles;
|
|
146
|
+
return _ref8 = sstyled(styles), /* @__PURE__ */ React.createElement(SAddon, _ref8.cn("SAddon", _objectSpread({}, assignProps({
|
|
147
|
+
"tag": "span"
|
|
148
|
+
}, _ref3))));
|
|
127
149
|
}
|
|
128
|
-
var
|
|
129
|
-
Text:
|
|
130
|
-
Addon
|
|
150
|
+
var Link = createComponent(RootLink, {
|
|
151
|
+
Text: LinkText,
|
|
152
|
+
Addon
|
|
131
153
|
});
|
|
132
154
|
export {
|
|
133
|
-
|
|
155
|
+
Link as default
|
|
134
156
|
};
|
package/lib/esm/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/link",
|
|
3
3
|
"description": "Semrush Link Component",
|
|
4
|
-
"version": "16.0.0-prerelease.
|
|
4
|
+
"version": "16.0.0-prerelease.7",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/typography": "16.0.0-prerelease.
|
|
18
|
-
"@semcore/tooltip": "16.0.0-prerelease.
|
|
19
|
-
"@semcore/flex-box": "16.0.0-prerelease.
|
|
17
|
+
"@semcore/typography": "16.0.0-prerelease.7",
|
|
18
|
+
"@semcore/tooltip": "16.0.0-prerelease.7",
|
|
19
|
+
"@semcore/flex-box": "16.0.0-prerelease.7"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@semcore/base-components": "^16.0.0-prerelease.
|
|
22
|
+
"@semcore/base-components": "^16.0.0-prerelease.7"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|