playbook_ui 16.3.0.pre.alpha.PLAY2782RTEPOCs14848 → 16.3.0.pre.alpha.PLAY2791closeonclick14694
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 +4 -17
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +1 -3
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +9 -21
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +1 -25
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +1 -5
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +1 -74
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_advanced_table/index.js +29 -48
- data/app/pb_kits/playbook/pb_button/_button_mixins.scss +1 -6
- data/app/pb_kits/playbook/pb_collapsible/index.js +26 -15
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.html.erb +9 -18
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.jsx +5 -24
- data/app/pb_kits/playbook/pb_dropdown/index.js +37 -67
- data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +15 -24
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.scss +0 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +3 -3
- data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +0 -9
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +0 -3
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.html.erb +0 -1
- data/app/pb_kits/playbook/pb_table/_table.tsx +21 -24
- data/app/pb_kits/playbook/pb_table/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_table/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_table/table.html.erb +11 -12
- data/app/pb_kits/playbook/pb_table/table.rb +0 -4
- data/app/pb_kits/playbook/pb_table/table.test.js +0 -33
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -105
- data/dist/chunks/_typeahead-QhswHQnq.js +1 -0
- data/dist/chunks/componentRegistry-DzmmLR2x.js +1 -0
- data/dist/chunks/vendor.js +2 -2
- data/dist/menu.yml +1 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/pb_forms_helper.rb +0 -3
- data/lib/playbook/version.rb +1 -1
- metadata +4 -26
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_cascade_collapse.jsx +0 -50
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_cascade_collapse.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/_lexxy_styles.scss +0 -69
- data/app/pb_kits/playbook/pb_rich_text_editor/_quill_styles.scss +0 -86
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_lexxy_default.html.erb +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_lexxy_default.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_quill_default.html.erb +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_quill_default.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_tiptap_default.html.erb +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_tiptap_default.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor_lexxy/rich_text_editor_lexxy.html.erb +0 -38
- data/app/pb_kits/playbook/pb_rich_text_editor_lexxy/rich_text_editor_lexxy.rb +0 -29
- data/app/pb_kits/playbook/pb_rich_text_editor_quill/rich_text_editor_quill.html.erb +0 -47
- data/app/pb_kits/playbook/pb_rich_text_editor_quill/rich_text_editor_quill.rb +0 -37
- data/app/pb_kits/playbook/pb_rich_text_editor_tiptap/README.md +0 -35
- data/app/pb_kits/playbook/pb_rich_text_editor_tiptap/rich_text_editor_tiptap.html.erb +0 -302
- data/app/pb_kits/playbook/pb_rich_text_editor_tiptap/rich_text_editor_tiptap.rb +0 -44
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props.jsx +0 -152
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props.md +0 -17
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props_rails.html.erb +0 -121
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props_rails.md +0 -17
- data/app/pb_kits/playbook/utilities/domHelpers.ts +0 -50
- data/dist/chunks/_typeahead-DAA1_5Wa.js +0 -1
- data/dist/chunks/componentRegistry-DRSp5D_e.js +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fd3f27912f0b549682a35207a8becb10ff8e4a631e6973fd7ce41e08ba29c441
|
|
4
|
+
data.tar.gz: ff6f8a7c236b63aca629414e40e9cb1863f2b65295abaf3f4e99de4e724564d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 37b26b7a34ff4f8422740b5f50db284e09a4c2ddb36ae3b60f2f6f66a2aea120937c765a8c3ef9b5cb0922b8f180ea43fc1a6ca16b66824a447afc0bb4d32f6d
|
|
7
|
+
data.tar.gz: 97d329ee90e4219b1be084961fd50fccd68a4c8948c6a5a1921519dfabfa2ebb2db0f0f57ab705f474e607c8c9305df275af54374f990785bd053daccd5879e2
|
|
@@ -11,7 +11,6 @@ import Icon from "../../pb_icon/_icon"
|
|
|
11
11
|
import Checkbox from "../../pb_checkbox/_checkbox"
|
|
12
12
|
|
|
13
13
|
import AdvancedTableContext from "../Context/AdvancedTableContext"
|
|
14
|
-
import { getDescendantRowIds } from "../Utilities/ExpansionControlHelpers"
|
|
15
14
|
|
|
16
15
|
interface CustomCellProps {
|
|
17
16
|
getValue?: Getter<string>
|
|
@@ -32,25 +31,13 @@ export const CustomCell = ({
|
|
|
32
31
|
selectableRows,
|
|
33
32
|
customStyle = {},
|
|
34
33
|
}: CustomCellProps & GlobalProps) => {
|
|
35
|
-
const { setExpanded, expanded, expandedControl, inlineRowLoading, hasAnySubRows
|
|
34
|
+
const { setExpanded, expanded, expandedControl, inlineRowLoading, hasAnySubRows } = useContext(AdvancedTableContext);
|
|
36
35
|
|
|
37
36
|
const handleOnExpand = (row: Row<GenericObject>) => {
|
|
38
37
|
onRowToggleClick && onRowToggleClick(row);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (!expandedControl) {
|
|
43
|
-
setExpanded({ ...expanded, [row.id]: true });
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
if (cascadeCollapse) {
|
|
47
|
-
const idsToRemove = new Set([row.id, ...getDescendantRowIds(row)]);
|
|
48
|
-
const nextExpanded = { ...expanded };
|
|
49
|
-
idsToRemove.forEach((id) => delete nextExpanded[id]);
|
|
50
|
-
setExpanded(nextExpanded);
|
|
51
|
-
} else if (!expandedControl) {
|
|
52
|
-
setExpanded({ ...expanded, [row.id]: false });
|
|
53
|
-
}
|
|
38
|
+
|
|
39
|
+
if (!expandedControl) {
|
|
40
|
+
setExpanded({ ...expanded, [row.id]: !row.getIsExpanded() });
|
|
54
41
|
}
|
|
55
42
|
};
|
|
56
43
|
|
|
@@ -63,7 +63,6 @@ export const TableHeaderCell = ({
|
|
|
63
63
|
stickyLeftColumn,
|
|
64
64
|
inlineRowLoading,
|
|
65
65
|
isActionBarVisible,
|
|
66
|
-
cascadeCollapse,
|
|
67
66
|
} = useContext(AdvancedTableContext);
|
|
68
67
|
|
|
69
68
|
type justifyTypes = "none" | "center" | "start" | "end" | "between" | "around" | "evenly"
|
|
@@ -183,8 +182,7 @@ const isToggleExpansionEnabled =
|
|
|
183
182
|
table.getRowModel(),
|
|
184
183
|
expanded,
|
|
185
184
|
undefined,
|
|
186
|
-
depth
|
|
187
|
-
cascadeCollapse
|
|
185
|
+
depth
|
|
188
186
|
)
|
|
189
187
|
setExpanded(updated)
|
|
190
188
|
}
|
|
@@ -12,7 +12,6 @@ interface UseTableActionsProps {
|
|
|
12
12
|
inlineRowLoading?: boolean;
|
|
13
13
|
localPagination?: { pageIndex: number; pageSize: number };
|
|
14
14
|
setLocalPagination?: (pagination: { pageIndex: number; pageSize: number }) => void;
|
|
15
|
-
cascadeCollapse?: boolean;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
export function useTableActions({
|
|
@@ -23,8 +22,7 @@ export function useTableActions({
|
|
|
23
22
|
onRowSelectionChange,
|
|
24
23
|
inlineRowLoading = false,
|
|
25
24
|
localPagination,
|
|
26
|
-
setLocalPagination
|
|
27
|
-
cascadeCollapse = false
|
|
25
|
+
setLocalPagination
|
|
28
26
|
}: UseTableActionsProps) {
|
|
29
27
|
|
|
30
28
|
// State to achieve 1 second delay before fetching more rows
|
|
@@ -34,25 +32,15 @@ export function useTableActions({
|
|
|
34
32
|
// Handle expand/collapse
|
|
35
33
|
const handleExpandOrCollapse = useCallback(async (row: Row<GenericObject>) => {
|
|
36
34
|
if (onToggleExpansionClick) onToggleExpansionClick(row)
|
|
35
|
+
const updatedExpandedState = await updateExpandAndCollapseState(
|
|
36
|
+
table.getRowModel(),
|
|
37
|
+
expanded,
|
|
38
|
+
row?.parentId,
|
|
39
|
+
undefined
|
|
40
|
+
)
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (cascadeCollapse && isHeaderCollapseAll) {
|
|
42
|
-
setExpanded({})
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const updatedExpandedState = await updateExpandAndCollapseState(
|
|
47
|
-
table.getRowModel(),
|
|
48
|
-
expanded,
|
|
49
|
-
row?.parentId,
|
|
50
|
-
undefined,
|
|
51
|
-
cascadeCollapse
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
setExpanded(updatedExpandedState)
|
|
55
|
-
}, [expanded, setExpanded, onToggleExpansionClick, table, cascadeCollapse]);
|
|
42
|
+
setExpanded(updatedExpandedState)
|
|
43
|
+
}, [expanded, setExpanded, onToggleExpansionClick, table]);
|
|
56
44
|
|
|
57
45
|
// Handle pagination
|
|
58
46
|
const onPageChange = useCallback((page: number) => {
|
|
@@ -11,21 +11,11 @@ const filterExpandableRows = (expandedState: Record<string, boolean>) => {
|
|
|
11
11
|
return expandedState
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const getDescendantRowIds = (row: Row<GenericObject>): string[] => {
|
|
15
|
-
const ids: string[] = []
|
|
16
|
-
for (const sub of row.subRows || []) {
|
|
17
|
-
ids.push(sub.id)
|
|
18
|
-
ids.push(...getDescendantRowIds(sub))
|
|
19
|
-
}
|
|
20
|
-
return ids
|
|
21
|
-
}
|
|
22
|
-
|
|
23
14
|
export const updateExpandAndCollapseState = (
|
|
24
15
|
tableRows: RowModel<GenericObject>,
|
|
25
16
|
expanded: Record<string, boolean>,
|
|
26
17
|
targetParent?: string,
|
|
27
18
|
targetDepth?: number,
|
|
28
|
-
cascadeCollapse?: boolean,
|
|
29
19
|
) => {
|
|
30
20
|
const updateExpandedRows: Record<string, boolean> = {};
|
|
31
21
|
const rows = targetDepth !== undefined ? tableRows.flatRows : tableRows.rows;
|
|
@@ -61,22 +51,8 @@ export const updateExpandAndCollapseState = (
|
|
|
61
51
|
}
|
|
62
52
|
}
|
|
63
53
|
|
|
64
|
-
|
|
54
|
+
return filterExpandableRows({
|
|
65
55
|
...(expanded as ExpandedStateObject),
|
|
66
56
|
...updateExpandedRows,
|
|
67
57
|
});
|
|
68
|
-
|
|
69
|
-
if (cascadeCollapse && !isExpandAction) {
|
|
70
|
-
const idsToRemove = new Set<string>();
|
|
71
|
-
for (const row of rowsToToggle) {
|
|
72
|
-
const shouldUpdate =
|
|
73
|
-
targetDepth === undefined ? true : row.depth === targetDepth;
|
|
74
|
-
if (shouldUpdate) {
|
|
75
|
-
getDescendantRowIds(row).forEach((id) => idsToRemove.add(id));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
idsToRemove.forEach((id) => delete updatedExpandedState[id]);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return updatedExpandedState;
|
|
82
58
|
};
|
|
@@ -31,7 +31,6 @@ type FullscreenControls = {
|
|
|
31
31
|
type AdvancedTableProps = {
|
|
32
32
|
aria?: { [key: string]: string }
|
|
33
33
|
actions?: React.ReactNode[] | React.ReactNode
|
|
34
|
-
cascadeCollapse?: boolean
|
|
35
34
|
children?: React.ReactNode | React.ReactNode[]
|
|
36
35
|
className?: string
|
|
37
36
|
columnDefinitions: GenericObject[]
|
|
@@ -81,7 +80,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
|
81
80
|
const {
|
|
82
81
|
aria = {},
|
|
83
82
|
actions,
|
|
84
|
-
cascadeCollapse = false,
|
|
85
83
|
children,
|
|
86
84
|
className,
|
|
87
85
|
columnDefinitions,
|
|
@@ -175,8 +173,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
|
175
173
|
onRowSelectionChange,
|
|
176
174
|
inlineRowLoading,
|
|
177
175
|
localPagination,
|
|
178
|
-
setLocalPagination
|
|
179
|
-
cascadeCollapse
|
|
176
|
+
setLocalPagination
|
|
180
177
|
});
|
|
181
178
|
|
|
182
179
|
// Set table row count for loading state
|
|
@@ -342,7 +339,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
|
342
339
|
>
|
|
343
340
|
{renderFullscreenHeader()}
|
|
344
341
|
<AdvancedTableProvider
|
|
345
|
-
cascadeCollapse={cascadeCollapse}
|
|
346
342
|
columnDefinitions={columnDefinitions}
|
|
347
343
|
columnGroupBorderColor={columnGroupBorderColor}
|
|
348
344
|
columnVisibilityControl={columnVisibilityControl}
|
|
@@ -1015,77 +1015,4 @@ test("columnStyling.headerFontColor works as excpected", () => {
|
|
|
1015
1015
|
|
|
1016
1016
|
const firstEnrollmentHeader = screen.getAllByText("New Enrollments")[0].closest("th");
|
|
1017
1017
|
expect(firstEnrollmentHeader).toHaveStyle({ color: colors.white });
|
|
1018
|
-
});
|
|
1019
|
-
|
|
1020
|
-
test("cascadeCollapse=false (default) preserves existing behavior when parent is re-expanded", () => {
|
|
1021
|
-
render(
|
|
1022
|
-
<AdvancedTable
|
|
1023
|
-
columnDefinitions={columnDefinitions}
|
|
1024
|
-
data={{ testid: testId }}
|
|
1025
|
-
tableData={MOCK_DATA}
|
|
1026
|
-
/>
|
|
1027
|
-
)
|
|
1028
|
-
|
|
1029
|
-
const kit = screen.getByTestId(testId)
|
|
1030
|
-
const getParentExpandButton = () => kit.querySelector("tbody tr .gray-icon.expand-toggle-icon")
|
|
1031
|
-
const parentButton = getParentExpandButton()
|
|
1032
|
-
expect(parentButton).toBeInTheDocument()
|
|
1033
|
-
parentButton.click()
|
|
1034
|
-
let subRow = kit.querySelector(".pb-bg-row-white.depth-sub-row-1")
|
|
1035
|
-
expect(subRow).toBeInTheDocument()
|
|
1036
|
-
getParentExpandButton().click()
|
|
1037
|
-
subRow = kit.querySelector(".pb-bg-row-white.depth-sub-row-1")
|
|
1038
|
-
expect(subRow).not.toBeInTheDocument()
|
|
1039
|
-
getParentExpandButton().click()
|
|
1040
|
-
subRow = kit.querySelector(".pb-bg-row-white.depth-sub-row-1")
|
|
1041
|
-
expect(subRow).toBeInTheDocument()
|
|
1042
|
-
})
|
|
1043
|
-
|
|
1044
|
-
test("cascadeCollapse=true collapses all descendants when parent is collapsed", () => {
|
|
1045
|
-
render(
|
|
1046
|
-
<AdvancedTable
|
|
1047
|
-
cascadeCollapse
|
|
1048
|
-
columnDefinitions={columnDefinitions}
|
|
1049
|
-
data={{ testid: testId }}
|
|
1050
|
-
tableData={MOCK_DATA}
|
|
1051
|
-
/>
|
|
1052
|
-
)
|
|
1053
|
-
|
|
1054
|
-
const kit = screen.getByTestId(testId)
|
|
1055
|
-
const getParentExpandButton = () => kit.querySelector("tbody tr .gray-icon.expand-toggle-icon")
|
|
1056
|
-
const parentButton = getParentExpandButton()
|
|
1057
|
-
expect(parentButton).toBeInTheDocument()
|
|
1058
|
-
parentButton.click()
|
|
1059
|
-
expect(kit.querySelector(".depth-sub-row-1")).toBeInTheDocument()
|
|
1060
|
-
getParentExpandButton().click()
|
|
1061
|
-
expect(kit.querySelector(".depth-sub-row-1")).not.toBeInTheDocument()
|
|
1062
|
-
getParentExpandButton().click()
|
|
1063
|
-
expect(kit.querySelector(".depth-sub-row-1")).toBeInTheDocument()
|
|
1064
|
-
})
|
|
1065
|
-
|
|
1066
|
-
test("cascadeCollapse=true with header toggle all: collapse all then expand all shows only direct children", async () => {
|
|
1067
|
-
render(
|
|
1068
|
-
<AdvancedTable
|
|
1069
|
-
cascadeCollapse
|
|
1070
|
-
columnDefinitions={columnDefinitions}
|
|
1071
|
-
data={{ testid: testId }}
|
|
1072
|
-
tableData={MOCK_DATA}
|
|
1073
|
-
/>
|
|
1074
|
-
)
|
|
1075
|
-
|
|
1076
|
-
const kit = screen.getByTestId(testId)
|
|
1077
|
-
const toggleAllButton = kit.querySelector(".gray-icon.toggle-all-icon")
|
|
1078
|
-
expect(toggleAllButton).toBeInTheDocument()
|
|
1079
|
-
toggleAllButton.click()
|
|
1080
|
-
await waitFor(() => {
|
|
1081
|
-
expect(kit.querySelector(".depth-sub-row-1")).toBeInTheDocument()
|
|
1082
|
-
})
|
|
1083
|
-
toggleAllButton.click()
|
|
1084
|
-
await waitFor(() => {
|
|
1085
|
-
expect(kit.querySelector(".depth-sub-row-1")).not.toBeInTheDocument()
|
|
1086
|
-
})
|
|
1087
|
-
toggleAllButton.click()
|
|
1088
|
-
await waitFor(() => {
|
|
1089
|
-
expect(kit.querySelector(".depth-sub-row-1")).toBeInTheDocument()
|
|
1090
|
-
})
|
|
1091
|
-
})
|
|
1018
|
+
});
|
|
@@ -42,7 +42,6 @@ examples:
|
|
|
42
42
|
- advanced_table_expanded_control: Expanded Control
|
|
43
43
|
- advanced_table_expand_by_depth: Expand by Depth
|
|
44
44
|
- advanced_table_subrow_headers: SubRow Headers
|
|
45
|
-
- advanced_table_cascade_collapse: Cascade Collapse
|
|
46
45
|
- advanced_table_collapsible_trail: Collapsible Trail
|
|
47
46
|
- advanced_table_table_options: Table Options
|
|
48
47
|
- advanced_table_table_props: Table Props
|
|
@@ -48,5 +48,4 @@ export { default as AdvancedTablePaddingControl } from './_advanced_table_paddin
|
|
|
48
48
|
export { default as AdvancedTablePaddingControlPerRow } from './_advanced_table_padding_control_per_row.jsx'
|
|
49
49
|
export { default as AdvancedTableColumnStylingBackground } from './_advanced_table_column_styling_background.jsx'
|
|
50
50
|
export { default as AdvancedTableColumnStylingBackgroundMulti } from './_advanced_table_column_styling_background_multi.jsx'
|
|
51
|
-
export { default as AdvancedTableColumnStylingBackgroundCustom } from './_advanced_table_column_styling_background_custom.jsx'
|
|
52
|
-
export { default as AdvancedTableCascadeCollapse } from './_advanced_table_cascade_collapse.jsx'
|
|
51
|
+
export { default as AdvancedTableColumnStylingBackgroundCustom } from './_advanced_table_column_styling_background_custom.jsx'
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import PbEnhancedElement from "../pb_enhanced_element";
|
|
2
2
|
import { updateSelectionActionBar } from "./advanced_table_action_bar";
|
|
3
|
-
import { setArrowVisibility, toggleVisibility } from "../utilities/domHelpers";
|
|
4
3
|
|
|
5
4
|
const ADVANCED_TABLE_SELECTOR = "[data-advanced-table]";
|
|
6
5
|
const DOWN_ARROW_SELECTOR = "#advanced-table_open_icon";
|
|
@@ -21,18 +20,10 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
|
21
20
|
this.childRowsMap = new Map();
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
get table() {
|
|
25
|
-
return this.cachedTable || (this.cachedTable = this.element.closest("table"));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
get mainTable() {
|
|
29
|
-
return this.cachedMainTable || (this.cachedMainTable = this.element.closest(".pb_advanced_table"));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
23
|
// Fetch and cache child rows for a given parent row ID
|
|
33
24
|
childRowsFor(parentId) {
|
|
34
25
|
if (!this.childRowsMap.has(parentId)) {
|
|
35
|
-
const table = this.table;
|
|
26
|
+
const table = this.element.closest("table");
|
|
36
27
|
const rows = Array.from(
|
|
37
28
|
table.querySelectorAll(`tr[data-row-parent="${parentId}"]`)
|
|
38
29
|
);
|
|
@@ -42,8 +33,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
|
42
33
|
}
|
|
43
34
|
|
|
44
35
|
updateTableSelectedRowsAttribute() {
|
|
45
|
-
const mainTable = this.
|
|
46
|
-
if (!mainTable) return;
|
|
36
|
+
const mainTable = this.element.closest(".pb_advanced_table");
|
|
47
37
|
mainTable.dataset.selectedRows = JSON.stringify(
|
|
48
38
|
Array.from(PbAdvancedTable.selectedRows)
|
|
49
39
|
);
|
|
@@ -51,8 +41,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
|
51
41
|
|
|
52
42
|
// Recalculate selected count based on all checked checkboxes
|
|
53
43
|
recalculateSelectedCount() {
|
|
54
|
-
const table = this.table;
|
|
55
|
-
if (!table) return;
|
|
44
|
+
const table = this.element.closest("table");
|
|
56
45
|
|
|
57
46
|
// Get all checkboxes that could be part of the selection
|
|
58
47
|
// This includes row checkboxes and any parent checkboxes that might be programmatically checked
|
|
@@ -106,7 +95,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
|
106
95
|
});
|
|
107
96
|
|
|
108
97
|
this.updateTableSelectedRowsAttribute();
|
|
109
|
-
updateSelectionActionBar(
|
|
98
|
+
updateSelectionActionBar(table.closest(".pb_advanced_table"), PbAdvancedTable.selectedRows.size);
|
|
110
99
|
|
|
111
100
|
// Sync header select-all state
|
|
112
101
|
if (selectAllCheckbox) {
|
|
@@ -150,7 +139,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
|
150
139
|
|
|
151
140
|
this.updateTableSelectedRowsAttribute();
|
|
152
141
|
|
|
153
|
-
const table =
|
|
142
|
+
const table = checkbox.closest("table");
|
|
154
143
|
const selectAllCheckbox = table.querySelector("#select-all-rows");
|
|
155
144
|
|
|
156
145
|
if (selectAllCheckbox) {
|
|
@@ -164,7 +153,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
|
164
153
|
);
|
|
165
154
|
selectAllInput.checked = allChecked;
|
|
166
155
|
}
|
|
167
|
-
updateSelectionActionBar(
|
|
156
|
+
updateSelectionActionBar(table.closest(".pb_advanced_table"), PbAdvancedTable.selectedRows.size);
|
|
168
157
|
}
|
|
169
158
|
|
|
170
159
|
get target() {
|
|
@@ -172,11 +161,10 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
|
172
161
|
}
|
|
173
162
|
|
|
174
163
|
connect() {
|
|
175
|
-
const table = this.table;
|
|
176
|
-
if (!table) return;
|
|
164
|
+
const table = this.element.closest("table");
|
|
177
165
|
|
|
178
166
|
this.hideCloseIcon();
|
|
179
|
-
const mainTable = this.
|
|
167
|
+
const mainTable = this.element.closest(".pb_advanced_table");
|
|
180
168
|
|
|
181
169
|
// This so it is hidden on first render
|
|
182
170
|
if (mainTable) {
|
|
@@ -283,7 +271,9 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
|
283
271
|
}
|
|
284
272
|
|
|
285
273
|
// Find direct child rows
|
|
286
|
-
const childRows =
|
|
274
|
+
const childRows = Array.from(
|
|
275
|
+
table.querySelectorAll(`[data-row-parent="${toggleBtn.id}"]`)
|
|
276
|
+
);
|
|
287
277
|
this.toggleElement(childRows);
|
|
288
278
|
|
|
289
279
|
// Restore original element context
|
|
@@ -294,8 +284,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
|
294
284
|
}
|
|
295
285
|
|
|
296
286
|
addBorderRadiusOnLastVisibleRow() {
|
|
297
|
-
const parentElement = this.
|
|
298
|
-
if (!parentElement) return;
|
|
287
|
+
const parentElement = this.element.closest(".pb_advanced_table");
|
|
299
288
|
|
|
300
289
|
const table = document.getElementById(parentElement.id);
|
|
301
290
|
|
|
@@ -327,9 +316,11 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
|
327
316
|
elements.forEach((elem) => {
|
|
328
317
|
elem.style.display = "table-row";
|
|
329
318
|
elem.classList.add("is-visible");
|
|
330
|
-
const childRowsAll = this.
|
|
331
|
-
|
|
332
|
-
|
|
319
|
+
const childRowsAll = this.element
|
|
320
|
+
.closest("table")
|
|
321
|
+
.querySelectorAll(
|
|
322
|
+
`[data-advanced-table-content^="${elem.dataset.advancedTableContent}-"]`
|
|
323
|
+
);
|
|
333
324
|
|
|
334
325
|
childRowsAll.forEach((childRow) => {
|
|
335
326
|
const dataContent = childRow.dataset.advancedTableContent;
|
|
@@ -391,7 +382,8 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
|
391
382
|
const currentDepth = parseInt(elem.dataset.rowDepth);
|
|
392
383
|
if (childrenArray.length > currentDepth) {
|
|
393
384
|
// Find the child rows corresponding to this parent row
|
|
394
|
-
const childRows = this.
|
|
385
|
+
const childRows = this.element
|
|
386
|
+
.closest("table")
|
|
395
387
|
.querySelectorAll(
|
|
396
388
|
`[data-advanced-table-content^="${elem.dataset.advancedTableContent}-"]`
|
|
397
389
|
);
|
|
@@ -409,39 +401,28 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
|
409
401
|
|
|
410
402
|
const isVisible = elements[0].classList.contains("is-visible");
|
|
411
403
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
onHide: () => this.hideElement(elements),
|
|
415
|
-
onShow: () => this.showElement(elements),
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
isExpanded ? this.displayUpArrow() : this.displayDownArrow();
|
|
404
|
+
isVisible ? this.hideElement(elements) : this.showElement(elements);
|
|
405
|
+
isVisible ? this.displayDownArrow() : this.displayUpArrow();
|
|
419
406
|
|
|
420
407
|
const row = this.element.closest("tr");
|
|
421
408
|
if (row) {
|
|
422
|
-
row.classList.toggle("bg-silver",
|
|
423
|
-
row.classList.toggle("pb-bg-row-white",
|
|
409
|
+
row.classList.toggle("bg-silver", !isVisible);
|
|
410
|
+
row.classList.toggle("pb-bg-row-white", isVisible);
|
|
424
411
|
}
|
|
425
412
|
|
|
426
413
|
this.addBorderRadiusOnLastVisibleRow();
|
|
427
414
|
}
|
|
428
415
|
|
|
429
416
|
displayDownArrow() {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
upSelector: UP_ARROW_SELECTOR,
|
|
434
|
-
showDownArrow: true,
|
|
435
|
-
});
|
|
417
|
+
this.element.querySelector(DOWN_ARROW_SELECTOR).style.display =
|
|
418
|
+
"inline-block";
|
|
419
|
+
this.element.querySelector(UP_ARROW_SELECTOR).style.display = "none";
|
|
436
420
|
}
|
|
437
421
|
|
|
438
422
|
displayUpArrow() {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
upSelector: UP_ARROW_SELECTOR,
|
|
443
|
-
showDownArrow: false,
|
|
444
|
-
});
|
|
423
|
+
this.element.querySelector(UP_ARROW_SELECTOR).style.display =
|
|
424
|
+
"inline-block";
|
|
425
|
+
this.element.querySelector(DOWN_ARROW_SELECTOR).style.display = "none";
|
|
445
426
|
}
|
|
446
427
|
|
|
447
428
|
static handleToggleAllHeaders(element) {
|
|
@@ -57,7 +57,7 @@ $pb_button_border_width: 0px;
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
.loading-icon {
|
|
60
|
-
position:
|
|
60
|
+
position: absolute;
|
|
61
61
|
display: none;
|
|
62
62
|
}
|
|
63
63
|
.pb_button_content {
|
|
@@ -158,15 +158,10 @@ $pb_button_border_width: 0px;
|
|
|
158
158
|
// Loading =====================
|
|
159
159
|
@mixin pb_button_loading($loading: false) {
|
|
160
160
|
@if $loading == true {
|
|
161
|
-
display: inline-grid;
|
|
162
|
-
place-items: center;
|
|
163
|
-
|
|
164
161
|
.loading-icon {
|
|
165
|
-
grid-area: 1 / 1;
|
|
166
162
|
display: block;
|
|
167
163
|
}
|
|
168
164
|
.pb_button_content {
|
|
169
|
-
grid-area: 1 / 1;
|
|
170
165
|
visibility: hidden;
|
|
171
166
|
}
|
|
172
167
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import PbEnhancedElement from '../pb_enhanced_element'
|
|
2
|
-
import { getElementHeight, setArrowVisibility, toggleVisibility } from '../utilities/domHelpers'
|
|
3
2
|
|
|
4
3
|
const MAIN_SELECTOR = '[data-collapsible-main]'
|
|
5
4
|
const CONTENT_SELECTOR = '[data-collapsible-content]'
|
|
@@ -44,7 +43,15 @@ export default class PbCollapsible extends PbEnhancedElement {
|
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
showElement(elem) {
|
|
47
|
-
|
|
46
|
+
// Get the natural height of the element
|
|
47
|
+
const getHeight = () => {
|
|
48
|
+
elem.style.display = 'block'
|
|
49
|
+
const height = elem.scrollHeight + 'px' // Get it's height
|
|
50
|
+
elem.style.display = '' // Hide it again
|
|
51
|
+
return height
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const height = getHeight()
|
|
48
55
|
elem.classList.add('is-visible')
|
|
49
56
|
elem.style.height = height // Update the max-height
|
|
50
57
|
elem.style.overflow = "hidden"
|
|
@@ -75,22 +82,26 @@ export default class PbCollapsible extends PbEnhancedElement {
|
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
toggleElement(elem) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
if (elem.classList.contains('is-visible')) {
|
|
86
|
+
this.hideElement(elem)
|
|
87
|
+
this.displayDownArrow()
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
// Otherwise, show it
|
|
91
|
+
this.showElement(elem)
|
|
92
|
+
this.displayUpArrow()
|
|
85
93
|
}
|
|
86
94
|
|
|
87
95
|
toggleArrows(showDownArrow) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
showDownArrow
|
|
93
|
-
}
|
|
96
|
+
const downArrow = this.element.querySelector(DOWN_ARROW_SELECTOR);
|
|
97
|
+
const upArrow = this.element.querySelector(UP_ARROW_SELECTOR);
|
|
98
|
+
|
|
99
|
+
if (downArrow) {
|
|
100
|
+
downArrow.style.display = showDownArrow ? 'inline-block' : 'none';
|
|
101
|
+
}
|
|
102
|
+
if (upArrow) {
|
|
103
|
+
upArrow.style.display = showDownArrow ? 'none' : 'inline-block';
|
|
104
|
+
}
|
|
94
105
|
}
|
|
95
106
|
|
|
96
107
|
displayDownArrow() {
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
<%= pb_rails("button", props: { text: "Open Dialog", data: {"open-dialog": "dialog-1"} }) %>
|
|
2
2
|
|
|
3
|
-
<%= pb_rails("dialog", props: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<% end %>
|
|
13
|
-
|
|
14
|
-
<%= pb_rails("dialog/dialog_footer") do %>
|
|
15
|
-
<%= pb_rails("flex", props: { spacing: "between", padding_x: "md", padding_bottom: "md", padding: "sm" }) do %>
|
|
16
|
-
<%= pb_rails("button", props: { loading: true, text: "Send My Issue" }) %>
|
|
17
|
-
<%= pb_rails("button", props: { text: "Back", variant: "link", data: {"close-dialog": "dialog-1"} }) %>
|
|
18
|
-
<% end %>
|
|
19
|
-
<% end %>
|
|
20
|
-
<% end %>
|
|
3
|
+
<%= pb_rails("dialog", props: {
|
|
4
|
+
id:"dialog-1",
|
|
5
|
+
size: "sm",
|
|
6
|
+
title: "Header Title is the Title Prop",
|
|
7
|
+
text: "Hello Body Text, Nice to meet ya.",
|
|
8
|
+
cancel_button: "Cancel Button",
|
|
9
|
+
confirm_button: "Okay",
|
|
10
|
+
confirm_button_id: "confirm-button-1"
|
|
11
|
+
}) %>
|
|
@@ -12,35 +12,16 @@ const DialogDefault = () => {
|
|
|
12
12
|
<>
|
|
13
13
|
<Button onClick={open}>{'Open Dialog'}</Button>
|
|
14
14
|
<Dialog
|
|
15
|
+
cancelButton="Cancel Button"
|
|
16
|
+
confirmButton="Okay"
|
|
15
17
|
onCancel={close}
|
|
16
18
|
onClose={close}
|
|
17
19
|
onConfirm={close}
|
|
18
20
|
opened={isOpen}
|
|
19
|
-
size="
|
|
21
|
+
size="sm"
|
|
22
|
+
text="Hello Body Text, Nice to meet ya."
|
|
20
23
|
title="Header Title is the Title Prop"
|
|
21
|
-
|
|
22
|
-
<Dialog.Body>
|
|
23
|
-
<Button
|
|
24
|
-
aria={{ label: 'Loading' }}
|
|
25
|
-
loading
|
|
26
|
-
text="Button Primary"
|
|
27
|
-
/>
|
|
28
|
-
<div style={{height: '800px', backgroundColor: 'lightgray'}} />
|
|
29
|
-
<Button
|
|
30
|
-
loading
|
|
31
|
-
text="Loading..."
|
|
32
|
-
/>
|
|
33
|
-
</Dialog.Body>
|
|
34
|
-
<Dialog.Footer>
|
|
35
|
-
<Button
|
|
36
|
-
loading
|
|
37
|
-
text="Send My Issue"
|
|
38
|
-
/>
|
|
39
|
-
<Button variant="link">
|
|
40
|
-
{"Back"}
|
|
41
|
-
</Button>
|
|
42
|
-
</Dialog.Footer>
|
|
43
|
-
</Dialog>
|
|
24
|
+
/>
|
|
44
25
|
</>
|
|
45
26
|
)
|
|
46
27
|
}
|