@sheinx/base 3.4.3-beta.1 → 3.4.3-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/link/link.d.ts.map +1 -1
- package/cjs/link/link.js +26 -5
- package/esm/link/link.d.ts.map +1 -1
- package/esm/link/link.js +26 -6
- package/package.json +2 -2
package/cjs/link/link.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["link.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["link.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAe,MAAM,aAAa,CAAC;AAIrD,QAAA,MAAM,IAAI,UAAW,SAAS,gBAkE7B,CAAA;AAED,eAAe,IAAI,CAAC"}
|
package/cjs/link/link.js
CHANGED
|
@@ -9,8 +9,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _icons = _interopRequireDefault(require("../icons"));
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
var _excluded = ["jssStyle", "className", "type", "underline", "disabled", "size", "icon", "href", "
|
|
13
|
-
// import from icons
|
|
12
|
+
var _excluded = ["jssStyle", "className", "type", "underline", "disabled", "size", "icon", "href", "children"];
|
|
14
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
15
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -30,16 +29,38 @@ var Link = function Link(props) {
|
|
|
30
29
|
size = props.size,
|
|
31
30
|
icon = props.icon,
|
|
32
31
|
href = props.href,
|
|
33
|
-
target = props.target,
|
|
34
32
|
children = props.children,
|
|
35
33
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
36
34
|
var linkClasses = (jssStyle === null || jssStyle === void 0 || (_jssStyle$link = jssStyle.link) === null || _jssStyle$link === void 0 ? void 0 : _jssStyle$link.call(jssStyle)) || {};
|
|
37
35
|
var rootClass = (0, _classnames.default)(className, linkClasses.wrapper, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, linkClasses.underline, underline === true), linkClasses.underlineHover, underline === 'hover'), linkClasses.disabled, disabled), linkClasses.sizeSmall, size === 'small'), linkClasses.sizeLarge, size === 'large'), linkClasses.primary, type === 'primary'), linkClasses.secondary, type === 'secondary'), linkClasses.danger, type === 'danger'), linkClasses.warning, type === 'warning'), linkClasses.success, type === 'success'));
|
|
36
|
+
var handleClick = function handleClick(e) {
|
|
37
|
+
if (disabled) {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
e.stopPropagation();
|
|
40
|
+
} else {
|
|
41
|
+
var _props$onClick;
|
|
42
|
+
(_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
46
|
+
if (e.key === 'Enter' && !disabled) {
|
|
47
|
+
var _props$onClick2;
|
|
48
|
+
(_props$onClick2 = props.onClick) === null || _props$onClick2 === void 0 || _props$onClick2.call(props, e);
|
|
49
|
+
} else if (disabled) {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
e.stopPropagation();
|
|
52
|
+
} else {
|
|
53
|
+
var _props$onKeyDown;
|
|
54
|
+
(_props$onKeyDown = props.onKeyDown) === null || _props$onKeyDown === void 0 || _props$onKeyDown.call(props, e);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
38
57
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("a", _objectSpread(_objectSpread({
|
|
39
58
|
href: disabled ? undefined : href,
|
|
40
|
-
|
|
41
|
-
|
|
59
|
+
className: rootClass,
|
|
60
|
+
"aria-disabled": disabled
|
|
42
61
|
}, restProps), {}, {
|
|
62
|
+
onClick: handleClick,
|
|
63
|
+
onKeyDown: handleKeyDown,
|
|
43
64
|
children: [typeof icon === 'boolean' && icon && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
44
65
|
className: linkClasses.icon,
|
|
45
66
|
children: _icons.default.link.prefixIcon
|
package/esm/link/link.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["link.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["link.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAe,MAAM,aAAa,CAAC;AAIrD,QAAA,MAAM,IAAI,UAAW,SAAS,gBAkE7B,CAAA;AAED,eAAe,IAAI,CAAC"}
|
package/esm/link/link.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["jssStyle", "className", "type", "underline", "disabled", "size", "icon", "href", "
|
|
2
|
+
var _excluded = ["jssStyle", "className", "type", "underline", "disabled", "size", "icon", "href", "children"];
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -7,10 +7,8 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
7
7
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
8
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
9
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
-
// import { } from '@sheinx/hooks';
|
|
11
10
|
import classNames from 'classnames';
|
|
12
11
|
import React from 'react';
|
|
13
|
-
// import from icons
|
|
14
12
|
import Icons from "../icons";
|
|
15
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -25,16 +23,38 @@ var Link = function Link(props) {
|
|
|
25
23
|
size = props.size,
|
|
26
24
|
icon = props.icon,
|
|
27
25
|
href = props.href,
|
|
28
|
-
target = props.target,
|
|
29
26
|
children = props.children,
|
|
30
27
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
31
28
|
var linkClasses = (jssStyle === null || jssStyle === void 0 || (_jssStyle$link = jssStyle.link) === null || _jssStyle$link === void 0 ? void 0 : _jssStyle$link.call(jssStyle)) || {};
|
|
32
29
|
var rootClass = classNames(className, linkClasses.wrapper, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, linkClasses.underline, underline === true), linkClasses.underlineHover, underline === 'hover'), linkClasses.disabled, disabled), linkClasses.sizeSmall, size === 'small'), linkClasses.sizeLarge, size === 'large'), linkClasses.primary, type === 'primary'), linkClasses.secondary, type === 'secondary'), linkClasses.danger, type === 'danger'), linkClasses.warning, type === 'warning'), linkClasses.success, type === 'success'));
|
|
30
|
+
var handleClick = function handleClick(e) {
|
|
31
|
+
if (disabled) {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
e.stopPropagation();
|
|
34
|
+
} else {
|
|
35
|
+
var _props$onClick;
|
|
36
|
+
(_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, e);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
40
|
+
if (e.key === 'Enter' && !disabled) {
|
|
41
|
+
var _props$onClick2;
|
|
42
|
+
(_props$onClick2 = props.onClick) === null || _props$onClick2 === void 0 || _props$onClick2.call(props, e);
|
|
43
|
+
} else if (disabled) {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
} else {
|
|
47
|
+
var _props$onKeyDown;
|
|
48
|
+
(_props$onKeyDown = props.onKeyDown) === null || _props$onKeyDown === void 0 || _props$onKeyDown.call(props, e);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
33
51
|
return /*#__PURE__*/_jsxs("a", _objectSpread(_objectSpread({
|
|
34
52
|
href: disabled ? undefined : href,
|
|
35
|
-
|
|
36
|
-
|
|
53
|
+
className: rootClass,
|
|
54
|
+
"aria-disabled": disabled
|
|
37
55
|
}, restProps), {}, {
|
|
56
|
+
onClick: handleClick,
|
|
57
|
+
onKeyDown: handleKeyDown,
|
|
38
58
|
children: [typeof icon === 'boolean' && icon && /*#__PURE__*/_jsx("span", {
|
|
39
59
|
className: linkClasses.icon,
|
|
40
60
|
children: Icons.link.prefixIcon
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheinx/base",
|
|
3
|
-
"version": "3.4.3-beta.
|
|
3
|
+
"version": "3.4.3-beta.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"module": "./esm/index.js",
|
|
11
11
|
"typings": "./cjs/index.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@sheinx/hooks": "3.4.3-beta.
|
|
13
|
+
"@sheinx/hooks": "3.4.3-beta.2",
|
|
14
14
|
"immer": "^10.0.0",
|
|
15
15
|
"classnames": "^2.0.0",
|
|
16
16
|
"@shined/reactive": "^0.1.3-alpha.0"
|