UNPKG

@attivio/suit

Version:

Attivio SUIT, the Search UI Toolkit, is a library for creating search clients for searching the Attivio platform.

104 lines (90 loc) 3.45 kB
var _class2, _temp; function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } import React from 'react'; import Panel from 'react-bootstrap/lib/Panel'; import PanelGroup from 'react-bootstrap/lib/PanelGroup'; /** * Describes one panel for an Accordion component. The body can be either * an element or a simple string. */ export var AccordionPanel = function AccordionPanel(heading, key, body) { _classCallCheck(this, AccordionPanel); this.heading = heading; this.key = key; this.body = body; }; /** * This component presents a series of titled, collapsible panels, only one of which can be open at * any given time. */ var Accordion = (_temp = _class2 = function (_React$Component) { _inherits(Accordion, _React$Component); function Accordion() { _classCallCheck(this, Accordion); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } Accordion.prototype.render = function render() { var panels = this.props.panels.map(function (panel) { var body = void 0; if (typeof panel.body === 'string') { body = React.createElement( 'div', null, panel.body ); } else { body = panel.body; } return React.createElement( Panel, { eventKey: panel.key, bsStyle: 'primary', key: panel.key, style: { border: 'none', borderBottom: '1px solid #ccc' } }, React.createElement( Panel.Heading, { style: { color: '#2f75b0', backgroundColor: 'white', border: 'none', borderBottom: '1px solid #2f75b0', borderRadius: '0px' } }, React.createElement( Panel.Title, { toggle: true }, panel.heading ) ), React.createElement( Panel.Body, { collapsible: true }, body ) ); }); if (panels.length > 0) { var _defaultPanelKey = this.props.defaultPanelKey ? this.props.defaultPanelKey : this.props.panels[0].key; return React.createElement( PanelGroup, { accordion: true, id: 'queryFrameDescriptionAccordion', defaultActiveKey: _defaultPanelKey }, panels ); } return null; }; return Accordion; }(React.Component), _class2.defaultProps = { defaultPanelKey: null }, _class2.displayName = 'Accordion', _temp); export { Accordion as default }; Accordion.AccordionPanel = AccordionPanel;