UNPKG

@sisu-llc/pki-suit

Version:

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

100 lines (79 loc) 3.22 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 CardPickerCard from './CardPickerCard'; import GridLayout from './GridLayout'; export var CardPickerItem = function CardPickerItem(label, key) { var iconUri = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; _classCallCheck(this, CardPickerItem); this.label = label; this.key = key; this.iconUri = iconUri; }; var CardPicker = (_temp = _class2 = function (_React$Component) { _inherits(CardPicker, _React$Component); function CardPicker(props) { _classCallCheck(this, CardPicker); var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); _this.state = { selection: _this.props.initialSelection }; _this.onClick = _this.onClick.bind(_this); return _this; } CardPicker.prototype.onClick = function onClick(key) { var _this2 = this; this.setState({ selection: key }, function () { _this2.props.onChange(key); }); }; CardPicker.prototype.render = function render() { var _this3 = this; var cardComponnents = this.props.cards.map(function (cardItem) { return React.createElement(CardPickerCard, { key: cardItem.label + '|' + (cardItem.iconUri ? cardItem.iconUri : 'noicon'), label: cardItem.label, iconUri: cardItem.iconUri || _this3.props.defaultIconUri, selected: cardItem.key === _this3.state.selection, onClick: function onClick() { _this3.onClick(cardItem.key); }, columns: _this3.props.columns }); }); return React.createElement( GridLayout, null, cardComponnents ); }; return CardPicker; }(React.Component), _class2.defaultProps = { initialSelection: null, defaultIconUri: null, columns: 3 }, _temp); export { CardPicker as default }; CardPicker.CardPickerItem = CardPickerItem; /* <Scrollable style={{ height: '100%' }}> <div style={{ width: '100%', padding: 0, display: 'flex', flex: 1, flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'flex-start', alignItems: 'flex-start', }} > {cardComponnents} </div> </Scrollable> */