react-bootstrap-table-ng-paginator 4.19.0 → 4.19.2
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.
- package/README.md +120 -129
- package/dist/react-bootstrap-table-ng-paginator.js +2 -2
- package/dist/react-bootstrap-table-ng-paginator.min.js +2 -2
- package/lib/index.d.ts +2 -12
- package/lib/index.js +0 -4
- package/lib/index.js.map +1 -1
- package/lib/src/data-context.d.ts +0 -6
- package/lib/src/data-context.js +15 -18
- package/lib/src/data-context.js.map +1 -1
- package/lib/src/page-button.js +1 -12
- package/lib/src/page-button.js.map +1 -1
- package/lib/src/pagination-list.d.ts +13 -11
- package/lib/src/pagination-list.js +6 -16
- package/lib/src/pagination-list.js.map +1 -1
- package/lib/src/pagination-total.d.ts +10 -7
- package/lib/src/pagination-total.js +2 -9
- package/lib/src/pagination-total.js.map +1 -1
- package/lib/src/pagination.js +30 -59
- package/lib/src/pagination.js.map +1 -1
- package/lib/src/size-per-page-dropdown-adapter.js +5 -5
- package/lib/src/size-per-page-dropdown-adapter.js.map +1 -1
- package/lib/src/size-per-page-dropdown.d.ts +19 -19
- package/lib/src/size-per-page-dropdown.js +0 -16
- package/lib/src/size-per-page-dropdown.js.map +1 -1
- package/lib/src/size-per-page-option.d.ts +9 -7
- package/lib/src/size-per-page-option.js +2 -9
- package/lib/src/size-per-page-option.js.map +1 -1
- package/lib/src/state-context.js +32 -27
- package/lib/src/state-context.js.map +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
`react-bootstrap-table-ng` separate the pagination code base to [`react-bootstrap-table-ng-paginator`](https://github.com/jeff-k-zhou/react-bootstrap-table-ng/tree/main/packages/react-bootstrap-table-ng-paginator), so there's a little bit different when you use pagination. In the following, we are going to show you how to enable and configure the a pagination table
|
|
4
4
|
|
|
5
|
-
**[Live Demo For Pagination](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/storybook
|
|
5
|
+
**[Live Demo For Pagination](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/storybook/?path=/docs/pagination--docs)**
|
|
6
6
|
|
|
7
|
-
**[API&Props Definitation](https://
|
|
7
|
+
**[API&Props Definitation](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html)**
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
---
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
@@ -18,10 +18,10 @@ $ npm install react-bootstrap-table-ng-paginator --save
|
|
|
18
18
|
|
|
19
19
|
```js
|
|
20
20
|
// es5
|
|
21
|
-
require(
|
|
21
|
+
require("react-bootstrap-table-ng-paginator/dist/react-bootstrap-table-ng-paginator.min.css");
|
|
22
22
|
|
|
23
23
|
// es6
|
|
24
|
-
import
|
|
24
|
+
import "react-bootstrap-table-ng-paginator/dist/react-bootstrap-table-ng-paginator.min.css";
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## How
|
|
@@ -29,10 +29,15 @@ import 'react-bootstrap-table-ng-paginator/dist/react-bootstrap-table-ng-paginat
|
|
|
29
29
|
Let's enable a pagination on your table:
|
|
30
30
|
|
|
31
31
|
```js
|
|
32
|
-
import paginationFactory from
|
|
32
|
+
import paginationFactory from "react-bootstrap-table-ng-paginator";
|
|
33
33
|
// omit...
|
|
34
34
|
|
|
35
|
-
<BootstrapTable
|
|
35
|
+
<BootstrapTable
|
|
36
|
+
keyField="id"
|
|
37
|
+
data={products}
|
|
38
|
+
columns={columns}
|
|
39
|
+
pagination={paginationFactory()}
|
|
40
|
+
/>;
|
|
36
41
|
```
|
|
37
42
|
|
|
38
43
|
## Customization
|
|
@@ -41,49 +46,50 @@ import paginationFactory from 'react-bootstrap-table-ng-paginator';
|
|
|
41
46
|
|
|
42
47
|
`react-bootstrap-table-ng` give some simple ways to customize something like text, styling etc, following is all the props we support for basic customization:
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
You can check [this online demo](https://
|
|
49
|
+
- [paginationSize](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationsizeperpage-number)
|
|
50
|
+
- [sizePerPageList](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationsizeperpagelist-array)
|
|
51
|
+
- [withFirstAndLast](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationwithfirstandlast-bool)
|
|
52
|
+
- [alwaysShowAllBtns](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationalwaysshowallbtns-bool)
|
|
53
|
+
- [firstPageText](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationfirstpagetext-any)
|
|
54
|
+
- [prePageText](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationprepagetext-any)
|
|
55
|
+
- [nextPageText](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationnextpagetext-any)
|
|
56
|
+
- [lastPageText](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationlastpagetext-any)
|
|
57
|
+
- [firstPageTitle](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationfirstpagetitle-any)
|
|
58
|
+
- [prePageTitle](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationprepagetitle-any)
|
|
59
|
+
- [nextPageTitle](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationnextpagetitle-any)
|
|
60
|
+
- [lastPageTitle](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationlastpagetitle-any)
|
|
61
|
+
- [hideSizePerPage](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationhidesizeperpage-bool)
|
|
62
|
+
- [hidePageListOnlyOnePage](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationhidepagelistonlyonepage-bool)
|
|
63
|
+
- [showTotal](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationshowtotal-bool)
|
|
64
|
+
- [disablePageTitle](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationdisablepagetitle-bool)
|
|
65
|
+
|
|
66
|
+
You can check [this online demo](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/storybook/?path=/story/pagination--full-custom-pagination) for above props usage.
|
|
62
67
|
|
|
63
68
|
### Advance Customization
|
|
64
69
|
|
|
65
70
|
Sometime, you may feel above props is not satisfied with your requirement, don't worry, we provide following renderer for each part of pagination:
|
|
66
71
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
- [pageListRenderer](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationpagelistrenderer-function)
|
|
73
|
+
- [pageButtonRenderer](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationpagebuttonrenderer-function)
|
|
74
|
+
- [sizePerPageRenderer](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationsizeperpagerenderer-function)
|
|
75
|
+
- [sizePerPageOptionRenderer](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationsizeperpageoptionrenderer-function)
|
|
76
|
+
- [paginationTotalRenderer](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/docs/pagination-props.html#paginationpaginationtotalrenderer-function)
|
|
72
77
|
|
|
73
78
|
### Fully Customization
|
|
74
79
|
|
|
75
80
|
If you want to customize the pagination component completely, you may get interesting on following solutions:
|
|
76
81
|
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
- Standalone
|
|
83
|
+
- Non-standalone
|
|
79
84
|
|
|
80
85
|
`react-bootstrap-table-ng-paginator` have a `PaginationProvider` which is a react context and that will be easier to customize the pagination components under the scope of `PaginationProvider`. Let's introduce it step by step:
|
|
81
86
|
|
|
82
87
|
#### 1. Import PaginationProvider
|
|
83
88
|
|
|
84
89
|
```js
|
|
85
|
-
import paginationFactory, {
|
|
86
|
-
|
|
90
|
+
import paginationFactory, {
|
|
91
|
+
PaginationProvider,
|
|
92
|
+
} from "react-bootstrap-table-ng-paginator";
|
|
87
93
|
```
|
|
88
94
|
|
|
89
95
|
#### 2. Declare custom and totalSize in pagination option:
|
|
@@ -91,7 +97,7 @@ import paginationFactory, { PaginationProvider } from 'react-bootstrap-table-ng-
|
|
|
91
97
|
```js
|
|
92
98
|
const paginationOption = {
|
|
93
99
|
custom: true,
|
|
94
|
-
totalSize: products.length
|
|
100
|
+
totalSize: products.length,
|
|
95
101
|
};
|
|
96
102
|
```
|
|
97
103
|
|
|
@@ -114,40 +120,35 @@ const paginationOption = {
|
|
|
114
120
|
|
|
115
121
|
`PaginationProvider` actually is a wrapper for the concumser of react context, so that now you have to get the props from context provide then render to your compoennt and `BootstrapTable`:
|
|
116
122
|
|
|
117
|
-
|
|
118
|
-
|
|
123
|
+
- `paginationProps`: this include everything about pagination, you will use it when you render standalone component or your custom component.
|
|
124
|
+
- `paginationTableProps`: you don't need to know about this, but you have to render this as props to `BootstrapTable`.
|
|
119
125
|
|
|
120
126
|
So far, your customization pagination is supposed to look like it:
|
|
127
|
+
|
|
121
128
|
```js
|
|
122
|
-
<PaginationProvider
|
|
123
|
-
|
|
124
|
-
>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
data={ products }
|
|
134
|
-
columns={ columns }
|
|
135
|
-
{ ...paginationTableProps }
|
|
136
|
-
/>
|
|
137
|
-
</div>
|
|
138
|
-
)
|
|
139
|
-
}
|
|
129
|
+
<PaginationProvider pagination={paginationFactory(options)}>
|
|
130
|
+
{({ paginationProps, paginationTableProps }) => (
|
|
131
|
+
<div>
|
|
132
|
+
<BootstrapTable
|
|
133
|
+
keyField="id"
|
|
134
|
+
data={products}
|
|
135
|
+
columns={columns}
|
|
136
|
+
{...paginationTableProps}
|
|
137
|
+
/>
|
|
138
|
+
</div>
|
|
139
|
+
)}
|
|
140
140
|
</PaginationProvider>
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
Now, you have to choose which solution you like: standalone or non-standalone ?
|
|
144
144
|
|
|
145
145
|
#### 4.1 Use Standalone Component
|
|
146
|
+
|
|
146
147
|
`react-bootstrap-table-ng-paginator` provider three standalone components:
|
|
147
148
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
- Size Per Page Dropdwn Standalone
|
|
150
|
+
- Pagination List Standalone
|
|
151
|
+
- Pagination Total Standalone
|
|
151
152
|
|
|
152
153
|
When render each standalone, you just need to pass the `paginationProps` props to standalone component:
|
|
153
154
|
|
|
@@ -156,93 +157,83 @@ import paginationFactory, {
|
|
|
156
157
|
PaginationProvider,
|
|
157
158
|
PaginationListStandalone,
|
|
158
159
|
SizePerPageDropdownStandalone,
|
|
159
|
-
PaginationTotalStandalone
|
|
160
|
-
} from
|
|
161
|
-
|
|
162
|
-
<PaginationProvider
|
|
163
|
-
|
|
164
|
-
>
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
<BootstrapTable
|
|
178
|
-
keyField="id"
|
|
179
|
-
data={ products }
|
|
180
|
-
columns={ columns }
|
|
181
|
-
{ ...paginationTableProps }
|
|
182
|
-
/>
|
|
183
|
-
<PaginationListStandalone
|
|
184
|
-
{ ...paginationProps }
|
|
185
|
-
/>
|
|
186
|
-
</div>
|
|
187
|
-
)
|
|
188
|
-
}
|
|
189
|
-
</PaginationProvider>
|
|
160
|
+
PaginationTotalStandalone,
|
|
161
|
+
} from "react-bootstrap-table-ng-paginator";
|
|
162
|
+
|
|
163
|
+
<PaginationProvider pagination={paginationFactory(options)}>
|
|
164
|
+
{({ paginationProps, paginationTableProps }) => (
|
|
165
|
+
<div>
|
|
166
|
+
<SizePerPageDropdownStandalone {...paginationProps} />
|
|
167
|
+
<PaginationTotalStandalone {...paginationProps} />
|
|
168
|
+
<BootstrapTable
|
|
169
|
+
keyField="id"
|
|
170
|
+
data={products}
|
|
171
|
+
columns={columns}
|
|
172
|
+
{...paginationTableProps}
|
|
173
|
+
/>
|
|
174
|
+
<PaginationListStandalone {...paginationProps} />
|
|
175
|
+
</div>
|
|
176
|
+
)}
|
|
177
|
+
</PaginationProvider>;
|
|
190
178
|
```
|
|
191
179
|
|
|
192
|
-
That's it!!
|
|
180
|
+
That's it!! The benifit for using standalone is you can much easier to render the standalone component in any posistion. In the future, we will implement more featue like applying `style`, `className` etc on standalone components.
|
|
193
181
|
|
|
194
182
|
##### Customizable props for `PaginationListStandalone`
|
|
195
|
-
|
|
183
|
+
|
|
184
|
+
- N/A
|
|
196
185
|
|
|
197
186
|
##### Customizable props for `SizePerPageDropdownStandalone`
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
187
|
+
|
|
188
|
+
- `open`: `true` to make dropdown show.
|
|
189
|
+
- `hidden`: `true` to hide the size per page dropdown.
|
|
190
|
+
- `btnContextual`: Set the button contextual
|
|
191
|
+
- `variation`: Variation for dropdown, available value is `dropdown` and `dropup`.
|
|
192
|
+
- `className`: Custom the class on size per page dropdown
|
|
203
193
|
|
|
204
194
|
##### Customizable props for `SizePerPageDropdownStandalone`
|
|
205
|
-
|
|
195
|
+
|
|
196
|
+
- N/A
|
|
206
197
|
|
|
207
198
|
#### 4.2 Customization Everything
|
|
208
199
|
|
|
209
200
|
If you choose to custom the pagination component by yourself, the `paginationProps` will be important for you. Becasue you have to know for example how to change page or what's the current page etc. Hence, following is all the props in `paginationProps` object:
|
|
210
201
|
|
|
211
202
|
```js
|
|
212
|
-
page,
|
|
213
|
-
sizePerPage,
|
|
214
|
-
pageStartIndex,
|
|
215
|
-
hidePageListOnlyOnePage,
|
|
216
|
-
hideSizePerPage,
|
|
217
|
-
alwaysShowAllBtns,
|
|
218
|
-
withFirstAndLast,
|
|
219
|
-
dataSize,
|
|
220
|
-
sizePerPageList,
|
|
221
|
-
paginationSize,
|
|
222
|
-
showTotal,
|
|
223
|
-
pageListRenderer,
|
|
224
|
-
pageButtonRenderer,
|
|
225
|
-
sizePerPageRenderer,
|
|
226
|
-
paginationTotalRenderer,
|
|
227
|
-
sizePerPageOptionRenderer,
|
|
228
|
-
firstPageText,
|
|
229
|
-
prePageText,
|
|
230
|
-
nextPageText,
|
|
231
|
-
lastPageText,
|
|
232
|
-
prePageTitle,
|
|
233
|
-
nextPageTitle,
|
|
234
|
-
firstPageTitle,
|
|
235
|
-
lastPageTitle,
|
|
236
|
-
onPageChange,
|
|
237
|
-
onSizePerPageChange,
|
|
238
|
-
disablePageTitle
|
|
203
|
+
(page,
|
|
204
|
+
sizePerPage,
|
|
205
|
+
pageStartIndex,
|
|
206
|
+
hidePageListOnlyOnePage,
|
|
207
|
+
hideSizePerPage,
|
|
208
|
+
alwaysShowAllBtns,
|
|
209
|
+
withFirstAndLast,
|
|
210
|
+
dataSize,
|
|
211
|
+
sizePerPageList,
|
|
212
|
+
paginationSize,
|
|
213
|
+
showTotal,
|
|
214
|
+
pageListRenderer,
|
|
215
|
+
pageButtonRenderer,
|
|
216
|
+
sizePerPageRenderer,
|
|
217
|
+
paginationTotalRenderer,
|
|
218
|
+
sizePerPageOptionRenderer,
|
|
219
|
+
firstPageText,
|
|
220
|
+
prePageText,
|
|
221
|
+
nextPageText,
|
|
222
|
+
lastPageText,
|
|
223
|
+
prePageTitle,
|
|
224
|
+
nextPageTitle,
|
|
225
|
+
firstPageTitle,
|
|
226
|
+
lastPageTitle,
|
|
227
|
+
onPageChange,
|
|
228
|
+
onSizePerPageChange,
|
|
229
|
+
disablePageTitle);
|
|
239
230
|
```
|
|
240
231
|
|
|
241
232
|
In most of case, `page`, `sizePerPage`, `onPageChange` and `onSizePerPageChange` are most important things for developer.
|
|
242
233
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
234
|
+
- `page`: Current page.
|
|
235
|
+
- `sizePerPage`: Current size per page.
|
|
236
|
+
- `onPageChange`: Call it when you nede to change page. This function accept one number argument which indicate the new page
|
|
237
|
+
- `onSizePerPageChange`: Call it when you nede to change size per page. This function accept two number argument which indicate the new sizePerPage and new page
|
|
247
238
|
|
|
248
|
-
[Here](https://
|
|
239
|
+
[Here](https://jeff-k-zhou.github.io/react-bootstrap-table-ng/storybook/?path=/story/pagination--full-custom-pagination) is a online example.
|