playbook_ui 14.18.1.pre.rc.0 → 14.19.0.pre.alpha.PLAY2033atactionbarrails7730
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/_playbook.scss +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +11 -1
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +148 -15
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +20 -3
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +23 -13
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/VisibilityTree.ts +47 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +313 -21
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +12 -3
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +19 -8
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +15 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.md +0 -6
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color.jsx +80 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.html.erb +58 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility.jsx +57 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility.md +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_custom.jsx +62 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_custom.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_multi.jsx +82 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_multi.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.jsx +65 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.html.erb +56 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_no_subrows_rails.md +5 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_no_subrows.jsx → _advanced_table_selectable_rows_no_subrows_react.jsx} +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.md +3 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +11 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +7 -2
- data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +106 -0
- data/app/pb_kits/playbook/pb_advanced_table/index.js +529 -31
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_action_bar.html.erb +23 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_action_bar.rb +19 -0
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +9 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +1 -2
- data/app/pb_kits/playbook/pb_avatar/_avatar.scss +4 -0
- data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +3 -0
- data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +3 -3
- data/app/pb_kits/playbook/pb_avatar/avatar.rb +2 -0
- data/app/pb_kits/playbook/pb_avatar/avatar.test.js +18 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_grayscale.html.erb +5 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_grayscale.jsx +16 -0
- data/app/pb_kits/playbook/pb_avatar/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_avatar/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_card/card.html.erb +1 -1
- data/app/pb_kits/playbook/pb_card/card.rb +12 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_error.html.erb +2 -2
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones.html.erb +22 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_line.html.erb +55 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_line_rails.md +5 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_drop_zones_rails.md +5 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_event_listeners.jsx +59 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_event_listeners_react.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_draggable/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_draggable/draggable_container.rb +11 -1
- data/app/pb_kits/playbook/pb_draggable/draggable_item.rb +11 -1
- data/app/pb_kits/playbook/pb_draggable/index.js +4 -2
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +33 -5
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +5 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +5 -16
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_error.html.erb +5 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.html.erb +28 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.jsx +17 -64
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_with_subcomponents.html.erb +58 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/{_dropdown_with_autocomplete_and_custom_display.jsx → _dropdown_with_autocomplete_with_subcomponents.jsx} +11 -25
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_with_subcomponents.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_external_control.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_search.jsx +61 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_search.md +2 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_search_rails.html.erb +52 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_search_rails.md +2 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +7 -4
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +2 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +2 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +4 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +45 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +10 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +3 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +12 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +3 -1
- data/app/pb_kits/playbook/pb_dropdown/index.js +57 -0
- data/app/pb_kits/playbook/pb_dropdown/keyboard_accessibility.js +26 -0
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +3 -4
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +4 -4
- data/app/pb_kits/playbook/pb_empty_state/_empty_state.scss +8 -1
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_alignment.html.erb +27 -0
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_default.html.erb +7 -0
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_orientation.html.erb +12 -0
- data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_size.html.erb +23 -0
- data/app/pb_kits/playbook/pb_empty_state/docs/example.yml +5 -1
- data/app/pb_kits/playbook/pb_empty_state/empty_state.html.erb +19 -0
- data/app/pb_kits/playbook/pb_empty_state/empty_state.rb +123 -0
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.scss +13 -0
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.tsx +11 -1
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_error.html.erb +1 -0
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_error.jsx +41 -0
- data/app/pb_kits/playbook/pb_file_upload/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_file_upload/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +1 -0
- data/app/pb_kits/playbook/pb_file_upload/file_upload.rb +7 -1
- data/app/pb_kits/playbook/pb_file_upload/fileupload.test.js +18 -0
- data/app/pb_kits/playbook/pb_message/_message.tsx +3 -0
- data/app/pb_kits/playbook/pb_message/docs/_message_grayscale.html.erb +9 -0
- data/app/pb_kits/playbook/pb_message/docs/_message_grayscale.jsx +21 -0
- data/app/pb_kits/playbook/pb_message/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_message/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_message/message.html.erb +2 -1
- data/app/pb_kits/playbook/pb_message/message.rb +1 -0
- data/app/pb_kits/playbook/pb_overlay/_overlay.scss +2 -1
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_vertical_dynamic_multi_directional.jsx +1 -1
- data/app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_token.tsx +5 -4
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +9 -9
- data/app/pb_kits/playbook/pb_section_separator/_section_separator.tsx +2 -2
- data/app/pb_kits/playbook/pb_select/_select.scss +10 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_error.html.erb +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click.jsx +7 -7
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +5 -5
- data/app/pb_kits/playbook/pb_text_input/_text_input.scss +4 -2
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_error.html.erb +1 -1
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_error.html.erb +5 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.html.erb +8 -1
- data/app/pb_kits/playbook/pb_user/_user.tsx +3 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_grayscale.html.erb +6 -0
- data/app/pb_kits/playbook/pb_user/docs/_user_grayscale.jsx +16 -0
- data/app/pb_kits/playbook/pb_user/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_user/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_user/user.html.erb +2 -1
- data/app/pb_kits/playbook/pb_user/user.rb +1 -0
- data/dist/chunks/{_typeahead-D8CsVBZO.js → _typeahead-BPSIWtFT.js} +3 -3
- data/dist/chunks/_weekday_stacked-PfWrqC3z.js +45 -0
- data/dist/chunks/{lib-BmTAc7Nc.js → lib-B20MXZcW.js} +2 -2
- data/dist/chunks/{pb_form_validation-BWjy4bFn.js → pb_form_validation-WWvUXPKD.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +6 -14
- data/dist/playbook-doc.js +2 -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/version.rb +2 -2
- metadata +57 -21
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.md +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx +0 -79
- data/app/pb_kits/playbook/pb_gantt_chart/_gantt_chart.scss +0 -3
- data/app/pb_kits/playbook/pb_gantt_chart/_gantt_chart.tsx +0 -72
- data/app/pb_kits/playbook/pb_gantt_chart/docs/_gantt_chart_default.jsx +0 -53
- data/app/pb_kits/playbook/pb_gantt_chart/docs/example.yml +0 -7
- data/app/pb_kits/playbook/pb_gantt_chart/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_gantt_chart/gantt_chart.test.jsx +0 -19
- data/dist/chunks/_weekday_stacked-CHQsoCdP.js +0 -45
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_react.md → _advanced_table_selectable_rows.md} +0 -0
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows_no_subrows.html.erb → _advanced_table_selectable_rows_no_subrows_rails.html.erb} +0 -0
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_selectable_rows.html.erb → _advanced_table_selectable_rows_rails.html.erb} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_drop_zones_line.md → _draggable_drop_zones_line_react.md} +0 -0
- /data/app/pb_kits/playbook/pb_draggable/docs/{_draggable_event_listeners.md → _draggable_event_listeners_rails.md} +0 -0
@@ -9,54 +9,481 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
9
9
|
return ADVANCED_TABLE_SELECTOR;
|
10
10
|
}
|
11
11
|
|
12
|
+
// Track selections per table
|
13
|
+
static tableData = new Map();
|
14
|
+
|
15
|
+
// Get or initialize data for a specific table
|
16
|
+
static getTableData(tableId) {
|
17
|
+
if (!PbAdvancedTable.tableData.has(tableId)) {
|
18
|
+
PbAdvancedTable.tableData.set(tableId, {
|
19
|
+
selectedRows: new Set(),
|
20
|
+
expandedRows: new Set(),
|
21
|
+
initialized: false
|
22
|
+
});
|
23
|
+
}
|
24
|
+
return PbAdvancedTable.tableData.get(tableId);
|
25
|
+
}
|
26
|
+
|
27
|
+
// Get the table container from any element within the table
|
28
|
+
getTableContainer() {
|
29
|
+
return this.element.closest(".pb_advanced_table");
|
30
|
+
}
|
31
|
+
|
32
|
+
// Get table ID, create one if needed
|
33
|
+
getTableId() {
|
34
|
+
const tableContainer = this.getTableContainer();
|
35
|
+
if (!tableContainer) return null;
|
36
|
+
|
37
|
+
// Generate ID if none exists
|
38
|
+
if (!tableContainer.id) {
|
39
|
+
tableContainer.id = `table-${Date.now()}-${Math.floor(Math.random() * 10000)}`;
|
40
|
+
}
|
41
|
+
|
42
|
+
return tableContainer.id;
|
43
|
+
}
|
44
|
+
|
45
|
+
// Update the data attribute with selected rows
|
46
|
+
updateTableSelectedRowsAttribute() {
|
47
|
+
const tableContainer = this.getTableContainer();
|
48
|
+
const tableId = this.getTableId();
|
49
|
+
if (!tableId) return;
|
50
|
+
|
51
|
+
const tableData = PbAdvancedTable.getTableData(tableId);
|
52
|
+
const selectedRowsArray = Array.from(tableData.selectedRows);
|
53
|
+
|
54
|
+
// Update data attribute
|
55
|
+
tableContainer.dataset.selectedRows = JSON.stringify(selectedRowsArray);
|
56
|
+
|
57
|
+
// Update action bar visibility
|
58
|
+
this.updateActionBarVisibility(tableContainer, tableData.selectedRows);
|
59
|
+
}
|
60
|
+
|
61
|
+
// Update action bar visibility based on selection state
|
62
|
+
updateActionBarVisibility(tableContainer, selectedRows) {
|
63
|
+
if (!tableContainer) return;
|
64
|
+
|
65
|
+
const actionBar = tableContainer.querySelector(".row-selection-actions-card");
|
66
|
+
if (!actionBar) return;
|
67
|
+
|
68
|
+
const selectedCount = selectedRows.size;
|
69
|
+
|
70
|
+
// Update count display
|
71
|
+
const countElement = actionBar.querySelector(".selected-count");
|
72
|
+
if (countElement) {
|
73
|
+
countElement.textContent = `${selectedCount} Selected`;
|
74
|
+
}
|
75
|
+
|
76
|
+
// Show/hide based on selection
|
77
|
+
if (selectedCount > 0) {
|
78
|
+
this.showActionBar(actionBar);
|
79
|
+
} else {
|
80
|
+
this.hideActionBar(actionBar);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
// Show action bar with animation
|
85
|
+
showActionBar(actionBar) {
|
86
|
+
if (!actionBar) return;
|
87
|
+
|
88
|
+
// Force display block
|
89
|
+
actionBar.style.display = "block";
|
90
|
+
|
91
|
+
// Get the height before animation
|
92
|
+
const height = actionBar.scrollHeight + "px";
|
93
|
+
|
94
|
+
// Force all style changes directly
|
95
|
+
actionBar.style.height = height;
|
96
|
+
actionBar.classList.add("is-visible");
|
97
|
+
actionBar.classList.add("show-action-card");
|
98
|
+
actionBar.style.overflow = "hidden";
|
99
|
+
|
100
|
+
// Complete animation after delay
|
101
|
+
window.setTimeout(() => {
|
102
|
+
if (actionBar.classList.contains("is-visible")) {
|
103
|
+
actionBar.style.height = "";
|
104
|
+
actionBar.style.overflow = "visible";
|
105
|
+
}
|
106
|
+
}, 300);
|
107
|
+
}
|
108
|
+
|
109
|
+
// Hide action bar with animation
|
110
|
+
hideActionBar(actionBar) {
|
111
|
+
if (!actionBar) return;
|
112
|
+
|
113
|
+
// Set exact height before animation
|
114
|
+
actionBar.style.height = actionBar.scrollHeight + "px";
|
115
|
+
actionBar.offsetHeight; // Trigger reflow
|
116
|
+
|
117
|
+
// Animate to height 0
|
118
|
+
window.setTimeout(() => {
|
119
|
+
actionBar.style.height = "0";
|
120
|
+
actionBar.style.overflow = "hidden";
|
121
|
+
}, 10);
|
122
|
+
|
123
|
+
// Remove visibility classes after animation
|
124
|
+
window.setTimeout(() => {
|
125
|
+
actionBar.classList.remove("is-visible");
|
126
|
+
actionBar.classList.remove("show-action-card");
|
127
|
+
}, 300);
|
128
|
+
}
|
129
|
+
|
130
|
+
// Check if row is expanded
|
131
|
+
isRowExpanded(rowEl) {
|
132
|
+
const closeIcon = rowEl.querySelector(UP_ARROW_SELECTOR);
|
133
|
+
return closeIcon?.style.display === "none" || !closeIcon;
|
134
|
+
}
|
135
|
+
|
136
|
+
// Update parent checkboxes based on child selections
|
137
|
+
updateParentCheckboxes(checkbox) {
|
138
|
+
const rowEl = checkbox.closest("tr");
|
139
|
+
if (!rowEl) return;
|
140
|
+
|
141
|
+
const table = rowEl.closest("table");
|
142
|
+
if (!table) return;
|
143
|
+
|
144
|
+
const tableId = this.getTableId();
|
145
|
+
if (!tableId) return;
|
146
|
+
|
147
|
+
const tableData = PbAdvancedTable.getTableData(tableId);
|
148
|
+
|
149
|
+
const contentTrail = rowEl.dataset.advancedTableContent;
|
150
|
+
if (!contentTrail) return;
|
151
|
+
|
152
|
+
const ancestorIds = contentTrail.split("-").slice(0, -1);
|
153
|
+
|
154
|
+
ancestorIds.reverse();
|
155
|
+
ancestorIds.forEach((ancestorId) => {
|
156
|
+
const parentRowSelector = `[data-advanced-table-content$="${ancestorId}"]`;
|
157
|
+
const parentRow = table.querySelector(parentRowSelector);
|
158
|
+
if (!parentRow) return;
|
159
|
+
|
160
|
+
const parentLabel = parentRow.querySelector("label[data-row-id]");
|
161
|
+
if (!parentLabel) return;
|
162
|
+
|
163
|
+
const parentCheckbox = parentLabel.querySelector(
|
164
|
+
"input[type='checkbox']"
|
165
|
+
);
|
166
|
+
if (!parentCheckbox) return;
|
167
|
+
|
168
|
+
// Find all immediate children of parent linked to ancestor Id, filter our subrow headers
|
169
|
+
const children = Array.from(
|
170
|
+
table.querySelectorAll(`tr[data-row-parent$="_${ancestorId}"]`)
|
171
|
+
).filter((child) => {
|
172
|
+
const content = child.dataset.advancedTableContent;
|
173
|
+
return !(content && content.endsWith("sr"));
|
174
|
+
});
|
175
|
+
|
176
|
+
const allChildrenChecked = Array.from(children).every((child) => {
|
177
|
+
const childLabel = child.querySelector("label[data-row-id]");
|
178
|
+
if (!childLabel) return false;
|
179
|
+
const childCheckbox = childLabel.querySelector(
|
180
|
+
"input[type='checkbox']"
|
181
|
+
);
|
182
|
+
if (!childCheckbox) return false;
|
183
|
+
return childCheckbox.checked;
|
184
|
+
});
|
185
|
+
|
186
|
+
// Update parent checkbox
|
187
|
+
parentCheckbox.checked = allChildrenChecked;
|
188
|
+
|
189
|
+
const parentCheckboxId = parentCheckbox.id;
|
190
|
+
if (allChildrenChecked) {
|
191
|
+
tableData.selectedRows.add(parentCheckboxId);
|
192
|
+
parentRow.classList.add("bg-row-selection");
|
193
|
+
parentRow.classList.remove("bg-white", "bg-silver");
|
194
|
+
} else {
|
195
|
+
tableData.selectedRows.delete(parentCheckboxId);
|
196
|
+
}
|
197
|
+
if (!allChildrenChecked) {
|
198
|
+
parentRow.classList.remove("bg-row-selection");
|
199
|
+
|
200
|
+
if (this.isRowExpanded(parentRow)) {
|
201
|
+
parentRow.classList.remove("bg-silver");
|
202
|
+
parentRow.classList.add("bg-white");
|
203
|
+
} else {
|
204
|
+
parentRow.classList.remove("bg-white");
|
205
|
+
parentRow.classList.add("bg-silver");
|
206
|
+
}
|
207
|
+
}
|
208
|
+
});
|
209
|
+
}
|
210
|
+
|
211
|
+
// Handle row checkbox click
|
212
|
+
handleCheckboxClick(event) {
|
213
|
+
const checkbox = event.currentTarget;
|
214
|
+
const rowId = checkbox.id;
|
215
|
+
const isChecked = checkbox.checked;
|
216
|
+
const rowEl = checkbox.closest("tr");
|
217
|
+
|
218
|
+
const tableId = this.getTableId();
|
219
|
+
if (!tableId) return;
|
220
|
+
|
221
|
+
const tableData = PbAdvancedTable.getTableData(tableId);
|
222
|
+
|
223
|
+
if (isChecked) {
|
224
|
+
tableData.selectedRows.add(rowId);
|
225
|
+
rowEl.classList.add("bg-row-selection");
|
226
|
+
rowEl.classList.remove("bg-white", "bg-silver");
|
227
|
+
} else {
|
228
|
+
tableData.selectedRows.delete(rowId);
|
229
|
+
}
|
230
|
+
// Update background color on row
|
231
|
+
if (!isChecked) {
|
232
|
+
rowEl.classList.remove("bg-row-selection");
|
233
|
+
|
234
|
+
if (this.isRowExpanded(rowEl)) {
|
235
|
+
rowEl.classList.remove("bg-silver");
|
236
|
+
rowEl.classList.add("bg-white");
|
237
|
+
} else {
|
238
|
+
rowEl.classList.remove("bg-white");
|
239
|
+
rowEl.classList.add("bg-silver");
|
240
|
+
}
|
241
|
+
}
|
242
|
+
|
243
|
+
if (rowEl) {
|
244
|
+
const table = rowEl.closest("table");
|
245
|
+
const rowContent = rowEl.dataset.advancedTableContent;
|
246
|
+
|
247
|
+
if (rowContent) {
|
248
|
+
const childRows = table.querySelectorAll(
|
249
|
+
`[data-advanced-table-content^="${rowContent}-"]`
|
250
|
+
);
|
251
|
+
|
252
|
+
childRows.forEach((childRow) => {
|
253
|
+
const label = childRow.querySelector("label[data-row-id]");
|
254
|
+
if (!label) return;
|
255
|
+
|
256
|
+
const childCheckbox = label.querySelector("input[type='checkbox']");
|
257
|
+
if (!childCheckbox) return;
|
258
|
+
|
259
|
+
childCheckbox.checked = isChecked;
|
260
|
+
|
261
|
+
const childRowId = childCheckbox.id;
|
262
|
+
const childRowEl = childCheckbox.closest("tr");
|
263
|
+
if (isChecked) {
|
264
|
+
tableData.selectedRows.add(childRowId);
|
265
|
+
childRowEl?.classList.add("bg-row-selection");
|
266
|
+
childRowEl?.classList.remove("bg-white", "bg-silver");
|
267
|
+
} else {
|
268
|
+
tableData.selectedRows.delete(childRowId);
|
269
|
+
}
|
270
|
+
if (!isChecked) {
|
271
|
+
childRowEl?.classList.remove("bg-row-selection");
|
272
|
+
|
273
|
+
if (this.isRowExpanded(childRowEl)) {
|
274
|
+
childRowEl?.classList.remove("bg-silver");
|
275
|
+
childRowEl?.classList.add("bg-white");
|
276
|
+
} else {
|
277
|
+
childRowEl?.classList.remove("bg-white");
|
278
|
+
childRowEl?.classList.add("bg-silver");
|
279
|
+
}
|
280
|
+
}
|
281
|
+
});
|
282
|
+
}
|
283
|
+
}
|
284
|
+
|
285
|
+
this.updateParentCheckboxes(checkbox);
|
286
|
+
|
287
|
+
this.updateTableSelectedRowsAttribute();
|
288
|
+
|
289
|
+
const table = checkbox.closest("table");
|
290
|
+
const selectAllCheckbox = table.querySelector("#select-all-rows");
|
291
|
+
|
292
|
+
if (selectAllCheckbox) {
|
293
|
+
const allCheckboxes = table.querySelectorAll(
|
294
|
+
"label[data-row-id] input[type='checkbox']"
|
295
|
+
);
|
296
|
+
const allChecked = Array.from(allCheckboxes).every((cb) => cb.checked);
|
297
|
+
|
298
|
+
const selectAllInput = selectAllCheckbox.querySelector(
|
299
|
+
'input[type="checkbox"]'
|
300
|
+
);
|
301
|
+
selectAllInput.checked = allChecked;
|
302
|
+
}
|
303
|
+
}
|
304
|
+
|
12
305
|
get target() {
|
13
306
|
const table = this.element.closest("table");
|
14
307
|
return table.querySelectorAll(`[data-row-parent="${this.element.id}"]`);
|
15
308
|
}
|
16
309
|
|
17
|
-
static expandedRows = new Set();
|
18
310
|
static isCollapsing = false;
|
19
311
|
|
20
312
|
connect() {
|
313
|
+
// Get table container and generate ID if needed
|
314
|
+
const tableContainer = this.getTableContainer();
|
315
|
+
if (!tableContainer) return;
|
316
|
+
|
317
|
+
const tableId = this.getTableId();
|
318
|
+
if (!tableId) return;
|
319
|
+
|
320
|
+
// Get or initialize table data
|
321
|
+
const tableData = PbAdvancedTable.getTableData(tableId);
|
322
|
+
|
323
|
+
// Handle toggle click
|
21
324
|
this.element.addEventListener("click", () => {
|
22
325
|
if (!PbAdvancedTable.isCollapsing) {
|
23
326
|
const isExpanded =
|
24
327
|
this.element.querySelector(UP_ARROW_SELECTOR).style.display ===
|
25
328
|
"inline-block";
|
26
329
|
if (!isExpanded) {
|
27
|
-
|
330
|
+
tableData.expandedRows.add(this.element.id);
|
28
331
|
} else {
|
29
|
-
|
332
|
+
tableData.expandedRows.delete(this.element.id);
|
30
333
|
}
|
31
|
-
this.toggleElement(this.target);
|
334
|
+
this.toggleElement(this.target, tableData.expandedRows);
|
32
335
|
}
|
33
336
|
});
|
34
|
-
|
35
|
-
this.hideCloseIcon()
|
36
337
|
|
37
|
-
|
38
|
-
|
39
|
-
|
338
|
+
this.hideCloseIcon();
|
339
|
+
|
340
|
+
const table = this.element.closest("table");
|
341
|
+
if (!table) return;
|
342
|
+
|
343
|
+
// Skip if this table is already initialized
|
344
|
+
if (tableData.initialized) return;
|
345
|
+
|
346
|
+
// Initialize the action bar
|
347
|
+
const actionBar = tableContainer.querySelector(".row-selection-actions-card");
|
348
|
+
if (actionBar) {
|
349
|
+
// Direct style application
|
350
|
+
Object.assign(actionBar.style, {
|
351
|
+
height: '0px',
|
352
|
+
overflow: 'hidden',
|
353
|
+
display: 'block',
|
354
|
+
opacity: '0'
|
355
|
+
});
|
356
|
+
|
357
|
+
// Remove visibility classes
|
358
|
+
actionBar.classList.remove("is-visible", "show-action-card");
|
359
|
+
|
360
|
+
// Add CSS rules
|
361
|
+
const styleId = `action-bar-styles-${tableId}`;
|
362
|
+
let styleTag = document.getElementById(styleId);
|
363
|
+
if (!styleTag) {
|
364
|
+
styleTag = document.createElement('style');
|
365
|
+
styleTag.id = styleId;
|
366
|
+
document.head.appendChild(styleTag);
|
367
|
+
}
|
368
|
+
|
369
|
+
styleTag.textContent = `
|
370
|
+
#${tableId} .row-selection-actions-card.is-visible.show-action-card {
|
371
|
+
height: auto !important;
|
372
|
+
overflow: visible !important;
|
373
|
+
display: block !important;
|
374
|
+
opacity: 1 !important;
|
375
|
+
transition: height 0.3s ease, opacity 0.3s ease !important;
|
376
|
+
}
|
377
|
+
`;
|
378
|
+
|
379
|
+
// Direct DOM event listeners for checkboxes
|
380
|
+
const checkboxes = table.querySelectorAll('input[type="checkbox"]');
|
381
|
+
checkboxes.forEach(checkbox => {
|
382
|
+
checkbox.addEventListener('change', function() {
|
383
|
+
// Count selected checkboxes
|
384
|
+
const selectedCount = Array.from(checkboxes).filter(cb => cb.checked).length;
|
385
|
+
|
386
|
+
if (selectedCount > 0) {
|
387
|
+
// Show action bar directly
|
388
|
+
actionBar.style.height = 'auto';
|
389
|
+
actionBar.style.overflow = 'visible';
|
390
|
+
actionBar.style.opacity = '1';
|
391
|
+
actionBar.classList.add("is-visible", "show-action-card");
|
392
|
+
|
393
|
+
// Update the count
|
394
|
+
const countElement = actionBar.querySelector(".selected-count");
|
395
|
+
if (countElement) {
|
396
|
+
countElement.textContent = `${selectedCount} Selected`;
|
397
|
+
}
|
398
|
+
} else {
|
399
|
+
// Hide action bar directly
|
400
|
+
actionBar.style.height = '0px';
|
401
|
+
actionBar.style.overflow = 'hidden';
|
402
|
+
actionBar.style.opacity = '0';
|
403
|
+
actionBar.classList.remove("is-visible", "show-action-card");
|
404
|
+
}
|
405
|
+
});
|
406
|
+
});
|
407
|
+
}
|
408
|
+
|
409
|
+
// Bind checkbox change handlers
|
410
|
+
const checkboxLabels = table.querySelectorAll("label[data-row-id]");
|
411
|
+
checkboxLabels.forEach((label) => {
|
412
|
+
const checkbox = label.querySelector("input[type='checkbox']");
|
413
|
+
if (!checkbox) return;
|
414
|
+
|
415
|
+
// Remove any existing event listeners
|
416
|
+
const newCheckbox = checkbox.cloneNode(true);
|
417
|
+
checkbox.parentNode.replaceChild(newCheckbox, checkbox);
|
418
|
+
|
419
|
+
// Add our event listener
|
420
|
+
newCheckbox.addEventListener("change", (event) => {
|
421
|
+
this.handleCheckboxClick(event);
|
422
|
+
});
|
423
|
+
});
|
424
|
+
|
425
|
+
// Bind nested row expansion logic
|
426
|
+
const nestedButtons = table.querySelectorAll("[data-advanced-table]");
|
40
427
|
nestedButtons.forEach((button) => {
|
41
428
|
button.addEventListener("click", () => {
|
42
429
|
const isExpanded =
|
43
|
-
button.querySelector(UP_ARROW_SELECTOR).style.display ===
|
44
|
-
"inline-block";
|
430
|
+
button.querySelector(UP_ARROW_SELECTOR).style.display === "inline-block";
|
45
431
|
if (isExpanded) {
|
46
|
-
|
432
|
+
tableData.expandedRows.add(button.id);
|
47
433
|
} else {
|
48
|
-
|
434
|
+
tableData.expandedRows.delete(button.id);
|
49
435
|
}
|
50
436
|
});
|
51
437
|
});
|
438
|
+
|
439
|
+
// Bind select-all logic
|
440
|
+
const selectAllCheckbox = table.querySelector("#select-all-rows");
|
441
|
+
if (selectAllCheckbox) {
|
442
|
+
// Remove any existing event listeners
|
443
|
+
const newSelectAllCheckbox = selectAllCheckbox.cloneNode(true);
|
444
|
+
selectAllCheckbox.parentNode.replaceChild(newSelectAllCheckbox, selectAllCheckbox);
|
445
|
+
|
446
|
+
// Add our event listener
|
447
|
+
newSelectAllCheckbox.addEventListener("change", () => {
|
448
|
+
const checkboxInput = newSelectAllCheckbox.querySelector('input[type="checkbox"]');
|
449
|
+
const checkAll = checkboxInput.checked;
|
450
|
+
|
451
|
+
const checkboxes = Array.from(
|
452
|
+
table.querySelectorAll("label[data-row-id] input[type='checkbox']")
|
453
|
+
);
|
454
|
+
|
455
|
+
checkboxes.forEach((cb) => {
|
456
|
+
cb.checked = checkAll;
|
457
|
+
const rowId = cb.id;
|
458
|
+
const rowEl = cb.closest("tr");
|
459
|
+
|
460
|
+
if (checkAll) {
|
461
|
+
tableData.selectedRows.add(rowId);
|
462
|
+
rowEl?.classList.add("bg-row-selection");
|
463
|
+
rowEl?.classList.remove("bg-white", "bg-silver");
|
464
|
+
} else {
|
465
|
+
tableData.selectedRows.delete(rowId);
|
466
|
+
rowEl?.classList.remove("bg-row-selection");
|
467
|
+
rowEl?.classList.add("bg-white");
|
468
|
+
}
|
469
|
+
});
|
470
|
+
|
471
|
+
checkboxes.forEach((cb) => this.updateParentCheckboxes(cb));
|
472
|
+
|
473
|
+
this.updateTableSelectedRowsAttribute();
|
474
|
+
});
|
475
|
+
}
|
476
|
+
|
477
|
+
// Mark table as initialized
|
478
|
+
tableData.initialized = true;
|
52
479
|
}
|
53
480
|
|
54
481
|
hideCloseIcon() {
|
55
482
|
const closeIcon = this.element.querySelector(UP_ARROW_SELECTOR);
|
56
483
|
closeIcon.style.display = "none";
|
57
|
-
}
|
484
|
+
}
|
58
485
|
|
59
|
-
showElement(elements) {
|
486
|
+
showElement(elements, expandedRows) {
|
60
487
|
elements.forEach((elem) => {
|
61
488
|
elem.style.display = "table-row";
|
62
489
|
elem.classList.add("is-visible");
|
@@ -79,7 +506,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
79
506
|
(id) => `${childRow.id}_${id}`
|
80
507
|
);
|
81
508
|
const allAncestorsExpanded = prefixedAncestorIds.every((id) =>
|
82
|
-
|
509
|
+
expandedRows.has(id)
|
83
510
|
);
|
84
511
|
|
85
512
|
const checkIfParentIsExpanded = () => {
|
@@ -88,7 +515,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
88
515
|
const isParentVisible =
|
89
516
|
childRow.previousElementSibling.classList.contains("is-visible");
|
90
517
|
if (parentRowId) {
|
91
|
-
const isInSet =
|
518
|
+
const isInSet = expandedRows.has(parentRowId);
|
92
519
|
if (isInSet && isParentVisible) {
|
93
520
|
return true;
|
94
521
|
}
|
@@ -108,14 +535,14 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
108
535
|
});
|
109
536
|
}
|
110
537
|
|
111
|
-
hideElement(elements) {
|
538
|
+
hideElement(elements, expandedRows) {
|
112
539
|
elements.forEach((elem) => {
|
113
540
|
elem.style.display = "none";
|
114
541
|
elem.classList.remove("is-visible");
|
115
542
|
|
116
543
|
// Remove the row ID from expandedRows when this row is hidden
|
117
|
-
if (
|
118
|
-
|
544
|
+
if (expandedRows.has(elem.id)) {
|
545
|
+
expandedRows.delete(elem.id);
|
119
546
|
}
|
120
547
|
|
121
548
|
const childrenArray = elem.dataset.advancedTableContent.split("-");
|
@@ -136,12 +563,12 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
136
563
|
});
|
137
564
|
}
|
138
565
|
|
139
|
-
toggleElement(elements) {
|
566
|
+
toggleElement(elements, expandedRows) {
|
140
567
|
if (!elements.length) return;
|
141
568
|
|
142
569
|
const isVisible = elements[0].classList.contains("is-visible");
|
143
570
|
|
144
|
-
isVisible ? this.hideElement(elements) : this.showElement(elements);
|
571
|
+
isVisible ? this.hideElement(elements, expandedRows) : this.showElement(elements, expandedRows);
|
145
572
|
isVisible ? this.displayDownArrow() : this.displayUpArrow();
|
146
573
|
|
147
574
|
const row = this.element.closest("tr");
|
@@ -151,7 +578,6 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
151
578
|
}
|
152
579
|
}
|
153
580
|
|
154
|
-
|
155
581
|
displayDownArrow() {
|
156
582
|
this.element.querySelector(DOWN_ARROW_SELECTOR).style.display =
|
157
583
|
"inline-block";
|
@@ -165,6 +591,12 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
165
591
|
}
|
166
592
|
|
167
593
|
static handleToggleAllHeaders(element) {
|
594
|
+
// Get table ID
|
595
|
+
const tableContainer = element.closest(".pb_advanced_table");
|
596
|
+
if (!tableContainer || !tableContainer.id) return;
|
597
|
+
|
598
|
+
const tableData = PbAdvancedTable.getTableData(tableContainer.id);
|
599
|
+
|
168
600
|
const table = element.closest(".pb_table");
|
169
601
|
const firstLevelButtons = table.querySelectorAll(
|
170
602
|
".pb_advanced_table_body > .pb_table_tr[data-row-depth='0'] [data-advanced-table]"
|
@@ -178,17 +610,17 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
178
610
|
if (allExpanded) {
|
179
611
|
firstLevelButtons.forEach((button) => {
|
180
612
|
button.click();
|
181
|
-
|
613
|
+
tableData.expandedRows.delete(button.id);
|
182
614
|
});
|
183
615
|
} else {
|
184
616
|
firstLevelButtons.forEach((button) => {
|
185
|
-
if (!
|
617
|
+
if (!tableData.expandedRows.has(button.id)) {
|
186
618
|
button.click();
|
187
|
-
|
619
|
+
tableData.expandedRows.add(button.id);
|
188
620
|
}
|
189
621
|
});
|
190
622
|
|
191
|
-
|
623
|
+
tableData.expandedRows.forEach((rowId) => {
|
192
624
|
const nestedButton = table.querySelector(
|
193
625
|
`[data-advanced-table][id="${rowId}"]`
|
194
626
|
);
|
@@ -200,6 +632,12 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
200
632
|
}
|
201
633
|
|
202
634
|
static handleToggleAllSubRows(element, rowDepth) {
|
635
|
+
// Get table ID
|
636
|
+
const tableContainer = element.closest(".pb_advanced_table");
|
637
|
+
if (!tableContainer || !tableContainer.id) return;
|
638
|
+
|
639
|
+
const tableData = PbAdvancedTable.getTableData(tableContainer.id);
|
640
|
+
|
203
641
|
const table = element.closest(".pb_table");
|
204
642
|
const parentRow = element.closest("tr");
|
205
643
|
if (!parentRow) {
|
@@ -219,23 +657,83 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
219
657
|
if (allExpanded) {
|
220
658
|
subRowButtons.forEach((button) => {
|
221
659
|
button.click();
|
222
|
-
|
660
|
+
tableData.expandedRows.delete(button.id);
|
223
661
|
});
|
224
662
|
} else {
|
225
663
|
subRowButtons.forEach((button) => {
|
226
|
-
if (!
|
664
|
+
if (!tableData.expandedRows.has(button.id)) {
|
227
665
|
button.click();
|
228
|
-
|
666
|
+
tableData.expandedRows.add(button.id);
|
229
667
|
}
|
230
668
|
});
|
231
669
|
}
|
232
670
|
}
|
233
671
|
}
|
234
672
|
|
673
|
+
// Initialize on page load
|
674
|
+
document.addEventListener('DOMContentLoaded', () => {
|
675
|
+
const advancedTables = document.querySelectorAll('.pb_advanced_table');
|
676
|
+
|
677
|
+
// Initialize each table and its action bar
|
678
|
+
advancedTables.forEach(table => {
|
679
|
+
// Generate ID if needed
|
680
|
+
if (!table.id) {
|
681
|
+
table.id = `table-${Date.now()}-${Math.floor(Math.random() * 10000)}`;
|
682
|
+
}
|
683
|
+
|
684
|
+
// Initialize table data
|
685
|
+
PbAdvancedTable.getTableData(table.id);
|
686
|
+
|
687
|
+
// Initialize action bar
|
688
|
+
const actionBar = table.querySelector('.row-selection-actions-card');
|
689
|
+
if (actionBar) {
|
690
|
+
// Direct styling override
|
691
|
+
Object.assign(actionBar.style, {
|
692
|
+
height: '0px',
|
693
|
+
overflow: 'hidden',
|
694
|
+
display: 'block',
|
695
|
+
opacity: '0'
|
696
|
+
});
|
697
|
+
|
698
|
+
// Remove any visibility classes
|
699
|
+
actionBar.classList.remove("is-visible", "show-action-card");
|
700
|
+
|
701
|
+
// Direct DOM manipulation for checkboxes
|
702
|
+
const checkboxes = table.querySelectorAll('input[type="checkbox"]');
|
703
|
+
checkboxes.forEach(checkbox => {
|
704
|
+
checkbox.addEventListener('change', function() {
|
705
|
+
// Count selected checkboxes
|
706
|
+
const selectedCount = Array.from(checkboxes).filter(cb => cb.checked).length;
|
707
|
+
|
708
|
+
if (selectedCount > 0) {
|
709
|
+
// Show action bar directly
|
710
|
+
actionBar.style.height = 'auto';
|
711
|
+
actionBar.style.overflow = 'visible';
|
712
|
+
actionBar.style.opacity = '1';
|
713
|
+
actionBar.classList.add("is-visible", "show-action-card");
|
714
|
+
|
715
|
+
// Update the count
|
716
|
+
const countElement = actionBar.querySelector(".selected-count");
|
717
|
+
if (countElement) {
|
718
|
+
countElement.textContent = `${selectedCount} Selected`;
|
719
|
+
}
|
720
|
+
} else {
|
721
|
+
// Hide action bar directly
|
722
|
+
actionBar.style.height = '0px';
|
723
|
+
actionBar.style.overflow = 'hidden';
|
724
|
+
actionBar.style.opacity = '0';
|
725
|
+
actionBar.classList.remove("is-visible", "show-action-card");
|
726
|
+
}
|
727
|
+
});
|
728
|
+
});
|
729
|
+
}
|
730
|
+
});
|
731
|
+
});
|
732
|
+
|
235
733
|
window.expandAllRows = (element) => {
|
236
734
|
PbAdvancedTable.handleToggleAllHeaders(element);
|
237
735
|
};
|
238
736
|
|
239
737
|
window.expandAllSubRows = (element, rowDepth) => {
|
240
738
|
PbAdvancedTable.handleToggleAllSubRows(element, rowDepth);
|
241
|
-
};
|
739
|
+
};
|