/** * External dependencies */ import React from 'react'; import classNames from 'classnames'; /** * Select component. */ export default class Select extends React.Component { /** * Share UI actions need to be performed manually for elements. * They should be done in this method. */ componentDidMount() { this.$el = jQuery( this.el ); this.$el.SUIselect2( { minimumResultsForSearch: -1 } ); this.$el.on( 'change', this.props.onChange ); } /** * Render component. * * @return {JSX.Element} Select component. */ render() { const selectOptions = this.props.items.map( ( item, id ) => { return ( ); } ); const width = 'undefined' === typeof this.props.classes ? '250' : null; return (
{ this.props.description && ( { this.props.description } ) }
); } } /** * Default props. * * @param {string} selectId Select ID. Will be also used as class and htmlFor in the label. * @param {string} label Label text. * @param {Array} items List of items for the select. * @param {string|Array} selected Selected item. * * @type {{selectId: string, multiple: boolean, label: string, items: *[], selected: string}} */ Select.defaultProps = { selectId: '', label: '', items: [], selected: '', multiple: false, };