Skip to content

Commit

Permalink
Merge pull request #380 from Espressive/chore/FDS-389-show-proptypes-…
Browse files Browse the repository at this point in the history
…in-table

chore(FDS-389):[Docs]: Fix propTypes for Table
  • Loading branch information
odiseo42 committed Feb 17, 2022
2 parents ec77a4a + 08a1fd6 commit c2190d1
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-grapes-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@espressive/cascara": patch
---

chore(FDS-389):[Docs]: Fix propTypes for Table
78 changes: 76 additions & 2 deletions packages/cascara/src/components/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import TableBase from './TableBase';
import TableLoading from '../../private/TemporaryLoading';
import TableEmpty from '../../private/TemporaryEmpty';

import { TABLE_SHAPE } from './__propTypes';
import pt from 'prop-types';
import { actionModules, dataModules } from '../../modules/ModuleKeys';

const actionModuleOptions = Object.keys(actionModules);
const dataModuleOptions = Object.keys(dataModules);

/** This is a Table */
const Table = (props) => {
Expand Down Expand Up @@ -37,6 +41,76 @@ const Table = (props) => {
);
};

Table.propTypes = TABLE_SHAPE;
Table.propTypes = {
/** Actions will be appended to each row, they'll appear as buttons. */
actions: pt.shape({
actionButtonMenuIndex: pt.number,

modules: pt.arrayOf(
pt.shape({
module: pt.oneOf(actionModuleOptions).isRequired,
})
),

// Resolve record actions.
// A function that returns the actions available to the current row
resolveRecordActions: pt.func,
}),

// An array of objects.
//
// Every object in this array will potencially be rendered as a table row.
data: pt.arrayOf(pt.shape({})),

// DEPRECATED: The main configuration for your table. Here you can specify the columns to display
// as well as the available actions (if any) for each row.
dataConfig: pt.shape({
/** DEPRECATED - use actions instead */
actionButtonMenuIndex: pt.number,

/** DEPRECATED - use actions instead */
actions: pt.arrayOf(
pt.shape({
module: pt.oneOf(actionModuleOptions).isRequired,
})
),

/** DEPRECATED dataDisplay instead */
display: pt.arrayOf(
pt.shape({
module: pt.oneOf(dataModuleOptions).isRequired,
})
),
}),

/** Here you can describe each of the visible columns in your table. */
dataDisplay: pt.arrayOf(
pt.shape({
module: pt.oneOf(dataModuleOptions).isRequired,
})
),

// Event handler.
//
// An event handler you can pass to handle every event your table emits.
onAction: pt.func,

// Resolve record actions.
// A function that returns the actions available to the current row
resolveRecordActions: pt.func,

// Selection
selections: pt.oneOfType([
pt.bool,
pt.exact({
max: pt.number,
}),
]),

// Unique ID Attribute.
//
// specifies the attribute that uniquely identifies every object in the 'data' array.
uniqueIdAttribute: pt.string,
};

export default Table;

0 comments on commit c2190d1

Please sign in to comment.