rax-link
Version:
Link component for Rax.
54 lines (42 loc) • 2.23 kB
JavaScript
;
exports.__esModule = true;
exports.default = void 0;
var _rax = require("rax");
var _raxText = _interopRequireDefault(require("rax-text"));
var _wrapDefaultProperties = _interopRequireDefault(require("../utils/wrapDefaultProperties"));
var _excluded = ["className", "style", "onClick", "onPress", "children", "miniappHref"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
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; }
var Link = (0, _rax.forwardRef)(function (props, ref) {
var className = props.className,
_props$style = props.style,
style = _props$style === void 0 ? {} : _props$style,
onClick = props.onClick,
onPress = props.onPress,
children = props.children,
_props$miniappHref = props.miniappHref,
miniappHref = _props$miniappHref === void 0 ? '' : _props$miniappHref,
rest = _objectWithoutPropertiesLoose(props, _excluded);
var textStyle = {
color: style.color,
lines: style.lines,
fontSize: style.fontSize,
fontStyle: style.fontStyle,
fontWeight: style.fontWeight,
textDecoration: style.textDecoration || 'none',
textAlign: style.textAlign,
fontFamily: style.fontFamily,
textOverflow: style.textOverflow
};
return (0, _rax.createElement)("a", _extends({}, rest, {
ref: ref,
className: className,
style: style,
onClick: onClick || onPress
}), typeof children === 'string' ? (0, _rax.createElement)(_raxText.default, {
style: textStyle
}, children) : children);
});
var _default = (0, _wrapDefaultProperties.default)(Link);
exports.default = _default;