UNPKG

react-collection-helpers

Version:
35 lines (25 loc) 1.38 kB
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } import React, { PropTypes } from 'react'; import { DISPLAY_NAME_PREFIX } from '../../constants'; import filterBy from '../../utils/filter-by'; import BaseCollectionHelper from '../BaseCollectionHelper'; var Filter = function Filter(_ref) { var collection = _ref.collection, predicate = _ref.predicate, baseProps = _objectWithoutProperties(_ref, ['collection', 'predicate']); var filteredCollection = filterBy({ collection: collection, predicate: predicate, component: 'Filter' }); return React.createElement(BaseCollectionHelper, _extends({ collection: filteredCollection }, baseProps)); }; Filter.displayName = DISPLAY_NAME_PREFIX + 'Filter'; process.env.NODE_ENV !== "production" ? Filter.propTypes = { collection: PropTypes.array, predicate: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired } : void 0; export default Filter;