import { h, Component } from 'preact' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' class Select extends Component { constructor(props){ super(props) this.handleChange = this.handleChange.bind(this) } handleChange(e){ clearTimeout(this.timeout) let new_value = e.target.value if (new_value === 'PLACEHOLDER') return this.props.onChange && this.props.onChange(this.props.name, new_value) } render() { const currentValue = this.props.live ? this.props.opt[this.props.name] : this.props.value let lastValue const options = (this.props.options || []).map((key,i) => { let name, value if (typeof key === 'string') { name = key.length < 2 ? key.toUpperCase() : key value = key } else if (typeof key === 'object') { if (key.length) { [name, value] = key } else if (key.count) { let frames = Math.round(key.count / 30) + ' s.' name = key.name.replace(/_/g, ' ') + ' (' + frames + ')' value = key.name } else { name = key.name value = key.value || key.name } } lastValue = value return ( ) }) return (
{this.props.children}
) } } function capitalize(s){ return (s || "").replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); }); } const mapStateToProps = (state, props) => ({ opt: props.opt || state.live.opt, }) const mapDispatchToProps = (dispatch, ownProps) => ({ }) export default connect(mapStateToProps, mapDispatchToProps)(Select)