diff --git a/.storybook/config.js b/.storybook/config.js
index 10e74d00bd68..8eb5d0aab102 100644
--- a/.storybook/config.js
+++ b/.storybook/config.js
@@ -2,6 +2,7 @@ import React from 'react';
import { configure, addDecorator } from '@storybook/react';
import { withInfo } from '@storybook/addon-info';
import { withOptions } from '@storybook/addon-options';
+import { configureActions } from '@storybook/addon-actions';
import { initializeRTL } from 'storybook-addon-rtl';
// import { checkA11y } from 'storybook-addon-a11y';
import Container from './Container';
@@ -19,6 +20,11 @@ addDecorator(
})
);
+configureActions({
+ depth: 100,
+ limit: 20,
+});
+
addDecorator(story => );
// addDecorator(checkA11y);
diff --git a/notes.md b/notes.md
new file mode 100644
index 000000000000..06351fc7df5a
--- /dev/null
+++ b/notes.md
@@ -0,0 +1,2 @@
+Use overflow menu for settings
+toolbar actions become overflow menu items
diff --git a/package.json b/package.json
index a3d4c87dd400..4fe24059f432 100644
--- a/package.json
+++ b/package.json
@@ -125,7 +125,7 @@
}
},
"peerDependencies": {
- "carbon-components": "^10.0.0",
+ "carbon-components": "^10.1.0",
"carbon-icons": "^7.0.7",
"react": "^16.8.6",
"react-dom": "^16.8.6"
diff --git a/src/components/DataTable/DataTable-story.js b/src/components/DataTable/DataTable-story.js
index 2a868da76c9f..c38dc3daf8e7 100644
--- a/src/components/DataTable/DataTable-story.js
+++ b/src/components/DataTable/DataTable-story.js
@@ -6,15 +6,19 @@
*/
import { storiesOf } from '@storybook/react';
-import { withKnobs, boolean } from '@storybook/addon-knobs';
+import { withKnobs, boolean, select } from '@storybook/addon-knobs';
import { withReadme } from 'storybook-readme';
import readme from './README.md';
const readmeURL = 'https://goo.gl/dq6CEK';
const props = () => ({
- short: boolean('Short variant (short)', false),
- shouldShowBorder: boolean('Table Border variant (shouldShowBorder)', true),
+ useZebraStyles: boolean('Zebra row styles (useZebraStyles)', false),
+ size: select(
+ 'Row height (size)',
+ { compact: 'compact', short: 'short', tall: 'tall', none: null },
+ null
+ ),
});
storiesOf('DataTable', module)
@@ -39,118 +43,135 @@ storiesOf('DataTable', module)
)
.add(
'with toolbar',
- withReadme(readme, require('./stories/with-toolbar').default),
+ withReadme(readme, () =>
+ require('./stories/with-toolbar').default(props())
+ ),
{
info: {
text: `
- DataTable with toolbar and filtering.
+ DataTable with action menu and filtering.
- You can find more detailed information surrounding usage of this component
- at the following url: ${readmeURL}
- `,
+ You can find more detailed information surrounding usage of this component
+ at the following url: ${readmeURL}
+ `,
},
}
)
.add(
'with sorting',
- withReadme(readme, require('./stories/with-sorting').default),
+ withReadme(readme, () =>
+ require('./stories/with-sorting').default(props())
+ ),
{
info: {
text: `
- DataTable with sorting
+ DataTable with sorting
- You can find more detailed information surrounding usage of this component
- at the following url: ${readmeURL}
- `,
+ You can find more detailed information surrounding usage of this component
+ at the following url: ${readmeURL}
+ `,
},
}
)
.add(
'with selection',
- withReadme(readme, require('./stories/with-selection').default),
+ withReadme(readme, () =>
+ require('./stories/with-selection').default(props())
+ ),
{
info: {
text: `
- DataTable with selection
+ DataTable with selection
- You can find more detailed information surrounding usage of this component
- at the following url: ${readmeURL}
- `,
+ You can find more detailed information surrounding usage of this component
+ at the following url: ${readmeURL}
+ `,
},
}
)
+
.add(
'with radio button selection',
- withReadme(readme, require('./stories/with-selection--radio').default),
+ withReadme(readme, () =>
+ require('./stories/with-selection--radio').default(props())
+ ),
{
info: {
text: `
- DataTable with radio button selection
+ DataTable with radio button selection
- You can find more detailed information surrounding usage of this component
- at the following url: ${readmeURL}
- `,
+ You can find more detailed information surrounding usage of this component
+ at the following url: ${readmeURL}
+ `,
},
}
)
.add(
'with expansion',
- withReadme(readme, require('./stories/with-expansion').default),
+ withReadme(readme, () =>
+ require('./stories/with-expansion').default(props())
+ ),
{
info: {
text: `
- DataTable with expansion
+ DataTable with expansion
- You can find more detailed information surrounding usage of this component
- at the following url: ${readmeURL}
- `,
+ You can find more detailed information surrounding usage of this component
+ at the following url: ${readmeURL}
+ `,
},
}
)
.add(
'with batch actions',
- withReadme(readme, require('./stories/with-batch-actions').default),
+ withReadme(readme, () =>
+ require('./stories/with-batch-actions').default(props())
+ ),
{
info: {
text: `
- Uses alongside and
- to create the toolbar and placeholder for where the batch action menu will
- be displayed.
+ Uses alongside and
+ to create the toolbar and placeholder for where the batch action menu will
+ be displayed.
- You can use the \`getBatchActionProps\` prop getter on the
- component to have it wire up the ghost menu for you.
+ You can use the \`getBatchActionProps\` prop getter on the
+ component to have it wire up the ghost menu for you.
- Individual components take in any kind of event handler
- prop that you would expect to use, like \`onClick\`. You can use these
- alongside the \`selectedRows\` property in your \`render\` prop function
- to pass along this info to your batch action handler.
+ Individual components take in any kind of event handler
+ prop that you would expect to use, like \`onClick\`. You can use these
+ alongside the \`selectedRows\` property in your \`render\` prop function
+ to pass along this info to your batch action handler.
- You can find more detailed information surrounding usage of this component
- at the following url: ${readmeURL}
- `,
+ You can find more detailed information surrounding usage of this component
+ at the following url: ${readmeURL}
+ `,
},
}
)
.add(
'with dynamic content',
- withReadme(readme, require('./stories/with-dynamic-content').default),
+ withReadme(readme, () =>
+ require('./stories/with-dynamic-content').default(props())
+ ),
{
info: {
text: `
- Showcases DataTable behavior when rows are added to the component,
- and when cell data changes dynamically.
- `,
+ Showcases DataTable behavior when rows are added to the component,
+ and when cell data changes dynamically.
+ `,
},
}
)
.add(
'with boolean column',
- withReadme(readme, require('./stories/with-boolean-column').default),
+ withReadme(readme, () =>
+ require('./stories/with-boolean-column').default(props())
+ ),
{
info: {
text: `
- DataTable with toolbar and filtering with column has boolean value.
- `,
+ DataTable with toolbar and filtering with column has boolean value.
+ `,
},
}
);
diff --git a/src/components/DataTable/DataTable.js b/src/components/DataTable/DataTable.js
index 6ea8917ac3b1..d1eda0b7f154 100644
--- a/src/components/DataTable/DataTable.js
+++ b/src/components/DataTable/DataTable.js
@@ -98,16 +98,6 @@ export default class DataTable extends React.Component {
*/
translateWithId: PropTypes.func,
- /**
- * Optional boolean to create a short data table.
- */
- short: PropTypes.bool,
-
- /**
- * Optional boolean to remove borders from data table.
- */
- shouldShowBorder: PropTypes.bool,
-
/**
* Specify whether the control should be a radio button or inline checkbox
*/
@@ -119,8 +109,6 @@ export default class DataTable extends React.Component {
filterRows: defaultFilterRows,
locale: 'en',
translateWithId,
- short: false,
- shouldShowBorder: true,
};
static translationKeys = Object.values(translationKeys);
@@ -163,7 +151,12 @@ export default class DataTable extends React.Component {
* @param {Function} config.onClick a custom click handler for the header
* @returns {Object}
*/
- getHeaderProps = ({ header, onClick, isSortable = true, ...rest }) => {
+ getHeaderProps = ({
+ header,
+ onClick,
+ isSortable = this.props.isSortable,
+ ...rest
+ }) => {
const { sortDirection, sortHeaderKey } = this.state;
return {
...rest,
@@ -287,9 +280,18 @@ export default class DataTable extends React.Component {
* Helper utility to get the Table Props.
*/
getTableProps = () => {
- const { short, shouldShowBorder } = this.props;
+ const {
+ useZebraStyles,
+ size,
+ isSortable,
+ useStaticWidth,
+ shouldShowBorder,
+ } = this.props;
return {
- short,
+ useZebraStyles,
+ size,
+ isSortable,
+ useStaticWidth,
shouldShowBorder,
};
};
@@ -453,7 +455,9 @@ export default class DataTable extends React.Component {
* @param {Event} event
*/
handleOnInputValueChange = event => {
- this.setState({ filterInputValue: event.target.value });
+ if (event.currentTarget) {
+ this.setState({ filterInputValue: event.currentTarget.value });
+ }
};
render() {
diff --git a/src/components/DataTable/README.md b/src/components/DataTable/README.md
index ad154f5059ef..1c1cbc746a99 100644
--- a/src/components/DataTable/README.md
+++ b/src/components/DataTable/README.md
@@ -393,9 +393,9 @@ In practice, the combination of these components looks like the following:
(
+ render={({ rows, headers, getHeaderProps, getRowProps, getTableProps }) => (
-
+
{/* add the expand header before all other headers */}
diff --git a/src/components/DataTable/Table.js b/src/components/DataTable/Table.js
index d357436d911b..97fb1f0745c4 100644
--- a/src/components/DataTable/Table.js
+++ b/src/components/DataTable/Table.js
@@ -13,18 +13,22 @@ import { settings } from 'carbon-components';
const { prefix } = settings;
export const Table = ({
- zebra,
className,
children,
- short,
- shouldShowBorder,
+ useZebraStyles,
+ size,
isSortable,
+ useStaticWidth,
+ shouldShowBorder,
...other
}) => {
const componentClass = cx(`${prefix}--data-table`, className, {
- [`${prefix}--data-table--zebra`]: zebra,
- [`${prefix}--data-table--short`]: short,
+ [`${prefix}--data-table--compact`]: size === 'compact',
+ [`${prefix}--data-table--short`]: size === 'short',
+ [`${prefix}--data-table--tall`]: size === 'tall',
[`${prefix}--data-table--sort`]: isSortable,
+ [`${prefix}--data-table--zebra`]: useZebraStyles,
+ [`${prefix}--data-table--static`]: useStaticWidth,
[`${prefix}--data-table--no-border`]: !shouldShowBorder,
});
return (
@@ -35,36 +39,36 @@ export const Table = ({
};
Table.propTypes = {
- /**
- * The CSS class names.
- */
className: PropTypes.string,
/**
- * `true` to add zebra striping.
+ * `true` to add useZebraStyles striping.
*/
- zebra: PropTypes.bool,
+ useZebraStyles: PropTypes.bool,
/**
- * `true` for short data table.
+ * `normal` Change the row height of table
*/
- short: PropTypes.bool,
+ size: PropTypes.oneOf(['compact', 'small', 'normal', 'tall']),
/**
- * `false` Applies styles for data tables with sorting functionality.
+ * `false` If true, will use a width of 'auto' instead of 100%
*/
- isSortable: PropTypes.bool,
+ useStaticWidth: PropTypes.bool,
/**
- * `true` for data table without borders.
+ * `false` If true, will remove the table border
*/
shouldShowBorder: PropTypes.bool,
+
+ /**
+ * `false` If true, will apply sorting styles
+ */
+ isSortable: PropTypes.bool,
};
Table.defaultProps = {
- zebra: true,
- short: false,
- shouldShowBorder: true,
+ isSortable: false,
};
export default Table;
diff --git a/src/components/DataTable/TableBatchAction.js b/src/components/DataTable/TableBatchAction.js
index ae36ac8cb299..10ed554001c5 100644
--- a/src/components/DataTable/TableBatchAction.js
+++ b/src/components/DataTable/TableBatchAction.js
@@ -10,9 +10,7 @@ import React from 'react';
import iconAddSolid from '@carbon/icons-react/lib/add--filled/16';
import Button from '../Button';
-const TableBatchAction = props => (
-
-);
+const TableBatchAction = props => ;
TableBatchAction.propTypes = {
/**
@@ -28,6 +26,7 @@ TableBatchAction.propTypes = {
TableBatchAction.defaultProps = {
iconDescription: 'Add',
+ renderIcon: iconAddSolid,
};
export default TableBatchAction;
diff --git a/src/components/DataTable/TableBatchActions.js b/src/components/DataTable/TableBatchActions.js
index 2ec4e517b62e..737ac444c9b3 100644
--- a/src/components/DataTable/TableBatchActions.js
+++ b/src/components/DataTable/TableBatchActions.js
@@ -9,6 +9,8 @@ import cx from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import { settings } from 'carbon-components';
+import Button from '../Button';
+import TableActionList from './TableActionList';
const { prefix } = settings;
@@ -44,7 +46,14 @@ const TableBatchActions = ({
return (