playbook_ui 13.16.0.pre.alpha.PLAY12002127 → 13.16.0.pre.alpha.fonttest1972
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +12 -14
- data/app/pb_kits/playbook/index.js +1 -2
- data/app/pb_kits/playbook/pb_flex/_flex.tsx +1 -1
- data/app/pb_kits/playbook/pb_label_value/_label_value.tsx +1 -1
- data/app/pb_kits/playbook/pb_layout/_layout.tsx +1 -2
- data/app/pb_kits/playbook/pb_layout/layout.test.js +4 -8
- data/app/pb_kits/playbook/pb_legend/_legend.tsx +6 -6
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Slides.tsx +4 -4
- data/app/pb_kits/playbook/pb_lightbox/Carousel/Thumbnail.tsx +1 -1
- data/app/pb_kits/playbook/pb_lightbox/Carousel/index.tsx +3 -3
- data/app/pb_kits/playbook/pb_lightbox/Header/_lightbox_header.tsx +22 -30
- data/app/pb_kits/playbook/pb_lightbox/_lightbox.tsx +5 -5
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +4 -4
- data/app/pb_kits/playbook/pb_list/_list.tsx +15 -15
- data/app/pb_kits/playbook/pb_list/_list_item.tsx +1 -1
- data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.tsx +9 -9
- data/app/pb_kits/playbook/pb_map/_map.tsx +8 -8
- data/app/pb_kits/playbook/pb_map/_map_controls.tsx +7 -15
- data/app/pb_kits/playbook/pb_map/_map_custom_button.tsx +2 -4
- data/app/pb_kits/playbook/pb_message/_message.tsx +1 -1
- data/app/pb_kits/playbook/pb_message/_message_mention.tsx +6 -6
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +42 -46
- data/app/pb_kits/playbook/pb_multiple_users_stacked/_multiple_users_stacked.tsx +20 -20
- data/app/pb_kits/playbook/pb_nav/_item.tsx +47 -56
- data/app/pb_kits/playbook/pb_nav/_nav.tsx +15 -15
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.html.erb +7 -5
- data/app/pb_kits/playbook/pb_popover/_popover.tsx +14 -12
- data/app/pb_kits/playbook/pb_popover/docs/example.yml +1 -2
- data/app/pb_kits/playbook/pb_popover/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_table/_table.tsx +29 -29
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.jsx +2 -4
- data/app/pb_kits/playbook/playbook-doc.js +0 -2
- data/app/pb_kits/playbook/utilities/globalProps.ts +1 -1
- data/dist/menu.yml +1 -4
- data/dist/playbook-rails.js +6 -14
- data/lib/playbook/version.rb +1 -1
- metadata +2 -46
- data/app/pb_kits/playbook/pb_advanced_table/Components/CollapsibleTrail.tsx +0 -30
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +0 -62
- data/app/pb_kits/playbook/pb_advanced_table/Components/LoadingCell.tsx +0 -5
- data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +0 -30
- data/app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx +0 -61
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +0 -127
- data/app/pb_kits/playbook/pb_advanced_table/Components/ToggleIconButton.tsx +0 -28
- data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +0 -5
- data/app/pb_kits/playbook/pb_advanced_table/README.md +0 -288
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +0 -95
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +0 -51
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/BrowserCheck.tsx +0 -5
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +0 -63
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/IconHelpers.tsx +0 -8
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/types.ts +0 -8
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +0 -98
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +0 -246
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +0 -56
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.jsx +0 -52
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx +0 -49
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +0 -18
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.jsx +0 -59
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.md +0 -18
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.jsx +0 -60
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.md +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.jsx +0 -52
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.md +0 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.jsx +0 -63
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.md +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.jsx +0 -57
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.md +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.jsx +0 -61
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.md +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +0 -55
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_description.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data.js +0 -278
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -12
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +0 -9
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/_loading.scss +0 -72
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/_pseudo_states.scss +0 -12
- data/app/pb_kits/playbook/pb_popover/docs/_popover_actionable_content.html.erb +0 -30
- data/app/pb_kits/playbook/pb_popover/docs/_popover_actionable_content.jsx +0 -57
@@ -1,246 +0,0 @@
|
|
1
|
-
import React, { useState, useEffect, useCallback } from "react";
|
2
|
-
import classnames from "classnames";
|
3
|
-
import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
|
4
|
-
import { globalProps, GlobalProps } from "../utilities/globalProps";
|
5
|
-
import Table from "../pb_table/_table";
|
6
|
-
import {
|
7
|
-
createColumnHelper,
|
8
|
-
getCoreRowModel,
|
9
|
-
getExpandedRowModel,
|
10
|
-
getSortedRowModel,
|
11
|
-
Row,
|
12
|
-
useReactTable,
|
13
|
-
Getter,
|
14
|
-
} from "@tanstack/react-table";
|
15
|
-
|
16
|
-
import { updateExpandAndCollapseState } from "./Utilities/ExpansionControlHelpers";
|
17
|
-
|
18
|
-
import { CustomCell } from "./Components/CustomCell";
|
19
|
-
import AdvancedTableContext from "./Context/AdvancedTableContext";
|
20
|
-
import { TableHeader } from "./SubKits/TableHeader";
|
21
|
-
import { TableBody } from "./SubKits/TableBody";
|
22
|
-
|
23
|
-
import { DataType, ExpandedStateObject } from "./Utilities/types";
|
24
|
-
|
25
|
-
type AdvancedTableProps = {
|
26
|
-
aria?: { [key: string]: string };
|
27
|
-
children?: React.ReactNode | React.ReactNode[];
|
28
|
-
className?: string;
|
29
|
-
columnDefinitions: DataType[];
|
30
|
-
data?: { [key: string]: string };
|
31
|
-
enableToggleExpansion?: "all" | "header";
|
32
|
-
expandedControl?: DataType;
|
33
|
-
id?: string;
|
34
|
-
initialLoadingRowsCount?: number;
|
35
|
-
loading?: boolean | string;
|
36
|
-
onRowToggleClick?: (arg: Row<DataType>) => void;
|
37
|
-
onToggleExpansionClick?: (arg: Row<DataType>) => void;
|
38
|
-
sortControl?: DataType;
|
39
|
-
tableData: DataType[];
|
40
|
-
tableOptions?: DataType;
|
41
|
-
tableProps?: DataType;
|
42
|
-
toggleExpansionIcon?: string | string[];
|
43
|
-
} & GlobalProps;
|
44
|
-
|
45
|
-
const AdvancedTable = (props: AdvancedTableProps) => {
|
46
|
-
const {
|
47
|
-
aria = {},
|
48
|
-
children,
|
49
|
-
className,
|
50
|
-
columnDefinitions,
|
51
|
-
data = {},
|
52
|
-
enableToggleExpansion = "header",
|
53
|
-
expandedControl,
|
54
|
-
id,
|
55
|
-
initialLoadingRowsCount = 10,
|
56
|
-
loading,
|
57
|
-
onRowToggleClick,
|
58
|
-
onToggleExpansionClick,
|
59
|
-
sortControl,
|
60
|
-
tableData,
|
61
|
-
tableOptions,
|
62
|
-
tableProps,
|
63
|
-
toggleExpansionIcon = "arrows-from-line",
|
64
|
-
} = props;
|
65
|
-
|
66
|
-
const [loadingStateRowCount, setLoadingStateRowCount] = useState(
|
67
|
-
initialLoadingRowsCount
|
68
|
-
);
|
69
|
-
|
70
|
-
// Create a local state for expanded and setExpanded if expandedControl not used
|
71
|
-
const [localExpanded, setLocalExpanded] = useState({});
|
72
|
-
|
73
|
-
// Determine whether to use the prop or the local state
|
74
|
-
const expanded = expandedControl ? expandedControl.value : localExpanded;
|
75
|
-
const setExpanded = expandedControl
|
76
|
-
? expandedControl.onChange
|
77
|
-
: setLocalExpanded;
|
78
|
-
|
79
|
-
const columnHelper = createColumnHelper<DataType>();
|
80
|
-
|
81
|
-
//Create cells for first columns
|
82
|
-
const createCellFunction = (cellAccessors: string[]) => {
|
83
|
-
const columnCells = ({
|
84
|
-
row,
|
85
|
-
getValue,
|
86
|
-
}: {
|
87
|
-
row: Row<DataType>;
|
88
|
-
getValue: Getter<string>;
|
89
|
-
}) => {
|
90
|
-
const rowData = row.original;
|
91
|
-
|
92
|
-
switch (row.depth) {
|
93
|
-
case 0: {
|
94
|
-
return (
|
95
|
-
<CustomCell
|
96
|
-
getValue={getValue}
|
97
|
-
onRowToggleClick={onRowToggleClick}
|
98
|
-
row={row}
|
99
|
-
/>
|
100
|
-
);
|
101
|
-
}
|
102
|
-
default: {
|
103
|
-
// Handle other depths based on cellAccessors
|
104
|
-
const depthAccessor = cellAccessors[row.depth - 1]; // Adjust index for depth
|
105
|
-
const accessorValue = rowData[depthAccessor];
|
106
|
-
return accessorValue ? (
|
107
|
-
<CustomCell row={row}
|
108
|
-
value={accessorValue}
|
109
|
-
/>
|
110
|
-
) : (
|
111
|
-
"N/A"
|
112
|
-
);
|
113
|
-
}
|
114
|
-
}
|
115
|
-
};
|
116
|
-
|
117
|
-
return columnCells;
|
118
|
-
};
|
119
|
-
|
120
|
-
//Create column array in format needed by Tanstack
|
121
|
-
const columns =
|
122
|
-
columnDefinitions &&
|
123
|
-
columnDefinitions.map((column) => {
|
124
|
-
// Define the base column structure
|
125
|
-
const columnStructure = {
|
126
|
-
...columnHelper.accessor(column.accessor, {
|
127
|
-
header: column.label,
|
128
|
-
}),
|
129
|
-
};
|
130
|
-
if (column.cellAccessors) {
|
131
|
-
columnStructure.cell = createCellFunction(column.cellAccessors);
|
132
|
-
}
|
133
|
-
return columnStructure;
|
134
|
-
});
|
135
|
-
|
136
|
-
//Syntax for sorting Array if we want to manage state ourselves
|
137
|
-
const sorting = [
|
138
|
-
{
|
139
|
-
id: columnDefinitions[0].accessor,
|
140
|
-
desc:
|
141
|
-
sortControl && sortControl.value !== null
|
142
|
-
? !sortControl.value.desc
|
143
|
-
: false,
|
144
|
-
},
|
145
|
-
];
|
146
|
-
|
147
|
-
const expandAndSortState = () => {
|
148
|
-
if (sortControl) {
|
149
|
-
return { state: { expanded, sorting } };
|
150
|
-
} else {
|
151
|
-
return { state: { expanded } };
|
152
|
-
}
|
153
|
-
};
|
154
|
-
|
155
|
-
//initialize table
|
156
|
-
const table = useReactTable({
|
157
|
-
data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
|
158
|
-
columns,
|
159
|
-
onExpandedChange: setExpanded,
|
160
|
-
getSubRows: (row) => row.children,
|
161
|
-
getCoreRowModel: getCoreRowModel(),
|
162
|
-
getExpandedRowModel: getExpandedRowModel(),
|
163
|
-
getSortedRowModel: getSortedRowModel(),
|
164
|
-
enableSortingRemoval: false,
|
165
|
-
sortDescFirst: true,
|
166
|
-
...expandAndSortState(),
|
167
|
-
...tableOptions,
|
168
|
-
});
|
169
|
-
|
170
|
-
const tableRows = table.getRowModel();
|
171
|
-
|
172
|
-
// Set table row count for loading state
|
173
|
-
const updateLoadingStateRowCount = useCallback(() => {
|
174
|
-
const rowsCount = table.getRowModel().rows.length;
|
175
|
-
if (rowsCount !== loadingStateRowCount && rowsCount !== 0) {
|
176
|
-
setLoadingStateRowCount(rowsCount);
|
177
|
-
}
|
178
|
-
}, [tableData, loadingStateRowCount]);
|
179
|
-
|
180
|
-
useEffect(() => {
|
181
|
-
if (!loading) {
|
182
|
-
updateLoadingStateRowCount();
|
183
|
-
}
|
184
|
-
}, [loading, updateLoadingStateRowCount]);
|
185
|
-
|
186
|
-
const handleExpandOrCollapse = (row: Row<DataType>) => {
|
187
|
-
onToggleExpansionClick && onToggleExpansionClick(row);
|
188
|
-
|
189
|
-
const expandedState = expanded as ExpandedStateObject;
|
190
|
-
const targetParent = row?.parentId;
|
191
|
-
return setExpanded(
|
192
|
-
updateExpandAndCollapseState(tableRows, expandedState, targetParent)
|
193
|
-
);
|
194
|
-
};
|
195
|
-
|
196
|
-
const ariaProps = buildAriaProps(aria);
|
197
|
-
const dataProps = buildDataProps(data);
|
198
|
-
const classes = classnames(
|
199
|
-
buildCss("pb_advanced_table"),
|
200
|
-
globalProps(props),
|
201
|
-
className
|
202
|
-
);
|
203
|
-
|
204
|
-
return (
|
205
|
-
<div {...ariaProps}
|
206
|
-
{...dataProps}
|
207
|
-
className={classes}
|
208
|
-
id={id}
|
209
|
-
>
|
210
|
-
<AdvancedTableContext.Provider
|
211
|
-
value={{
|
212
|
-
table,
|
213
|
-
handleExpandOrCollapse,
|
214
|
-
loading,
|
215
|
-
enableToggleExpansion,
|
216
|
-
toggleExpansionIcon,
|
217
|
-
setExpanded,
|
218
|
-
expanded,
|
219
|
-
sortControl,
|
220
|
-
}}
|
221
|
-
>
|
222
|
-
<Table
|
223
|
-
className={`${loading ? "content-loading" : ""}`}
|
224
|
-
dataTable
|
225
|
-
numberSpacing="tabular"
|
226
|
-
responsive="none"
|
227
|
-
{...tableProps}
|
228
|
-
>
|
229
|
-
{children ? (
|
230
|
-
children
|
231
|
-
) : (
|
232
|
-
<>
|
233
|
-
<TableHeader />
|
234
|
-
<TableBody />
|
235
|
-
</>
|
236
|
-
)}
|
237
|
-
</Table>
|
238
|
-
</AdvancedTableContext.Provider>
|
239
|
-
</div>
|
240
|
-
);
|
241
|
-
};
|
242
|
-
|
243
|
-
AdvancedTable.Header = TableHeader;
|
244
|
-
AdvancedTable.Body = TableBody;
|
245
|
-
|
246
|
-
export default AdvancedTable;
|
@@ -1,56 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { render, screen } from "../utilities/test-utils";
|
3
|
-
|
4
|
-
import { AdvancedTable } from "../";
|
5
|
-
|
6
|
-
const MOCK_DATA = [
|
7
|
-
{
|
8
|
-
year: "2021",
|
9
|
-
quarter: null,
|
10
|
-
month: null,
|
11
|
-
day: null,
|
12
|
-
newEnrollments: "20",
|
13
|
-
scheduledMeetings: "10",
|
14
|
-
children: [
|
15
|
-
{
|
16
|
-
year: "2011",
|
17
|
-
quarter: "Q1",
|
18
|
-
month: null,
|
19
|
-
day: null,
|
20
|
-
newEnrollments: "2",
|
21
|
-
scheduledMeetings: "35",
|
22
|
-
},
|
23
|
-
],
|
24
|
-
},
|
25
|
-
];
|
26
|
-
|
27
|
-
const columnDefinitions = [
|
28
|
-
{
|
29
|
-
accessor: "year",
|
30
|
-
label: "Year",
|
31
|
-
cellAccessors: ["quarter", "month", "day"],
|
32
|
-
},
|
33
|
-
{
|
34
|
-
accessor: "newEnrollments",
|
35
|
-
label: "New Enrollments",
|
36
|
-
},
|
37
|
-
{
|
38
|
-
accessor: "scheduledMeetings",
|
39
|
-
label: "Scheduled Meetings",
|
40
|
-
},
|
41
|
-
];
|
42
|
-
|
43
|
-
const testId = "advanced_table";
|
44
|
-
|
45
|
-
test("generated scaffold test", () => {
|
46
|
-
render(
|
47
|
-
<AdvancedTable
|
48
|
-
columnDefinitions={columnDefinitions}
|
49
|
-
data={{ testid: testId }}
|
50
|
-
tableData={MOCK_DATA}
|
51
|
-
/>
|
52
|
-
);
|
53
|
-
|
54
|
-
const kit = screen.getByTestId(testId);
|
55
|
-
expect(kit).toBeInTheDocument();
|
56
|
-
});
|
@@ -1,52 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { AdvancedTable } from "../../";
|
3
|
-
import { MOCK_DATA } from "./_mock_data";
|
4
|
-
|
5
|
-
const AdvancedTableCollapsibleTrail = (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
|
-
<div>
|
40
|
-
<AdvancedTable
|
41
|
-
columnDefinitions={columnDefinitions}
|
42
|
-
tableData={MOCK_DATA}
|
43
|
-
{...props}
|
44
|
-
>
|
45
|
-
<AdvancedTable.Header />
|
46
|
-
<AdvancedTable.Body collapsibleTrail={false} />
|
47
|
-
</AdvancedTable>
|
48
|
-
</div>
|
49
|
-
);
|
50
|
-
};
|
51
|
-
|
52
|
-
export default AdvancedTableCollapsibleTrail;
|
@@ -1 +0,0 @@
|
|
1
|
-
`collapsibleTrail` is an optional prop that is set to 'true' by default. If set to 'false', it will remove the trail on the left of rows when subRows are toggled open.
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { AdvancedTable } from "../../";
|
3
|
-
import { MOCK_DATA } from "./_mock_data";
|
4
|
-
|
5
|
-
const AdvancedTableDefault = (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
|
-
<div>
|
40
|
-
<AdvancedTable
|
41
|
-
columnDefinitions={columnDefinitions}
|
42
|
-
tableData={MOCK_DATA}
|
43
|
-
{...props}
|
44
|
-
/>
|
45
|
-
</div>
|
46
|
-
);
|
47
|
-
};
|
48
|
-
|
49
|
-
export default AdvancedTableDefault;
|
@@ -1,18 +0,0 @@
|
|
1
|
-
The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has two required props__:
|
2
|
-
|
3
|
-
### tableData
|
4
|
-
|
5
|
-
`tableData` accepts an array of objects as the table data. Each object is a table row, and each key:value pair within an object is a column value within that row. Nested children within a data object are automatically rendered as subrows under their parent row. Each parent row is prepended with expansion controls for toggling its nested child rows. The `toggleExpansionAll` button in the first column header can also be used to toggle expansion of all parent rows within the table.
|
6
|
-
|
7
|
-
For a visual of the data structure needed for `tableData`, see [here](https://github.com/powerhome/playbook/tree/master/playbook/app/pb_kits/playbook/pb_advanced_table#readme).
|
8
|
-
|
9
|
-
### columnDefinitions
|
10
|
-
|
11
|
-
`columnDefinitions` maps to the columns prop on the Tanstack table. Column definitions are the single most important part of building a table as they are responsible for building the underlying data model that is used for all sorting, expansion, etc. `ColumnDefinitions` in the AdvancedTable kit is a array of objects as seen in the code snippet below. Each object within the array has two REQUIRED items:
|
12
|
-
|
13
|
-
- `accessor`: this is the key from your data for the value you want rendered in that column
|
14
|
-
- `label`: this is what will be rendered as the column header label
|
15
|
-
|
16
|
-
There is also one optional item that is only required if the table has nested data:
|
17
|
-
|
18
|
-
- `cellAccessors`: This is an array of strings that represent keys from your data object. This is only required for the first column in case of nested data. If you have nested data, the AdvancedTable needs to know what to render in that first column for nested items. This array represents the nested data in the order you want it rendered.
|
@@ -1,59 +0,0 @@
|
|
1
|
-
import React, { useState } from "react";
|
2
|
-
import { AdvancedTable } from "../../";
|
3
|
-
import { MOCK_DATA } from "./_mock_data";
|
4
|
-
|
5
|
-
const AdvancedTableExpandedControl = (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
|
-
//State for manually effecting what is expanded
|
39
|
-
const [expanded, setExpanded] = useState({'0': true, '0.0': true, '0.0.1': true})
|
40
|
-
|
41
|
-
//Passing expanded state to AdvancedTable as prop
|
42
|
-
const expandedControl = {
|
43
|
-
value: expanded,
|
44
|
-
onChange: setExpanded,
|
45
|
-
}
|
46
|
-
|
47
|
-
return (
|
48
|
-
<div>
|
49
|
-
<AdvancedTable
|
50
|
-
columnDefinitions={columnDefinitions}
|
51
|
-
expandedControl={expandedControl}
|
52
|
-
tableData={MOCK_DATA}
|
53
|
-
{...props}
|
54
|
-
/>
|
55
|
-
</div>
|
56
|
-
);
|
57
|
-
};
|
58
|
-
|
59
|
-
export default AdvancedTableExpandedControl;
|
@@ -1,18 +0,0 @@
|
|
1
|
-
`expandedControl` is an optional prop that can be used to gain greater control over the expansion state of the Advanced Table. Tanstack handles expansion itself, however it does provide for a way to handle the state manually if needed. Usecases for this include needing to store the expansion state so it persists on page reload, set an initial expansion state, etc.
|
2
|
-
|
3
|
-
In this example we are showing that if initial expansion state is set, it will render the table expanded according to that state.
|
4
|
-
|
5
|
-
The expanded state must be an object with key/value pairs where the key is the row id and the value is a boolean, true or false. Tanstack by default assigns row ids based on index and depth of the row as can be seen in this example. For more information on row ids, see [here](https://tanstack.com/table/v8/docs/api/core/row#id).
|
6
|
-
|
7
|
-
### Single Row Expansion
|
8
|
-
|
9
|
-
By default, the click event on the row level toggleExpansion icon simply toggles the immediate sub rows open or closed. If you want to attach further logic to that button, the optional `onRowToggleClick` prop can be used. This click event provides one argument that can be hooked into: the current `row` object. Any additional functionality provided through this onClick will be applied in addition to the default.
|
10
|
-
|
11
|
-
### Multi-Row Expansion
|
12
|
-
|
13
|
-
Similar to the row level click event, the default of the click event on the toggleExpansion buttons that render in the first column header (and the subRow Header rows if prop enabled) toggles all top level rows open and closed. If you want to attach further logic to that button, the optional `onToggleExpansionClick` prop can be used. This click event provides one argument that can be hooked into: the current `row` object. Any additional functionality provided through this onClick will be applied in addition to the default.
|
14
|
-
|
15
|
-
### ToggleExpansionIcon
|
16
|
-
|
17
|
-
`ToggleExpansionIcon` is another optional prop that can be used to customize the icon for the toggleExpansion button. This prop takes a string value with the default set to `arrows-from-line`. All strings must be valid FA icons.
|
18
|
-
|
@@ -1,60 +0,0 @@
|
|
1
|
-
import React, { useState } from "react";
|
2
|
-
import { AdvancedTable } from "../../";
|
3
|
-
import { Button } from "../../"
|
4
|
-
import { MOCK_DATA } from "./_mock_data";
|
5
|
-
|
6
|
-
const AdvancedTableLoading = (props) => {
|
7
|
-
|
8
|
-
const [isloading, setIsLoading] = useState(true)
|
9
|
-
|
10
|
-
const columnDefinitions = [
|
11
|
-
{
|
12
|
-
accessor: "year",
|
13
|
-
label: "Year",
|
14
|
-
cellAccessors: ["quarter", "month", "day"],
|
15
|
-
},
|
16
|
-
{
|
17
|
-
accessor: "newEnrollments",
|
18
|
-
label: "New Enrollments",
|
19
|
-
},
|
20
|
-
{
|
21
|
-
accessor: "scheduledMeetings",
|
22
|
-
label: "Scheduled Meetings",
|
23
|
-
},
|
24
|
-
{
|
25
|
-
accessor: "attendanceRate",
|
26
|
-
label: "Attendance Rate",
|
27
|
-
},
|
28
|
-
{
|
29
|
-
accessor: "completedClasses",
|
30
|
-
label: "Completed Classes",
|
31
|
-
},
|
32
|
-
{
|
33
|
-
accessor: "classCompletionRate",
|
34
|
-
label: "Class Completion Rate",
|
35
|
-
},
|
36
|
-
{
|
37
|
-
accessor: "graduatedStudents",
|
38
|
-
label: "Graduated Students",
|
39
|
-
},
|
40
|
-
];
|
41
|
-
|
42
|
-
return (
|
43
|
-
<div>
|
44
|
-
<Button marginBottom="md"
|
45
|
-
onClick={()=> setIsLoading(!isloading)}
|
46
|
-
text="Toggle Loading State"
|
47
|
-
variant="secondary"
|
48
|
-
{...props}
|
49
|
-
/>
|
50
|
-
<AdvancedTable
|
51
|
-
columnDefinitions={columnDefinitions}
|
52
|
-
loading={isloading}
|
53
|
-
tableData={MOCK_DATA}
|
54
|
-
{...props}
|
55
|
-
/>
|
56
|
-
</div>
|
57
|
-
);
|
58
|
-
};
|
59
|
-
|
60
|
-
export default AdvancedTableLoading;
|
@@ -1,3 +0,0 @@
|
|
1
|
-
the optional `loading` prop takes a boolean value that can be managed using state. If loading is true, the table will display the loading skeleton and once loading is false, the table will render with the data provided.
|
2
|
-
|
3
|
-
By default, the inital row count of the loading skeleton is set to 10. If you want more control over this initial row count, the optional `initialLoadingRowCount` prop can be used to to pass in a number. __NOTE__: This is only for the first render of the table, subsequent loading skeleton row count logic is handled within the kit itself.
|
@@ -1,52 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { AdvancedTable } from "../..";
|
3
|
-
import { MOCK_DATA } from "./_mock_data";
|
4
|
-
|
5
|
-
const AdvancedTableSort = (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
|
-
<div>
|
40
|
-
<AdvancedTable
|
41
|
-
columnDefinitions={columnDefinitions}
|
42
|
-
tableData={MOCK_DATA}
|
43
|
-
{...props}
|
44
|
-
>
|
45
|
-
<AdvancedTable.Header enableSorting />
|
46
|
-
<AdvancedTable.Body />
|
47
|
-
</AdvancedTable>
|
48
|
-
</div>
|
49
|
-
);
|
50
|
-
};
|
51
|
-
|
52
|
-
export default AdvancedTableSort;
|
@@ -1,5 +0,0 @@
|
|
1
|
-
the `enableSorting` prop is a boolean prop set to false by default. If true, the table will add sort logic linked to the sort button in the header. Clicking the sort button will toggle sort between ascending and descending. Currently this sort functionality is only available on the first column.
|
2
|
-
|
3
|
-
### sortIcon
|
4
|
-
|
5
|
-
An optional prop, `sortIcon` allows you to customize your icon sets by passing it an array of any comma-separated pair of icon values. The first icon value will replace the kit's default icon when sort direction is desc, and the second value will replace the default icon when sort direction is asc. `sortIcon` also allows you to pass it a single icon as a string, in which case the icon will not toggle with the sort state. Default for this prop is `["arrow-up-short-wide", "arrow-down-short-wide"]`. All strings must be valid FA icons.
|
@@ -1,63 +0,0 @@
|
|
1
|
-
import React, { useState } from "react";
|
2
|
-
import { AdvancedTable } from "../..";
|
3
|
-
import { MOCK_DATA } from "./_mock_data";
|
4
|
-
|
5
|
-
const AdvancedTableSortControl = (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
|
-
//State for sort direction
|
39
|
-
const [isSortDesc, setIsSortDesc] = useState({desc: false})
|
40
|
-
|
41
|
-
// //Passing sort state to AdvancedTable as prop
|
42
|
-
const sortControl = {
|
43
|
-
value: isSortDesc,
|
44
|
-
onChange: setIsSortDesc,
|
45
|
-
}
|
46
|
-
|
47
|
-
|
48
|
-
return (
|
49
|
-
<div>
|
50
|
-
<AdvancedTable
|
51
|
-
columnDefinitions={columnDefinitions}
|
52
|
-
sortControl={sortControl}
|
53
|
-
tableData={MOCK_DATA}
|
54
|
-
{...props}
|
55
|
-
>
|
56
|
-
<AdvancedTable.Header enableSorting />
|
57
|
-
<AdvancedTable.Body />
|
58
|
-
</AdvancedTable>
|
59
|
-
</div>
|
60
|
-
);
|
61
|
-
};
|
62
|
-
|
63
|
-
export default AdvancedTableSortControl;
|