playbook_ui 14.9.0.pre.alpha.pbntr700newresettodefaultprop4736 → 14.9.0.pre.alpha.play1742globalheightfixes4766

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +61 -17
  3. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.jsx +50 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.md +1 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.jsx +57 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.md +5 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_pagination_mock_data.json +5600 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -0
  10. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +0 -5
  11. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +0 -10
  12. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +0 -1
  13. data/app/pb_kits/playbook/pb_drawer/_drawer.tsx +2 -2
  14. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -2
  15. data/app/pb_kits/playbook/pb_layout/_layout.tsx +30 -11
  16. data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +2 -2
  17. data/dist/chunks/{_typeahead-DU1QgR52.js → _typeahead-B8fkIeXA.js} +1 -1
  18. data/dist/chunks/{_weekday_stacked-BLOmRNnB.js → _weekday_stacked-DjRTXEi-.js} +3 -3
  19. data/dist/chunks/{lib-Ce7MLbJk.js → lib-SyD3buPZ.js} +1 -1
  20. data/dist/chunks/{pb_form_validation-kPWA1Z2g.js → pb_form_validation-Dt8UJgrJ.js} +1 -1
  21. data/dist/chunks/vendor.js +1 -1
  22. data/dist/playbook-doc.js +1 -1
  23. data/dist/playbook-rails-react-bindings.js +1 -1
  24. data/dist/playbook-rails.js +1 -1
  25. data/lib/playbook/version.rb +1 -1
  26. metadata +11 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed2801ec0227abe6135982abb6b527499bfd93c6bdb9f60abeb128b177e7b86f
4
- data.tar.gz: b48246eb5583601ec41ef7ae8fcdb8f3ca8f50b481f634de6b596f5b82ff1692
3
+ metadata.gz: b11194d151b3e24db52c214a1e3dcad53c2a70fa66202a339f52208baea87636
4
+ data.tar.gz: bc9bcfd9149d3501e2ad32a85e5f20c49d0b9a24366a3432cbd1af254a32a8f4
5
5
  SHA512:
6
- metadata.gz: 21ae6b48959d1c92fe17977b28386e1d63db657cfed8b4494ed0dccecce97011918631f336ea06dfc008dca129c41d889b31e6cb0bdd6cf74ffc55285ea4710f
7
- data.tar.gz: 2944e11aca37b9ff421f1404eec2e91a552bb59a11ff3058bd9ab4e5c1cfdc3d6a5c5c2a74f642591c6c6af5a3a03c247698ef47e05e7fe315b1fc37379ebe07
6
+ metadata.gz: 05141da61222882833c06a7e264cab818552acf7ee1624a77196a3103c8942ae867d353d012680db35d702676c933cb125f91e51c7db966fec51b96d8b84a723
7
+ data.tar.gz: be4d849aaac1e5ae95a43d1714b7cde01235d586f9eaf871e55d399fda9291bc26b45c4a590460147364001d872e0835dc9e3518e1a18ace66bbd97d9e0cd242
@@ -7,6 +7,7 @@ import {
7
7
  createColumnHelper,
8
8
  getCoreRowModel,
9
9
  getExpandedRowModel,
10
+ getPaginationRowModel,
10
11
  getSortedRowModel,
11
12
  Row,
12
13
  useReactTable,
@@ -25,6 +26,7 @@ import { updateExpandAndCollapseState } from "./Utilities/ExpansionControlHelper
25
26
  import { CustomCell } from "./Components/CustomCell"
26
27
  import { TableHeader } from "./SubKits/TableHeader"
27
28
  import { TableBody } from "./SubKits/TableBody"
29
+ import Pagination from "../pb_pagination/_pagination"
28
30
 
29
31
  type AdvancedTableProps = {
30
32
  aria?: { [key: string]: string }
@@ -42,6 +44,8 @@ type AdvancedTableProps = {
42
44
  loading?: boolean | string
43
45
  onRowToggleClick?: (arg: Row<GenericObject>) => void
44
46
  onToggleExpansionClick?: (arg: Row<GenericObject>) => void
47
+ pagination?: boolean,
48
+ paginationProps?: GenericObject
45
49
  responsive?: "scroll" | "none",
46
50
  sortControl?: GenericObject
47
51
  tableData: GenericObject[]
@@ -67,6 +71,8 @@ const AdvancedTable = (props: AdvancedTableProps) => {
67
71
  loading,
68
72
  onRowToggleClick,
69
73
  onToggleExpansionClick,
74
+ pagination = false,
75
+ paginationProps,
70
76
  responsive = "scroll",
71
77
  sortControl,
72
78
  tableData,
@@ -177,6 +183,17 @@ const AdvancedTable = (props: AdvancedTableProps) => {
177
183
  }
178
184
  }
179
185
 
186
+ const paginationInitializer = pagination ? {
187
+ getPaginationRowModel: getPaginationRowModel(),
188
+ paginateExpandedRows: false,
189
+ initialState: {
190
+ pagination: {
191
+ pageIndex: paginationProps?.pageIndex ?? 0,
192
+ pageSize: paginationProps?.pageSize ?? 20,
193
+ },
194
+ },
195
+ } : {}
196
+
180
197
  //initialize table
181
198
  const table = useReactTable({
182
199
  data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
@@ -189,6 +206,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
189
206
  enableSortingRemoval: false,
190
207
  sortDescFirst: true,
191
208
  ...expandAndSortState(),
209
+ ... paginationInitializer,
192
210
  ...tableOptions,
193
211
  })
194
212
 
@@ -227,6 +245,10 @@ const AdvancedTable = (props: AdvancedTableProps) => {
227
245
  className
228
246
  )
229
247
 
248
+ const onPageChange = (page: number) => {
249
+ table.setPageIndex(page - 1)
250
+ }
251
+
230
252
  return (
231
253
  <div {...ariaProps}
232
254
  {...dataProps}
@@ -250,23 +272,45 @@ const AdvancedTable = (props: AdvancedTableProps) => {
250
272
  toggleExpansionIcon,
251
273
  }}
252
274
  >
253
- <Table
254
- className={`${loading ? "content-loading" : ""}`}
255
- dark={dark}
256
- dataTable
257
- numberSpacing="tabular"
258
- responsive="none"
259
- {...tableProps}
260
- >
261
- {children ? (
262
- children
263
- ) : (
264
- <>
265
- <TableHeader />
266
- <TableBody />
267
- </>
268
- )}
269
- </Table>
275
+ <>
276
+ {pagination &&
277
+ <Pagination
278
+ current={table.getState().pagination.pageIndex + 1}
279
+ key={`pagination-top-${table.getState().pagination.pageIndex + 1}`}
280
+ marginBottom="xs"
281
+ onChange={onPageChange}
282
+ range={paginationProps?.range ? paginationProps?.range : 5}
283
+ total={table.getPageCount()}
284
+ />
285
+ }
286
+ <Table
287
+ className={`${loading ? "content-loading" : ""}`}
288
+ dark={dark}
289
+ dataTable
290
+ numberSpacing="tabular"
291
+ responsive="none"
292
+ {...tableProps}
293
+ >
294
+ {children ? (
295
+ children
296
+ ) : (
297
+ <>
298
+ <TableHeader />
299
+ <TableBody />
300
+ </>
301
+ )}
302
+ </Table>
303
+ {pagination &&
304
+ <Pagination
305
+ current={table.getState().pagination.pageIndex + 1}
306
+ key={`pagination-bottom-${table.getState().pagination.pageIndex + 1}`}
307
+ marginTop="xs"
308
+ onChange={onPageChange}
309
+ range={paginationProps?.range ? paginationProps?.range : 5}
310
+ total={table.getPageCount()}
311
+ />
312
+ }
313
+ </>
270
314
  </AdvancedTableContext.Provider>
271
315
  </div>
272
316
  )
@@ -0,0 +1,50 @@
1
+ import React from "react"
2
+ import { AdvancedTable } from "playbook-ui"
3
+ import PAGINATION_MOCK_DATA from "./advanced_table_pagination_mock_data.json"
4
+
5
+ const AdvancedTablePagination = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ]
37
+
38
+ return (
39
+ <>
40
+ <AdvancedTable
41
+ columnDefinitions={columnDefinitions}
42
+ pagination
43
+ tableData={PAGINATION_MOCK_DATA}
44
+ {...props}
45
+ />
46
+ </>
47
+ )
48
+ }
49
+
50
+ export default AdvancedTablePagination
@@ -0,0 +1 @@
1
+ `pagination` is an optional prop that can be used to add pagination to the AdvancedTable. If present, it will add pagination with default values for pageSize, etc. To customize pagination, you can also use `paginationProps` shown in the next example.
@@ -0,0 +1,57 @@
1
+ import React from "react"
2
+ import { AdvancedTable } from "playbook-ui"
3
+ import PAGINATION_MOCK_DATA from "./advanced_table_pagination_mock_data.json"
4
+
5
+ const AdvancedTablePaginationWithProps = (props) => {
6
+ const columnDefinitions = [
7
+ {
8
+ accessor: "year",
9
+ label: "Year",
10
+ cellAccessors: ["quarter", "month", "day"],
11
+ },
12
+ {
13
+ accessor: "newEnrollments",
14
+ label: "New Enrollments",
15
+ },
16
+ {
17
+ accessor: "scheduledMeetings",
18
+ label: "Scheduled Meetings",
19
+ },
20
+ {
21
+ accessor: "attendanceRate",
22
+ label: "Attendance Rate",
23
+ },
24
+ {
25
+ accessor: "completedClasses",
26
+ label: "Completed Classes",
27
+ },
28
+ {
29
+ accessor: "classCompletionRate",
30
+ label: "Class Completion Rate",
31
+ },
32
+ {
33
+ accessor: "graduatedStudents",
34
+ label: "Graduated Students",
35
+ },
36
+ ]
37
+
38
+ const paginationProps = {
39
+ pageIndex: 1,
40
+ pageSize: 10,
41
+ range: 2
42
+ }
43
+
44
+ return (
45
+ <>
46
+ <AdvancedTable
47
+ columnDefinitions={columnDefinitions}
48
+ pagination
49
+ paginationProps={paginationProps}
50
+ tableData={PAGINATION_MOCK_DATA}
51
+ {...props}
52
+ />
53
+ </>
54
+ )
55
+ }
56
+
57
+ export default AdvancedTablePaginationWithProps
@@ -0,0 +1,5 @@
1
+ `paginationProps` is an optional prop that can be used to further customize pagination for the AdvancedTable. This prop is an object with 2 optional items:
2
+
3
+ - `pageIndex`: An optional prop to set which page is set to open on initial load. Default is '0'
4
+ - `pageSize`: An optional prop to set total number of rows for each page before the Table paginates. Default is '20'
5
+ - `range`: The range prop determines how many pages to display in the Pagination component. Regardless of this value, the first two and last two pages are always visible to facilitate navigation to the beginning and end of the pagination. If these always-visible pages fall within the specified range, they are included in the display. If they fall outside the range, the pagination will show additional pages up to the number defined by the range prop. See [here for more details](https://playbook.powerapp.cloud/kits/pagination/react#default). Default is set to '5'