jb-grid 0.4.1 → 0.5.0
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 +138 -11
- package/package.json +5 -8
- package/react/README.md +207 -202
- package/react/dist/Content.d.ts +1 -2
- package/react/dist/Footer.d.ts +1 -2
- package/react/dist/Header.d.ts +3 -16
- package/react/dist/JBGrid.cjs.js +3631 -1
- package/react/dist/JBGrid.cjs.js.map +1 -1
- package/react/dist/JBGrid.d.ts +288 -26
- package/react/dist/JBGrid.js +3624 -1
- package/react/dist/JBGrid.js.map +1 -1
- package/react/dist/JBGrid.umd.js +3641 -1
- package/react/dist/JBGrid.umd.js.map +1 -1
- package/react/dist/JBGridData.d.ts +1 -5
- package/react/dist/JBGridViewModel.d.ts +28 -25
- package/react/dist/types.d.ts +17 -49
- package/react/lib/Components/Cell.tsx +17 -15
- package/react/lib/Components/ColumnHeader.tsx +44 -0
- package/react/lib/Components/ExpandToggle.tsx +14 -10
- package/react/lib/Components/FullscreenIcon.tsx +28 -0
- package/react/lib/Components/JBLoading.tsx +5 -4
- package/react/lib/Components/Pagination.tsx +1 -1
- package/react/lib/Components/PaginationInfo.tsx +71 -0
- package/react/lib/Components/RefreshIcon.tsx +11 -0
- package/react/lib/Components/Row.tsx +17 -15
- package/react/lib/Components/TableHeader.tsx +21 -0
- package/react/lib/Components/blob-loading.css +27 -23
- package/react/lib/Components/cell.css +7 -7
- package/react/lib/Components/content-error/ContentError.tsx +19 -16
- package/react/lib/Components/content-error/content-error.css +5 -11
- package/react/lib/Components/module-declaration.ts +61 -13
- package/react/lib/Content.tsx +23 -47
- package/react/lib/Footer.tsx +52 -79
- package/react/lib/Header.tsx +11 -24
- package/react/lib/JBGrid.tsx +129 -70
- package/react/lib/JBGridViewModel.ts +189 -452
- package/react/lib/footer.css +25 -55
- package/react/lib/header.css +20 -20
- package/react/lib/jb-grid.css +69 -55
- package/react/lib/types.ts +32 -129
- package/react/lib/variables.css +6 -0
- package/react/package.json +14 -10
- package/react/tsconfig.json +5 -4
- package/web-component/dist/index.cjs.js +559 -1
- package/web-component/dist/index.cjs.js.br +0 -0
- package/web-component/dist/index.cjs.js.gz +0 -0
- package/web-component/dist/index.cjs.js.map +1 -1
- package/web-component/dist/index.d.ts +161 -4
- package/web-component/dist/index.d.ts.map +1 -1
- package/web-component/dist/index.js +561 -1
- package/web-component/dist/index.js.br +0 -0
- package/web-component/dist/index.js.gz +0 -0
- package/web-component/dist/index.js.map +1 -1
- package/web-component/dist/index.umd.js +567 -1
- package/web-component/dist/index.umd.js.br +0 -0
- package/web-component/dist/index.umd.js.gz +0 -0
- package/web-component/dist/index.umd.js.map +1 -1
- package/web-component/dist/row/row.d.ts.map +1 -1
- package/web-component/dist/row/types.d.ts +3 -5
- package/web-component/dist/row/types.d.ts.map +1 -1
- package/web-component/dist/row/utils.d.ts +1 -2
- package/web-component/dist/row/utils.d.ts.map +1 -1
- package/web-component/dist/table-header/render.d.ts +2 -0
- package/web-component/dist/table-header/render.d.ts.map +1 -0
- package/web-component/dist/table-header/table-header.d.ts +9 -0
- package/web-component/dist/table-header/table-header.d.ts.map +1 -0
- package/web-component/dist/table-header/types.d.ts +4 -0
- package/web-component/dist/table-header/types.d.ts.map +1 -0
- package/web-component/dist/types.d.ts +6 -0
- package/web-component/dist/types.d.ts.map +1 -0
- package/web-component/dist/utils.d.ts +8 -0
- package/web-component/dist/utils.d.ts.map +1 -0
- package/web-component/lib/cell/cell.ts +10 -5
- package/web-component/lib/cell/style.css +2 -1
- package/web-component/lib/column-header/column-header.ts +117 -0
- package/web-component/lib/column-header/render.ts +14 -0
- package/web-component/lib/column-header/style.css +60 -0
- package/web-component/lib/column-header/types.ts +10 -0
- package/web-component/lib/fullscreen-icon/fullscreen-icon.ts +72 -0
- package/web-component/lib/fullscreen-icon/render.ts +23 -0
- package/web-component/lib/fullscreen-icon/style.css +44 -0
- package/web-component/lib/fullscreen-icon/types.ts +1 -0
- package/web-component/lib/i18n.ts +38 -0
- package/web-component/lib/index.ts +9 -4
- package/web-component/lib/pagination/README.md +4 -0
- package/web-component/lib/pagination/pagination.ts +25 -15
- package/web-component/lib/pagination/render.ts +13 -10
- package/web-component/lib/pagination/style.css +43 -31
- package/web-component/lib/pagination/types.ts +1 -1
- package/web-component/lib/pagination/variables.css +10 -0
- package/web-component/lib/pagination-info/pagination-info.ts +191 -0
- package/web-component/lib/pagination-info/render.ts +16 -0
- package/web-component/lib/pagination-info/style.css +47 -0
- package/web-component/lib/pagination-info/types.ts +12 -0
- package/web-component/lib/refresh-icon/refresh-icon.ts +79 -0
- package/web-component/lib/refresh-icon/render.ts +10 -0
- package/web-component/lib/refresh-icon/style.css +21 -0
- package/web-component/lib/row/render.ts +3 -3
- package/web-component/lib/row/row.ts +29 -15
- package/web-component/lib/row/style.css +30 -30
- package/web-component/lib/row/types.ts +7 -8
- package/web-component/lib/row/utils.ts +1 -40
- package/web-component/lib/row/variables.css +13 -0
- package/web-component/lib/table-header/render.ts +9 -0
- package/web-component/lib/table-header/style.css +29 -0
- package/web-component/lib/table-header/table-header.ts +50 -0
- package/web-component/lib/table-header/types.ts +4 -0
- package/web-component/lib/toggle/expand-toggle.ts +17 -13
- package/web-component/lib/toggle/render.ts +18 -13
- package/web-component/lib/toggle/style.css +18 -5
- package/web-component/lib/types.ts +6 -0
- package/web-component/lib/utils.ts +46 -0
- package/react/lib/JBGridBridgeExample.js +0 -90
- package/react/lib/JBGridData.ts +0 -51
- package/react/lib/global.d.ts +0 -15
- package/web-component/lib/global.d.ts +0 -15
- package/web-component/tsconfig.json +0 -17
package/README.md
CHANGED
|
@@ -40,9 +40,26 @@ For the standalone pagination API and CSS variables, see [jb-pagination README](
|
|
|
40
40
|
|
|
41
41
|
### jb-pagination CSS variables
|
|
42
42
|
|
|
43
|
-
| CSS variable name | description |
|
|
44
|
-
| --- | --- |
|
|
45
|
-
| --jb-pagination-
|
|
43
|
+
| CSS variable name | description |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| --jb-pagination-arrow-button-fill-color | Fill color of pagination arrow buttons. |
|
|
46
|
+
| --jb-pagination-arrow-button-fill-color-disabled | Fill color of disabled pagination arrow buttons. |
|
|
47
|
+
| --jb-pagination-index-width | Width of each page index button. |
|
|
48
|
+
| --jb-pagination-page-index-color | Color of page index buttons. |
|
|
49
|
+
| --jb-pagination-page-index-color-current | Color of the current page index button. |
|
|
50
|
+
|
|
51
|
+
### jb-row CSS variables
|
|
52
|
+
|
|
53
|
+
| CSS variable name | description |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| --jb-row-bg-color | Row background color. |
|
|
56
|
+
| --jb-row-bg-color-even | Even row background color. |
|
|
57
|
+
| --jb-row-bg-color-even-tablet | Even row background color in tablet layout. |
|
|
58
|
+
| --jb-row-border-radius | Row border radius in tablet layout. |
|
|
59
|
+
| --jb-row-expand-border-color | Expand panel bottom border color. |
|
|
60
|
+
| --jb-row-expand-padding-block | Expand panel block padding. |
|
|
61
|
+
| --jb-row-expand-padding-inline | Expand panel inline padding. |
|
|
62
|
+
| --jb-row-shadow-color | Row shadow color in tablet layout. |
|
|
46
63
|
|
|
47
64
|
## Row & Cells
|
|
48
65
|
`jb-row` is a row web-component that imply a grid template based on given config to below cells. it also accept expand row that you can open and close it.
|
|
@@ -64,7 +81,7 @@ to set column size of the row you can pass a config that tell each column size.
|
|
|
64
81
|
```js
|
|
65
82
|
document.querySelector(""jb-row).rowTemplate = [
|
|
66
83
|
{name:"id",size:"1fr"},
|
|
67
|
-
{name:"name",size:"
|
|
84
|
+
{name:"name",size:"25rem"},
|
|
68
85
|
{name:"age",size:200},
|
|
69
86
|
{name:"operation",size:20%},
|
|
70
87
|
]
|
|
@@ -91,11 +108,121 @@ document.querySelector(`jb-row`).isOpen = true;
|
|
|
91
108
|
document.querySelector(`jb-row`).isOpen = false;
|
|
92
109
|
```
|
|
93
110
|
|
|
94
|
-
### Ellipses Cell
|
|
95
|
-
|
|
96
|
-
|
|
111
|
+
### Ellipses Cell
|
|
112
|
+
|
|
113
|
+
Cells clip horizontal overflow to stay inside their grid column. If long text should show an ellipsis, add the `ellipsis` attribute to `jb-cell`; use `ellipsis="max line"` for multiline truncation.
|
|
97
114
|
```html
|
|
98
|
-
<jb-cell ellipsis>Put Long Text Here</jb-cell>
|
|
99
|
-
<!-- Limited Browser Support for Multiline -->
|
|
100
|
-
<jb-cell ellipsis="3">Put Long Text Here</jb-cell>
|
|
101
|
-
```
|
|
115
|
+
<jb-cell ellipsis>Put Long Text Here</jb-cell>
|
|
116
|
+
<!-- Limited Browser Support for Multiline -->
|
|
117
|
+
<jb-cell ellipsis="3">Put Long Text Here</jb-cell>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Table Header
|
|
121
|
+
|
|
122
|
+
`jb-table-header` is a grid header wrapper for `jb-col-header` cells. Set `headerTemplate` to the same column template shape used by `jb-row`.
|
|
123
|
+
|
|
124
|
+
```html
|
|
125
|
+
<jb-table-header>
|
|
126
|
+
<jb-col-header name="id">
|
|
127
|
+
<span slot="title">ID</span>
|
|
128
|
+
</jb-col-header>
|
|
129
|
+
<jb-col-header name="name" sortable>
|
|
130
|
+
<span slot="title">Name</span>
|
|
131
|
+
</jb-col-header>
|
|
132
|
+
</jb-table-header>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
import 'jb-grid';
|
|
137
|
+
|
|
138
|
+
document.querySelector('jb-table-header').headerTemplate = [
|
|
139
|
+
{ name: 'id', size: '5rem' },
|
|
140
|
+
{ name: 'name', size: '1fr' },
|
|
141
|
+
];
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### jb-table-header API
|
|
145
|
+
|
|
146
|
+
| name | type | description |
|
|
147
|
+
| --- | --- | --- |
|
|
148
|
+
| `headerTemplate` | property | Column template config for the header grid. |
|
|
149
|
+
|
|
150
|
+
### jb-col-header API
|
|
151
|
+
|
|
152
|
+
| name | type | description |
|
|
153
|
+
| --- | --- | --- |
|
|
154
|
+
| `name` | attribute/property | Column name. It is used as the grid-area name. |
|
|
155
|
+
| `sortable` | attribute/property | Enables click sorting for this column. |
|
|
156
|
+
| `sort` | attribute/property | Current sort direction. Accepts `asc`, `desc`, or no value. |
|
|
157
|
+
| `sort` | event | Fired when a sortable header is clicked. Event detail is `{ name, sort }`. |
|
|
158
|
+
| `title` | slot | Header caption content. |
|
|
159
|
+
|
|
160
|
+
```js
|
|
161
|
+
document.querySelector('jb-col-header').addEventListener('sort', (event) => {
|
|
162
|
+
console.log(event.detail.name, event.detail.sort);
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Pagination Info
|
|
167
|
+
|
|
168
|
+
`jb-pagination-info` shows page-size selection and the current item range.
|
|
169
|
+
|
|
170
|
+
```html
|
|
171
|
+
<jb-pagination-info></jb-pagination-info>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
```js
|
|
175
|
+
const paginationInfo = document.querySelector('jb-pagination-info');
|
|
176
|
+
|
|
177
|
+
paginationInfo.pageSize = 20;
|
|
178
|
+
paginationInfo.pageSizes = [10, 20, 50, 100];
|
|
179
|
+
paginationInfo.startItemIndex = 1;
|
|
180
|
+
paginationInfo.endItemIndex = 20;
|
|
181
|
+
paginationInfo.totalItemsCount = 124;
|
|
182
|
+
paginationInfo.pageItemCountTitle = 'Items per page';
|
|
183
|
+
paginationInfo.fromLabel = 'of';
|
|
184
|
+
paginationInfo.currentAvailableItemTitle = 'Available items';
|
|
185
|
+
paginationInfo.showPersianNumber = false;
|
|
186
|
+
|
|
187
|
+
paginationInfo.addEventListener('page-size-change', (event) => {
|
|
188
|
+
console.log(event.detail.pageSize);
|
|
189
|
+
});
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### jb-pagination-info API
|
|
193
|
+
|
|
194
|
+
| name | type | description |
|
|
195
|
+
| --- | --- | --- |
|
|
196
|
+
| `pageSize` | property | Current selected page size. |
|
|
197
|
+
| `pageSizes` | property | Available page-size options. Default is `[20, 30, 50, 100]`. |
|
|
198
|
+
| `startItemIndex` | property | First visible item index. |
|
|
199
|
+
| `endItemIndex` | property | Last visible item index. |
|
|
200
|
+
| `totalItemsCount` | property | Total item count. |
|
|
201
|
+
| `pageItemCountTitle` | property | Tooltip text for the page-size section. |
|
|
202
|
+
| `fromLabel` | property | Label rendered before the total count. |
|
|
203
|
+
| `currentAvailableItemTitle` | property | Tooltip text for the total count. |
|
|
204
|
+
| `showPersianNumber` | property | Converts displayed numbers to Persian digits when `true`. |
|
|
205
|
+
| `page-size-change` | event | Fired when the selected page size changes. Event detail is `{ pageSize }`. |
|
|
206
|
+
|
|
207
|
+
## Utility Icons
|
|
208
|
+
|
|
209
|
+
`jb-refresh-icon` and `jb-fullscreen-icon` are standalone icons used by the grid controls.
|
|
210
|
+
|
|
211
|
+
```html
|
|
212
|
+
<jb-refresh-icon></jb-refresh-icon>
|
|
213
|
+
<jb-fullscreen-icon state="enter"></jb-fullscreen-icon>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### jb-refresh-icon API
|
|
217
|
+
|
|
218
|
+
| name | type | description |
|
|
219
|
+
| --- | --- | --- |
|
|
220
|
+
| `play()` | method | Starts the refresh rotation animation. |
|
|
221
|
+
| `pause()` | method | Pauses the refresh rotation animation. |
|
|
222
|
+
| `stop()` | method | Stops the animation after the current rotation finishes. |
|
|
223
|
+
|
|
224
|
+
### jb-fullscreen-icon API
|
|
225
|
+
|
|
226
|
+
| name | type | description |
|
|
227
|
+
| --- | --- | --- |
|
|
228
|
+
| `state` | attribute/property | Icon state. Accepts `enter` or `exit`. |
|
package/package.json
CHANGED
|
@@ -14,17 +14,15 @@
|
|
|
14
14
|
"web component",
|
|
15
15
|
"react component"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.
|
|
17
|
+
"version": "0.5.0",
|
|
18
18
|
"bugs": "https://github.com/javadbat/jb-grid/issues",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"files": [
|
|
21
21
|
"LICENSE",
|
|
22
22
|
"README.md",
|
|
23
|
-
"lib/",
|
|
24
|
-
"dist/",
|
|
25
23
|
"react/",
|
|
26
|
-
"web-component/",
|
|
27
|
-
"web-component/dist",
|
|
24
|
+
"web-component/lib/",
|
|
25
|
+
"web-component/dist/",
|
|
28
26
|
"react/dist/"
|
|
29
27
|
],
|
|
30
28
|
"main": "index.js",
|
|
@@ -34,9 +32,8 @@
|
|
|
34
32
|
"url": "git@github.com:javadbat/jb-grid.git"
|
|
35
33
|
},
|
|
36
34
|
"dependencies": {
|
|
37
|
-
"jb-
|
|
38
|
-
"
|
|
39
|
-
"mobx-react":">=7.0.0",
|
|
35
|
+
"jb-button":">=3.10.0",
|
|
36
|
+
"jb-core":">=0.30.0",
|
|
40
37
|
"jb-searchbar":">=3.0.2"
|
|
41
38
|
}
|
|
42
39
|
}
|
package/react/README.md
CHANGED
|
@@ -1,206 +1,211 @@
|
|
|
1
|
-
# jb-grid React component
|
|
2
|
-
|
|
3
|
-
[](https://www.webcomponents.org/element/jb-grid)
|
|
4
|
-
[](https://raw.githubusercontent.com/javadbat/jb-grid/main/LICENSE)
|
|
5
|
-
[](https://www.npmjs.com/package/jb-grid-react)
|
|
6
|
-

|
|
7
|
-
|
|
8
|
-
react
|
|
9
|
-
|
|
10
|
-
- responsive
|
|
11
|
-
-
|
|
12
|
-
- easy filter implementation (customizable)
|
|
13
|
-
- customizable column templates
|
|
14
|
-
- flexible column size
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
## instructions
|
|
18
|
-
|
|
19
|
-
### install the package
|
|
20
|
-
|
|
21
|
-
```sh
|
|
22
|
-
npm i jb-grid
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### import and use in your component
|
|
26
|
-
```JSX
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
1
|
+
# jb-grid React component
|
|
2
|
+
|
|
3
|
+
[](https://www.webcomponents.org/element/jb-grid)
|
|
4
|
+
[](https://raw.githubusercontent.com/javadbat/jb-grid/main/LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/jb-grid-react)
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
react table grid with pagination, filtering and sorting functionality.
|
|
9
|
+
|
|
10
|
+
- responsive
|
|
11
|
+
- React state ready
|
|
12
|
+
- easy filter implementation (customizable)
|
|
13
|
+
- customizable column templates
|
|
14
|
+
- flexible column size
|
|
15
|
+
- stateless data, pagination, loading, and error handling
|
|
16
|
+
|
|
17
|
+
## instructions
|
|
18
|
+
|
|
19
|
+
### install the package
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm i jb-grid
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### import and use in your component
|
|
26
|
+
```JSX
|
|
27
|
+
import {JBCell, JBRow, JBGrid} from 'jb-grid/react';
|
|
28
|
+
import {Searchbar} from './Searchbar';
|
|
29
|
+
|
|
30
|
+
<JBGrid
|
|
31
|
+
data={data}
|
|
32
|
+
pageIndex={pageIndex}
|
|
33
|
+
pageSize={pageSize}
|
|
34
|
+
totalItemsCount={totalItemsCount}
|
|
35
|
+
title="user list"
|
|
36
|
+
searchbarComponent={<Searchbar />}
|
|
37
|
+
onPageIndexChange={setPageIndex}
|
|
38
|
+
onPageSizeChange={setPageSize}
|
|
39
|
+
onRefresh={refreshData}
|
|
40
|
+
></JBGrid>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### state
|
|
44
|
+
|
|
45
|
+
`JBGrid` is stateless. Keep data, pagination, loading, error, filtering, sorting, columns, and row expansion in your own component/store and pass the current values to the grid.
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
<JBGrid
|
|
49
|
+
data={data}
|
|
50
|
+
pageIndex={pageIndex}
|
|
51
|
+
pageSize={pageSize}
|
|
52
|
+
totalItemsCount={totalItemsCount}
|
|
53
|
+
totalPages={totalPages}
|
|
54
|
+
isLoading={isLoading}
|
|
55
|
+
isErrorOccurred={isErrorOccurred}
|
|
56
|
+
onPageIndexChange={(newPageIndex) => setPageIndex(newPageIndex)}
|
|
57
|
+
onPageSizeChange={(newPageSize) => setPageSize(newPageSize)}
|
|
58
|
+
onRefresh={() => loadData()}
|
|
59
|
+
title="user list"
|
|
60
|
+
/>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### table header and rows
|
|
64
|
+
|
|
65
|
+
The grid does not own column definitions. If you need a table header, render it yourself with `tableHeader`. Pass row layout directly to `JBRow`.
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
const rowTemplate = [
|
|
69
|
+
{ name: "name", size: "1fr" },
|
|
70
|
+
{ name: "age", size: "6.25rem" },
|
|
71
|
+
{ name: "operation", size: "10rem" }
|
|
72
|
+
];
|
|
73
|
+
```
|
|
74
|
+
```tsx
|
|
75
|
+
<JBTableHeader headerTemplate={rowTemplate}>
|
|
76
|
+
<JBColumnHeader name="id">ID</JBColumnHeader>
|
|
77
|
+
<JBColumnHeader name="name" sortable>Name</JBColumnHeader>
|
|
78
|
+
<JBColumnHeader name="family" sortable>Family</JBColumnHeader>
|
|
79
|
+
<JBColumnHeader name="age">Age</JBColumnHeader>
|
|
80
|
+
</JBTableHeader>
|
|
81
|
+
```
|
|
82
|
+
```tsx
|
|
83
|
+
<JBGrid
|
|
84
|
+
tableHeader={<YourTableHeader />}
|
|
85
|
+
data={data}
|
|
86
|
+
pageIndex={pageIndex}
|
|
87
|
+
pageSize={pageSize}
|
|
88
|
+
totalItemsCount={totalItemsCount}
|
|
89
|
+
title="user list"
|
|
90
|
+
>
|
|
91
|
+
{(data) => data.map((item) => (
|
|
92
|
+
<JBRow key={item.id} rowTemplate={rowTemplate}>
|
|
93
|
+
<JBCell name="name" label="name:">{item.name}</JBCell>
|
|
94
|
+
<JBCell name="age" label="age:">{item.age}</JBCell>
|
|
95
|
+
<JBCell name="operation" label="operations:"><button>detail</button></JBCell>
|
|
96
|
+
</JBRow>
|
|
97
|
+
))}
|
|
98
|
+
</JBGrid>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### i18n
|
|
102
|
+
you can pass a i18n config to set a text, number display and other localization config to jb-grid
|
|
103
|
+
```tsx
|
|
104
|
+
const i18nMessages:JBGridI18nMessage = {
|
|
105
|
+
EnterPageNumberMessage:"شماره صفحه ای که میخواهید وارد آن شوید را وارد کنید",
|
|
106
|
+
serverErrorText:"متاسفانه در هنگام بارگذاری اطلاعات خطایی رخ داده است",
|
|
107
|
+
serverErrorTitle:"すみません",
|
|
108
|
+
serverErrorRefreshButtonTitle:"تلاش مجدد",
|
|
109
|
+
currentAvailableItem:"تعداد کل ایتم های موجود",
|
|
110
|
+
pageItemCount:"تعداد آیتم در هر صفحه",
|
|
111
|
+
from:"از"
|
|
112
|
+
};
|
|
113
|
+
export const i18n:JBGridI18nConfig = {
|
|
114
|
+
messages: i18nMessages,
|
|
115
|
+
showPersianNumber:false
|
|
116
|
+
};
|
|
117
|
+
<JBGrid i18n={i18n} data={data} pageIndex={pageIndex} pageSize={pageSize} totalItemsCount={totalItemsCount}></JBGrid>
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### filter
|
|
122
|
+
|
|
123
|
+
### show list
|
|
124
|
+
|
|
125
|
+
### custom error page
|
|
126
|
+
|
|
127
|
+
if you want to show customized error page instead of default one use `contentError` prop
|
|
128
|
+
```jsx
|
|
129
|
+
<JBGrid {...gridProps} contentError={<CustomErrorComponent />} isErrorOccurred={isErrorOccurred}></JBGrid>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### full-screen grid
|
|
133
|
+
|
|
134
|
+
jb-grid has a fullscreenable feature and you can activate that by set `isFullscreen={value:bool}` for example
|
|
135
|
+
|
|
136
|
+
```jsx
|
|
137
|
+
const [isFullscreen,setIsFullscreen] = useState(false);
|
|
138
|
+
<JBGrid {...gridProps} isFullscreen={isFullscreen} onFullscreen={()=>setIsFullscreen(true)} onExitFullscreen={()=>setIsFullscreen(false)}></JBGrid>
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
### expandable row
|
|
142
|
+
you can add expandable row so user can expand row to see more info about a row in detail
|
|
143
|
+
|
|
144
|
+
```jsx
|
|
145
|
+
<JBGrid data={data} pageIndex={pageIndex} pageSize={pageSize} totalItemsCount={totalItemsCount} title="general list" searchbarComponent={<Searchbar />}>
|
|
146
|
+
{
|
|
147
|
+
(data) => data.map(
|
|
148
|
+
(item) => {
|
|
149
|
+
return (
|
|
150
|
+
<React.Fragment key={item.id}>
|
|
151
|
+
<JBRow isOpen={expandedRowIds.has(item.id)}>
|
|
152
|
+
<JBCell name="name">{item.name}</JBCell>
|
|
153
|
+
<JBCell name="age">{item.age}</JBCell>
|
|
154
|
+
<JBCell name="operation"><button onClick={()=>toggleRowExpanded(item.id)}>detail</button></JBCell>
|
|
155
|
+
<div slot="expand">
|
|
156
|
+
<YourExpandedData></YourExpandedData>
|
|
157
|
+
</div>
|
|
158
|
+
</JBRow>
|
|
159
|
+
</React.Fragment>
|
|
160
|
+
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
</JBGrid>
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## make it mobile friendly
|
|
170
|
+
|
|
171
|
+
jb-grid by default is mobile friendly but when it turns to mobile view it show row as cards. this cards show the table fields in themselves but without any label. to show label of columns beside the cell in mobile just add `label` property to each cell like this:
|
|
172
|
+
```jsx
|
|
173
|
+
<JBRow>
|
|
174
|
+
<JBCell name="name" label="name:">{item.name}</JBCell>
|
|
175
|
+
<JBCell name="age" label="age:">{item.age}</JBCell>
|
|
176
|
+
<JBCell name="operation" label="operations:"><button onClick={()=>toggleRowExpanded(item.id)}>detail</button></JBCell>
|
|
177
|
+
</JBRow>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Pagination
|
|
181
|
+
|
|
182
|
+
The full React grid shows pagination from `pageIndex`, `pageSize`, `totalItemsCount`, and `totalPages`, and reports changes with `onPageIndexChange` and `onPageSizeChange`. If you need the standalone web-component pagination primitive, import and use `jb-pagination` from the web-component package directly.
|
|
183
|
+
|
|
184
|
+
```jsx
|
|
185
|
+
import 'jb-grid/web-component/lib/pagination';
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
See the web-component README for the standalone `pageIndex`, `min`, and `max` API.
|
|
189
|
+
|
|
190
|
+
## Row & Cells
|
|
191
|
+
|
|
192
|
+
The React package exports `Row`, `Cell`, and `ExpandRow` wrappers for the underlying row/cell primitives.
|
|
193
|
+
|
|
194
|
+
```jsx
|
|
195
|
+
<Row>
|
|
196
|
+
<Cell label="Name">Sara</Cell>
|
|
197
|
+
<Cell label="Age">32</Cell>
|
|
198
|
+
</Row>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Use `Cell` for normal content, `ExpandRow` for expandable detail panels, and `label` on cells for the mobile card view.
|
|
202
|
+
|
|
199
203
|
## Styling
|
|
200
|
-
| CSS variable name | description |
|
|
201
|
-
| ------------- | ------------- |
|
|
202
|
-
| --jb-grid-
|
|
203
|
-
| --jb-grid-
|
|
204
|
+
| CSS variable name | description |
|
|
205
|
+
| ------------- | ------------- |
|
|
206
|
+
| --jb-grid-footer-icon-fill-color-hover | footer icon hover fill color |
|
|
207
|
+
| --jb-grid-loading-color | list loading color |
|
|
208
|
+
| --jb-grid-page-color-active | color of active page |
|
|
204
209
|
|
|
205
210
|
## Shared Documentation
|
|
206
211
|
|
package/react/dist/Content.d.ts
CHANGED
package/react/dist/Footer.d.ts
CHANGED