playbook_ui 14.21.2.pre.alpha.PLAY2046advancedtableinfinitescroll8311 → 14.21.2.pre.alpha.PLAY21318324

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.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +4 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +8 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/Components/VirtualizedTableView.tsx +16 -36
  5. data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +5 -18
  6. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +17 -37
  7. data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +5 -2
  8. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +0 -3
  9. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +40 -91
  10. data/app/pb_kits/playbook/pb_advanced_table/Utilities/CellRendererUtils.tsx +4 -1
  11. data/app/pb_kits/playbook/pb_advanced_table/Utilities/TableContainerStyles.ts +2 -3
  12. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +4 -32
  13. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +22 -32
  14. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +15 -10
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling.jsx +64 -0
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling.md +7 -0
  17. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -1
  18. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -1
  19. data/dist/chunks/{_typeahead-CVIBi3oA.js → _typeahead-CoOpeYom.js} +2 -2
  20. data/dist/chunks/_weekday_stacked-BPs62iuT.js +45 -0
  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/dist/playbook.css +1 -1
  26. data/lib/playbook/version.rb +1 -1
  27. metadata +5 -4
  28. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_infinite_scroll.md +0 -3
  29. data/dist/chunks/_weekday_stacked-BQMmOtHu.js +0 -45
@@ -57,6 +57,7 @@ type AdvancedTableProps = {
57
57
  onChange?: (value: RowPinningState) => void;
58
58
  };
59
59
  responsive?: "scroll" | "none",
60
+ rowStyling?: GenericObject[],
60
61
  scrollBarNone?: boolean,
61
62
  selectableRows?: boolean,
62
63
  showActionsBar?: boolean,
@@ -98,6 +99,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
98
99
  paginationProps,
99
100
  pinnedRows,
100
101
  responsive = "scroll",
102
+ rowStyling,
101
103
  scrollBarNone= false,
102
104
  showActionsBar = true,
103
105
  selectableRows,
@@ -144,6 +146,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
144
146
  onRowSelectionChange,
145
147
  columnVisibilityControl,
146
148
  pinnedRows,
149
+ rowStyling
147
150
  });
148
151
 
149
152
  // Initialize table actions
@@ -266,29 +269,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
266
269
  // Visibility flag for action bar
267
270
  const isActionBarVisible = (selectableRows && showActionsBar && selectedRowsLength > 0) || columnVisibilityControl;
268
271
 
269
- // The actual Main <Table /> element
270
- const tableElement = (
271
- <Table
272
- className={`${loading ? "content-loading" : ""}`}
273
- dark={dark}
274
- dataTable
275
- numberSpacing="tabular"
276
- responsive="none"
277
- {...tableProps}
278
- >
279
- {children ? (
280
- children
281
- ) : (
282
- <>
283
- <TableHeader />
284
- <TableBody
285
- isFetching={isFetching}
286
- />
287
- </>
288
- )}
289
- </Table>
290
- )
291
-
292
272
  return (
293
273
  <>
294
274
  {/* Top Pagination */}
@@ -336,6 +316,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
336
316
  onExpandByDepthClick={onExpandByDepthClick}
337
317
  pinnedRows={pinnedRows}
338
318
  responsive={responsive}
319
+ rowStyling={rowStyling}
339
320
  selectableRows={selectableRows}
340
321
  setExpanded={setExpanded}
341
322
  showActionsBar={showActionsBar}
@@ -345,7 +326,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
345
326
  table={table}
346
327
  tableContainerRef={tableWrapperRef}
347
328
  toggleExpansionIcon={toggleExpansionIcon}
348
- totalAvailableCount={fullData.length}
349
329
  virtualizedRows={virtualizedRows}
350
330
  >
351
331
  <React.Fragment>
@@ -357,14 +337,24 @@ const AdvancedTable = (props: AdvancedTableProps) => {
357
337
  type={columnVisibilityControl ? "column-visibility" : "row-selection"}
358
338
  />
359
339
 
360
- {/* Virtualized wrapper div only if virtualizedRows is true */}
361
- {virtualizedRows ? (
362
- <div style={{ overflow: 'auto', width: '100%' }}>
363
- {tableElement}
364
- </div>
365
- ) : (
366
- tableElement
367
- )}
340
+ {/* Main Table */}
341
+ <Table
342
+ className={`${loading ? "content-loading" : ""}`}
343
+ dark={dark}
344
+ dataTable
345
+ numberSpacing="tabular"
346
+ responsive="none"
347
+ {...tableProps}
348
+ >
349
+ {children ? (
350
+ children
351
+ ) : (
352
+ <>
353
+ <TableHeader />
354
+ <TableBody />
355
+ </>
356
+ )}
357
+ </Table>
368
358
  </React.Fragment>
369
359
  </AdvancedTableProvider>
370
360
 
@@ -1,7 +1,7 @@
1
1
  import React, {useState} from "react"
2
2
  import { render, screen, waitFor } from "../utilities/test-utils"
3
3
 
4
- import { AdvancedTable, Pill } from "playbook-ui"
4
+ import { AdvancedTable, Pill, colors } from "playbook-ui"
5
5
 
6
6
  global.ResizeObserver = class {
7
7
  observe() {}
@@ -634,21 +634,26 @@ test("columnStyling.cellAlignment sets each <td> align attribute as expected", (
634
634
  expect(firstEnrollmentCell).toHaveAttribute("align", "left");
635
635
  });
636
636
 
637
- test("renders virtualized table rows and header", () => {
637
+ test("rowStyling prop works as expected", () => {
638
+ const rowStyling = [
639
+ {
640
+ rowId: "1",
641
+ backgroundColor: colors.white,
642
+ fontColor: colors.black
643
+ },
644
+ ];
645
+
638
646
  render(
639
647
  <AdvancedTable
640
648
  columnDefinitions={columnDefinitions}
641
649
  data={{ testid: testId }}
650
+ rowStyling={rowStyling}
642
651
  tableData={MOCK_DATA_WITH_ID}
643
- virtualizedRows
644
652
  />
645
653
  )
646
654
 
647
655
  const kit = screen.getByTestId(testId)
648
-
649
- const virtualizedHeader = kit.querySelector('.virtualized-header-row-header')
650
- expect(virtualizedHeader).toBeInTheDocument()
651
-
652
- const virtualizedRows = kit.querySelectorAll('.virtualized-table-row')
653
- expect(virtualizedRows.length).toBeLessThan(MOCK_DATA_WITH_ID.length)
654
- })
656
+ const tableBody = kit.querySelector('tbody')
657
+ const row1 = tableBody.querySelector('tr:nth-child(1)')
658
+ expect(row1).toHaveStyle({backgroundColor: colors.white, color: colors.black})
659
+ })
@@ -0,0 +1,64 @@
1
+ import React from "react"
2
+ import AdvancedTable from '../_advanced_table'
3
+ import MOCK_DATA from "./advanced_table_mock_data_with_id.json"
4
+ import { colors } from "playbook-ui"
5
+
6
+ const AdvancedTableRowStyling = (props) => {
7
+ const columnDefinitions = [
8
+ {
9
+ accessor: "year",
10
+ label: "Year",
11
+ cellAccessors: ["quarter", "month", "day"],
12
+ },
13
+ {
14
+ accessor: "newEnrollments",
15
+ label: "New Enrollments",
16
+ },
17
+ {
18
+ accessor: "scheduledMeetings",
19
+ label: "Scheduled Meetings",
20
+ },
21
+ {
22
+ accessor: "attendanceRate",
23
+ label: "Attendance Rate",
24
+ },
25
+ {
26
+ accessor: "completedClasses",
27
+ label: "Completed Classes",
28
+ },
29
+ {
30
+ accessor: "classCompletionRate",
31
+ label: "Class Completion Rate",
32
+ },
33
+ {
34
+ accessor: "graduatedStudents",
35
+ label: "Graduated Students",
36
+ },
37
+ ]
38
+
39
+ const rowStyling = [
40
+ {
41
+ rowId: "1",
42
+ backgroundColor: colors.warning,
43
+ },
44
+ {
45
+ rowId: "8",
46
+ backgroundColor: colors.category_1,
47
+ fontColor: colors.white,
48
+ expandButtonColor: colors.white,
49
+ },
50
+ ];
51
+
52
+ return (
53
+ <div>
54
+ <AdvancedTable
55
+ columnDefinitions={columnDefinitions}
56
+ rowStyling={rowStyling}
57
+ tableData={MOCK_DATA}
58
+ {...props}
59
+ />
60
+ </div>
61
+ )
62
+ }
63
+
64
+ export default AdvancedTableRowStyling
@@ -0,0 +1,7 @@
1
+ The `rowStyling` prop can be used in conjunction with row ids to control certain styling options on individual rows. Currently, `rowStyling` gives you 3 optional controls:
2
+
3
+ - `backgroundColor` : use this to control the background color of the row.
4
+ - `fontColor`: use this to control font color for each row if needed, for example if using a darker background color.
5
+ - `expandButtonColor`: use this to control the color of the expand icon if needed, for example if using a darker background color.
6
+
7
+ **NOTE:** Each object within the `tableData` Array must contain a unique id in order to attach an id to all Rows for this to function.
@@ -59,6 +59,6 @@ examples:
59
59
  - advanced_table_column_visibility_multi: Column Visibility Control with Multi-Header Columns
60
60
  - advanced_table_pinned_rows: Pinned Rows
61
61
  - advanced_table_scrollbar_none: Advanced Table Scrollbar None
62
+ - advanced_table_row_styling: Row Styling
62
63
  - advanced_table_column_styling: Column Styling
63
64
  - advanced_table_column_styling_column_headers: Column Styling with Multiple Headers
64
- - advanced_table_infinite_scroll: Infinite Scroll
@@ -34,6 +34,6 @@ export { default as AdvancedTableColumnVisibilityMulti } from './_advanced_table
34
34
  export { default as AdvancedTableColumnVisibilityWithState } from './_advanced_table_column_visibility_with_state.jsx'
35
35
  export { default as AdvancedTablePinnedRows } from './_advanced_table_pinned_rows.jsx'
36
36
  export { default as AdvancedTableScrollbarNone} from './_advanced_table_scrollbar_none.jsx'
37
+ export { default as AdvancedTableRowStyling } from './_advanced_table_row_styling.jsx'
37
38
  export { default as AdvancedTableColumnStyling } from './_advanced_table_column_styling.jsx'
38
39
  export { default as AdvancedTableColumnStylingColumnHeaders } from './_advanced_table_column_styling_column_headers.jsx'
39
- export { default as AdvancedTableInfiniteScroll} from './_advanced_table_infinite_scroll.jsx'