playbook_ui 13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2023 → 13.16.0.pre.alpha.PLAY11641991

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +12 -14
  3. data/app/pb_kits/playbook/index.js +1 -2
  4. data/app/pb_kits/playbook/pb_flex/_flex.tsx +1 -1
  5. data/app/pb_kits/playbook/pb_icon/_icon.tsx +28 -16
  6. data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.html.erb +5 -11
  7. data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.jsx +44 -18
  8. data/app/pb_kits/playbook/pb_icon/docs/_icon_custom.md +7 -12
  9. data/app/pb_kits/playbook/pb_icon/icon.html.erb +6 -4
  10. data/app/pb_kits/playbook/pb_icon/icon.rb +10 -10
  11. data/app/pb_kits/playbook/pb_label_value/_label_value.tsx +1 -1
  12. data/app/pb_kits/playbook/pb_layout/_layout.tsx +1 -2
  13. data/app/pb_kits/playbook/pb_layout/layout.test.js +4 -8
  14. data/app/pb_kits/playbook/pb_legend/_legend.tsx +6 -6
  15. data/app/pb_kits/playbook/pb_lightbox/Carousel/Slides.tsx +4 -4
  16. data/app/pb_kits/playbook/pb_lightbox/Carousel/Thumbnail.tsx +1 -1
  17. data/app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx +3 -3
  18. data/app/pb_kits/playbook/pb_lightbox/Header/_lightbox_header.tsx +22 -30
  19. data/app/pb_kits/playbook/pb_lightbox/_lightbox.tsx +5 -5
  20. data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +4 -4
  21. data/app/pb_kits/playbook/pb_list/_list.tsx +15 -15
  22. data/app/pb_kits/playbook/pb_list/_list_item.tsx +1 -1
  23. data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.tsx +9 -9
  24. data/app/pb_kits/playbook/pb_map/_map.tsx +8 -8
  25. data/app/pb_kits/playbook/pb_map/_map_controls.tsx +7 -15
  26. data/app/pb_kits/playbook/pb_map/_map_custom_button.tsx +2 -4
  27. data/app/pb_kits/playbook/pb_message/_message.tsx +1 -1
  28. data/app/pb_kits/playbook/pb_message/_message_mention.tsx +6 -6
  29. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +42 -46
  30. data/app/pb_kits/playbook/pb_multiple_users_stacked/_multiple_users_stacked.tsx +20 -20
  31. data/app/pb_kits/playbook/pb_nav/_item.tsx +47 -56
  32. data/app/pb_kits/playbook/pb_nav/_nav.tsx +15 -15
  33. data/app/pb_kits/playbook/pb_table/_table.tsx +29 -29
  34. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +1 -1
  35. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.jsx +2 -4
  36. data/app/pb_kits/playbook/playbook-doc.js +0 -2
  37. data/app/pb_kits/playbook/utilities/globalProps.ts +1 -1
  38. data/dist/menu.yml +1 -4
  39. data/dist/playbook-rails.js +6 -14
  40. data/lib/playbook/version.rb +1 -1
  41. metadata +2 -28
  42. data/app/pb_kits/playbook/pb_advanced_table/Components/CollapsibleTrail.tsx +0 -30
  43. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +0 -59
  44. data/app/pb_kits/playbook/pb_advanced_table/Components/LoadingCell.tsx +0 -5
  45. data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +0 -30
  46. data/app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx +0 -61
  47. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +0 -128
  48. data/app/pb_kits/playbook/pb_advanced_table/Components/ToggleIconButton.tsx +0 -28
  49. data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +0 -5
  50. data/app/pb_kits/playbook/pb_advanced_table/README.md +0 -133
  51. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +0 -95
  52. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +0 -51
  53. data/app/pb_kits/playbook/pb_advanced_table/Utilities/BrowserCheck.tsx +0 -5
  54. data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +0 -63
  55. data/app/pb_kits/playbook/pb_advanced_table/Utilities/IconHelpers.tsx +0 -8
  56. data/app/pb_kits/playbook/pb_advanced_table/Utilities/types.ts +0 -8
  57. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +0 -98
  58. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +0 -245
  59. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +0 -56
  60. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx +0 -49
  61. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +0 -13
  62. data/app/pb_kits/playbook/pb_advanced_table/docs/_description.md +0 -1
  63. data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data.js +0 -278
  64. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -5
  65. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +0 -1
  66. data/app/pb_kits/playbook/pb_advanced_table/scss_partials/_loading.scss +0 -71
  67. data/app/pb_kits/playbook/pb_advanced_table/scss_partials/_pseudo_states.scss +0 -12
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "13.16.0"
5
- VERSION = "13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2023"
5
+ VERSION = "13.16.0.pre.alpha.PLAY11641991"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.16.0.pre.alpha.PBNTR177NewAdvancedTableKit2023
4
+ version: 13.16.0.pre.alpha.PLAY11641991
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-01-29 00:00:00.000000000 Z
12
+ date: 2024-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -269,32 +269,6 @@ files:
269
269
  - app/pb_kits/playbook/_playbook.scss
270
270
  - app/pb_kits/playbook/_reset.scss
271
271
  - app/pb_kits/playbook/index.js
272
- - app/pb_kits/playbook/pb_advanced_table/Components/CollapsibleTrail.tsx
273
- - app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx
274
- - app/pb_kits/playbook/pb_advanced_table/Components/LoadingCell.tsx
275
- - app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx
276
- - app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
277
- - app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx
278
- - app/pb_kits/playbook/pb_advanced_table/Components/ToggleIconButton.tsx
279
- - app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx
280
- - app/pb_kits/playbook/pb_advanced_table/README.md
281
- - app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx
282
- - app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
283
- - app/pb_kits/playbook/pb_advanced_table/Utilities/BrowserCheck.tsx
284
- - app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx
285
- - app/pb_kits/playbook/pb_advanced_table/Utilities/IconHelpers.tsx
286
- - app/pb_kits/playbook/pb_advanced_table/Utilities/types.ts
287
- - app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss
288
- - app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx
289
- - app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx
290
- - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx
291
- - app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md
292
- - app/pb_kits/playbook/pb_advanced_table/docs/_description.md
293
- - app/pb_kits/playbook/pb_advanced_table/docs/_mock_data.js
294
- - app/pb_kits/playbook/pb_advanced_table/docs/example.yml
295
- - app/pb_kits/playbook/pb_advanced_table/docs/index.js
296
- - app/pb_kits/playbook/pb_advanced_table/scss_partials/_loading.scss
297
- - app/pb_kits/playbook/pb_advanced_table/scss_partials/_pseudo_states.scss
298
272
  - app/pb_kits/playbook/pb_avatar/_avatar.scss
299
273
  - app/pb_kits/playbook/pb_avatar/_avatar.tsx
300
274
  - app/pb_kits/playbook/pb_avatar/avatar.html.erb
@@ -1,30 +0,0 @@
1
- import React from "react"
2
-
3
- //CollapsibleTrail component
4
- const CollapsibleTrail = ({ leftOffset }: { leftOffset: number }) => {
5
- const style: { [key: string]: string | number } = {
6
- position: "absolute",
7
- left: `${leftOffset}rem`,
8
- top: 0,
9
- bottom: 0,
10
- width: "2px",
11
- backgroundColor: "#E4E8F0",
12
- }
13
-
14
- return <div style={style} />
15
- }
16
-
17
- // Updated function to render multiple trails depending on depth
18
- export const renderCollapsibleTrail = (currentDepth: number) => {
19
- const lines = []
20
- for (let i = 1; i <= currentDepth; i++) {
21
- // Calculate leftOffset with additional 0.4rem for each depth level above 1
22
- const additionalOffset = i > 1 ? (i - 1) * 0.4 : 0
23
- const leftOffset = i * 1.6 + additionalOffset
24
- lines.push(<CollapsibleTrail key={i}
25
- leftOffset={leftOffset}
26
- />
27
- )
28
- }
29
- return lines
30
- }
@@ -1,59 +0,0 @@
1
- import React, { useContext } from "react";
2
-
3
- import Flex from "../../pb_flex/_flex";
4
- import FlexItem from "../../pb_flex/_flex_item";
5
- import Icon from "../../pb_icon/_icon";
6
- import { GlobalProps } from "../../utilities/globalProps";
7
-
8
- import { Getter, Row } from "@tanstack/react-table";
9
- import { DataType } from "../Utilities/types";
10
- import AdvancedTableContext from "../Context/AdvancedTableContext";
11
-
12
- interface CustomCellProps {
13
- getValue?: Getter<string>;
14
- onRowToggleClick?: (arg: Row<DataType>) => void;
15
- row: Row<DataType>;
16
- value?: string;
17
- }
18
-
19
- export const CustomCell = ({
20
- getValue,
21
- onRowToggleClick,
22
- row,
23
- value,
24
- }: CustomCellProps & GlobalProps) => {
25
- const { setExpanded, expanded } = useContext(AdvancedTableContext);
26
- const RowWithoutChildren = row.originalSubRows === undefined;
27
-
28
- const handleOnExpand = (row: Row<DataType>) => {
29
- onRowToggleClick && onRowToggleClick(row);
30
- setExpanded({ ...expanded, [row.id]: !row.getIsExpanded() });
31
- };
32
-
33
- return (
34
- <div style={{ paddingLeft: `${row.depth * 2}rem` }}>
35
- <Flex alignItems="center"
36
- columnGap="xs"
37
- orientation="row"
38
- >
39
- {!RowWithoutChildren ? (
40
- <button
41
- className="gray-icon expand-toggle-icon"
42
- onClick={() => handleOnExpand(row)}
43
- >
44
- {row.getIsExpanded() ? (
45
- <Icon icon="circle-play"
46
- rotation={90}
47
- />
48
- ) : (
49
- <Icon icon="circle-play" />
50
- )}
51
- </button>
52
- ) : null}
53
- <FlexItem paddingLeft={!RowWithoutChildren ? "none" : "xs"}>
54
- {row.depth === 0 ? getValue() : value}
55
- </FlexItem>
56
- </Flex>
57
- </div>
58
- );
59
- };
@@ -1,5 +0,0 @@
1
- import React from "react"
2
-
3
- export const LoadingCell = () => {
4
- return <div className="loading-cell" />
5
- }
@@ -1,30 +0,0 @@
1
- import React from "react"
2
- import Icon from "../../pb_icon/_icon"
3
- import { Header } from "@tanstack/react-table"
4
- import { DataType } from "../Utilities/types"
5
- import { displayIcon } from "../Utilities/IconHelpers"
6
-
7
- type SortIconButtonProps = {
8
- header: Header<DataType, unknown>
9
- sortIcon?: string | string[]
10
- }
11
- export const SortIconButton = ({ header, sortIcon }: SortIconButtonProps) => {
12
-
13
- return (
14
- <>
15
- {header.column.getIsSorted() === "desc" ? (
16
- <div className="year-sort-icon"
17
- key={displayIcon(sortIcon)[0]}
18
- >
19
- <Icon icon={displayIcon(sortIcon)[0]} />
20
- </div>
21
- ) : (
22
- <div className="year-sort-icon"
23
- key={displayIcon(sortIcon)[1]}
24
- >
25
- <Icon icon={displayIcon(sortIcon)[1]} />
26
- </div>
27
- )}
28
- </>
29
- )
30
- }
@@ -1,61 +0,0 @@
1
- import React from "react"
2
- import Flex from "../../pb_flex/_flex"
3
- import Caption from "../../pb_caption/_caption"
4
- import { Row, Table } from "@tanstack/react-table"
5
-
6
- import { ToggleIconButton } from "./ToggleIconButton"
7
- import { renderCollapsibleTrail } from "./CollapsibleTrail"
8
-
9
- import { isChrome } from "../Utilities/BrowserCheck"
10
- import { DataType } from "../Utilities/types"
11
- import { GlobalProps } from "../../utilities/globalProps"
12
-
13
- interface SubRowHeaderRowProps {
14
- collapsibleTrail?: boolean
15
- enableToggleExpansion?: "all" | "header"
16
- onClick: (row: Row<DataType>) => void
17
- row: Row<DataType>
18
- subRowHeaders?: string[]
19
- table: Table<DataType>
20
- }
21
-
22
- export const SubRowHeaderRow = ({
23
- collapsibleTrail,
24
- enableToggleExpansion,
25
- onClick,
26
- row,
27
- subRowHeaders,
28
- table,
29
- }: SubRowHeaderRowProps & GlobalProps) => {
30
- const numberOfColumns = table.getAllFlatColumns().length
31
-
32
- return (
33
- <tr className="custom-row bg-silver">
34
- <td
35
- className={`custom-row-first-column ${
36
- isChrome() ? "chrome-styles" : ""
37
- }`}
38
- colSpan={1}
39
- >
40
- {collapsibleTrail && row.depth > 0 && renderCollapsibleTrail(row.depth)}
41
- <div style={{ paddingLeft: `${row.depth * 2}rem` }}>
42
- <Flex align="center"
43
- columnGap="xs"
44
- >
45
- {enableToggleExpansion === "all" && row.getCanExpand() ? (
46
- <ToggleIconButton onClick={onClick}
47
- row={row}
48
- />
49
- ) : null}
50
- <Caption
51
- marginLeft={row.getCanExpand() ? "none" : "xs"}
52
- text={subRowHeaders[row.depth - 1]}
53
- />
54
- </Flex>
55
- </div>
56
- </td>
57
-
58
- <td colSpan={numberOfColumns - 1} />
59
- </tr>
60
- )
61
- }
@@ -1,128 +0,0 @@
1
- import React, { useContext } from "react"
2
- import classnames from "classnames";
3
- import Flex from "../../pb_flex/_flex"
4
- import { flexRender, Header } from "@tanstack/react-table"
5
-
6
- import { SortIconButton } from "./SortIconButton"
7
- import { ToggleIconButton } from "./ToggleIconButton"
8
- import { isChrome } from "../Utilities/BrowserCheck"
9
- import { DataType } from "../Utilities/types"
10
- import AdvancedTableContext from "../Context/AdvancedTableContext"
11
- import { GlobalProps } from "../../utilities/globalProps"
12
-
13
- type TableHeaderCellProps = {
14
- enableSorting?: boolean
15
- enableToggleExpansion?: "all" | "header"
16
- handleExpandOrCollapse?: () => void
17
- header?: Header<DataType, unknown>
18
- headerChildren?: React.ReactNode | React.ReactNode[]
19
- headerId?: string
20
- loading?: boolean
21
- sortIcon?: string | string[]
22
- } & GlobalProps
23
-
24
- export const TableHeaderCell = ({
25
- enableSorting,
26
- enableToggleExpansion,
27
- handleExpandOrCollapse,
28
- header,
29
- headerChildren,
30
- headerId,
31
- loading,
32
- sortIcon,
33
- }: TableHeaderCellProps) => {
34
- const { sortControl } = useContext(AdvancedTableContext)
35
-
36
- const toggleSortButton = (event: React.SyntheticEvent) => {
37
- if (sortControl) {
38
- const sortIsDesc = header.column.getIsSorted() === "desc"
39
- sortIsDesc
40
- ? sortControl.onChange({ desc: true })
41
- : sortControl.onChange({ desc: false })
42
- } else {
43
- header.column.getToggleSortingHandler()(event)
44
- }
45
- }
46
-
47
- const cellClassName = classnames("table-header-cells",
48
- `${isChrome() ? "chrome-styles" : ""}`,
49
- `${enableSorting ? "table-header-cells-active" : ""}`
50
- );
51
-
52
- const cellId = `${loading ?
53
- `loading-${header.id}${headerId ? `-${headerId}` : ""}`
54
- : `${header.id}${headerId ? `-${headerId}` : ""}`
55
- }`;
56
-
57
- return (
58
- <th
59
- align="right"
60
- className={cellClassName}
61
- id={cellId}
62
- key={`${header.id}-header`}
63
- >
64
- {header.isPlaceholder ? null : headerChildren && header.index === 0 ? (
65
- <Flex alignItems="center">
66
- {headerChildren}
67
- <div>
68
- {flexRender(header.column.columnDef.header, header.getContext())}
69
- </div>
70
- </Flex>
71
- ) : (
72
- <Flex
73
- alignItems="center"
74
- justify={header.index === 0 && enableSorting ? "between" : header.index === 0 && !enableSorting ? "start" : "end"}
75
- paddingLeft={loading ? "sm" : "none"}
76
- >
77
- {header.index === 0 &&
78
- !loading &&
79
- (enableToggleExpansion === "all" || "header") && (
80
- <ToggleIconButton onClick={handleExpandOrCollapse} />
81
- )}
82
-
83
- {header.index === 0 &&
84
- loading &&
85
- (enableToggleExpansion === "all" || "header") && (
86
- <div className="loading-toggle-icon header-toggle-icon" />
87
- )}
88
-
89
- <Flex
90
- className={`${header.index === 0 &&
91
- enableSorting &&
92
- "header-sort-button pb_th_link"}`}
93
- cursor={header.index === 0 && enableSorting ? "pointer" : "default"}
94
- {...(header.index === 0 &&
95
- enableSorting && {
96
- htmlOptions: {
97
- onClick: (event: React.MouseEvent) => toggleSortButton(event),
98
- onKeyDown: (event: React.KeyboardEvent) => {
99
- if (event.key === "Enter") {
100
- toggleSortButton(event)
101
- }
102
- },
103
- tabIndex: 0,
104
- },
105
- })}
106
- justify={header.index === 0 && enableSorting ? "between" : "none"}
107
- paddingLeft={enableSorting ? "xxs" : "xs"}
108
- >
109
- <div>
110
- {flexRender(header.column.columnDef.header, header.getContext())}
111
- </div>
112
-
113
- {header.index === 0 &&
114
- header.column.getCanSort() &&
115
- enableSorting &&
116
- (loading ? (
117
- <div className="loading-toggle-icon header-sort-icon" />
118
- ) : (
119
- <SortIconButton header={header}
120
- sortIcon={sortIcon}
121
- />
122
- ))}
123
- </Flex>
124
- </Flex>
125
- )}
126
- </th>
127
- )
128
- }
@@ -1,28 +0,0 @@
1
- import React, { useContext } from "react"
2
- import Icon from "../../pb_icon/_icon"
3
- import { Row } from "@tanstack/react-table"
4
- import AdvancedTableContext from "../Context/AdvancedTableContext"
5
- import { DataType } from "../Utilities/types"
6
- import { displayIcon } from "../Utilities/IconHelpers"
7
-
8
- interface ToggleIconButtonProps {
9
- onClick: (row: Row<DataType>) => void
10
- row?: Row<DataType>
11
- }
12
-
13
- export const ToggleIconButton = ({ row, onClick }: ToggleIconButtonProps) => {
14
- const { toggleExpansionIcon } = useContext(AdvancedTableContext)
15
- return (
16
- <button
17
- className="gray-icon time-period-toggle-icon"
18
- key={displayIcon(toggleExpansionIcon)[0]}
19
- onClick={() => onClick(row)}
20
- >
21
- <Icon
22
- cursor="pointer"
23
- fixedWidth
24
- icon={displayIcon(toggleExpansionIcon)[0]}
25
- />
26
- </button>
27
- )
28
- }
@@ -1,5 +0,0 @@
1
- import { createContext } from "react"
2
-
3
- const AdvancedTableContext = createContext<any>({})
4
-
5
- export default AdvancedTableContext
@@ -1,133 +0,0 @@
1
- # Advanced Table Kit Data Structure
2
-
3
- The AdvancedTable Kit's `tableData` prop consumes the data that will render the table and as such has a specific structure. It must be an array of objects, where the key/value pairs will become the values rendered within each column. If children are present, they must also take the form of an array of objects. The kit will automatically render `children` as subRows.
4
-
5
- Here is the data structure being used within the kits doc examples:
6
-
7
- ```
8
- MOCK_DATA = [
9
- {
10
- year: "2021",
11
- quarter: null,
12
- month: null,
13
- day: null,
14
- newEnrollments: "20",
15
- scheduledMeetings: "10",
16
- attendanceRate: "51%",
17
- completedClasses: "3",
18
- classCompletionRate: "33%",
19
- graduatedStudents: "19",
20
- children: [
21
- {
22
- year: "2021",
23
- quarter: "Q1",
24
- month: null,
25
- day: null,
26
- newEnrollments: "2",
27
- scheduledMeetings: "35",
28
- attendanceRate: "32%",
29
- completedClasses: "15",
30
- classCompletionRate: "52%",
31
- graduatedStudents: "36",
32
- children: [
33
- {
34
- year: "2021",
35
- quarter: "Q1",
36
- month: "January",
37
- day: null,
38
- newEnrollments: "16",
39
- scheduledMeetings: "20",
40
- attendanceRate: "11%",
41
- completedClasses: "13",
42
- classCompletionRate: "47%",
43
- graduatedStudents: "28",
44
- children: [
45
- {
46
- year: "2021",
47
- quarter: "Q1",
48
- month: "January",
49
- day: "10",
50
- newEnrollments: "34",
51
- scheduledMeetings: "28",
52
- attendanceRate: "97%",
53
- completedClasses: "20",
54
- classCompletionRate: "15%",
55
- graduatedStudents: "17",
56
- },
57
- {
58
- year: "2021",
59
- quarter: "Q1",
60
- month: "January",
61
- day: "20",
62
- newEnrollments: "43",
63
- scheduledMeetings: "23",
64
- attendanceRate: "66%",
65
- completedClasses: "26",
66
- classCompletionRate: "47%",
67
- graduatedStudents: "9",
68
- },
69
- ],
70
- },
71
- {
72
- year: "2021",
73
- quarter: "Q1",
74
- month: "February",
75
- day: null,
76
- newEnrollments: "20",
77
- scheduledMeetings: "41",
78
- attendanceRate: "95%",
79
- completedClasses: "26",
80
- classCompletionRate: "83%",
81
- graduatedStudents: "43",
82
- children: [
83
- {
84
- year: "2011",
85
- quarter: "Q1",
86
- month: "February",
87
- day: "15",
88
- newEnrollments: "19",
89
- scheduledMeetings: "35",
90
- attendanceRate: "69%",
91
- completedClasses: "8",
92
- classCompletionRate: "75%",
93
- graduatedStudents: "23",
94
- },
95
- ],
96
- },
97
- ],
98
- },
99
- ],
100
- },
101
- {
102
- year: "2022",
103
- quarter: null,
104
- month: null,
105
- day: null,
106
- newEnrollments: "25",
107
- scheduledMeetings: "17",
108
- attendanceRate: "75%",
109
- completedClasses: "5",
110
- classCompletionRate: "45%",
111
- graduatedStudents: "32",
112
- children: [
113
- //similar to chldren above
114
- ]
115
- },
116
- {
117
- year: "2023",
118
- quarter: null,
119
- month: null,
120
- day: null,
121
- newEnrollments: "10",
122
- scheduledMeetings: "15",
123
- attendanceRate: "65%",
124
- completedClasses: "4",
125
- classCompletionRate: "49%",
126
- graduatedStudents: "29",
127
- children: [
128
- //similar to children above
129
- ],
130
- },
131
- ];
132
-
133
- ```
@@ -1,95 +0,0 @@
1
- import React, { useContext } from "react"
2
- import LoadingInline from "../../pb_loading_inline/_loading_inline"
3
- import { flexRender, Row } from "@tanstack/react-table"
4
-
5
- import { SubRowHeaderRow } from "../Components/SubRowHeaderRow"
6
- import { LoadingCell } from "../Components/LoadingCell"
7
- import { renderCollapsibleTrail } from "../Components/CollapsibleTrail"
8
- import AdvancedTableContext from "../Context/AdvancedTableContext"
9
- import { isChrome } from "../Utilities/BrowserCheck"
10
- import { DataType } from "../Utilities/types"
11
-
12
- type TableBodyProps = {
13
- collapsibleTrail?: boolean
14
- subRowHeaders?: string[]
15
- }
16
-
17
- export const TableBody = ({
18
- collapsibleTrail = true,
19
- subRowHeaders,
20
- }: TableBodyProps) => {
21
- const {
22
- enableToggleExpansion,
23
- handleExpandOrCollapse,
24
- loading,
25
- table,
26
- } = useContext(AdvancedTableContext)
27
- return (
28
- <>
29
- <tbody>
30
- {table.getRowModel().rows.map((row: Row<DataType>) => {
31
- const isExpandable = row.getIsExpanded()
32
- const isFirstChildofSubrow = row.depth > 0 && row.index === 0
33
- const rowHasNoChildren = !row.original.children?.length
34
- const numberOfColumns = table.getAllFlatColumns().length
35
-
36
- return (
37
- <React.Fragment key={`${row.index}-${row.id}-${row.depth}-row`}>
38
- {isFirstChildofSubrow && subRowHeaders && (
39
- <SubRowHeaderRow
40
- collapsibleTrail={collapsibleTrail}
41
- enableToggleExpansion={enableToggleExpansion}
42
- onClick={handleExpandOrCollapse}
43
- row={row}
44
- subRowHeaders={subRowHeaders}
45
- table={table}
46
- />
47
- )}
48
-
49
- <tr
50
- className={`${isExpandable ? "bg-silver" : "bg-white"} ${
51
- row.depth > 0 ? `depth-sub-row-${row.depth}` : ""
52
- }`}
53
- id={`${row.index}-${row.id}-${row.depth}-row`}
54
- >
55
- {row.getVisibleCells().map((cell, i) => (
56
- <td
57
- align="right"
58
- className={`${cell.id}-cell position_relative ${
59
- isChrome() ? "chrome-styles" : ""
60
- }`}
61
- key={`${cell.id}-data`}
62
- >
63
- {collapsibleTrail &&
64
- i === 0 &&
65
- row.depth > 0 &&
66
- renderCollapsibleTrail(row.depth)}
67
- <span id={`${cell.id}-span`}>
68
- {loading ? (
69
- <LoadingCell />
70
- ) : (
71
- flexRender(
72
- cell.column.columnDef.cell,
73
- cell.getContext()
74
- )
75
- )}
76
- </span>
77
- </td>
78
- ))}
79
- </tr>
80
-
81
- {/* Display LoadingInline if Row Data is querying and there are no children already */}
82
- {isExpandable && rowHasNoChildren && row.depth === 0 ? (
83
- <tr key={`${row.id}-row`}>
84
- <td colSpan={numberOfColumns}>
85
- <LoadingInline />
86
- </td>
87
- </tr>
88
- ) : null}
89
- </React.Fragment>
90
- )
91
- })}
92
- </tbody>
93
- </>
94
- )
95
- }