playbook_ui 13.16.0 → 13.17.0.pre.alpha.nodealphaupgrade2157
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 +14 -12
- data/app/pb_kits/playbook/_reset.scss +2 -2
- data/app/pb_kits/playbook/index.js +2 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/CollapsibleTrail.tsx +30 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +62 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/LoadingCell.tsx +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +30 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx +61 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +127 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/ToggleIconButton.tsx +28 -0
- data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/README.md +288 -0
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +95 -0
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +51 -0
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/BrowserCheck.tsx +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +63 -0
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/IconHelpers.tsx +8 -0
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/types.ts +8 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +98 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +246 -0
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +345 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.jsx +52 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx +49 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +18 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.jsx +59 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.md +18 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.jsx +60 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.jsx +52 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.md +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.jsx +63 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.jsx +57 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.jsx +61 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +55 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_description.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data.js +278 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +12 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +9 -0
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/_loading.scss +72 -0
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/_pseudo_states.scss +12 -0
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.scss +2 -2
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_flatpickr_styles.scss +1 -1
- 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 +2 -1
- data/app/pb_kits/playbook/pb_layout/layout.test.js +8 -4
- 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 +30 -22
- 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 +15 -7
- data/app/pb_kits/playbook/pb_map/_map_custom_button.tsx +4 -2
- 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 +46 -42
- data/app/pb_kits/playbook/pb_multiple_users_stacked/_multiple_users_stacked.tsx +20 -20
- data/app/pb_kits/playbook/pb_nav/_item.tsx +56 -47
- 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 +5 -7
- data/app/pb_kits/playbook/pb_popover/_popover.tsx +12 -14
- data/app/pb_kits/playbook/pb_popover/docs/_popover_actionable_content.html.erb +30 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_actionable_content.jsx +57 -0
- data/app/pb_kits/playbook/pb_popover/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_popover/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_popover/popover.test.js +29 -31
- data/app/pb_kits/playbook/pb_table/_table.tsx +32 -29
- data/app/pb_kits/playbook/pb_table/docs/_table_striped.html.erb +48 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_striped.jsx +58 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_striped.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_table/styles/_all.scss +1 -0
- data/app/pb_kits/playbook/pb_table/styles/_striped.scss +19 -0
- data/app/pb_kits/playbook/pb_table/table.rb +7 -1
- data/app/pb_kits/playbook/pb_table/table.test.js +5 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.jsx +4 -2
- data/app/pb_kits/playbook/playbook-doc.js +2 -0
- data/app/pb_kits/playbook/utilities/globalProps.ts +1 -1
- data/dist/menu.yml +105 -3
- data/dist/playbook-rails.js +14 -6
- data/dist/reset.css +1 -2
- data/lib/playbook/version.rb +2 -2
- metadata +55 -7
@@ -0,0 +1,59 @@
|
|
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;
|
@@ -0,0 +1,18 @@
|
|
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
|
+
|
@@ -0,0 +1,60 @@
|
|
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;
|
@@ -0,0 +1,3 @@
|
|
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.
|
@@ -0,0 +1,52 @@
|
|
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;
|
@@ -0,0 +1,5 @@
|
|
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.
|
@@ -0,0 +1,63 @@
|
|
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;
|
@@ -0,0 +1,3 @@
|
|
1
|
+
`sortControl` is an optional prop that can be used to gain greater control over the sort state of the Advanced Table. Tanstack handles sort itself, however it does provide for a way to handle the state manually if needed. Usecases for this include needing to store the sort state so it persists on page reload, set an initial sort state, etc.
|
2
|
+
|
3
|
+
The sort state must be an object with a single key/value pair, with the key being "desc" and the value being a boolean. The default for sort directino is `desc: true`.
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { AdvancedTable } from "../..";
|
3
|
+
import { MOCK_DATA } from "./_mock_data";
|
4
|
+
|
5
|
+
const AdvancedTableSubrowHeaders = (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
|
+
//Render the subRow header rows
|
39
|
+
const subRowHeaders = ["Quarter", "Month", "Day"]
|
40
|
+
|
41
|
+
|
42
|
+
return (
|
43
|
+
<div>
|
44
|
+
<AdvancedTable
|
45
|
+
columnDefinitions={columnDefinitions}
|
46
|
+
enableToggleExpansion="all"
|
47
|
+
tableData={MOCK_DATA}
|
48
|
+
{...props}
|
49
|
+
>
|
50
|
+
<AdvancedTable.Header />
|
51
|
+
<AdvancedTable.Body subRowHeaders={subRowHeaders}/>
|
52
|
+
</AdvancedTable>
|
53
|
+
</div>
|
54
|
+
);
|
55
|
+
};
|
56
|
+
|
57
|
+
export default AdvancedTableSubrowHeaders;
|
@@ -0,0 +1,3 @@
|
|
1
|
+
`subRowHeaders` is an optional prop that if present will add header rows at each level of the nested data. The prop takes an array of strings, each string being the text for each header row. The array of strings must be in the order in which they need to be rendered in the UI according to depth.
|
2
|
+
|
3
|
+
`enableToggleExpansion` is an additional optional prop that can be used in conjunction with the subRowHeaders prop. `enableToggleExpansion` is a string that can be 'all' or 'header". If set to 'all', the toggle exapansion button will appear in the table header as well as in the subRow headers. If set to 'header' button will only appear in header and NOT in subRow headers. This is set to 'headeer' by default.
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { AdvancedTable } from "../../";
|
3
|
+
import { MOCK_DATA } from "./_mock_data";
|
4
|
+
|
5
|
+
const AdvancedTableTableOptions = (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 tableOptions = {
|
39
|
+
initialState: {
|
40
|
+
sorting: [
|
41
|
+
{
|
42
|
+
id: "year",
|
43
|
+
desc: true,
|
44
|
+
},
|
45
|
+
],
|
46
|
+
},
|
47
|
+
}
|
48
|
+
|
49
|
+
return (
|
50
|
+
<div>
|
51
|
+
<AdvancedTable
|
52
|
+
columnDefinitions={columnDefinitions}
|
53
|
+
tableData={MOCK_DATA}
|
54
|
+
tableOptions={tableOptions}
|
55
|
+
{...props}
|
56
|
+
/>
|
57
|
+
</div>
|
58
|
+
);
|
59
|
+
};
|
60
|
+
|
61
|
+
export default AdvancedTableTableOptions;
|
@@ -0,0 +1,3 @@
|
|
1
|
+
The Tanstack table consumes the useReactTable hook to create the table. This hook takes an object that can contain any of the functions that the Tanstack table provides. The advancedTable's optional `tableOptions` can be used to pass tanstack options to the kit.
|
2
|
+
|
3
|
+
In the above example, we are using the initialState option provided by tanstack that takes sort as one of it's values. Setting it to true for the first column is reversing the sort order on first render of the table. For a complete list of possible options and hoe to use them, see [here](https://tanstack.com/table/v8/docs/api/core/table#usereacttable--createsolidtable--usevuetable--createsveltetable)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { AdvancedTable } from "../../";
|
3
|
+
import { MOCK_DATA } from "./_mock_data";
|
4
|
+
|
5
|
+
const AdvancedTableTableProps = (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 tableProps = {
|
39
|
+
container: false,
|
40
|
+
sticky: true
|
41
|
+
}
|
42
|
+
|
43
|
+
return (
|
44
|
+
<div>
|
45
|
+
<AdvancedTable
|
46
|
+
columnDefinitions={columnDefinitions}
|
47
|
+
tableData={MOCK_DATA}
|
48
|
+
tableProps={tableProps}
|
49
|
+
{...props}
|
50
|
+
/>
|
51
|
+
</div>
|
52
|
+
);
|
53
|
+
};
|
54
|
+
|
55
|
+
export default AdvancedTableTableProps;
|
@@ -0,0 +1 @@
|
|
1
|
+
This kit uses the [Table kit](https://playbook.powerapp.cloud/kits/table/react) under the hood which comes with it's own set of props. If you want to apply certain Table props to that underlying kit, you can do so by using the optional `tableProps` prop. This prop must be an object that contains valid Table props. For a full list of Table props, see [here](https://playbook.powerapp.cloud/kits/table/react).
|
@@ -0,0 +1 @@
|
|
1
|
+
The AdvancedTable kit uses the [Tanstack Table v8](https://tanstack.com/table/v8/docs/introduction) under the hood to render advanced tables that allow for complex, nested data structures with expansion and sort options.
|