UNPKG

ssc-refer

Version:
74 lines (61 loc) 1.85 kB
'use strict'; import _extends from 'babel-runtime/helpers/extends'; import { pick, filter, noop } from 'lodash'; import React, { PropTypes } from 'react'; import TreeTable from './TreeTable.react'; import TreeTableRender from './TreeTableRender.react'; var ReferTreeTable = React.createClass({ displayName: 'ReferTreeTable', /** * In addition to the propTypes below, the following props are automatically * passed down by `Typeahead`: * * - labelKey * - onPaginate * - options * - paginate * - text */ propTypes: { /** * Provides the ability to specify a prefix before the user-entered text to * indicate that the selection will be new. No-op unless `allowNew={true}`. */ newSelectionPrefix: PropTypes.string, /** * Provides a hook for customized rendering of menu item contents. */ onClickItem: PropTypes.func }, getDefaultProps: function getDefaultProps() { return { newSelectionPrefix: 'New selection: ', onClickItem: noop }; }, render: function render() { var menuProps = pick(this.props, ['align', 'className', 'dropup', 'emptyLabel', 'maxHeight', 'onPaginate', 'paginate', 'paginationText', 'style']); var options = this.props.options; return React.createElement( TreeTable, menuProps, this._renderTable(options) ); }, _renderTable: function _renderTable(options) { var tableColumns = this.props.tableColumns; var tableProps = { tableColumns: tableColumns }; return React.createElement( TreeTableRender, _extends({ onClickItem: this._handleClickItem }, tableProps), options ); }, _handleClickItem: function _handleClickItem(record) { var onClickItem = this.props.onClickItem; onClickItem(record); } }); export default ReferTreeTable;