playbook_ui 13.21.0.pre.alpha.PLAY12582531 → 13.21.0.pre.alpha.PLAY12652489
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +19 -21
- data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +3 -6
- data/app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx +8 -12
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +9 -14
- data/app/pb_kits/playbook/pb_advanced_table/Components/ToggleIconButton.tsx +5 -9
- data/app/pb_kits/playbook/pb_advanced_table/README.md +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +11 -15
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +8 -12
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +37 -23
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/types.ts +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +9 -7
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +80 -83
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +61 -67
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.jsx +7 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx +7 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.jsx +7 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.jsx +7 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.jsx +7 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.jsx +7 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.jsx +7 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.jsx +7 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.jsx +7 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +7 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data.js +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data_inline_loading.js +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +1 -2
- data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +1 -2
- data/app/pb_kits/playbook/pb_background/background.html.erb +1 -2
- data/app/pb_kits/playbook/pb_badge/badge.html.erb +1 -2
- data/app/pb_kits/playbook/pb_body/body.html.erb +1 -2
- data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumbs.scss +7 -0
- data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumb_item.html.erb +1 -2
- data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumbs.html.erb +1 -2
- data/app/pb_kits/playbook/pb_button/button.html.erb +1 -2
- data/app/pb_kits/playbook/pb_button/button.rb +3 -2
- data/app/pb_kits/playbook/pb_button_toolbar/button_toolbar.html.erb +1 -2
- data/app/pb_kits/playbook/pb_caption/caption.html.erb +1 -2
- data/app/pb_kits/playbook/pb_card/card.html.erb +1 -2
- data/app/pb_kits/playbook/pb_card/card_body.html.erb +1 -2
- data/app/pb_kits/playbook/pb_card/card_header.html.erb +1 -2
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +1 -3
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +1 -2
- data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +1 -2
- data/app/pb_kits/playbook/pb_collapsible/collapsible_content.html.erb +1 -2
- data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +1 -2
- data/app/pb_kits/playbook/pb_contact/contact.html.erb +1 -2
- data/app/pb_kits/playbook/pb_currency/currency.html.erb +1 -2
- data/app/pb_kits/playbook/pb_dashboard_value/dashboard_value.html.erb +1 -2
- data/app/pb_kits/playbook/pb_date/date.html.erb +1 -2
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +2 -1
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +0 -3
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +2 -4
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +1 -2
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +1 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_input_styles.scss +2 -1
- data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.html.erb +1 -2
- data/app/pb_kits/playbook/pb_date_range_stacked/date_range_stacked.html.erb +1 -2
- data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +1 -2
- data/app/pb_kits/playbook/pb_date_time/date_time.html.erb +1 -2
- data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +2 -3
- data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.html.erb +1 -2
- data/app/pb_kits/playbook/pb_detail/detail.html.erb +1 -2
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +1 -2
- data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +2 -3
- data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +1 -2
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +2 -3
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +1 -2
- data/app/pb_kits/playbook/pb_filter/filter.html.erb +1 -2
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +3 -8
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +0 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line.html.erb +1 -51
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line.jsx +11 -62
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_positions.html.erb +2 -7
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.html.erb +3 -4
- data/app/pb_kits/playbook/pb_flex/docs/_flex_spacing.html.erb +4 -0
- data/app/pb_kits/playbook/pb_flex/flex.html.erb +1 -2
- data/app/pb_kits/playbook/pb_flex/flex_item.html.erb +1 -2
- data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +1 -2
- data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +2 -2
- data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +1 -2
- data/app/pb_kits/playbook/pb_highlight/highlight.html.erb +1 -2
- data/app/pb_kits/playbook/pb_home_address_street/home_address_street.html.erb +1 -2
- data/app/pb_kits/playbook/pb_icon/icon.html.erb +1 -2
- data/app/pb_kits/playbook/pb_icon_circle/icon_circle.html.erb +1 -2
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +1 -2
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.rb +2 -0
- data/app/pb_kits/playbook/pb_icon_value/icon_value.html.erb +1 -2
- data/app/pb_kits/playbook/pb_image/image.html.erb +1 -2
- data/app/pb_kits/playbook/pb_label_pill/label_pill.html.erb +1 -2
- data/app/pb_kits/playbook/pb_label_value/label_value.html.erb +2 -3
- data/app/pb_kits/playbook/pb_layout/body.html.erb +1 -2
- data/app/pb_kits/playbook/pb_layout/footer.html.erb +1 -2
- data/app/pb_kits/playbook/pb_layout/header.html.erb +1 -2
- data/app/pb_kits/playbook/pb_layout/item.html.erb +1 -2
- data/app/pb_kits/playbook/pb_layout/layout.html.erb +1 -2
- data/app/pb_kits/playbook/pb_layout/sidebar.html.erb +1 -2
- data/app/pb_kits/playbook/pb_legend/legend.html.erb +1 -2
- data/app/pb_kits/playbook/pb_list/item.html.erb +1 -2
- data/app/pb_kits/playbook/pb_list/list.html.erb +1 -2
- data/app/pb_kits/playbook/pb_list/list.rb +2 -0
- data/app/pb_kits/playbook/pb_loading_inline/loading_inline.html.erb +1 -2
- data/app/pb_kits/playbook/pb_message/message.html.erb +1 -2
- data/app/pb_kits/playbook/pb_message/message_mention.html.erb +2 -3
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +1 -2
- data/app/pb_kits/playbook/pb_multiple_users/multiple_users.html.erb +1 -2
- data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.html.erb +1 -2
- data/app/pb_kits/playbook/pb_nav/item.html.erb +2 -4
- data/app/pb_kits/playbook/pb_nav/nav.html.erb +1 -2
- data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +1 -2
- data/app/pb_kits/playbook/pb_pagination/pagination.html.erb +1 -2
- data/app/pb_kits/playbook/pb_passphrase/passphrase.html.erb +1 -1
- data/app/pb_kits/playbook/pb_person/person.html.erb +1 -2
- data/app/pb_kits/playbook/pb_person_contact/person_contact.html.erb +1 -2
- data/app/pb_kits/playbook/pb_pill/pill.html.erb +1 -2
- data/app/pb_kits/playbook/pb_popover/popover.html.erb +1 -2
- data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +1 -2
- data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +1 -2
- data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +1 -2
- data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +1 -2
- data/app/pb_kits/playbook/pb_radio/radio.html.erb +1 -2
- data/app/pb_kits/playbook/pb_section_separator/section_separator.html.erb +1 -2
- data/app/pb_kits/playbook/pb_select/select.html.erb +1 -2
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +1 -2
- data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +1 -2
- data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +1 -2
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list.html.erb +1 -2
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +1 -2
- data/app/pb_kits/playbook/pb_source/source.html.erb +1 -2
- data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +1 -2
- data/app/pb_kits/playbook/pb_stat_change/stat_change.html.erb +1 -2
- data/app/pb_kits/playbook/pb_stat_value/stat_value.html.erb +1 -2
- data/app/pb_kits/playbook/pb_table/table.html.erb +2 -4
- data/app/pb_kits/playbook/pb_table/table_body.html.erb +3 -5
- data/app/pb_kits/playbook/pb_table/table_cell.html.erb +3 -5
- data/app/pb_kits/playbook/pb_table/table_head.html.erb +3 -5
- data/app/pb_kits/playbook/pb_table/table_header.html.erb +3 -5
- data/app/pb_kits/playbook/pb_table/table_row.html.erb +3 -5
- data/app/pb_kits/playbook/pb_text_input/_text_input.scss +1 -0
- data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +1 -5
- data/app/pb_kits/playbook/pb_text_input/text_input.html.erb +1 -2
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +1 -2
- data/app/pb_kits/playbook/pb_text_input/text_input.test.js +1 -1
- data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +1 -2
- data/app/pb_kits/playbook/pb_time/time.html.erb +1 -2
- data/app/pb_kits/playbook/pb_time_range_inline/time_range_inline.html.erb +2 -3
- data/app/pb_kits/playbook/pb_time_stacked/time_stacked.html.erb +1 -2
- data/app/pb_kits/playbook/pb_timeline/item.html.erb +1 -2
- data/app/pb_kits/playbook/pb_timeline/timeline.html.erb +1 -2
- data/app/pb_kits/playbook/pb_timestamp/timestamp.html.erb +1 -2
- data/app/pb_kits/playbook/pb_title/title.html.erb +2 -3
- data/app/pb_kits/playbook/pb_title_count/title_count.html.erb +1 -2
- data/app/pb_kits/playbook/pb_title_detail/title_detail.html.erb +1 -2
- data/app/pb_kits/playbook/pb_toggle/toggle.html.erb +1 -2
- data/app/pb_kits/playbook/pb_tooltip/tooltip.html.erb +1 -2
- data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +1 -2
- data/app/pb_kits/playbook/pb_user/user.html.erb +1 -2
- data/app/pb_kits/playbook/pb_user_badge/user_badge.html.erb +1 -2
- data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.html.erb +1 -2
- data/dist/playbook-rails.js +3 -3
- data/lib/playbook/kit_base.rb +0 -18
- data/lib/playbook/pb_doc_helper.rb +1 -1
- data/lib/playbook/props/percentage.rb +2 -2
- data/lib/playbook/version.rb +1 -1
- metadata +39 -46
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +0 -14
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +0 -19
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/_chrome_styles.scss +0 -13
- data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +0 -9
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +0 -30
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +0 -20
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +0 -21
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +0 -37
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +0 -32
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_margin_bottom.html.erb +0 -7
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_margin_bottom.jsx +0 -41
@@ -1,8 +1,8 @@
|
|
1
|
-
import React, { useState, useEffect, useCallback } from "react"
|
2
|
-
import classnames from "classnames"
|
3
|
-
|
4
|
-
import {
|
5
|
-
|
1
|
+
import React, { useState, useEffect, useCallback } from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
|
4
|
+
import { globalProps, GlobalProps } from "../utilities/globalProps";
|
5
|
+
import Table from "../pb_table/_table";
|
6
6
|
import {
|
7
7
|
createColumnHelper,
|
8
8
|
getCoreRowModel,
|
@@ -11,43 +11,39 @@ import {
|
|
11
11
|
Row,
|
12
12
|
useReactTable,
|
13
13
|
Getter,
|
14
|
-
} from "@tanstack/react-table"
|
15
|
-
|
16
|
-
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props"
|
17
|
-
import { globalProps, GlobalProps } from "../utilities/globalProps"
|
18
|
-
|
19
|
-
import Table from "../pb_table/_table"
|
14
|
+
} from "@tanstack/react-table";
|
20
15
|
|
21
|
-
import
|
16
|
+
import { updateExpandAndCollapseState } from "./Utilities/ExpansionControlHelpers";
|
22
17
|
|
23
|
-
import {
|
18
|
+
import { CustomCell } from "./Components/CustomCell";
|
19
|
+
import AdvancedTableContext from "./Context/AdvancedTableContext";
|
20
|
+
import { TableHeader } from "./SubKits/TableHeader";
|
21
|
+
import { TableBody } from "./SubKits/TableBody";
|
24
22
|
|
25
|
-
import {
|
26
|
-
import { TableHeader } from "./SubKits/TableHeader"
|
27
|
-
import { TableBody } from "./SubKits/TableBody"
|
23
|
+
import { DataType } from "./Utilities/types";
|
28
24
|
|
29
25
|
type AdvancedTableProps = {
|
30
|
-
aria?: { [key: string]: string }
|
31
|
-
children?: React.ReactNode | React.ReactNode[]
|
32
|
-
className?: string
|
33
|
-
columnDefinitions:
|
34
|
-
dark?: boolean
|
35
|
-
data?: { [key: string]: string }
|
36
|
-
enableToggleExpansion?: "all" | "header" | "none"
|
37
|
-
expandedControl?:
|
26
|
+
aria?: { [key: string]: string };
|
27
|
+
children?: React.ReactNode | React.ReactNode[];
|
28
|
+
className?: string;
|
29
|
+
columnDefinitions: DataType[];
|
30
|
+
dark?: boolean,
|
31
|
+
data?: { [key: string]: string };
|
32
|
+
enableToggleExpansion?: "all" | "header" | "none";
|
33
|
+
expandedControl?: DataType;
|
38
34
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
39
|
-
id?: string
|
40
|
-
initialLoadingRowsCount?: number
|
41
|
-
inlineRowLoading?: boolean
|
42
|
-
loading?: boolean | string
|
43
|
-
onRowToggleClick?: (arg: Row<
|
44
|
-
onToggleExpansionClick?: (arg: Row<
|
45
|
-
sortControl?:
|
46
|
-
tableData:
|
47
|
-
tableOptions?:
|
48
|
-
tableProps?:
|
49
|
-
toggleExpansionIcon?: string | string[]
|
50
|
-
} & GlobalProps
|
35
|
+
id?: string;
|
36
|
+
initialLoadingRowsCount?: number;
|
37
|
+
inlineRowLoading?: boolean;
|
38
|
+
loading?: boolean | string;
|
39
|
+
onRowToggleClick?: (arg: Row<DataType>) => void;
|
40
|
+
onToggleExpansionClick?: (arg: Row<DataType>) => void;
|
41
|
+
sortControl?: DataType;
|
42
|
+
tableData: DataType[];
|
43
|
+
tableOptions?: DataType;
|
44
|
+
tableProps?: DataType;
|
45
|
+
toggleExpansionIcon?: string | string[];
|
46
|
+
} & GlobalProps;
|
51
47
|
|
52
48
|
const AdvancedTable = (props: AdvancedTableProps) => {
|
53
49
|
const {
|
@@ -71,22 +67,22 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
71
67
|
tableOptions,
|
72
68
|
tableProps,
|
73
69
|
toggleExpansionIcon = "arrows-from-line",
|
74
|
-
} = props
|
70
|
+
} = props;
|
75
71
|
|
76
72
|
const [loadingStateRowCount, setLoadingStateRowCount] = useState(
|
77
73
|
initialLoadingRowsCount
|
78
|
-
)
|
74
|
+
);
|
79
75
|
|
80
76
|
// Create a local state for expanded and setExpanded if expandedControl not used
|
81
|
-
const [localExpanded, setLocalExpanded] = useState({})
|
77
|
+
const [localExpanded, setLocalExpanded] = useState({});
|
82
78
|
|
83
79
|
// Determine whether to use the prop or the local state
|
84
|
-
const expanded = expandedControl ? expandedControl.value : localExpanded
|
80
|
+
const expanded = expandedControl ? expandedControl.value : localExpanded;
|
85
81
|
const setExpanded = expandedControl
|
86
82
|
? expandedControl.onChange
|
87
|
-
: setLocalExpanded
|
83
|
+
: setLocalExpanded;
|
88
84
|
|
89
|
-
const columnHelper = createColumnHelper()
|
85
|
+
const columnHelper = createColumnHelper();
|
90
86
|
|
91
87
|
//Create cells for first columns
|
92
88
|
const createCellFunction = (cellAccessors: string[]) => {
|
@@ -94,10 +90,10 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
94
90
|
row,
|
95
91
|
getValue,
|
96
92
|
}: {
|
97
|
-
row: Row<
|
98
|
-
getValue: Getter<string
|
93
|
+
row: Row<DataType>;
|
94
|
+
getValue: Getter<string>;
|
99
95
|
}) => {
|
100
|
-
const rowData = row.original
|
96
|
+
const rowData = row.original;
|
101
97
|
|
102
98
|
switch (row.depth) {
|
103
99
|
case 0: {
|
@@ -107,12 +103,12 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
107
103
|
onRowToggleClick={onRowToggleClick}
|
108
104
|
row={row}
|
109
105
|
/>
|
110
|
-
)
|
106
|
+
);
|
111
107
|
}
|
112
108
|
default: {
|
113
109
|
// Handle other depths based on cellAccessors
|
114
|
-
const depthAccessor = cellAccessors[row.depth - 1] // Adjust index for depth
|
115
|
-
const accessorValue = rowData[depthAccessor]
|
110
|
+
const depthAccessor = cellAccessors[row.depth - 1]; // Adjust index for depth
|
111
|
+
const accessorValue = rowData[depthAccessor];
|
116
112
|
return accessorValue ? (
|
117
113
|
<CustomCell
|
118
114
|
onRowToggleClick={onRowToggleClick}
|
@@ -121,13 +117,13 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
121
117
|
/>
|
122
118
|
) : (
|
123
119
|
"N/A"
|
124
|
-
)
|
120
|
+
);
|
125
121
|
}
|
126
122
|
}
|
127
|
-
}
|
123
|
+
};
|
128
124
|
|
129
|
-
return columnCells
|
130
|
-
}
|
125
|
+
return columnCells;
|
126
|
+
};
|
131
127
|
|
132
128
|
//Create column array in format needed by Tanstack
|
133
129
|
const columns =
|
@@ -138,12 +134,12 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
138
134
|
...columnHelper.accessor(column.accessor, {
|
139
135
|
header: column.label,
|
140
136
|
}),
|
141
|
-
}
|
137
|
+
};
|
142
138
|
if (column.cellAccessors) {
|
143
|
-
columnStructure.cell = createCellFunction(column.cellAccessors)
|
139
|
+
columnStructure.cell = createCellFunction(column.cellAccessors);
|
144
140
|
}
|
145
|
-
return columnStructure
|
146
|
-
})
|
141
|
+
return columnStructure;
|
142
|
+
});
|
147
143
|
|
148
144
|
//Syntax for sorting Array if we want to manage state ourselves
|
149
145
|
const sorting = [
|
@@ -154,22 +150,22 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
154
150
|
? !sortControl.value.desc
|
155
151
|
: false,
|
156
152
|
},
|
157
|
-
]
|
153
|
+
];
|
158
154
|
|
159
155
|
const expandAndSortState = () => {
|
160
156
|
if (sortControl) {
|
161
|
-
return { state: { expanded, sorting } }
|
157
|
+
return { state: { expanded, sorting } };
|
162
158
|
} else {
|
163
|
-
return { state: { expanded } }
|
159
|
+
return { state: { expanded } };
|
164
160
|
}
|
165
|
-
}
|
161
|
+
};
|
166
162
|
|
167
163
|
//initialize table
|
168
164
|
const table = useReactTable({
|
169
165
|
data: loading ? Array(loadingStateRowCount).fill({}) : tableData,
|
170
166
|
columns,
|
171
167
|
onExpandedChange: setExpanded,
|
172
|
-
getSubRows: (row:
|
168
|
+
getSubRows: (row: DataType) => row.children,
|
173
169
|
getCoreRowModel: getCoreRowModel(),
|
174
170
|
getExpandedRowModel: getExpandedRowModel(),
|
175
171
|
getSortedRowModel: getSortedRowModel(),
|
@@ -177,41 +173,42 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
177
173
|
sortDescFirst: true,
|
178
174
|
...expandAndSortState(),
|
179
175
|
...tableOptions,
|
180
|
-
})
|
176
|
+
});
|
181
177
|
|
182
|
-
const tableRows = table.getRowModel()
|
178
|
+
const tableRows = table.getRowModel();
|
183
179
|
|
184
180
|
// Set table row count for loading state
|
185
181
|
const updateLoadingStateRowCount = useCallback(() => {
|
186
|
-
const rowsCount = table.getRowModel().rows.length
|
182
|
+
const rowsCount = table.getRowModel().rows.length;
|
187
183
|
if (rowsCount !== loadingStateRowCount && rowsCount !== 0) {
|
188
|
-
setLoadingStateRowCount(rowsCount)
|
184
|
+
setLoadingStateRowCount(rowsCount);
|
189
185
|
}
|
190
|
-
}, [tableData, loadingStateRowCount])
|
186
|
+
}, [tableData, loadingStateRowCount]);
|
191
187
|
|
192
188
|
useEffect(() => {
|
193
189
|
if (!loading) {
|
194
|
-
updateLoadingStateRowCount()
|
190
|
+
updateLoadingStateRowCount();
|
195
191
|
}
|
196
|
-
}, [loading, updateLoadingStateRowCount])
|
192
|
+
}, [loading, updateLoadingStateRowCount]);
|
193
|
+
|
194
|
+
const handleExpandOrCollapse = (row: Row<DataType>) => {
|
195
|
+
onToggleExpansionClick && onToggleExpansionClick(row);
|
197
196
|
|
198
|
-
const handleExpandOrCollapse = async (row: Row<GenericObject>) => {
|
199
|
-
onToggleExpansionClick && onToggleExpansionClick(row)
|
200
|
-
|
201
197
|
const expandedState = expanded;
|
202
198
|
const targetParent = row?.parentId;
|
203
|
-
|
204
|
-
|
205
|
-
|
199
|
+
return setExpanded(
|
200
|
+
updateExpandAndCollapseState(tableRows, expandedState, targetParent)
|
201
|
+
);
|
202
|
+
};
|
206
203
|
|
207
|
-
const ariaProps = buildAriaProps(aria)
|
208
|
-
const dataProps = buildDataProps(data)
|
209
|
-
const htmlProps = buildHtmlProps(htmlOptions)
|
204
|
+
const ariaProps = buildAriaProps(aria);
|
205
|
+
const dataProps = buildDataProps(data);
|
206
|
+
const htmlProps = buildHtmlProps(htmlOptions);
|
210
207
|
const classes = classnames(
|
211
208
|
buildCss("pb_advanced_table"),
|
212
209
|
globalProps(props),
|
213
210
|
className
|
214
|
-
)
|
211
|
+
);
|
215
212
|
|
216
213
|
return (
|
217
214
|
<div {...ariaProps}
|
@@ -253,10 +250,10 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
253
250
|
</Table>
|
254
251
|
</AdvancedTableContext.Provider>
|
255
252
|
</div>
|
256
|
-
)
|
257
|
-
}
|
253
|
+
);
|
254
|
+
};
|
258
255
|
|
259
|
-
AdvancedTable.Header = TableHeader
|
260
|
-
AdvancedTable.Body = TableBody
|
256
|
+
AdvancedTable.Header = TableHeader;
|
257
|
+
AdvancedTable.Body = TableBody;
|
261
258
|
|
262
|
-
export default AdvancedTable
|
259
|
+
export default AdvancedTable;
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import React, {useState} from "react"
|
2
|
-
import { render, screen
|
1
|
+
import React, {useState} from "react";
|
2
|
+
import { render, screen } from "../utilities/test-utils";
|
3
3
|
|
4
|
-
import { AdvancedTable } from "../"
|
4
|
+
import { AdvancedTable } from "../";
|
5
5
|
|
6
6
|
const MOCK_DATA = [
|
7
7
|
{
|
@@ -40,7 +40,7 @@ const MOCK_DATA = [
|
|
40
40
|
},
|
41
41
|
],
|
42
42
|
},
|
43
|
-
]
|
43
|
+
];
|
44
44
|
|
45
45
|
const MOCK_DATA_LOADING = [
|
46
46
|
{
|
@@ -70,7 +70,7 @@ const MOCK_DATA_LOADING = [
|
|
70
70
|
},
|
71
71
|
],
|
72
72
|
},
|
73
|
-
]
|
73
|
+
];
|
74
74
|
|
75
75
|
const columnDefinitions = [
|
76
76
|
{
|
@@ -86,11 +86,11 @@ const columnDefinitions = [
|
|
86
86
|
accessor: "scheduledMeetings",
|
87
87
|
label: "Scheduled Meetings",
|
88
88
|
},
|
89
|
-
]
|
89
|
+
];
|
90
90
|
|
91
91
|
const subRowHeaders = ["Quarter"]
|
92
92
|
|
93
|
-
const testId = "advanced_table"
|
93
|
+
const testId = "advanced_table";
|
94
94
|
|
95
95
|
const AdvancedTableExpandControl = () => {
|
96
96
|
const [expanded, setExpanded] = useState({'0': true})
|
@@ -109,7 +109,7 @@ return (
|
|
109
109
|
tableData={MOCK_DATA}
|
110
110
|
/>
|
111
111
|
</div>
|
112
|
-
)
|
112
|
+
);
|
113
113
|
}
|
114
114
|
|
115
115
|
const AdvancedTableSortControl = () => {
|
@@ -132,7 +132,7 @@ return (
|
|
132
132
|
<AdvancedTable.Body />
|
133
133
|
</AdvancedTable>
|
134
134
|
</div>
|
135
|
-
)
|
135
|
+
);
|
136
136
|
}
|
137
137
|
|
138
138
|
const tableOptions = {
|
@@ -158,12 +158,12 @@ test("Generates default kit and classname", () => {
|
|
158
158
|
data={{ testid: testId }}
|
159
159
|
tableData={MOCK_DATA}
|
160
160
|
/>
|
161
|
-
)
|
161
|
+
);
|
162
162
|
|
163
|
-
const kit = screen.getByTestId(testId)
|
164
|
-
expect(kit).toBeInTheDocument()
|
163
|
+
const kit = screen.getByTestId(testId);
|
164
|
+
expect(kit).toBeInTheDocument();
|
165
165
|
expect(kit).toHaveClass('pb_advanced_table')
|
166
|
-
})
|
166
|
+
});
|
167
167
|
|
168
168
|
test("Generates aria label", () => {
|
169
169
|
render(
|
@@ -173,11 +173,11 @@ test("Generates aria label", () => {
|
|
173
173
|
data={{ testid: testId }}
|
174
174
|
tableData={MOCK_DATA}
|
175
175
|
/>
|
176
|
-
)
|
176
|
+
);
|
177
177
|
|
178
|
-
const kit = screen.getByTestId(testId)
|
178
|
+
const kit = screen.getByTestId(testId);
|
179
179
|
expect(kit).toHaveAttribute('aria-label', testId)
|
180
|
-
})
|
180
|
+
});
|
181
181
|
|
182
182
|
test("Row toggle button exists and toggles subrows open and closed", () => {
|
183
183
|
render(
|
@@ -186,9 +186,9 @@ test("Row toggle button exists and toggles subrows open and closed", () => {
|
|
186
186
|
data={{ testid: testId }}
|
187
187
|
tableData={MOCK_DATA}
|
188
188
|
/>
|
189
|
-
)
|
189
|
+
);
|
190
190
|
|
191
|
-
const kit = screen.getByTestId(testId)
|
191
|
+
const kit = screen.getByTestId(testId);
|
192
192
|
const rowButton = kit.querySelector(".gray-icon.expand-toggle-icon")
|
193
193
|
expect(rowButton).toBeInTheDocument()
|
194
194
|
const subRow1 = kit.querySelector(".bg-white.depth-sub-row-1")
|
@@ -196,32 +196,26 @@ test("Row toggle button exists and toggles subrows open and closed", () => {
|
|
196
196
|
rowButton.click()
|
197
197
|
const subRow = kit.querySelector(".bg-white.depth-sub-row-1")
|
198
198
|
expect(subRow).toBeInTheDocument()
|
199
|
-
})
|
199
|
+
});
|
200
200
|
|
201
|
-
test("toggleExpansionAll button exists and toggles subrows open and closed",
|
201
|
+
test("toggleExpansionAll button exists and toggles subrows open and closed", () => {
|
202
202
|
render(
|
203
203
|
<AdvancedTable
|
204
204
|
columnDefinitions={columnDefinitions}
|
205
205
|
data={{ testid: testId }}
|
206
206
|
tableData={MOCK_DATA}
|
207
207
|
/>
|
208
|
-
)
|
208
|
+
);
|
209
209
|
|
210
210
|
const kit = screen.getByTestId(testId);
|
211
|
-
const toggleButton = kit.querySelector(".gray-icon.toggle-all-icon")
|
212
|
-
expect(toggleButton).toBeInTheDocument()
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
await waitFor(() => {
|
220
|
-
const subRow = kit.querySelector(".bg-white.depth-sub-row-1");
|
221
|
-
expect(subRow).toBeInTheDocument();
|
222
|
-
})
|
223
|
-
})
|
224
|
-
|
211
|
+
const toggleButton = kit.querySelector(".gray-icon.toggle-all-icon")
|
212
|
+
expect(toggleButton).toBeInTheDocument()
|
213
|
+
const subRow1 = kit.querySelector(".bg-white.depth-sub-row-1")
|
214
|
+
expect(subRow1).not.toBeInTheDocument()
|
215
|
+
toggleButton.click()
|
216
|
+
const subRow = kit.querySelector(".bg-white.depth-sub-row-1")
|
217
|
+
expect(subRow).toBeInTheDocument()
|
218
|
+
});
|
225
219
|
|
226
220
|
test("loading state + initialLoadingRowCount prop", () => {
|
227
221
|
render(
|
@@ -232,16 +226,16 @@ test("loading state + initialLoadingRowCount prop", () => {
|
|
232
226
|
loading
|
233
227
|
tableData={MOCK_DATA}
|
234
228
|
/>
|
235
|
-
)
|
229
|
+
);
|
236
230
|
|
237
|
-
const kit = screen.getByTestId(testId)
|
231
|
+
const kit = screen.getByTestId(testId);
|
238
232
|
const table = kit.querySelector('table')
|
239
233
|
expect(table).toHaveClass('pb_table table-sm table-responsive-none table-card data_table ns_tabular content-loading')
|
240
234
|
|
241
235
|
const tableBody = kit.querySelector('tbody')
|
242
236
|
const tableRows = tableBody.getElementsByTagName('tr')
|
243
237
|
expect(tableRows).toHaveLength(13)
|
244
|
-
})
|
238
|
+
});
|
245
239
|
|
246
240
|
test("subRowHeaders are rendered", () => {
|
247
241
|
render(
|
@@ -253,21 +247,21 @@ test("subRowHeaders are rendered", () => {
|
|
253
247
|
<AdvancedTable.Header />
|
254
248
|
<AdvancedTable.Body subRowHeaders={subRowHeaders}/>
|
255
249
|
</AdvancedTable>
|
256
|
-
)
|
250
|
+
);
|
257
251
|
|
258
|
-
const kit = screen.getByTestId(testId)
|
252
|
+
const kit = screen.getByTestId(testId);
|
259
253
|
|
260
254
|
const rowButton = kit.querySelector(".gray-icon.expand-toggle-icon")
|
261
255
|
rowButton.click()
|
262
256
|
|
263
257
|
const subRowHeader = kit.querySelector(".custom-row.bg-silver")
|
264
258
|
expect(subRowHeader).toBeInTheDocument()
|
265
|
-
})
|
259
|
+
});
|
266
260
|
|
267
261
|
test("expandControl prop works as expected", () => {
|
268
262
|
render (<AdvancedTableExpandControl/>)
|
269
263
|
|
270
|
-
const kit = screen.getByTestId(testId)
|
264
|
+
const kit = screen.getByTestId(testId);
|
271
265
|
const subRow = kit.querySelector(".bg-white.depth-sub-row-1")
|
272
266
|
expect(subRow).toBeInTheDocument()
|
273
267
|
})
|
@@ -280,13 +274,13 @@ test("tableOptions prop functions as expected", () => {
|
|
280
274
|
tableData={MOCK_DATA}
|
281
275
|
tableOptions={tableOptions}
|
282
276
|
/>
|
283
|
-
)
|
277
|
+
);
|
284
278
|
|
285
|
-
const kit = screen.getByTestId(testId)
|
279
|
+
const kit = screen.getByTestId(testId);
|
286
280
|
const row1 = kit.getElementsByTagName('tr')[1]
|
287
281
|
|
288
282
|
expect(row1.id).toBe("1-1-0-row")
|
289
|
-
})
|
283
|
+
});
|
290
284
|
|
291
285
|
test("tableProps prop functions as expected", () => {
|
292
286
|
render(
|
@@ -296,12 +290,12 @@ test("tableProps prop functions as expected", () => {
|
|
296
290
|
tableData={MOCK_DATA}
|
297
291
|
tableProps={tableProps}
|
298
292
|
/>
|
299
|
-
)
|
293
|
+
);
|
300
294
|
|
301
|
-
const kit = screen.getByTestId(testId)
|
295
|
+
const kit = screen.getByTestId(testId);
|
302
296
|
const table = kit.querySelector('table')
|
303
297
|
expect(table).toHaveClass("pb_table table-sm table-responsive-none data_table sticky-header ns_tabular")
|
304
|
-
})
|
298
|
+
});
|
305
299
|
|
306
300
|
test("enableExpansionIcon changes icon", () => {
|
307
301
|
render(
|
@@ -312,13 +306,13 @@ test("enableExpansionIcon changes icon", () => {
|
|
312
306
|
tableProps={tableProps}
|
313
307
|
toggleExpansionIcon= "chevron-up"
|
314
308
|
/>
|
315
|
-
)
|
309
|
+
);
|
316
310
|
|
317
|
-
const kit = screen.getByTestId(testId)
|
311
|
+
const kit = screen.getByTestId(testId);
|
318
312
|
const tableHead = kit.querySelector('table')
|
319
313
|
const toggleIcon= tableHead.querySelector(".pb_icon_kit")
|
320
314
|
expect(toggleIcon).toHaveClass("fa-chevron-up")
|
321
|
-
})
|
315
|
+
});
|
322
316
|
|
323
317
|
test("sortIcon changes icon", () => {
|
324
318
|
render(
|
@@ -334,18 +328,18 @@ test("sortIcon changes icon", () => {
|
|
334
328
|
/>
|
335
329
|
<AdvancedTable.Body />
|
336
330
|
</AdvancedTable>
|
337
|
-
)
|
331
|
+
);
|
338
332
|
|
339
|
-
const kit = screen.getByTestId(testId)
|
333
|
+
const kit = screen.getByTestId(testId);
|
340
334
|
const sortIcon = kit.querySelector('.sort-button-icon')
|
341
335
|
const icon= sortIcon.querySelector(".pb_icon_kit")
|
342
336
|
expect(icon).toHaveClass("fa-chevron-down")
|
343
|
-
})
|
337
|
+
});
|
344
338
|
|
345
339
|
test("Sort icon renders with enableSorting + sortControl works as expected", () => {
|
346
340
|
render (<AdvancedTableSortControl/>)
|
347
341
|
|
348
|
-
const kit = screen.getByTestId(testId)
|
342
|
+
const kit = screen.getByTestId(testId);
|
349
343
|
const sortIcon = kit.querySelector(".sort-button-icon")
|
350
344
|
expect(sortIcon).toBeInTheDocument()
|
351
345
|
|
@@ -364,9 +358,9 @@ test("sort button exists and sorts column data", () => {
|
|
364
358
|
<AdvancedTable.Header enableSorting />
|
365
359
|
<AdvancedTable.Body />
|
366
360
|
</AdvancedTable>
|
367
|
-
)
|
361
|
+
);
|
368
362
|
|
369
|
-
const kit = screen.getByTestId(testId)
|
363
|
+
const kit = screen.getByTestId(testId);
|
370
364
|
|
371
365
|
const sortButton= kit.querySelector(".pb_flex_kit_orientation_row_justify_content_between_align_items_top_spacing_none.pl_xxs.cursor_pointer.header-sort-button.pb_th_link")
|
372
366
|
expect(sortButton).toBeInTheDocument()
|
@@ -378,7 +372,7 @@ test("sort button exists and sorts column data", () => {
|
|
378
372
|
|
379
373
|
const row2 = kit.getElementsByTagName('tr')[2]
|
380
374
|
expect(row2.id).toBe("0-0-0-row")
|
381
|
-
})
|
375
|
+
});
|
382
376
|
|
383
377
|
test("Generates Table.Header default + custom classname", () => {
|
384
378
|
render(
|
@@ -391,12 +385,12 @@ test("Generates Table.Header default + custom classname", () => {
|
|
391
385
|
<AdvancedTable.Body />
|
392
386
|
|
393
387
|
</AdvancedTable>
|
394
|
-
)
|
388
|
+
);
|
395
389
|
|
396
|
-
const kit = screen.getByTestId(testId)
|
390
|
+
const kit = screen.getByTestId(testId);
|
397
391
|
const tableHeader = kit.querySelector('thead')
|
398
392
|
expect(tableHeader).toHaveClass('pb_advanced_table_header custom-header')
|
399
|
-
})
|
393
|
+
});
|
400
394
|
|
401
395
|
test("Generates Table.Body default + custom classname", () => {
|
402
396
|
render(
|
@@ -409,12 +403,12 @@ test("Generates Table.Body default + custom classname", () => {
|
|
409
403
|
<AdvancedTable.Body className="custom-body-classname"/>
|
410
404
|
|
411
405
|
</AdvancedTable>
|
412
|
-
)
|
406
|
+
);
|
413
407
|
|
414
|
-
const kit = screen.getByTestId(testId)
|
408
|
+
const kit = screen.getByTestId(testId);
|
415
409
|
const tableHeader = kit.querySelector('tbody')
|
416
410
|
expect(tableHeader).toHaveClass('pb_advanced_table_body custom-body-classname')
|
417
|
-
})
|
411
|
+
});
|
418
412
|
|
419
413
|
test("inlineRowLoading prop renders inline loading if true", () => {
|
420
414
|
render(
|
@@ -424,12 +418,12 @@ test("inlineRowLoading prop renders inline loading if true", () => {
|
|
424
418
|
inlineRowLoading
|
425
419
|
tableData={MOCK_DATA_LOADING}
|
426
420
|
/>
|
427
|
-
)
|
421
|
+
);
|
428
422
|
|
429
|
-
const kit = screen.getByTestId(testId)
|
423
|
+
const kit = screen.getByTestId(testId);
|
430
424
|
const rowButton = kit.querySelector(".gray-icon.expand-toggle-icon")
|
431
425
|
expect(rowButton).toBeInTheDocument()
|
432
426
|
rowButton.click()
|
433
427
|
const inlineLoading = kit.querySelector(".fa-spinner")
|
434
428
|
expect(inlineLoading).toBeInTheDocument()
|
435
|
-
})
|
429
|
+
});
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import React from "react"
|
2
|
-
import { AdvancedTable } from "../../"
|
3
|
-
import { MOCK_DATA } from "./_mock_data"
|
1
|
+
import React from "react";
|
2
|
+
import { AdvancedTable } from "../../";
|
3
|
+
import { MOCK_DATA } from "./_mock_data";
|
4
4
|
|
5
5
|
const AdvancedTableCollapsibleTrail = (props) => {
|
6
6
|
const columnDefinitions = [
|
@@ -33,7 +33,7 @@ const AdvancedTableCollapsibleTrail = (props) => {
|
|
33
33
|
accessor: "graduatedStudents",
|
34
34
|
label: "Graduated Students",
|
35
35
|
},
|
36
|
-
]
|
36
|
+
];
|
37
37
|
|
38
38
|
return (
|
39
39
|
<div>
|
@@ -46,7 +46,7 @@ const AdvancedTableCollapsibleTrail = (props) => {
|
|
46
46
|
<AdvancedTable.Body collapsibleTrail={false} />
|
47
47
|
</AdvancedTable>
|
48
48
|
</div>
|
49
|
-
)
|
50
|
-
}
|
49
|
+
);
|
50
|
+
};
|
51
51
|
|
52
|
-
export default AdvancedTableCollapsibleTrail
|
52
|
+
export default AdvancedTableCollapsibleTrail;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import React from "react"
|
2
|
-
import { AdvancedTable } from "../../"
|
3
|
-
import { MOCK_DATA } from "./_mock_data"
|
1
|
+
import React from "react";
|
2
|
+
import { AdvancedTable } from "../../";
|
3
|
+
import { MOCK_DATA } from "./_mock_data";
|
4
4
|
|
5
5
|
const AdvancedTableDefault = (props) => {
|
6
6
|
const columnDefinitions = [
|
@@ -33,7 +33,7 @@ const AdvancedTableDefault = (props) => {
|
|
33
33
|
accessor: "graduatedStudents",
|
34
34
|
label: "Graduated Students",
|
35
35
|
},
|
36
|
-
]
|
36
|
+
];
|
37
37
|
|
38
38
|
return (
|
39
39
|
<div>
|
@@ -43,7 +43,7 @@ const AdvancedTableDefault = (props) => {
|
|
43
43
|
{...props}
|
44
44
|
/>
|
45
45
|
</div>
|
46
|
-
)
|
47
|
-
}
|
46
|
+
);
|
47
|
+
};
|
48
48
|
|
49
|
-
export default AdvancedTableDefault
|
49
|
+
export default AdvancedTableDefault;
|