react-spatial
Version:
Components to build React map apps.
99 lines (83 loc) • 2.36 kB
JavaScript
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
var propTypes = {
/**
* Function triggered on button's click event.
*/
onClick: PropTypes.func.isRequired,
/**
* Function triggered on input change event.
*/
onChange: PropTypes.func,
/**
* Boolean attribute if input is checked or not.
*/
checked: PropTypes.bool,
/**
* CSS class of the checkbox.
*/
className: PropTypes.string,
/**
* Is either checkbox or radio.
*/
inputType: PropTypes.string,
/**
* HTML tabIndex attribute.
*/
tabIndex: PropTypes.number,
/**
* title of the checkbox.
*/
title: PropTypes.string,
};
var defaultProps = {
className: 'tm-check',
inputType: 'checkbox',
onChange: function () {},
checked: false,
tabIndex: 0,
title: 'checkbox',
};
var Checkbox = /*@__PURE__*/(function (PureComponent) {
function Checkbox () {
PureComponent.apply(this, arguments);
}
if ( PureComponent ) Checkbox.__proto__ = PureComponent;
Checkbox.prototype = Object.create( PureComponent && PureComponent.prototype );
Checkbox.prototype.constructor = Checkbox;
Checkbox.prototype.render = function render () {
var ref = this.props;
var className = ref.className;
var onClick = ref.onClick;
var onChange = ref.onChange;
var tabIndex = ref.tabIndex;
var inputType = ref.inputType;
var checked = ref.checked;
var title = ref.title;
/*
eslint-disable jsx-a11y/label-has-associated-control,
jsx-a11y/label-has-for
*/
return (
React.createElement( 'label', {
className: (className + " tm-" + inputType), tabIndex: tabIndex, title: title, 'aria-label': title, onKeyPress: function (e) {
if (e.which === 13) {
onClick(e);
}
} },
React.createElement( 'input', {
type: inputType, tabIndex: -1, checked: checked, onChange: function (e) { return onChange(e); }, onClick: function (e) { return onClick(e); } }),
React.createElement( 'span', null )
)
);
/*
eslint-enable jsx-a11y/label-has-associated-control,
jsx-a11y/label-has-for
*/
};
return Checkbox;
}(PureComponent));
Checkbox.propTypes = propTypes;
Checkbox.defaultProps = defaultProps;
export default Checkbox;
//# sourceMappingURL=Checkbox.js.map