react-bootstrap-table-ng-example 4.19.1 → 5.19.0-beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,271 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
+
3
+ // import bootstrap style by given version
4
+ import paginationFactory from "../../../react-bootstrap-table-ng-paginator";
5
+ import { columns, productsGenerator, sortColumns } from '../utils/common';
6
+ import BootstrapTable from './Bootstrap5';
7
+ import bootstrapStyle, { BOOTSTRAP_VERSION } from './bootstrap-style';
8
+
9
+ // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
10
+ const meta = {
11
+ title: 'Bootstrap 5',
12
+ component: BootstrapTable as any,
13
+ parameters: {
14
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
15
+ layout: 'centered',
16
+ },
17
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
18
+ tags: ['autodocs'],
19
+ argTypes: {
20
+ mode: { control: 'text', description: 'mode' },
21
+ data: { control: 'object', description: 'table data' },
22
+ columns: { control: 'object', description: 'table columns' },
23
+ sourceCode: { control: 'text', description: 'source code of the table' },
24
+ defaultSorted: { control: 'object', description: 'default sorted data field' },
25
+ selectRow: { control: 'object', description: 'table select row' },
26
+ pagination: { control: 'object', description: 'table pagination' },
27
+ },
28
+ decorators: [
29
+ (Story: any) => bootstrapStyle(BOOTSTRAP_VERSION.FIVE)(Story),
30
+ ],
31
+ } satisfies Meta<typeof BootstrapTable>;
32
+
33
+ export default meta;
34
+
35
+ type Story = StoryObj<typeof meta>;
36
+
37
+ // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
38
+ const defaultSorted = [{
39
+ dataField: 'name',
40
+ order: 'desc'
41
+ }];
42
+
43
+ export const SortTableWithBootstrap5: Story = {
44
+ name: "Sort table with Bootstrap 5",
45
+ args: {
46
+ columns: sortColumns,
47
+ data: productsGenerator(),
48
+ sourceCode: `\
49
+ import BootstrapTable from 'react-bootstrap-table-ng';
50
+
51
+ const columns = [{
52
+ dataField: 'id',
53
+ text: 'Product ID',
54
+ sort: true
55
+ }, {
56
+ dataField: 'name',
57
+ text: 'Product Name',
58
+ sort: true
59
+ }, {
60
+ dataField: 'price',
61
+ text: 'Product Price',
62
+ sort: true
63
+ }];
64
+
65
+ const defaultSorted = [{
66
+ dataField: 'name',
67
+ order: 'desc'
68
+ }];
69
+
70
+ <BootstrapTable
71
+ bootstrap5
72
+ keyField="id"
73
+ data={ products }
74
+ columns={ columns }
75
+ defaultSorted={ defaultSorted }
76
+ />
77
+ `,
78
+ defaultSorted: defaultSorted,
79
+ }
80
+ };
81
+
82
+ export const TableCaptionBootstrap5: Story = {
83
+ name: "Table caption Bootstrap 5",
84
+ args: {
85
+ mode: "caption",
86
+ columns: columns,
87
+ data: productsGenerator(),
88
+ sourceCode: `\
89
+ import BootstrapTable from 'react-bootstrap-table-ng';
90
+
91
+ const columns = [{
92
+ dataField: 'id',
93
+ text: 'Product ID'
94
+ }, {
95
+ dataField: 'name',
96
+ text: 'Product Name'
97
+ }, {
98
+ dataField: 'price',
99
+ text: 'Product Price'
100
+ }];
101
+
102
+ const CaptionElement = () => <h3 style={{ borderRadius: '0.25em', textAlign: 'center', color: 'purple', border: '1px solid purple', padding: '0.5em' }}>Component as Header</h3>;
103
+
104
+ <BootstrapTable bootstrap5 keyField="id" data={ products } caption="Plain text header" columns={ columns } />
105
+
106
+ <BootstrapTable bootstrap5 keyField="id" data={ products } caption={<CaptionElement />} columns={ columns } />
107
+ `,
108
+ }
109
+ };
110
+
111
+ const selectRow = {
112
+ mode: 'radio',
113
+ clickToSelect: true
114
+ };
115
+
116
+ export const RowSelectionTableWithBootstrap5: Story = {
117
+ name: "Row selection table with Bootstrap 5",
118
+ args: {
119
+ columns: columns,
120
+ data: productsGenerator(),
121
+ sourceCode: `\
122
+ import BootstrapTable from 'react-bootstrap-table-ng';
123
+
124
+ const columns = [{
125
+ dataField: 'id',
126
+ text: 'Product ID'
127
+ }, {
128
+ dataField: 'name',
129
+ text: 'Product Name'
130
+ }, {
131
+ dataField: 'price',
132
+ text: 'Product Price'
133
+ }];
134
+
135
+ const selectRow = {
136
+ mode: 'radio',
137
+ clickToSelect: true
138
+ };
139
+
140
+ <BootstrapTable
141
+ bootstrap5
142
+ keyField='id'
143
+ data={ products }
144
+ columns={ columns }
145
+ selectRow={ selectRow }
146
+ />
147
+ `,
148
+ selectRow: selectRow,
149
+ }
150
+ };
151
+
152
+ export const PaginationTableWithBootstrap5: Story = {
153
+ name: "Pagination table with Bootstrap 5",
154
+ args: {
155
+ columns: columns,
156
+ data: productsGenerator(87),
157
+ sourceCode: `\
158
+ import BootstrapTable from 'react-bootstrap-table-ng';
159
+ import paginationFactory from 'react-bootstrap-table-ng-paginator';
160
+
161
+ const columns = [{
162
+ dataField: 'id',
163
+ text: 'Product ID'
164
+ }, {
165
+ dataField: 'name',
166
+ text: 'Product Name'
167
+ }, {
168
+ dataField: 'price',
169
+ text: 'Product Price'
170
+ }];
171
+
172
+ <BootstrapTable bootstrap5 keyField='id' data={ products } columns={ columns } pagination={ paginationFactory() } />
173
+ `,
174
+ pagination: paginationFactory(),
175
+ }
176
+ };
177
+
178
+ export const ColumnToggleWithBootstrap5: Story = {
179
+ name: "Columns toggle with Bootstrap 5",
180
+ args: {
181
+ mode: "toggle",
182
+ columns: columns,
183
+ data: productsGenerator(),
184
+ sourceCode: `\
185
+ import BootstrapTable from 'react-bootstrap-table-ng';
186
+ import ToolkitProvider, { ColumnToggle } from 'react-bootstrap-table-ng-toolkit';
187
+
188
+ const { ToggleList } = ColumnToggle;
189
+ const columns = [{
190
+ dataField: 'id',
191
+ text: 'Product ID'
192
+ }, {
193
+ dataField: 'name',
194
+ text: 'Product Name'
195
+ }, {
196
+ dataField: 'price',
197
+ text: 'Product Price'
198
+ }];
199
+
200
+ <ToolkitProvider
201
+ bootstrap5
202
+ keyField="id"
203
+ data={ products }
204
+ columns={ columns }
205
+ columnToggle
206
+ >
207
+ {
208
+ props => (
209
+ <div>
210
+ <ToggleList { ...props.columnToggleProps } />
211
+ <hr />
212
+ <BootstrapTable
213
+ { ...props.baseProps }
214
+ />
215
+ </div>
216
+ )
217
+ }
218
+ </ToolkitProvider>
219
+ `,
220
+ }
221
+ };
222
+
223
+ export const ToolkitsTableBootstrap5: Story = {
224
+ name: "Toolkits table Bootstrap 5",
225
+ args: {
226
+ mode: "toolkits",
227
+ columns: columns,
228
+ data: productsGenerator(),
229
+ sourceCode: `\
230
+ import BootstrapTable from 'react-bootstrap-table-ng';
231
+ import ToolkitProvider, { Search, CSVExport } from 'react-bootstrap-table-ng-toolkit';
232
+
233
+ const { SearchBar, ClearSearchButton } = Search;
234
+ const { ExportCSVButton } = CSVExport;
235
+
236
+ const columns = [{
237
+ dataField: 'id',
238
+ text: 'Product ID'
239
+ }, {
240
+ dataField: 'name',
241
+ text: 'Product Name'
242
+ }, {
243
+ dataField: 'price',
244
+ text: 'Product Price'
245
+ }];
246
+
247
+ <ToolkitProvider
248
+ bootstrap5
249
+ keyField="id"
250
+ data={ products }
251
+ columns={ columns }
252
+ search
253
+ >
254
+ {
255
+ props => (
256
+ <div>
257
+ <h3>Input something at below input field:</h3>
258
+ <SearchBar { ...props.searchProps } />
259
+ <ClearSearchButton { ...props.searchProps } />
260
+ <hr />
261
+ <BootstrapTable
262
+ { ...props.baseProps }
263
+ />
264
+ <ExportCSVButton { ...props.csvProps }>Export CSV!!</ExportCSVButton>
265
+ </div>
266
+ )
267
+ }
268
+ </ToolkitProvider>
269
+ `,
270
+ }
271
+ };
@@ -0,0 +1,132 @@
1
+ /* eslint-disable import/no-anonymous-default-export */
2
+ import React from "react";
3
+
4
+ import BootstrapTable from "../../../react-bootstrap-table-ng";
5
+ import ToolkitProvider, {
6
+ CSVExport,
7
+ ColumnToggle,
8
+ Search,
9
+ } from "../../../react-bootstrap-table-ng-toolkit";
10
+ import Code from "../components/common/code-block";
11
+
12
+ import "../../../react-bootstrap-table-ng-filter/style/react-bootstrap-table-ng-filter.scss";
13
+ import "../../../react-bootstrap-table-ng-paginator/style/react-bootstrap-table-ng-paginator.scss";
14
+ import "../../../react-bootstrap-table-ng-toolkit/style/react-bootstrap-table-ng-toolkit.scss";
15
+ import "../../../react-bootstrap-table-ng/style/react-bootstrap-table-ng.scss";
16
+ import "./stylesheet/storybook.scss";
17
+ import "./stylesheet/tomorrow.min.css";
18
+
19
+ interface Bootstrap5Props {
20
+ mode?: any;
21
+ data?: any;
22
+ columns?: any;
23
+ sourceCode?: any;
24
+ defaultSorted?: any;
25
+ selectRow?: any;
26
+ pagination?: any;
27
+ }
28
+
29
+ export default ({
30
+ mode,
31
+ data,
32
+ columns,
33
+ sourceCode,
34
+ defaultSorted,
35
+ selectRow,
36
+ pagination,
37
+ }: Bootstrap5Props) => {
38
+ switch (mode) {
39
+ case "caption":
40
+ const Caption = () => (
41
+ <h3
42
+ style={{
43
+ borderRadius: "0.25em",
44
+ textAlign: "center",
45
+ color: "purple",
46
+ border: "1px solid purple",
47
+ padding: "0.5em",
48
+ }}
49
+ >
50
+ Component as Header
51
+ </h3>
52
+ );
53
+ return (
54
+ <div>
55
+ <BootstrapTable
56
+ bootstrap5
57
+ keyField="id"
58
+ data={data}
59
+ caption="Plain text header"
60
+ columns={columns}
61
+ />
62
+ <BootstrapTable
63
+ bootstrap5
64
+ keyField="id"
65
+ data={data}
66
+ caption={<Caption />}
67
+ columns={columns}
68
+ />
69
+ <Code>{sourceCode}</Code>
70
+ </div>
71
+ );
72
+ case "toggle":
73
+ const { ToggleList } = ColumnToggle;
74
+ return (
75
+ <div>
76
+ <ToolkitProvider
77
+ bootstrap5
78
+ keyField="id"
79
+ data={data}
80
+ columns={columns}
81
+ columnToggle
82
+ >
83
+ {(props: any) => (
84
+ <div>
85
+ <ToggleList {...props.columnToggleProps} />
86
+ <hr />
87
+ <BootstrapTable {...props.baseProps} />
88
+ </div>
89
+ )}
90
+ </ToolkitProvider>
91
+ <Code>{sourceCode}</Code>
92
+ </div>
93
+ );
94
+ case "toolkits":
95
+ const { SearchBar, ClearSearchButton } = Search;
96
+ const { ExportCSVButton } = CSVExport;
97
+ return (
98
+ <div>
99
+ <ToolkitProvider bootstrap5 keyField="id" data={data} columns={columns} search>
100
+ {(props: any) => (
101
+ <div>
102
+ <h3>Input something at below input field:</h3>
103
+ <SearchBar {...props.searchProps} />
104
+ <ClearSearchButton {...props.searchProps} />
105
+ <hr />
106
+ <BootstrapTable {...props.baseProps} />
107
+ <ExportCSVButton {...props.csvProps}>
108
+ Export CSV!!
109
+ </ExportCSVButton>
110
+ </div>
111
+ )}
112
+ </ToolkitProvider>
113
+ <Code>{sourceCode}</Code>
114
+ </div>
115
+ );
116
+ default:
117
+ return (
118
+ <div>
119
+ <BootstrapTable
120
+ bootstrap5
121
+ keyField="id"
122
+ data={data}
123
+ columns={columns}
124
+ defaultSorted={defaultSorted}
125
+ selectRow={selectRow}
126
+ pagination={pagination}
127
+ />
128
+ <Code>{sourceCode}</Code>
129
+ </div>
130
+ );
131
+ }
132
+ };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
2
+
3
3
  import type { Meta, StoryObj } from '@storybook/react-webpack5';
4
4
 
5
5
  // import bootstrap style by given version
@@ -1216,10 +1216,6 @@ interface QualityRangerState { }
1216
1216
  class QualityRanger extends React.Component<QualityRangerProps, QualityRangerState> {
1217
1217
  range: HTMLInputElement | null = null;
1218
1218
 
1219
- static propTypes = {
1220
- value: PropTypes.number,
1221
- onUpdate: PropTypes.func.isRequired,
1222
- };
1223
1219
 
1224
1220
  static defaultProps = {
1225
1221
  value: 0,
@@ -1281,11 +1277,15 @@ export const CustomEditor: Story = {
1281
1277
  import BootstrapTable from 'react-bootstrap-table-ng';
1282
1278
  import cellEditFactory from 'react-bootstrap-table-ng-editor';
1283
1279
 
1284
- class QualityRanger extends React.Component {
1285
- static propTypes = {
1286
- value: PropTypes.number,
1287
- onUpdate: PropTypes.func.isRequired
1288
- }
1280
+ interface QualityRangerProps {
1281
+ value?: number;
1282
+ onUpdate: (value: number) => void;
1283
+ }
1284
+
1285
+ interface QualityRangerState { }
1286
+
1287
+ class QualityRanger extends React.Component<QualityRangerProps, QualityRangerState> {
1288
+
1289
1289
  static defaultProps = {
1290
1290
  value: 0
1291
1291
  }
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
- import PropTypes from "prop-types";
2
+
3
3
  import React from "react";
4
4
 
5
5
  // import bootstrap style by given version
@@ -1568,11 +1568,7 @@ interface PriceFilterProps {
1568
1568
  }
1569
1569
 
1570
1570
  class PriceFilter extends React.Component<PriceFilterProps> {
1571
- static propTypes = {
1572
- column: PropTypes.object.isRequired,
1573
- onFilter: PropTypes.func.isRequired,
1574
- };
1575
-
1571
+
1576
1572
  private input: HTMLInputElement | null;
1577
1573
 
1578
1574
  constructor(props: PriceFilterProps) {
@@ -1633,12 +1629,14 @@ export const CustomFilter: Story = {
1633
1629
  import BootstrapTable from 'react-bootstrap-table-ng';
1634
1630
  import filterFactory, { textFilter, customFilter } from 'react-bootstrap-table-ng-filter';
1635
1631
 
1636
- class PriceFilter extends React.Component {
1637
- static propTypes = {
1638
- column: PropTypes.object.isRequired,
1639
- onFilter: PropTypes.func.isRequired
1640
- }
1641
- constructor(props) {
1632
+ interface PriceFilterProps {
1633
+ column: any;
1634
+ onFilter: (value: string) => void;
1635
+ }
1636
+
1637
+ class PriceFilter extends React.Component<PriceFilterProps> {
1638
+
1639
+ constructor(props: PriceFilterProps) {
1642
1640
  super(props);
1643
1641
  this.filter = this.filter.bind(this);
1644
1642
  this.getValue = this.getValue.bind(this);
@@ -1695,10 +1693,6 @@ interface AdvancePriceFilterProps {
1695
1693
  }
1696
1694
 
1697
1695
  class AdvancePriceFilter extends React.Component<AdvancePriceFilterProps, { value: number }> {
1698
- static propTypes = {
1699
- column: PropTypes.object.isRequired,
1700
- onFilter: PropTypes.func.isRequired,
1701
- };
1702
1696
 
1703
1697
  private range: HTMLInputElement | null;
1704
1698
  private showValue: HTMLParagraphElement | null;
@@ -1798,12 +1792,14 @@ export const AdvanceCustomFilter: Story = {
1798
1792
  import BootstrapTable from 'react-bootstrap-table-ng';
1799
1793
  import filterFactory, { textFilter, customFilter, Comparator, FILTER_TYPES } from 'react-bootstrap-table-ng-filter';
1800
1794
 
1801
- class PriceFilter extends React.Component {
1802
- static propTypes = {
1803
- column: PropTypes.object.isRequired,
1804
- onFilter: PropTypes.func.isRequired
1805
- }
1806
- constructor(props) {
1795
+ interface PriceFilterProps {
1796
+ column: any;
1797
+ onFilter: (value: string) => void;
1798
+ }
1799
+
1800
+ class PriceFilter extends React.Component<PriceFilterProps> {
1801
+
1802
+ constructor(props: PriceFilterProps) {
1807
1803
  super(props);
1808
1804
  this.filter = this.filter.bind(this);
1809
1805
  this.getValue = this.getValue.bind(this);