File size: 2,311 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React from 'react';
import { connectCurrentRefinements } from 'react-instantsearch-core';
import PanelCallbackHandler from '../components/PanelCallbackHandler';
import CurrentRefinements from '../components/CurrentRefinements';

/**
 * The CurrentRefinements widget displays the list of currently applied filters.
 *
 * It allows the user to selectively remove them.
 * @name CurrentRefinements
 * @kind widget
 * @propType {function} [transformItems] - Function to modify the items being displayed, e.g. for filtering or sorting them. Takes an items as parameter and expects it back in return.
 * @themeKey ais-CurrentRefinements - the root div of the widget
 * @themeKey ais-CurrentRefinements--noRefinement - the root div of the widget when there is no refinement
 * @themeKey ais-CurrentRefinements-list - the list of all refined items
 * @themeKey ais-CurrentRefinements-list--noRefinement - the list of all refined items when there is no refinement
 * @themeKey ais-CurrentRefinements-item - the refined list item
 * @themeKey ais-CurrentRefinements-button - the button of each refined list item
 * @themeKey ais-CurrentRefinements-label - the refined list label
 * @themeKey ais-CurrentRefinements-category - the category of each item
 * @themeKey ais-CurrentRefinements-categoryLabel - the label of each catgory
 * @themeKey ais-CurrentRefinements-delete - the delete button of each label
 * @translationKey clearFilter - the remove filter button label
 * @example
 * import React from 'react';
 * import algoliasearch from 'algoliasearch/lite';
 * import { InstantSearch, CurrentRefinements, RefinementList } from 'react-instantsearch-dom';
 *
 * const searchClient = algoliasearch(
 *   'latency',
 *   '6be0576ff61c053d5f9a3225e2a90f76'
 * );
 *
 * const App = () => (
 *   <InstantSearch
 *     searchClient={searchClient}
 *     indexName="instant_search"
 *   >
 *     <CurrentRefinements />
 *     <RefinementList
 *       attribute="brand"
 *       defaultRefinement={['Colors']}
 *     />
 *   </InstantSearch>
 * );
 */

const CurrentRefinementsWidget = (props) => (
  <PanelCallbackHandler {...props}>
    <CurrentRefinements {...props} />
  </PanelCallbackHandler>
);

export default connectCurrentRefinements(CurrentRefinementsWidget, {
  $$widgetType: 'ais.currentRefinements',
});