[功能请求] 添加 dcc.Dropdown 选项分组
import React from "react"; import "../styles/sideBar.css"; import Select from 'react-select'
export default class SelectWrapper extends React.Component { constructor(props) { super(props); this.state = { value: this.props.options[0] }; this.handleChange = this.handleChange.bind(this); }
handleChange = selectedOption => { this.props.setProps({ value: selectedOption.value }); this.setState({ value: selectedOption }); };
render() { return <Select {...this.props} onChange={this.handleChange} value={this.props.value} /> } }
SelectWrapper.defaultProps = { clearable: true, disabled: false, multi: false, searchable: true, optionHeight: 35, persisted_props: ['value'], persistence_type: 'local', };
SelectWrapper.propTypes = { /**
- Select options */ options: PropTypes.array,
/**
- The value of the input. If
multiis false (the default) - then value is just a string that corresponds to the values
- provided in the
optionsproperty. Ifmultiis true, then - multiple values can be selected at once, and
valueis an - array of items with values corresponding to those in the
optionsprop. */ value: PropTypes.oneOfType([ PropTypes.string, PropTypes.number, PropTypes.bool, PropTypes.arrayOf( PropTypes.oneOfType([ PropTypes.string,
…
内容来源: plotly/dash