Skip to content

Commit

Permalink
Merge branch 'allow-users-to-provide-ReactSelect-classNamePrefix'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbonaci committed Sep 24, 2019
2 parents 63f3dbc + 54f68bc commit d833720
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ You can style these components with `style` or `className`.
- _defaultPageSize_ overrides the default page size (if not specified 5 will be used)
- _autoHidePagination_ if pagination should be hidden if the number of pages is 1 (default is true, which means pagination is hidden if the number of pages is equal to 1)
- _filterClassName_ css class for the filter component
- _filterClassNamePrefix_ css class prefix forwarded to [react-select](https://react-select.com/styles#using-classnames) ('Select' by default)
- _filterContainerClassName_ css class for the filter component container element ('col-md-6' by default)
- _filterPlaceholder_ filter placeholder text
- _pageSizeClassName_ css class for the page size component ('col-md-6' by default)
Expand Down Expand Up @@ -283,6 +284,7 @@ getInitialData
getIsInitialized
getFiltered
getFilter
getFilterText
getColumns
getSortInfo
getPageInfo
Expand Down
3 changes: 3 additions & 0 deletions src/Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const propTypes = {
onTextChange: PropTypes.func.isRequired,
options: PropTypes.array.isRequired,
className: PropTypes.string,
classNamePrefix: PropTypes.string,
hasFilterable: PropTypes.bool,
placeholder: PropTypes.node,
style: PropTypes.object,
Expand Down Expand Up @@ -63,13 +64,15 @@ class Filter extends Component {
onChange,
options,
className,
classNamePrefix,
hasFilterable,
placeholder,
style,
} = this.props;
const defaultPlaceholder = hasFilterable ? 'Search or filter using tags...' : 'Search...';
return (
<Creatable
classNamePrefix={classNamePrefix || 'Select'}
className={className}
options={options}
noOptionsMessage={() => 'Type text to search, press Enter to save as filter'}
Expand Down
1 change: 1 addition & 0 deletions src/FilterContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const mapStateToProps = (state, { tableName }) => {
filterText: selectors.getFilterText(state),
options: selectors.getFilterOptions(state),
columns: selectors.getColumns(state),
classNamePrefix: selectors.getFilterClassNamePrefix(state),
};
};

Expand Down
2 changes: 2 additions & 0 deletions src/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default (tableName) => {
direction: tableProp(state, 'direction'),
});
const getSelectEnabled = (state) => tableProp(state, 'configs.selectEnabled');
const getFilterClassNamePrefix = (state) => tableProp(state, 'configs.filterClassNamePrefix');

const getFiltered = createSelector(
getInitialData,
Expand Down Expand Up @@ -261,6 +262,7 @@ export default (tableName) => {
getSelectAll,
getPrimaryKey,
getFilterOptions,
getFilterClassNamePrefix,
getFiltered,
};

Expand Down
2 changes: 2 additions & 0 deletions src/sematable.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ const sematable = (tableName, TableComponent, columns, configs = {}) => {
filterContainerClassName = 'col-md-6',
pageSizeClassName,
filterClassName,
filterClassNamePrefix = 'Select',
filterPlaceholder,
} = configs;

Expand Down Expand Up @@ -225,6 +226,7 @@ const sematable = (tableName, TableComponent, columns, configs = {}) => {
<div className={filterContainerClassName}>
{showFilter && <Filter
className={filterClassName}
classNamePrefix={filterClassNamePrefix}
value={filter}
filterText={filterText}
options={filterOptions}
Expand Down

0 comments on commit d833720

Please sign in to comment.