playbook_ui 14.19.0.pre.alpha.borderfixadvancedtable7816 → 14.19.0.pre.alpha.play1997dropdownenablepillsinselection7702
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/RegularTableView.tsx +1 -11
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +15 -148
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +3 -20
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +13 -23
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +3 -10
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +2 -7
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +8 -16
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +0 -9
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -6
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -5
- data/app/pb_kits/playbook/pb_advanced_table/index.js +52 -355
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +0 -4
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +2 -2
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.scss +0 -13
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.tsx +1 -11
- data/app/pb_kits/playbook/pb_file_upload/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_file_upload/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +0 -1
- data/app/pb_kits/playbook/pb_file_upload/file_upload.rb +1 -7
- data/app/pb_kits/playbook/pb_file_upload/fileupload.test.js +0 -18
- data/app/pb_kits/playbook/pb_form_group/_error_state_mixin.scss +2 -2
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +12 -19
- data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx +7 -13
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +2 -2
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color.html.erb +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.html.erb +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.html.erb +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled_options.html.erb +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled_options.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled_options_default.html.erb +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled_options_default.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled_options_parent.html.erb +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled_options_parent.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled_options_parent_default.html.erb +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_disabled_options_parent_default.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_error.html.erb +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_error.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_label.html.erb +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_label.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_reset.html.erb +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_return_all_selected.html.erb +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_return_all_selected.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids.html.erb +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids.md +0 -2
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids_react.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids_react.md +1 -3
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single.html.erb +22 -22
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single.jsx +22 -22
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_children_only.html.erb +22 -22
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single_children_only.jsx +22 -22
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_with_children.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_with_children_with_radios.jsx +11 -11
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_with_form.html.erb +11 -11
- data/app/pb_kits/playbook/pb_person/_person.tsx +2 -12
- 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_text_input/_text_input.scss +2 -4
- data/dist/chunks/_typeahead-BQV04mOl.js +22 -0
- data/dist/chunks/_weekday_stacked-BdaYw6Ra.js +45 -0
- data/dist/chunks/{lib-B20MXZcW.js → lib-DwFasxbk.js} +2 -2
- data/dist/chunks/{pb_form_validation-WWvUXPKD.js → pb_form_validation-nnXW3T-3.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- 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 +1 -1
- metadata +6 -23
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/VisibilityTree.ts +0 -47
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility.jsx +0 -57
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility.md +0 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_custom.jsx +0 -62
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_custom.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_multi.jsx +0 -82
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_multi.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.jsx +0 -65
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_visibility_with_state.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.html.erb +0 -137
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_actions_rails.md +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.html.erb +0 -40
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_action_bar.html.erb +0 -23
- data/app/pb_kits/playbook/pb_advanced_table/table_action_bar.rb +0 -19
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_error.html.erb +0 -1
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_error.jsx +0 -41
- data/dist/chunks/_typeahead-B9-s4j4U.js +0 -22
- data/dist/chunks/_weekday_stacked-CvzpmXD5.js +0 -45
@@ -9,128 +9,9 @@ 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
12
|
updateTableSelectedRowsAttribute() {
|
47
|
-
const
|
48
|
-
|
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.classList.replace("p_none", "p_xs");
|
99
|
-
// This is for keeping the border around the card when showing the action bar
|
100
|
-
actionBar.classList.replace("pb_card_kit_deselected_border_none", "pb_card_kit_deselected");
|
101
|
-
actionBar.style.overflow = "hidden";
|
102
|
-
|
103
|
-
// Complete animation after delay
|
104
|
-
window.setTimeout(() => {
|
105
|
-
if (actionBar.classList.contains("is-visible")) {
|
106
|
-
actionBar.style.height = "";
|
107
|
-
actionBar.style.overflow = "visible";
|
108
|
-
}
|
109
|
-
}, 300);
|
110
|
-
}
|
111
|
-
|
112
|
-
// Hide action bar with animation
|
113
|
-
hideActionBar(actionBar) {
|
114
|
-
if (!actionBar) return;
|
115
|
-
|
116
|
-
// Set exact height before animation
|
117
|
-
actionBar.style.height = actionBar.scrollHeight + "px";
|
118
|
-
actionBar.offsetHeight; // Trigger reflow
|
119
|
-
|
120
|
-
// Animate to height 0
|
121
|
-
window.setTimeout(() => {
|
122
|
-
actionBar.style.height = "0";
|
123
|
-
actionBar.style.overflow = "hidden";
|
124
|
-
}, 10);
|
125
|
-
|
126
|
-
// Remove visibility classes after animation
|
127
|
-
window.setTimeout(() => {
|
128
|
-
actionBar.classList.remove("is-visible");
|
129
|
-
actionBar.classList.remove("show-action-card");
|
130
|
-
actionBar.classList.replace("p_xs", "p_none");
|
131
|
-
// This is for removing the border when hiding the action bar
|
132
|
-
actionBar.classList.replace( "pb_card_kit_deselected", "pb_card_kit_deselected_border_none");
|
133
|
-
}, 300);
|
13
|
+
const mainTable = this.element.closest(".pb_advanced_table");
|
14
|
+
mainTable.dataset.selectedRows = JSON.stringify(Array.from(PbAdvancedTable.selectedRows));
|
134
15
|
}
|
135
16
|
|
136
17
|
// Check if the row is expanded or collapsed
|
@@ -141,7 +22,6 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
141
22
|
return closeIcon?.style.display === "none" || !closeIcon;
|
142
23
|
}
|
143
24
|
|
144
|
-
// Update parent checkboxes based on child selections
|
145
25
|
updateParentCheckboxes(checkbox) {
|
146
26
|
const rowEl = checkbox.closest("tr");
|
147
27
|
if (!rowEl) return;
|
@@ -149,11 +29,6 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
149
29
|
const table = rowEl.closest("table");
|
150
30
|
if (!table) return;
|
151
31
|
|
152
|
-
const tableId = this.getTableId();
|
153
|
-
if (!tableId) return;
|
154
|
-
|
155
|
-
const tableData = PbAdvancedTable.getTableData(tableId);
|
156
|
-
|
157
32
|
const contentTrail = rowEl.dataset.advancedTableContent;
|
158
33
|
if (!contentTrail) return;
|
159
34
|
|
@@ -196,15 +71,15 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
196
71
|
|
197
72
|
const parentCheckboxId = parentCheckbox.id;
|
198
73
|
if (allChildrenChecked) {
|
199
|
-
|
74
|
+
PbAdvancedTable.selectedRows.add(parentCheckboxId);
|
200
75
|
parentRow.classList.add("bg-row-selection");
|
201
76
|
parentRow.classList.remove("bg-white", "bg-silver");
|
202
77
|
} else {
|
203
|
-
|
78
|
+
PbAdvancedTable.selectedRows.delete(parentCheckboxId);
|
204
79
|
}
|
205
80
|
if (!allChildrenChecked) {
|
206
81
|
parentRow.classList.remove("bg-row-selection");
|
207
|
-
|
82
|
+
|
208
83
|
if (this.isRowExpanded(parentRow)) {
|
209
84
|
parentRow.classList.remove("bg-silver");
|
210
85
|
parentRow.classList.add("bg-white");
|
@@ -216,24 +91,18 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
216
91
|
});
|
217
92
|
}
|
218
93
|
|
219
|
-
// Handle row checkbox click
|
220
94
|
handleCheckboxClick(event) {
|
221
95
|
const checkbox = event.currentTarget;
|
222
96
|
const rowId = checkbox.id;
|
223
97
|
const isChecked = checkbox.checked;
|
224
98
|
const rowEl = checkbox.closest("tr");
|
225
99
|
|
226
|
-
const tableId = this.getTableId();
|
227
|
-
if (!tableId) return;
|
228
|
-
|
229
|
-
const tableData = PbAdvancedTable.getTableData(tableId);
|
230
|
-
|
231
100
|
if (isChecked) {
|
232
|
-
|
101
|
+
PbAdvancedTable.selectedRows.add(rowId);
|
233
102
|
rowEl.classList.add("bg-row-selection");
|
234
103
|
rowEl.classList.remove("bg-white", "bg-silver");
|
235
104
|
} else {
|
236
|
-
|
105
|
+
PbAdvancedTable.selectedRows.delete(rowId);
|
237
106
|
}
|
238
107
|
// Update background color on row
|
239
108
|
if (!isChecked) {
|
@@ -247,7 +116,6 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
247
116
|
rowEl.classList.add("bg-silver");
|
248
117
|
}
|
249
118
|
}
|
250
|
-
|
251
119
|
if (rowEl) {
|
252
120
|
const table = rowEl.closest("table");
|
253
121
|
const rowContent = rowEl.dataset.advancedTableContent;
|
@@ -269,11 +137,11 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
269
137
|
const childRowId = childCheckbox.id;
|
270
138
|
const childRowEl = childCheckbox.closest("tr");
|
271
139
|
if (isChecked) {
|
272
|
-
|
140
|
+
PbAdvancedTable.selectedRows.add(childRowId);
|
273
141
|
childRowEl?.classList.add("bg-row-selection");
|
274
142
|
childRowEl?.classList.remove("bg-white", "bg-silver");
|
275
143
|
} else {
|
276
|
-
|
144
|
+
PbAdvancedTable.selectedRows.delete(childRowId);
|
277
145
|
}
|
278
146
|
if (!isChecked) {
|
279
147
|
childRowEl?.classList.remove("bg-row-selection");
|
@@ -315,124 +183,43 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
315
183
|
return table.querySelectorAll(`[data-row-parent="${this.element.id}"]`);
|
316
184
|
}
|
317
185
|
|
186
|
+
static expandedRows = new Set();
|
187
|
+
static selectedRows = new Set();
|
318
188
|
static isCollapsing = false;
|
319
189
|
|
320
190
|
connect() {
|
321
|
-
// Get table container and generate ID if needed
|
322
|
-
const tableContainer = this.getTableContainer();
|
323
|
-
if (!tableContainer) return;
|
324
|
-
|
325
|
-
const tableId = this.getTableId();
|
326
|
-
if (!tableId) return;
|
327
|
-
|
328
|
-
// Get or initialize table data
|
329
|
-
const tableData = PbAdvancedTable.getTableData(tableId);
|
330
|
-
|
331
|
-
// Handle toggle click
|
332
191
|
this.element.addEventListener("click", () => {
|
333
192
|
if (!PbAdvancedTable.isCollapsing) {
|
334
193
|
const isExpanded =
|
335
194
|
this.element.querySelector(UP_ARROW_SELECTOR).style.display ===
|
336
195
|
"inline-block";
|
337
196
|
if (!isExpanded) {
|
338
|
-
|
197
|
+
PbAdvancedTable.expandedRows.add(this.element.id);
|
339
198
|
} else {
|
340
|
-
|
199
|
+
PbAdvancedTable.expandedRows.delete(this.element.id);
|
341
200
|
}
|
342
|
-
this.toggleElement(this.target
|
201
|
+
this.toggleElement(this.target);
|
343
202
|
}
|
344
203
|
});
|
345
|
-
|
204
|
+
|
346
205
|
this.hideCloseIcon();
|
347
|
-
|
206
|
+
|
348
207
|
const table = this.element.closest("table");
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
//
|
355
|
-
const actionBar = tableContainer.querySelector(".row-selection-actions-card");
|
356
|
-
if (actionBar) {
|
357
|
-
// Direct style application
|
358
|
-
Object.assign(actionBar.style, {
|
359
|
-
height: '0px',
|
360
|
-
overflow: 'hidden',
|
361
|
-
display: 'block',
|
362
|
-
opacity: '0'
|
363
|
-
});
|
364
|
-
|
365
|
-
// Remove visibility classes
|
366
|
-
actionBar.classList.remove("p_xs", "is-visible", "show-action-card");
|
367
|
-
actionBar.classList.add("p_none");
|
368
|
-
|
369
|
-
// Add CSS rules
|
370
|
-
const styleId = `action-bar-styles-${tableId}`;
|
371
|
-
let styleTag = document.getElementById(styleId);
|
372
|
-
if (!styleTag) {
|
373
|
-
styleTag = document.createElement('style');
|
374
|
-
styleTag.id = styleId;
|
375
|
-
document.head.appendChild(styleTag);
|
376
|
-
}
|
377
|
-
|
378
|
-
styleTag.textContent = `
|
379
|
-
#${tableId} .row-selection-actions-card.is-visible.show-action-card {
|
380
|
-
height: auto !important;
|
381
|
-
overflow: visible !important;
|
382
|
-
display: block !important;
|
383
|
-
opacity: 1 !important;
|
384
|
-
transition: height 0.3s ease, opacity 0.3s ease !important;
|
385
|
-
}
|
386
|
-
`;
|
387
|
-
|
388
|
-
// Direct DOM event listeners for checkboxes
|
389
|
-
const checkboxes = table.querySelectorAll('input[type="checkbox"]');
|
390
|
-
checkboxes.forEach(checkbox => {
|
391
|
-
checkbox.addEventListener('change', function() {
|
392
|
-
// Count selected checkboxes
|
393
|
-
const selectedCount = Array.from(checkboxes).filter(cb => cb.checked).length;
|
394
|
-
|
395
|
-
if (selectedCount > 0) {
|
396
|
-
// Show action bar directly
|
397
|
-
actionBar.style.height = 'auto';
|
398
|
-
actionBar.style.overflow = 'visible';
|
399
|
-
actionBar.style.opacity = '1';
|
400
|
-
actionBar.classList.remove("p_none");
|
401
|
-
actionBar.classList.add("p_xs", "is-visible", "show-action-card");
|
402
|
-
|
403
|
-
// Update the count
|
404
|
-
const countElement = actionBar.querySelector(".selected-count");
|
405
|
-
if (countElement) {
|
406
|
-
countElement.textContent = `${selectedCount} Selected`;
|
407
|
-
}
|
408
|
-
} else {
|
409
|
-
// Hide action bar directly
|
410
|
-
actionBar.style.height = '0px';
|
411
|
-
actionBar.style.overflow = 'hidden';
|
412
|
-
actionBar.style.opacity = '0';
|
413
|
-
actionBar.classList.remove("p_xs", "is-visible", "show-action-card");
|
414
|
-
actionBar.classList.add("p_none");
|
415
|
-
}
|
416
|
-
});
|
417
|
-
});
|
418
|
-
}
|
419
|
-
|
420
|
-
// Bind checkbox change handlers
|
208
|
+
|
209
|
+
// Prevent duplicate initialization
|
210
|
+
if (table.dataset.pbAdvancedTableInitialized) return;
|
211
|
+
table.dataset.pbAdvancedTableInitialized = "true";
|
212
|
+
|
213
|
+
// Bind checkbox change handlers for all row checkboxes
|
421
214
|
const checkboxLabels = table.querySelectorAll("label[data-row-id]");
|
422
215
|
checkboxLabels.forEach((label) => {
|
423
216
|
const checkbox = label.querySelector("input[type='checkbox']");
|
424
217
|
if (!checkbox) return;
|
425
|
-
|
426
|
-
// Remove any existing event listeners
|
427
|
-
const newCheckbox = checkbox.cloneNode(true);
|
428
|
-
checkbox.parentNode.replaceChild(newCheckbox, checkbox);
|
429
|
-
|
430
|
-
// Add our event listener
|
431
|
-
newCheckbox.addEventListener("change", (event) => {
|
218
|
+
checkbox.addEventListener("change", (event) => {
|
432
219
|
this.handleCheckboxClick(event);
|
433
220
|
});
|
434
221
|
});
|
435
|
-
|
222
|
+
|
436
223
|
// Bind nested row expansion logic
|
437
224
|
const nestedButtons = table.querySelectorAll("[data-advanced-table]");
|
438
225
|
nestedButtons.forEach((button) => {
|
@@ -440,61 +227,54 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
440
227
|
const isExpanded =
|
441
228
|
button.querySelector(UP_ARROW_SELECTOR).style.display === "inline-block";
|
442
229
|
if (isExpanded) {
|
443
|
-
|
230
|
+
PbAdvancedTable.expandedRows.add(button.id);
|
444
231
|
} else {
|
445
|
-
|
232
|
+
PbAdvancedTable.expandedRows.delete(button.id);
|
446
233
|
}
|
447
234
|
});
|
448
235
|
});
|
449
|
-
|
450
|
-
// Bind select-all logic
|
236
|
+
|
237
|
+
// Bind select-all logic for this table
|
451
238
|
const selectAllCheckbox = table.querySelector("#select-all-rows");
|
452
239
|
if (selectAllCheckbox) {
|
453
|
-
|
454
|
-
|
455
|
-
selectAllCheckbox.parentNode.replaceChild(newSelectAllCheckbox, selectAllCheckbox);
|
456
|
-
|
457
|
-
// Add our event listener
|
458
|
-
newSelectAllCheckbox.addEventListener("change", () => {
|
459
|
-
const checkboxInput = newSelectAllCheckbox.querySelector('input[type="checkbox"]');
|
240
|
+
selectAllCheckbox.addEventListener("change", () => {
|
241
|
+
const checkboxInput = selectAllCheckbox.querySelector('input[type="checkbox"]');
|
460
242
|
const checkAll = checkboxInput.checked;
|
461
|
-
|
243
|
+
|
462
244
|
const checkboxes = Array.from(
|
463
245
|
table.querySelectorAll("label[data-row-id] input[type='checkbox']")
|
464
246
|
);
|
465
|
-
|
247
|
+
|
466
248
|
checkboxes.forEach((cb) => {
|
467
249
|
cb.checked = checkAll;
|
468
250
|
const rowId = cb.id;
|
469
251
|
const rowEl = cb.closest("tr");
|
470
252
|
|
471
253
|
if (checkAll) {
|
472
|
-
|
254
|
+
PbAdvancedTable.selectedRows.add(rowId);
|
473
255
|
rowEl?.classList.add("bg-row-selection");
|
474
256
|
rowEl?.classList.remove("bg-white", "bg-silver");
|
475
257
|
} else {
|
476
|
-
|
258
|
+
PbAdvancedTable.selectedRows.delete(rowId);
|
477
259
|
rowEl?.classList.remove("bg-row-selection");
|
478
260
|
rowEl?.classList.add("bg-white");
|
479
261
|
}
|
480
262
|
});
|
481
|
-
|
263
|
+
|
482
264
|
checkboxes.forEach((cb) => this.updateParentCheckboxes(cb));
|
483
|
-
|
265
|
+
|
484
266
|
this.updateTableSelectedRowsAttribute();
|
485
267
|
});
|
486
268
|
}
|
487
|
-
|
488
|
-
// Mark table as initialized
|
489
|
-
tableData.initialized = true;
|
490
269
|
}
|
270
|
+
|
491
271
|
|
492
272
|
hideCloseIcon() {
|
493
273
|
const closeIcon = this.element.querySelector(UP_ARROW_SELECTOR);
|
494
274
|
closeIcon.style.display = "none";
|
495
275
|
}
|
496
276
|
|
497
|
-
showElement(elements
|
277
|
+
showElement(elements) {
|
498
278
|
elements.forEach((elem) => {
|
499
279
|
elem.style.display = "table-row";
|
500
280
|
elem.classList.add("is-visible");
|
@@ -517,7 +297,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
517
297
|
(id) => `${childRow.id}_${id}`
|
518
298
|
);
|
519
299
|
const allAncestorsExpanded = prefixedAncestorIds.every((id) =>
|
520
|
-
expandedRows.has(id)
|
300
|
+
PbAdvancedTable.expandedRows.has(id)
|
521
301
|
);
|
522
302
|
|
523
303
|
const checkIfParentIsExpanded = () => {
|
@@ -526,7 +306,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
526
306
|
const isParentVisible =
|
527
307
|
childRow.previousElementSibling.classList.contains("is-visible");
|
528
308
|
if (parentRowId) {
|
529
|
-
const isInSet = expandedRows.has(parentRowId);
|
309
|
+
const isInSet = PbAdvancedTable.expandedRows.has(parentRowId);
|
530
310
|
if (isInSet && isParentVisible) {
|
531
311
|
return true;
|
532
312
|
}
|
@@ -546,14 +326,14 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
546
326
|
});
|
547
327
|
}
|
548
328
|
|
549
|
-
hideElement(elements
|
329
|
+
hideElement(elements) {
|
550
330
|
elements.forEach((elem) => {
|
551
331
|
elem.style.display = "none";
|
552
332
|
elem.classList.remove("is-visible");
|
553
333
|
|
554
334
|
// Remove the row ID from expandedRows when this row is hidden
|
555
|
-
if (expandedRows.has(elem.id)) {
|
556
|
-
expandedRows.delete(elem.id);
|
335
|
+
if (PbAdvancedTable.expandedRows.has(elem.id)) {
|
336
|
+
PbAdvancedTable.expandedRows.delete(elem.id);
|
557
337
|
}
|
558
338
|
|
559
339
|
const childrenArray = elem.dataset.advancedTableContent.split("-");
|
@@ -574,12 +354,12 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
574
354
|
});
|
575
355
|
}
|
576
356
|
|
577
|
-
toggleElement(elements
|
357
|
+
toggleElement(elements) {
|
578
358
|
if (!elements.length) return;
|
579
359
|
|
580
360
|
const isVisible = elements[0].classList.contains("is-visible");
|
581
361
|
|
582
|
-
isVisible ? this.hideElement(elements
|
362
|
+
isVisible ? this.hideElement(elements) : this.showElement(elements);
|
583
363
|
isVisible ? this.displayDownArrow() : this.displayUpArrow();
|
584
364
|
|
585
365
|
const row = this.element.closest("tr");
|
@@ -602,12 +382,6 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
602
382
|
}
|
603
383
|
|
604
384
|
static handleToggleAllHeaders(element) {
|
605
|
-
// Get table ID
|
606
|
-
const tableContainer = element.closest(".pb_advanced_table");
|
607
|
-
if (!tableContainer || !tableContainer.id) return;
|
608
|
-
|
609
|
-
const tableData = PbAdvancedTable.getTableData(tableContainer.id);
|
610
|
-
|
611
385
|
const table = element.closest(".pb_table");
|
612
386
|
const firstLevelButtons = table.querySelectorAll(
|
613
387
|
".pb_advanced_table_body > .pb_table_tr[data-row-depth='0'] [data-advanced-table]"
|
@@ -621,17 +395,17 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
621
395
|
if (allExpanded) {
|
622
396
|
firstLevelButtons.forEach((button) => {
|
623
397
|
button.click();
|
624
|
-
|
398
|
+
PbAdvancedTable.expandedRows.delete(button.id);
|
625
399
|
});
|
626
400
|
} else {
|
627
401
|
firstLevelButtons.forEach((button) => {
|
628
|
-
if (!
|
402
|
+
if (!PbAdvancedTable.expandedRows.has(button.id)) {
|
629
403
|
button.click();
|
630
|
-
|
404
|
+
PbAdvancedTable.expandedRows.add(button.id);
|
631
405
|
}
|
632
406
|
});
|
633
407
|
|
634
|
-
|
408
|
+
PbAdvancedTable.expandedRows.forEach((rowId) => {
|
635
409
|
const nestedButton = table.querySelector(
|
636
410
|
`[data-advanced-table][id="${rowId}"]`
|
637
411
|
);
|
@@ -643,12 +417,6 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
643
417
|
}
|
644
418
|
|
645
419
|
static handleToggleAllSubRows(element, rowDepth) {
|
646
|
-
// Get table ID
|
647
|
-
const tableContainer = element.closest(".pb_advanced_table");
|
648
|
-
if (!tableContainer || !tableContainer.id) return;
|
649
|
-
|
650
|
-
const tableData = PbAdvancedTable.getTableData(tableContainer.id);
|
651
|
-
|
652
420
|
const table = element.closest(".pb_table");
|
653
421
|
const parentRow = element.closest("tr");
|
654
422
|
if (!parentRow) {
|
@@ -668,90 +436,19 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
668
436
|
if (allExpanded) {
|
669
437
|
subRowButtons.forEach((button) => {
|
670
438
|
button.click();
|
671
|
-
|
439
|
+
PbAdvancedTable.expandedRows.delete(button.id);
|
672
440
|
});
|
673
441
|
} else {
|
674
442
|
subRowButtons.forEach((button) => {
|
675
|
-
if (!
|
443
|
+
if (!PbAdvancedTable.expandedRows.has(button.id)) {
|
676
444
|
button.click();
|
677
|
-
|
445
|
+
PbAdvancedTable.expandedRows.add(button.id);
|
678
446
|
}
|
679
447
|
});
|
680
448
|
}
|
681
449
|
}
|
682
450
|
}
|
683
451
|
|
684
|
-
// Initialize on page load
|
685
|
-
document.addEventListener('DOMContentLoaded', () => {
|
686
|
-
const advancedTables = document.querySelectorAll('.pb_advanced_table');
|
687
|
-
|
688
|
-
// Initialize each table and its action bar
|
689
|
-
advancedTables.forEach(table => {
|
690
|
-
// Generate ID if needed
|
691
|
-
if (!table.id) {
|
692
|
-
table.id = `table-${Date.now()}-${Math.floor(Math.random() * 10000)}`;
|
693
|
-
}
|
694
|
-
|
695
|
-
// Initialize table data
|
696
|
-
PbAdvancedTable.getTableData(table.id);
|
697
|
-
|
698
|
-
// Initialize action bar
|
699
|
-
const actionBar = table.querySelector('.row-selection-actions-card');
|
700
|
-
if (actionBar) {
|
701
|
-
// Direct styling override
|
702
|
-
Object.assign(actionBar.style, {
|
703
|
-
height: '0px',
|
704
|
-
overflow: 'hidden',
|
705
|
-
display: 'block',
|
706
|
-
opacity: '0'
|
707
|
-
});
|
708
|
-
|
709
|
-
// Remove any visibility classes
|
710
|
-
actionBar.classList.remove("p_xs", "is-visible", "show-action-card");
|
711
|
-
actionBar.classList.add("p_none");
|
712
|
-
|
713
|
-
// Direct DOM manipulation for checkboxes - exclude select-all checkbox
|
714
|
-
const checkboxes = table.querySelectorAll('input[type="checkbox"]');
|
715
|
-
checkboxes.forEach(checkbox => {
|
716
|
-
checkbox.addEventListener('change', function() {
|
717
|
-
// Get all checked checkboxes
|
718
|
-
const allCheckedCheckboxes = Array.from(checkboxes).filter(cb => cb.checked);
|
719
|
-
|
720
|
-
// Filter out the select-all checkbox
|
721
|
-
const selectedRowCheckboxes = allCheckedCheckboxes.filter(cb => {
|
722
|
-
return cb.id !== 'select-all-rows' && !cb.closest('#select-all-rows');
|
723
|
-
});
|
724
|
-
|
725
|
-
// Get the selected count (excluding select-all)
|
726
|
-
const selectedCount = selectedRowCheckboxes.length;
|
727
|
-
|
728
|
-
if (selectedCount > 0) {
|
729
|
-
// Show action bar directly
|
730
|
-
actionBar.style.height = 'auto';
|
731
|
-
actionBar.style.overflow = 'visible';
|
732
|
-
actionBar.style.opacity = '1';
|
733
|
-
actionBar.classList.remove("p_none");
|
734
|
-
actionBar.classList.add("p_xs", "is-visible", "show-action-card");
|
735
|
-
|
736
|
-
// Update the count
|
737
|
-
const countElement = actionBar.querySelector(".selected-count");
|
738
|
-
if (countElement) {
|
739
|
-
countElement.textContent = `${selectedCount} Selected`;
|
740
|
-
}
|
741
|
-
} else {
|
742
|
-
// Hide action bar directly
|
743
|
-
actionBar.style.height = '0px';
|
744
|
-
actionBar.style.overflow = 'hidden';
|
745
|
-
actionBar.style.opacity = '0';
|
746
|
-
actionBar.classList.add("p_none");
|
747
|
-
actionBar.classList.remove("p_xs", "is-visible", "show-action-card");
|
748
|
-
}
|
749
|
-
});
|
750
|
-
});
|
751
|
-
}
|
752
|
-
});
|
753
|
-
});
|
754
|
-
|
755
452
|
window.expandAllRows = (element) => {
|
756
453
|
PbAdvancedTable.handleToggleAllHeaders(element);
|
757
454
|
};
|
@@ -15,8 +15,6 @@ module Playbook
|
|
15
15
|
default: "scroll"
|
16
16
|
prop :selectable_rows, type: Playbook::Props::Boolean,
|
17
17
|
default: false
|
18
|
-
prop :show_actions_bar, type: Playbook::Props::Boolean,
|
19
|
-
default: true
|
20
18
|
|
21
19
|
def classname
|
22
20
|
additional_classes = []
|
@@ -29,7 +27,6 @@ module Playbook
|
|
29
27
|
def th_classname(is_first_column: false)
|
30
28
|
additional_classes = []
|
31
29
|
additional_classes << "pinned-left" if is_first_column && responsive == "scroll" && !selectable_rows
|
32
|
-
additional_classes << "header-cells-with-actions" if selectable_rows && show_actions_bar
|
33
30
|
|
34
31
|
generate_classname("table-header-cells", *additional_classes, separator: " ")
|
35
32
|
end
|
@@ -49,7 +46,6 @@ module Playbook
|
|
49
46
|
if selectable_rows
|
50
47
|
additional_classes = []
|
51
48
|
additional_classes << "table-header-cells-custom"
|
52
|
-
additional_classes << "header-cells-with-actions" if show_actions_bar
|
53
49
|
additional_classes << "checkbox-cell-header"
|
54
50
|
additional_classes << "pinned-left" if responsive == "scroll"
|
55
51
|
pb_rails("table/table_header", props: {
|
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
buildDataProps,
|
7
7
|
buildHtmlProps
|
8
8
|
} from "../../utilities/props";
|
9
|
-
import { globalProps
|
9
|
+
import { globalProps } from "../../utilities/globalProps";
|
10
10
|
|
11
11
|
import DropdownContext from "../context";
|
12
12
|
|
@@ -24,7 +24,7 @@ type DropdownContainerProps = {
|
|
24
24
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
25
25
|
id?: string;
|
26
26
|
searchbar?: boolean;
|
27
|
-
}
|
27
|
+
};
|
28
28
|
|
29
29
|
const DropdownContainer = (props: DropdownContainerProps) => {
|
30
30
|
const {
|