UNPKG

@findify/react-components

Version:
29 lines (28 loc) 863 B
/** * @module components/Facet */ import TextFacet from "../CheckboxFacet"; import RangeFacet from "../RangeFacet"; import RatingFacet from "../RatingFacet"; import ColorFacet from "../ColorFacet"; import CategoryFacet from "../CategoryFacet"; import { createElement, memo } from 'react'; /** * Function, that takes one of filter types and returns facet component for it * @param type Filter type to fetch facet component for */ export var getComponent = function getComponent(type) { return { text: TextFacet, range: RangeFacet, rating: RatingFacet, price: RangeFacet, color: ColorFacet, category: CategoryFacet }[type] || function () { return null; }; }; export default /*#__PURE__*/memo(function (props) { return /*#__PURE__*/createElement(getComponent(props.config.get('type') || props.facet.get('type')), props); });