react-spatial
Version:
Components to build React map apps.
74 lines (64 loc) • 1.72 kB
JavaScript
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
var propTypes = {
/**
* Href attribute.
*/
href: PropTypes.string,
/**
* Children content of the link.
*/
children: PropTypes.node.isRequired,
/**
* Title attribute.
*/
title: PropTypes.string,
/**
* CSS class.
*/
className: PropTypes.string,
/**
* Function trigger on click event.
*/
onClick: PropTypes.func.isRequired,
};
var defaultProps = {
className: undefined,
href: '#',
title: undefined,
};
/**
* This component displays a simple a HTML element with an onclick attribute.
*/
var ActionLink = /*@__PURE__*/(function (PureComponent) {
function ActionLink () {
PureComponent.apply(this, arguments);
}
if ( PureComponent ) ActionLink.__proto__ = PureComponent;
ActionLink.prototype = Object.create( PureComponent && PureComponent.prototype );
ActionLink.prototype.constructor = ActionLink;
ActionLink.prototype.render = function render () {
var ref = this.props;
var href = ref.href;
var children = ref.children;
var title = ref.title;
var className = ref.className;
var onClick = ref.onClick;
return (
// eslint-disable-next-line jsx-a11y/anchor-is-valid
React.createElement( 'a', {
href: href, title: title, 'aria-label': title, className: className, onClick: function (evt) {
evt.preventDefault();
evt.stopPropagation();
onClick(evt);
} },
children
)
);
};
return ActionLink;
}(PureComponent));
ActionLink.propTypes = propTypes;
ActionLink.defaultProps = defaultProps;
export default ActionLink;
//# sourceMappingURL=ActionLink.js.map