@@ -2,6 +2,8 @@ var React = require('react');
2
2
var ReactDOM = require ( 'react-dom' ) ;
3
3
4
4
var utils = require ( '../../lib/utils.js' ) ;
5
+ var bem = utils . bemHelper ( 'ais-refinement-list' ) ;
6
+ var cx = require ( 'classnames/dedupe' ) ;
5
7
6
8
var autoHide = require ( '../../decorators/autoHide' ) ;
7
9
var headerFooter = require ( '../../decorators/headerFooter' ) ;
@@ -18,14 +20,19 @@ var defaultTemplates = require('./defaultTemplates');
18
20
* @param {String } [options.limit=1000] How much facet values to get
19
21
* @param {Object } [options.cssClasses] CSS classes to add to the wrapping elements: root, list, item
20
22
* @param {String|String[] } [options.cssClasses.root] CSS class to add to the root element
23
+ * @param {String|String[] } [options.cssClasses.header] CSS class to add to the header element
24
+ * @param {String|String[] } [options.cssClasses.body] CSS class to add to the body element
25
+ * @param {String|String[] } [options.cssClasses.footer] CSS class to add to the footer element
21
26
* @param {String|String[] } [options.cssClasses.list] CSS class to add to the list element
22
27
* @param {String|String[] } [options.cssClasses.item] CSS class to add to each item element
28
+ * @param {String|String[] } [options.cssClasses.active] CSS class to add to each active element
29
+ * @param {String|String[] } [options.cssClasses.label] CSS class to add to each label element (when using the default template)
30
+ * @param {String|String[] } [options.cssClasses.checkbox] CSS class to add to each checkbox element (when using the default template)
31
+ * @param {String|String[] } [options.cssClasses.count] CSS class to add to each count element (when using the default template)
23
32
* @param {Object } [options.templates] Templates to use for the widget
24
- * @param {String|Function } [options.templates.header=''] Header template
25
- * @param {String|Function } [options.templates.item=`<label>
26
- <input type="checkbox" value="{{name}}" {{#isRefined}}checked{{/isRefined}} />{{name}} <span>{{count}}</span>
27
- </label>`] Item template, provided with `name`, `count`, `isRefined`
28
- * @param {String|Function } [options.templates.footer=''] Footer template
33
+ * @param {String|Function } [options.templates.header] Header template
34
+ * @param {String|Function } [options.templates.item] Item template, provided with `name`, `count`, `isRefined`
35
+ * @param {String|Function } [options.templates.footer] Footer template
29
36
* @param {Function } [options.transformData] Function to change the object passed to the item template
30
37
* @param {boolean } [hideWhenNoResults=true] Hide the container when there's no results
31
38
* @return {Object }
@@ -37,12 +44,12 @@ function refinementList({
37
44
sortBy = [ 'count:desc' ] ,
38
45
limit = 1000 ,
39
46
cssClasses = { } ,
40
- hideWhenNoResults = true ,
41
47
templates = defaultTemplates ,
42
- transformData
48
+ transformData,
49
+ hideWhenNoResults = true
43
50
} ) {
44
51
var containerNode = utils . getContainerNode ( container ) ;
45
- var usage = 'Usage: refinementList({container, facetName, [operator, sortBy, limit, cssClasses.{root,list,item}, templates.{header,item,footer}, transformData, hideIfNoResults]})' ;
52
+ var usage = 'Usage: refinementList({container, facetName, [operator, sortBy, limit, cssClasses.{root,header,body,footer, list,item,active,label,checkbox,count }, templates.{header,item,footer}, transformData, hideIfNoResults]})' ;
46
53
47
54
if ( ! container || ! facetName ) {
48
55
throw new Error ( usage ) ;
@@ -79,6 +86,15 @@ function refinementList({
79
86
80
87
var facetValues = results . getFacetValues ( facetName , { sortBy : sortBy } ) . slice ( 0 , limit ) ;
81
88
89
+ cssClasses = {
90
+ list : cx ( bem ( 'list' ) , cssClasses . list ) ,
91
+ item : cx ( bem ( 'item' ) , cssClasses . item ) ,
92
+ active : cx ( bem ( 'item' , 'active' ) , cssClasses . active ) ,
93
+ label : cx ( bem ( 'label' ) , cssClasses . label ) ,
94
+ checkbox : cx ( bem ( 'checkbox' ) , cssClasses . checkbox ) ,
95
+ count : cx ( bem ( 'count' ) , cssClasses . count )
96
+ } ;
97
+
82
98
ReactDOM . render (
83
99
< RefinementList
84
100
cssClasses = { cssClasses }
0 commit comments