Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(FDS-389):[Docs]: Fix propTypes for Table #380

Merged
merged 2 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;