Skip to content

Commit

Permalink
fix: correct proptypes for datatable
Browse files Browse the repository at this point in the history
  • Loading branch information
monteri committed Oct 26, 2023
1 parent 2747ac1 commit d96a1b8
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/DataTable/CollapsibleButtonGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ CollapsibleButtonGroup.propTypes = {
className: PropTypes.string,
/** Array of action objects, containing a component and their callback args */
actions: PropTypes.arrayOf(PropTypes.shape({
component: PropTypes.oneOfType([PropTypes.func, PropTypes.element]).isRequired,
component: PropTypes.oneOfType([PropTypes.element, PropTypes.elementType]).isRequired,
args: PropTypes.shape({}),
})).isRequired,
};
Expand Down
4 changes: 2 additions & 2 deletions src/DataTable/TableFilters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ TableFilters.defaultProps = {

TableFilters.propTypes = {
columns: PropTypes.arrayOf(PropTypes.shape({
Header: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]).isRequired,
canFilter: PropTypes.bool,
render: PropTypes.func.isRequired,
})).isRequired,
manualFilters: PropTypes.bool,
onFilter: PropTypes.func,
onFilter: PropTypes.elementType,
currentFilters: PropTypes.arrayOf(PropTypes.shape()).isRequired,
};

Expand Down
6 changes: 1 addition & 5 deletions src/DataTable/TableFooter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ function TableFooter({ className, children }) {

TableFooter.propTypes = {
/** Specifies the content of the `TableFooter` */
children: PropTypes.oneOfType([
PropTypes.func,
PropTypes.node,
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.node])),
]),
children: PropTypes.node,
/** Specifies class name to append to the base element. */
className: PropTypes.string,
};
Expand Down
2 changes: 1 addition & 1 deletion src/DataTable/filters/CheckboxFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ CheckboxFilter.propTypes = {
*/
column: PropTypes.shape({
setFilter: PropTypes.func.isRequired,
Header: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]).isRequired,
filterChoices: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
Expand Down
2 changes: 1 addition & 1 deletion src/DataTable/filters/DropdownFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ DropdownFilter.propTypes = {
*/
column: PropTypes.shape({
setFilter: PropTypes.func.isRequired,
Header: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]).isRequired,
filterChoices: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string.isRequired,
number: PropTypes.number,
Expand Down
2 changes: 1 addition & 1 deletion src/DataTable/filters/MultiSelectDropdownFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ MultiSelectDropdownFilter.propTypes = {
/** Function to set the filter value */
setFilter: PropTypes.func.isRequired,
/** Column header used for labels and placeholders */
Header: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]).isRequired,
/** Names and values for the select options */
filterChoices: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion src/DataTable/filters/TextFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ TextFilter.propTypes = {
*/
column: PropTypes.shape({
setFilter: PropTypes.func.isRequired,
Header: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]).isRequired,
getHeaderProps: PropTypes.func.isRequired,
filterValue: PropTypes.string,
}).isRequired,
Expand Down
26 changes: 13 additions & 13 deletions src/DataTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,13 @@ DataTable.propTypes = {
/** Definition of table columns */
columns: PropTypes.arrayOf(PropTypes.shape({
/** User visible column name */
Header: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]).isRequired,
/** String used to access the correct cell data for this column */
accessor: requiredWhenNot(PropTypes.string, 'Cell'),
/** Specifies a function that receives `row` as argument and returns cell content */
Cell: PropTypes.oneOfType([PropTypes.func, PropTypes.element]),
Cell: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),
/** Specifies filter component */
Filter: PropTypes.func,
Filter: PropTypes.elementType,
/** Specifies filter type */
filter: PropTypes.string,
/** Specifies filter choices */
Expand All @@ -293,8 +293,8 @@ DataTable.propTypes = {
/** Alternate column for selecting rows. See react table useSort docs for more information */
manualSelectColumn: PropTypes.shape({
id: PropTypes.string.isRequired,
Header: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
Cell: PropTypes.func.isRequired,
Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]).isRequired,
Cell: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),
disableSortBy: PropTypes.bool.isRequired,
}),
/** Table columns can be sorted */
Expand All @@ -315,16 +315,16 @@ DataTable.propTypes = {
/** defaults that will be set on each column. Will be overridden by individual column values */
defaultColumnValues: PropTypes.shape({
/** A default filter component for the column */
Filter: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
Filter: PropTypes.elementType,
}),
/** Actions or other additional non-data columns can be added here */
additionalColumns: PropTypes.arrayOf(PropTypes.shape({
/** id must be unique from other columns ids */
id: PropTypes.string.isRequired,
/** column header that will be displayed to the user */
Header: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
Header: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),
/** Component that renders in the added column. It will receive the row as a prop */
Cell: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
Cell: PropTypes.oneOfType([PropTypes.elementType, PropTypes.node]),
})),
/** Function that will fetch table data. Called when page size, page index or filters change.
* Meant to be used with manual filters and pagination */
Expand Down Expand Up @@ -401,15 +401,15 @@ DataTable.propTypes = {
/** Number between one and four filters that can be shown on the top row. */
numBreakoutFilters: PropTypes.oneOf([1, 2, 3, 4]),
/** Component to be displayed when the table is empty */
EmptyTableComponent: PropTypes.func,
EmptyTableComponent: PropTypes.elementType,
/** Component to be displayed for row status, ie, 10 of 20 rows. Displayed by default in the TableControlBar */
RowStatusComponent: PropTypes.func,
RowStatusComponent: PropTypes.elementType,
/** Component to be displayed for selection status. Displayed when there are selected rows and no active filters */
SelectionStatusComponent: PropTypes.func,
SelectionStatusComponent: PropTypes.elementType,
/** Component to be displayed for filter status. Displayed when there are active filters. */
FilterStatusComponent: PropTypes.func,
FilterStatusComponent: PropTypes.elementType,
/** If children are not provided a table with control bar and footer will be rendered */
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
children: PropTypes.node,
/** If true filters will be shown on sidebar instead */
showFiltersInSidebar: PropTypes.bool,
/** options for data view toggle */
Expand Down

0 comments on commit d96a1b8

Please sign in to comment.