import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { translatable } from 'react-instantsearch-core';
import { createClassNames } from '../core/utils';
const cx = createClassNames('CurrentRefinements');
export const CurrentRefinements = ({
items,
canRefine,
refine,
translate,
className,
}) => (
{items.map((item) => (
-
{item.label}
{item.items ? (
item.items.map((nest) => (
{nest.label}
))
) : (
)}
))}
);
const itemPropTypes = PropTypes.arrayOf(
PropTypes.shape({
label: PropTypes.string.isRequired,
value: PropTypes.func.isRequired,
items: (...args) => itemPropTypes(...args),
})
);
CurrentRefinements.propTypes = {
items: itemPropTypes.isRequired,
canRefine: PropTypes.bool.isRequired,
refine: PropTypes.func.isRequired,
translate: PropTypes.func.isRequired,
className: PropTypes.string,
};
CurrentRefinements.defaultProps = {
className: '',
};
export default translatable({
clearFilter: '✕',
})(CurrentRefinements);