diff --git a/README.md b/README.md index 5098694..221c074 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,56 @@ # react-bootstrap-table2 + [![Build Status](https://travis-ci.org/react-bootstrap-table/react-bootstrap-table2.svg?branch=master)](https://travis-ci.org/react-bootstrap-table/react-bootstrap-table2) -Rebuilt [react-bootstrap-table](https://github.com/AllenFang/react-bootstrap-table) +Rebuilt of [react-bootstrap-table](https://github.com/AllenFang/react-bootstrap-table) -> `react-bootstrap-table2`'s npm module name is [**`react-bootstrap-table-next`**](https://www.npmjs.com/package/react-bootstrap-table-next) due to some guys already used it +> Note that `react-bootstrap-table2`'s npm module name is [**`react-bootstrap-table-next`**](https://www.npmjs.com/package/react-bootstrap-table-next) due to the name being already taken. -`react-bootstrap-table2` separate some functionalities from core modules to other modules like following: +`react-bootstrap-table2` separates some functionalities from its core modules to other modules as listed in the following: -* [`react-bootstrap-table-next`](https://www.npmjs.com/package/react-bootstrap-table-next) -* [`react-bootstrap-table2-filter`](https://www.npmjs.com/package/react-bootstrap-table2-filter) -* [`react-bootstrap-table2-editor`](https://www.npmjs.com/package/react-bootstrap-table2-editor) -* [`react-bootstrap-table2-paginator`](https://www.npmjs.com/package/react-bootstrap-table2-paginator) -* [`react-bootstrap-table2-overlay`](https://www.npmjs.com/package/react-bootstrap-table2-overlay) -* [`react-bootstrap-table2-toolkit`](https://www.npmjs.com/package/react-bootstrap-table2-toolkit) +- [`react-bootstrap-table-next`](https://www.npmjs.com/package/react-bootstrap-table-next) +- [`react-bootstrap-table2-filter`](https://www.npmjs.com/package/react-bootstrap-table2-filter) +- [`react-bootstrap-table2-editor`](https://www.npmjs.com/package/react-bootstrap-table2-editor) +- [`react-bootstrap-table2-paginator`](https://www.npmjs.com/package/react-bootstrap-table2-paginator) +- [`react-bootstrap-table2-overlay`](https://www.npmjs.com/package/react-bootstrap-table2-overlay) +- [`react-bootstrap-table2-toolkit`](https://www.npmjs.com/package/react-bootstrap-table2-toolkit) -This can help your application with less bundled size and also help us have clean design to avoid handling to much logic in kernel module(SRP). +Not only does this reduce the bundle size of your apps but also helps us have a cleaner design to avoid handling too much logic in the kernel module(SRP). ## Migration -If you are the user from legacy [`react-bootstrap-table`](https://github.com/AllenFang/react-bootstrap-table/), please have a look on [this](./docs/migration.md). + +If you are coming from the legacy [`react-bootstrap-table`](https://github.com/AllenFang/react-bootstrap-table/), please check out the [migration guide](./docs/migration.md). ## Usage + See [getting started](https://react-bootstrap-table.github.io/react-bootstrap-table2/docs/getting-started.html). ## Online Demo + See `react-bootstrap-table2` [storybook](https://react-bootstrap-table.github.io/react-bootstrap-table2/storybook/index.html). ## Roadmap + See [release plans](https://react-bootstrap-table.github.io/react-bootstrap-table2/blog/2018/01/24/release-plan.html). ## Development -Please check [development guide](./docs/development.md). -## How should I run storybook example in my local? +Please check the [development guide](./docs/development.md). + +## Running storybook example on your local machine ```sh +# Clone the repo $ git clone https://github.com/react-bootstrap-table/react-bootstrap-table2.git + +# change dir to the cloned repo $ cd react-bootstrap-table2 + +# Install all dependencies with yarn $ yarn install + +# Start the stroybook server, then go to localhost:6006 $ yarn storybook -$ Go to localhost:6006 + ``` **Storybook examples: [`packages/react-bootstrap-table2-example/examples`](https://github.com/react-bootstrap-table/react-bootstrap-table2/tree/master/packages/react-bootstrap-table2-example/examples)** diff --git a/packages/react-bootstrap-table2-editor/src/editor-indicator.js b/packages/react-bootstrap-table2-editor/src/editor-indicator.js index c19819d..e408bb4 100644 --- a/packages/react-bootstrap-table2-editor/src/editor-indicator.js +++ b/packages/react-bootstrap-table2-editor/src/editor-indicator.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; const EditorIndicator = ({ invalidMessage }) => ( -
+
{ invalidMessage }
); diff --git a/packages/react-bootstrap-table2-example/examples/column-filter/select-filter-preserve-option-order.js b/packages/react-bootstrap-table2-example/examples/column-filter/select-filter-preserve-option-order.js index f7a0fca..0f92088 100644 --- a/packages/react-bootstrap-table2-example/examples/column-filter/select-filter-preserve-option-order.js +++ b/packages/react-bootstrap-table2-example/examples/column-filter/select-filter-preserve-option-order.js @@ -8,9 +8,9 @@ import { productsQualityGenerator } from 'utils/common'; const products = productsQualityGenerator(6); const selectOptions = [ - { label: 0, value: 'good' }, - { label: 1, value: 'Bad' }, - { label: 2, value: 'unknown' } + { value: 0, label: 'good' }, + { value: 1, label: 'Bad' }, + { value: 2, label: 'unknown' } ]; const columns = [{ @@ -22,7 +22,7 @@ const columns = [{ }, { dataField: 'quality', text: 'Product Quailty', - formatter: cell => selectOptions.find(opt => opt.label === cell).value, + formatter: cell => selectOptions.find(opt => opt.value === cell).label, filter: selectFilter({ options: selectOptions }) @@ -33,9 +33,9 @@ import BootstrapTable from 'react-bootstrap-table-next'; import filterFactory, { selectFilter } from 'react-bootstrap-table2-filter'; const selectOptions = [ - { label: 0, value: 'good' }, - { label: 1, value: 'Bad' }, - { label: 2, value: 'unknown' } + { value: 0, label: 'good' }, + { value: 1, label: 'Bad' }, + { value: 2, label: 'unknown' } ]; const columns = [{ @@ -47,7 +47,7 @@ const columns = [{ }, { dataField: 'quality', text: 'Product Quailty', - formatter: cell => selectOptions.find(opt => opt.label === cell).value, + formatter: cell => selectOptions.find(opt => opt.value === cell).label, filter: selectFilter({ options: selectOptions }) diff --git a/packages/react-bootstrap-table2-example/examples/row-expand/expand-by-column-only.js b/packages/react-bootstrap-table2-example/examples/row-expand/expand-by-column-only.js index bc8f5be..ac11a85 100644 --- a/packages/react-bootstrap-table2-example/examples/row-expand/expand-by-column-only.js +++ b/packages/react-bootstrap-table2-example/examples/row-expand/expand-by-column-only.js @@ -51,7 +51,8 @@ const expandRow = {

expandRow.renderer callback will pass the origin row object to you

), - showExpandColumn: true + showExpandColumn: true, + expandByColumnOnly: true }; selectOptions.find(opt => opt.label === cell).value, + formatter: cell => selectOptions.find(opt => opt.value === cell).label, filter: selectFilter({ options: selectOptions }) diff --git a/packages/react-bootstrap-table2-filter/src/components/select.js b/packages/react-bootstrap-table2-filter/src/components/select.js index a30e691..973bdb3 100644 --- a/packages/react-bootstrap-table2-filter/src/components/select.js +++ b/packages/react-bootstrap-table2-filter/src/components/select.js @@ -9,7 +9,10 @@ import { FILTER_TYPE } from '../const'; function optionsEquals(currOpts, prevOpts) { if (Array.isArray(currOpts)) { for (let i = 0; i < currOpts.length; i += 1) { - if (currOpts[i].label !== prevOpts[i].label) { + if ( + currOpts[i].value !== prevOpts[i].value || + currOpts[i].label !== prevOpts[i].label + ) { return false; } } @@ -86,7 +89,7 @@ class SelectFilter extends Component { } if (Array.isArray(options)) { options.forEach(({ value, label }) => - optionTags.push()); + optionTags.push()); } else { Object.keys(options).forEach(key => optionTags.push() diff --git a/packages/react-bootstrap-table2-paginator/src/pagination-total.js b/packages/react-bootstrap-table2-paginator/src/pagination-total.js index cb2fb38..f8b29fb 100644 --- a/packages/react-bootstrap-table2-paginator/src/pagination-total.js +++ b/packages/react-bootstrap-table2-paginator/src/pagination-total.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; const PaginationTotal = props => ( -  Showing rows { props.from } to { props.to + 1 } of { props.dataSize } +  Showing rows { props.from } to { props.to } of { props.dataSize } ); diff --git a/packages/react-bootstrap-table2/src/bootstrap-table.js b/packages/react-bootstrap-table2/src/bootstrap-table.js index 0c5c862..c23eb91 100644 --- a/packages/react-bootstrap-table2/src/bootstrap-table.js +++ b/packages/react-bootstrap-table2/src/bootstrap-table.js @@ -45,6 +45,7 @@ class BootstrapTable extends PropsBaseResolver(Component) { tabIndexCell, id, classes, + bootstrap4, striped, hover, bordered, @@ -66,7 +67,7 @@ class BootstrapTable extends PropsBaseResolver(Component) { 'table-striped': striped, 'table-hover': hover, 'table-bordered': bordered, - 'table-condensed': condensed + [(bootstrap4 ? 'table-sm' : 'table-condensed')]: condensed }, classes); const tableCaption = (caption && { caption });