File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
package/src/components/DataTableFilter/helpers Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ import React from "react" ;
2+ import PropTypes from "prop-types" ;
3+ import DataTableFilter from "../DataTableFilter" ;
4+
5+ /**
6+ * @name makeDataTableColumnFilter
7+ * @summary Helper function for creating a column filter for the DataTable.
8+ * @param {Object } props Props to be applied to the DataTableFilter component
9+ * @param {Array } props.options Array of options `[{ label: "Display Label", value: "value" }]
10+ * @param {String } props.title Title to be displayed for the drop down button, or in the card title
11+ * @returns {PropTypes.elementType } DataTableFilter component configured with props
12+ */
13+ export default function makeDataTableColumnFilter ( props ) {
14+ const DataTableColumnFilter = ( {
15+ column : { filterValue, setFilter } ,
16+ container,
17+ className
18+ } ) => (
19+ < DataTableFilter
20+ title = "Filter"
21+ className = { className }
22+ container = { container }
23+ onSelect = { ( value ) => setFilter ( value ) }
24+ value = { filterValue }
25+ { ...props }
26+ />
27+ ) ;
28+
29+ DataTableColumnFilter . propTypes = {
30+ className : PropTypes . string ,
31+ column : PropTypes . shape ( {
32+ filterValue : PropTypes . any ,
33+ setFilter : PropTypes . func
34+ } ) ,
35+ container : PropTypes . oneOf ( [ "default" , "card" ] )
36+ } ;
37+
38+ return DataTableColumnFilter ;
39+ }
You can’t perform that action at this time.
0 commit comments