playbook_ui 14.22.0.pre.rc.5 → 14.22.0.pre.rc.7

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +0 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/advanced_table_action_bar.js +36 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +60 -84
  5. data/app/pb_kits/playbook/pb_advanced_table/index.js +114 -223
  6. data/app/pb_kits/playbook/pb_advanced_table/table_action_bar.html.erb +1 -1
  7. data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.ts +1 -39
  8. data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.ts +1 -39
  9. data/app/pb_kits/playbook/pb_table/styles/_table-card.scss +11 -0
  10. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +34 -22
  11. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_click_open.jsx +25 -0
  12. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_click_open.md +1 -0
  13. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -0
  14. data/app/pb_kits/playbook/pb_tooltip/docs/index.js +1 -0
  15. data/dist/chunks/_typeahead-B7FRYVtS.js +22 -0
  16. data/dist/chunks/{_weekday_stacked-D1bqIne1.js → _weekday_stacked-B0oaGhTW.js} +1 -1
  17. data/dist/chunks/{lib-CTkMyvfQ.js → lib-Carqm8Ip.js} +1 -1
  18. data/dist/chunks/{pb_form_validation-BVF3TmcL.js → pb_form_validation-DqRmTS8m.js} +1 -1
  19. data/dist/chunks/vendor.js +1 -1
  20. data/dist/menu.yml +0 -9
  21. data/dist/playbook-doc.js +2 -2
  22. data/dist/playbook-rails-react-bindings.js +1 -1
  23. data/dist/playbook-rails.js +1 -1
  24. data/dist/playbook.css +1 -1
  25. data/lib/playbook/version.rb +1 -1
  26. metadata +9 -29
  27. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.scss +0 -14
  28. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +0 -119
  29. data/app/pb_kits/playbook/pb_treemap_chart/docs/_description.md +0 -5
  30. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.html.erb +0 -37
  31. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.jsx +0 -48
  32. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.md +0 -2
  33. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.html.erb +0 -37
  34. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.jsx +0 -47
  35. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.md +0 -3
  36. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.html.erb +0 -79
  37. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.jsx +0 -90
  38. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_drillable.md +0 -1
  39. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.html.erb +0 -54
  40. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.jsx +0 -65
  41. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_grouped_data.md +0 -3
  42. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.html.erb +0 -37
  43. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.jsx +0 -48
  44. data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.md +0 -3
  45. data/app/pb_kits/playbook/pb_treemap_chart/docs/example.yml +0 -15
  46. data/app/pb_kits/playbook/pb_treemap_chart/docs/index.js +0 -5
  47. data/app/pb_kits/playbook/pb_treemap_chart/treemapChart.test.js +0 -63
  48. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.html.erb +0 -1
  49. data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.rb +0 -48
  50. data/dist/chunks/_typeahead-B80UsDrG.js +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49ddd7737d0cef09aa6010e30813ef33f6202f3ca6443f8ee52a644ccdc3fb83
4
- data.tar.gz: 69f3054455c3885674edc65f962433816fbbdbee18059c27b9d83b78a2413dfc
3
+ metadata.gz: 41c18c0c1f4ae27ccea671a7ca29e35edfdef4a22b4cfc806cc27f90e0d63814
4
+ data.tar.gz: d3b75ef1e55dd2a03b84f59fd424a1cbcc2eb7814a3f26095fb9e691a2b87597
5
5
  SHA512:
6
- metadata.gz: 8e6ec342701d4deaad0a332fe4a9815b6fd33780682766c6ec694c6470e5e501ebb39f9a6d5f79938b8dd87b9d1e741cbc1ac9852127bd5c8d31403353dbc0a7
7
- data.tar.gz: 52794a22016cb2c64d77deaaa81cf207149779407f1cbb7c1b3453068fb8596bb3890744e0558e25de5c7aaef173b06120a9445087c602393ff470be39f4bf4e
6
+ metadata.gz: '08bb1b746b94d9a8df7bb6a2d612b5546f5634fcfdf60b95e62035850bc302d1899628d01c86f7cd3f0e11a5d69e2905b6e952cbb0ba9c505a64320a3da9502f'
7
+ data.tar.gz: 0adc5454fae876ffc7bd1defcc215eda7939244cd089621ad9a2a7aa9ec52de0640fd2f93a6ab76a8ccedf0c9767f0c12b13f7408de2baf838207117cf3d0e49
@@ -104,7 +104,6 @@
104
104
  @import 'pb_title_detail/title_detail';
105
105
  @import 'pb_toggle/toggle';
106
106
  @import 'pb_tooltip/tooltip';
107
- @import 'pb_treemap_chart/treemap_chart';
108
107
  @import 'pb_typeahead/typeahead';
109
108
  @import 'pb_user/user';
110
109
  @import 'pb_user_badge/user_badge';
@@ -0,0 +1,36 @@
1
+ function showActionBar(actionBar, selectedCount) {
2
+ // Show action bar directly
3
+ actionBar.style.height = "auto";
4
+ actionBar.style.overflow = "visible";
5
+ actionBar.style.opacity = "1";
6
+ actionBar.style.transitionProperty = "all";
7
+ actionBar.style.transitionTimingFunction = "ease-in-out";
8
+ actionBar.classList.remove("p_none");
9
+ actionBar.classList.add("p_xs", "is-visible", "show-action-card");
10
+
11
+ // Update the count
12
+ const countElement = actionBar.querySelector(".selected-count");
13
+ if (countElement) {
14
+ countElement.textContent = `${selectedCount} Selected`;
15
+ }
16
+ }
17
+
18
+ function hideActionBar(actionBar) {
19
+ // Hide action bar directly
20
+ actionBar.style.height = "0px";
21
+ actionBar.style.overflow = "hidden";
22
+ actionBar.style.opacity = "0";
23
+ actionBar.classList.add("p_none");
24
+ actionBar.classList.remove("p_xs", "is-visible", "show-action-card");
25
+ }
26
+
27
+ export function updateSelectionActionBar(table, selectedCount) {
28
+ const actionBar = table.querySelector(".row-selection-actions-card");
29
+ if (!actionBar) return;
30
+
31
+ if (selectedCount > 0) {
32
+ showActionBar(actionBar, selectedCount);
33
+ } else {
34
+ hideActionBar(actionBar);
35
+ }
36
+ }
@@ -1,106 +1,82 @@
1
1
  import PbEnhancedElement from "../pb_enhanced_element";
2
+ import { updateSelectionActionBar } from "./advanced_table_action_bar";
2
3
 
3
- const FLAT_ADVANCED_TABLE_SELECTOR = "[data-flat-advanced-table-select]";
4
+ const FLAT_SELECTOR = "[data-flat-advanced-table-select='true']";
5
+ const SELECT_ALL_SELECTOR = "#select-all-rows input[type='checkbox']";
4
6
 
5
7
  export default class PbFlatAdvancedTable extends PbEnhancedElement {
6
8
  static get selector() {
7
- return FLAT_ADVANCED_TABLE_SELECTOR;
9
+ return FLAT_SELECTOR;
8
10
  }
9
11
 
10
- get target() {
11
- const table = this.element.closest("table");
12
- return table.querySelectorAll(
13
- `"label[data-flat-advanced-table-select='true']"`
14
- );
12
+ constructor(...args) {
13
+ super(...args);
14
+ // keep track of selected IDs per-table-instance
15
+ this.selectedRows = new Set();
15
16
  }
16
17
 
17
- static selectedRows = new Set();
18
-
19
18
  connect() {
20
19
  const table = this.element.closest("table");
21
- if (!table) return;
20
+ if (!table || table.dataset.flatAdvancedInit) return;
21
+ table.dataset.flatAdvancedInit = "true";
22
+
23
+ // Reference to outer container for action bar
22
24
  const mainTable = this.element.closest(".pb_advanced_table");
23
- // Prevent double-init
24
- if (table.dataset.flatAdvancedTableInitialized) return;
25
- table.dataset.flatAdvancedTableInitialized = "true";
25
+ // This so it is hidden on first render
26
+ if (mainTable) {
27
+ updateSelectionActionBar(mainTable, 0);
28
+ }
26
29
 
27
- const checkboxLabels = table.querySelectorAll(
28
- "label[data-flat-advanced-table-select='true']"
29
- );
30
- checkboxLabels.forEach((label) => {
31
- const checkbox = label.querySelector("input[type='checkbox']");
32
- if (!checkbox) return;
33
- checkbox.addEventListener("change", () => {
34
- const rowId = checkbox.id;
35
- const isChecked = checkbox.checked;
36
-
37
- if (isChecked) {
38
- PbFlatAdvancedTable.selectedRows.add(rowId);
39
- } else {
40
- PbFlatAdvancedTable.selectedRows.delete(rowId);
41
- }
42
-
43
- // Update row background color based on checkbox state
44
- const rowEl = checkbox.closest("tr");
45
- if (rowEl) {
46
- if (isChecked) {
47
- rowEl.classList.add("bg-row-selection");
48
- rowEl.classList.remove("bg-white");
49
- } else {
50
- rowEl.classList.remove("bg-row-selection");
51
- rowEl.classList.add("bg-white");
52
- }
53
- }
54
- const allCheckboxes = table.querySelectorAll(
55
- "label[data-flat-advanced-table-select='true'] input[type='checkbox']"
56
- );
57
-
58
- const selectAllInput = table.querySelector(
59
- "#select-all-rows input[type='checkbox']"
60
- );
61
-
62
- if (selectAllInput) {
63
- const allChecked = Array.from(allCheckboxes).every(cb => cb.checked);
64
- selectAllInput.checked = allChecked;
65
- }
66
-
30
+ const updateCheckboxState = () => {
31
+ // Sync dataset on main table
32
+ if (mainTable) {
67
33
  mainTable.dataset.selectedRows = JSON.stringify(
68
- Array.from(PbFlatAdvancedTable.selectedRows)
34
+ Array.from(this.selectedRows)
69
35
  );
70
- });
71
-
72
- });
36
+ updateSelectionActionBar(mainTable, this.selectedRows.size);
37
+ }
38
+ };
39
+
40
+ table.addEventListener("change", (e) => {
41
+ const rowCb = e.target.closest(FLAT_SELECTOR + " input[type='checkbox']");
42
+ const allCb = e.target.closest(SELECT_ALL_SELECTOR);
43
+ if (!rowCb && !allCb) return;
73
44
 
74
- // Handle select-all checkbox
75
- const selectAllWrapper = table.querySelector("#select-all-rows");
76
- if (selectAllWrapper) {
77
- const selectAllInput = selectAllWrapper.querySelector(
78
- 'input[type="checkbox"]'
79
- );
80
- selectAllInput.addEventListener("change", () => {
81
- const checkAll = selectAllInput.checked;
45
+ if (rowCb) {
46
+ const id = rowCb.id;
47
+ if (rowCb.checked) this.selectedRows.add(id);
48
+ else this.selectedRows.delete(id);
82
49
 
83
- checkboxLabels.forEach((label) => {
84
- const cb = label.querySelector("input[type='checkbox']");
85
- cb.checked = checkAll;
86
- const rowId = cb.id;
87
- const rowEl = cb.closest("tr");
50
+ const tr = rowCb.closest("tr");
51
+ tr?.classList.toggle("bg-row-selection", rowCb.checked);
52
+ tr?.classList.toggle("bg-white", !rowCb.checked);
53
+
54
+ // Sync header checkbox
55
+ const header = table.querySelector(SELECT_ALL_SELECTOR);
56
+ if (header) {
57
+ const all = Array.from(
58
+ table.querySelectorAll(FLAT_SELECTOR + " input[type='checkbox']")
59
+ ).every((cb) => cb.checked);
60
+ header.checked = all;
61
+ }
62
+ }
88
63
 
89
- if (checkAll) {
90
- PbFlatAdvancedTable.selectedRows.add(rowId);
91
- rowEl?.classList.add("bg-row-selection");
92
- rowEl?.classList.remove("bg-white");
93
- } else {
94
- PbFlatAdvancedTable.selectedRows.delete(rowId);
95
- rowEl?.classList.remove("bg-row-selection");
96
- rowEl?.classList.add("bg-white");
97
- }
64
+ if (allCb) {
65
+ const checked = allCb.checked;
66
+ Array.from(
67
+ table.querySelectorAll(FLAT_SELECTOR + " input[type='checkbox']")
68
+ ).forEach((cb) => {
69
+ cb.checked = checked;
70
+ const tr = cb.closest("tr");
71
+ tr?.classList.toggle("bg-row-selection", checked);
72
+ tr?.classList.toggle("bg-white", !checked);
73
+ const id = cb.id;
74
+ if (checked) this.selectedRows.add(id);
75
+ else this.selectedRows.delete(id);
98
76
  });
77
+ }
99
78
 
100
- mainTable.dataset.selectedRows = JSON.stringify(
101
- Array.from(PbFlatAdvancedTable.selectedRows)
102
- );
103
- });
104
- }
79
+ updateCheckboxState();
80
+ });
105
81
  }
106
82
  }
@@ -1,4 +1,5 @@
1
1
  import PbEnhancedElement from "../pb_enhanced_element";
2
+ import { updateSelectionActionBar } from "./advanced_table_action_bar";
2
3
 
3
4
  const ADVANCED_TABLE_SELECTOR = "[data-advanced-table]";
4
5
  const DOWN_ARROW_SELECTOR = "#advanced-table_open_icon";
@@ -9,9 +10,33 @@ export default class PbAdvancedTable extends PbEnhancedElement {
9
10
  return ADVANCED_TABLE_SELECTOR;
10
11
  }
11
12
 
13
+ static expandedRows = new Set();
14
+ static selectedRows = new Set();
15
+ static isCollapsing = false;
16
+
17
+ constructor(...args) {
18
+ super(...args);
19
+ // Map parent row ID to array of its child rows
20
+ this.childRowsMap = new Map();
21
+ }
22
+
23
+ // Fetch and cache child rows for a given parent row ID
24
+ childRowsFor(parentId) {
25
+ if (!this.childRowsMap.has(parentId)) {
26
+ const table = this.element.closest("table");
27
+ const rows = Array.from(
28
+ table.querySelectorAll(`tr[data-row-parent="${parentId}"]`)
29
+ );
30
+ this.childRowsMap.set(parentId, rows);
31
+ }
32
+ return this.childRowsMap.get(parentId);
33
+ }
34
+
12
35
  updateTableSelectedRowsAttribute() {
13
36
  const mainTable = this.element.closest(".pb_advanced_table");
14
- mainTable.dataset.selectedRows = JSON.stringify(Array.from(PbAdvancedTable.selectedRows));
37
+ mainTable.dataset.selectedRows = JSON.stringify(
38
+ Array.from(PbAdvancedTable.selectedRows)
39
+ );
15
40
  }
16
41
 
17
42
  // Check if the row is expanded or collapsed
@@ -104,7 +129,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
104
129
  } else {
105
130
  PbAdvancedTable.selectedRows.delete(rowId);
106
131
  }
107
- // Update background color on row
132
+ // Update background color on row
108
133
  if (!isChecked) {
109
134
  rowEl.classList.remove("bg-row-selection");
110
135
 
@@ -176,118 +201,129 @@ export default class PbAdvancedTable extends PbEnhancedElement {
176
201
  );
177
202
  selectAllInput.checked = allChecked;
178
203
  }
204
+ updateSelectionActionBar(table.closest(".pb_advanced_table"), PbAdvancedTable.selectedRows.size);
179
205
  }
180
206
 
181
207
  get target() {
182
- const table = this.element.closest("table");
183
- return table.querySelectorAll(`[data-row-parent="${this.element.id}"]`);
208
+ return this.childRowsFor(this.element.id) || [];
184
209
  }
185
210
 
186
- static expandedRows = new Set();
187
- static selectedRows = new Set();
188
- static isCollapsing = false;
189
-
190
211
  connect() {
191
- this.element.addEventListener("click", () => {
192
- if (!PbAdvancedTable.isCollapsing) {
193
- const isExpanded =
194
- this.element.querySelector(UP_ARROW_SELECTOR).style.display ===
195
- "inline-block";
196
- if (!isExpanded) {
197
- PbAdvancedTable.expandedRows.add(this.element.id);
198
- } else {
199
- PbAdvancedTable.expandedRows.delete(this.element.id);
200
- }
201
- this.toggleElement(this.target);
202
- }
203
- });
212
+ const table = this.element.closest("table");
204
213
 
205
214
  this.hideCloseIcon();
215
+ const mainTable = this.element.closest(".pb_advanced_table");
216
+
217
+ // This so it is hidden on first render
218
+ if (mainTable) {
219
+ updateSelectionActionBar(mainTable);
220
+ }
206
221
 
207
- const table = this.element.closest("table");
222
+ // Precompute parent→child rows mapping once
223
+ table.querySelectorAll("tr[data-row-parent]").forEach((row) => {
224
+ const parentId = row.dataset.rowParent;
225
+ if (!this.childRowsMap.has(parentId)) {
226
+ this.childRowsMap.set(parentId, []);
227
+ }
228
+ this.childRowsMap.get(parentId).push(row);
229
+ });
208
230
 
209
231
  // Prevent duplicate initialization
210
232
  if (table.dataset.pbAdvancedTableInitialized) return;
211
233
  table.dataset.pbAdvancedTableInitialized = "true";
212
234
 
213
- // Bind checkbox change handlers for all row checkboxes
214
- const checkboxLabels = table.querySelectorAll("label[data-row-id]");
215
- checkboxLabels.forEach((label) => {
216
- const checkbox = label.querySelector("input[type='checkbox']");
235
+ // Delegate checkbox changes
236
+ table.addEventListener("change", (event) => {
237
+ const checkbox = event.target.closest('input[type="checkbox"]');
217
238
  if (!checkbox) return;
218
- checkbox.addEventListener("change", (event) => {
219
- this.handleCheckboxClick(event);
220
- });
221
- });
222
239
 
223
- // Bind nested row expansion logic
224
- const nestedButtons = table.querySelectorAll("[data-advanced-table]");
225
- nestedButtons.forEach((button) => {
226
- button.addEventListener("click", () => {
227
- const isExpanded =
228
- button.querySelector(UP_ARROW_SELECTOR).style.display === "inline-block";
229
- if (isExpanded) {
230
- PbAdvancedTable.expandedRows.add(button.id);
231
- } else {
232
- PbAdvancedTable.expandedRows.delete(button.id);
233
- }
234
- });
235
- });
240
+ // Header "select-all" logic
241
+ if (checkbox.closest("#select-all-rows")) {
242
+ const checkAll = checkbox.checked;
243
+ const rowCheckboxes = table.querySelectorAll(
244
+ 'label[data-row-id] input[type="checkbox"]'
245
+ );
246
+ rowCheckboxes.forEach((cb) => {
247
+ if (cb.checked !== checkAll) {
248
+ cb.checked = checkAll;
249
+ this.handleCheckboxClick({ currentTarget: cb });
250
+ }
251
+ });
252
+ this.updateTableSelectedRowsAttribute();
253
+ updateSelectionActionBar(table.closest(".pb_advanced_table"), PbAdvancedTable.selectedRows.size);
254
+ return;
255
+ }
236
256
 
237
- // Bind select-all logic for this table
238
- const selectAllCheckbox = table.querySelector("#select-all-rows");
239
- if (selectAllCheckbox) {
240
- selectAllCheckbox.addEventListener("change", () => {
241
- const checkboxInput = selectAllCheckbox.querySelector('input[type="checkbox"]');
242
- const checkAll = checkboxInput.checked;
257
+ // Individual row checkbox logic
258
+ const rowLabel = checkbox.closest("label[data-row-id]");
259
+ if (rowLabel) {
260
+ this.handleCheckboxClick({ currentTarget: checkbox });
261
+ this.updateTableSelectedRowsAttribute();
243
262
 
244
- const checkboxes = Array.from(
245
- table.querySelectorAll("label[data-row-id] input[type='checkbox']")
263
+ // Sync header select-all state
264
+ const selectAllInput = table.querySelector(
265
+ '#select-all-rows input[type="checkbox"]'
246
266
  );
267
+ if (selectAllInput) {
268
+ selectAllInput.checked = Array.from(
269
+ table.querySelectorAll('label[data-row-id] input[type="checkbox"]')
270
+ ).every((cb) => cb.checked);
271
+ }
272
+ }
273
+ });
247
274
 
248
- checkboxes.forEach((cb) => {
249
- cb.checked = checkAll;
250
- const rowId = cb.id;
251
- const rowEl = cb.closest("tr");
275
+ // Delegate expand/collapse toggles
276
+ table.addEventListener("click", (event) => {
277
+ const toggleBtn = event.target.closest("[data-advanced-table]");
278
+ if (!toggleBtn || PbAdvancedTable.isCollapsing) return;
279
+
280
+ // Temporarily bind `this.element` to the clicked toggle
281
+ const prevElement = this.element;
282
+ this.element = toggleBtn;
283
+
284
+ // Update expandedRows set
285
+ const isExpanded =
286
+ toggleBtn.querySelector(UP_ARROW_SELECTOR).style.display ===
287
+ "inline-block";
288
+ if (!isExpanded) {
289
+ PbAdvancedTable.expandedRows.add(toggleBtn.id);
290
+ } else {
291
+ PbAdvancedTable.expandedRows.delete(toggleBtn.id);
292
+ }
252
293
 
253
- if (checkAll) {
254
- PbAdvancedTable.selectedRows.add(rowId);
255
- rowEl?.classList.add("bg-row-selection");
256
- rowEl?.classList.remove("bg-white", "bg-silver");
257
- } else {
258
- PbAdvancedTable.selectedRows.delete(rowId);
259
- rowEl?.classList.remove("bg-row-selection");
260
- rowEl?.classList.add("bg-white");
261
- }
262
- });
294
+ // Find direct child rows
295
+ const childRows = Array.from(
296
+ table.querySelectorAll(`[data-row-parent="${toggleBtn.id}"]`)
297
+ );
298
+ this.toggleElement(childRows);
263
299
 
264
- checkboxes.forEach((cb) => this.updateParentCheckboxes(cb));
300
+ // Restore original element context
301
+ this.element = prevElement;
302
+ });
265
303
 
266
- this.updateTableSelectedRowsAttribute();
267
- });
268
- }
269
- this.addBorderRadiusOnLastVisibleRow()
304
+ this.addBorderRadiusOnLastVisibleRow();
270
305
  }
271
306
 
272
307
  addBorderRadiusOnLastVisibleRow() {
273
- const parentElement = this.element.closest('.pb_advanced_table');
274
-
308
+ const parentElement = this.element.closest(".pb_advanced_table");
309
+
275
310
  const table = document.getElementById(parentElement.id);
276
311
 
277
312
  if (table) {
278
- const visibleRows = table.querySelectorAll('tr.is-visible, tr:not(.toggle-content)');
279
-
280
- visibleRows.forEach(row => row.classList.remove('last-visible-row'));
281
-
313
+ const visibleRows = table.querySelectorAll(
314
+ "tr.is-visible, tr:not(.toggle-content)"
315
+ );
316
+
317
+ visibleRows.forEach((row) => row.classList.remove("last-visible-row"));
318
+
282
319
  const lastVisibleRow = visibleRows[visibleRows.length - 1];
283
320
 
284
321
  if (lastVisibleRow) {
285
- lastVisibleRow.classList.add('last-visible-row');
322
+ lastVisibleRow.classList.add("last-visible-row");
286
323
  }
287
324
  }
288
325
  }
289
326
 
290
-
291
327
  hideCloseIcon() {
292
328
  const closeIcon = this.element.querySelector(UP_ARROW_SELECTOR);
293
329
  closeIcon.style.display = "none";
@@ -470,151 +506,6 @@ export default class PbAdvancedTable extends PbEnhancedElement {
470
506
  }
471
507
  }
472
508
 
473
- // Isolate action bar functionality so it doesn't mix with existing functionality
474
- class PbAdvancedTableActionBar {
475
- constructor() {
476
- this.init();
477
- }
478
-
479
- init() {
480
- // Initialize action bars for all advanced tables with action bars
481
- document.addEventListener('DOMContentLoaded', () => {
482
- this.setupActionBars();
483
- });
484
-
485
- // Also run immediately in case DOM is already loaded
486
- if (document.readyState === 'loading') {
487
- // DOM is still loading
488
- } else {
489
- // DOM is already loaded
490
- this.setupActionBars();
491
- }
492
- }
493
-
494
- setupActionBars() {
495
- const advancedTables = document.querySelectorAll('.pb_advanced_table');
496
-
497
- advancedTables.forEach(table => {
498
- // Only proceed if this table has both selectable rows AND an action bar
499
- if (!this.shouldEnableActionBar(table)) return;
500
-
501
- const actionBar = table.querySelector('.row-selection-actions-card');
502
- if (!actionBar) return; // Skip tables without action bars
503
-
504
- // Initialize action bar styles
505
- this.initializeActionBar(actionBar);
506
-
507
- // Set up checkbox listeners for this table
508
- this.setupCheckboxListeners(table, actionBar);
509
- });
510
- }
511
-
512
- shouldEnableActionBar(table) {
513
- // Check if the table has selectable rows
514
- const hasSelectableRows = table.querySelector('input[type="checkbox"]') !== null;
515
-
516
- // Check if the table has a row selection action bar (not other types of action bars)
517
- const hasRowSelectionActionBar = table.querySelector('.row-selection-actions-card') !== null;
518
-
519
- // Additional check: look for the presence of row checkboxes with data-row-id
520
- const hasRowCheckboxes = table.querySelector('label[data-row-id] input[type="checkbox"]') !== null;
521
-
522
- // Only enable if ALL conditions are met:
523
- // 1. Has selectable checkboxes
524
- // 2. Has the specific row selection action bar
525
- // 3. Has row checkboxes (not just other types of checkboxes)
526
- return hasSelectableRows && hasRowSelectionActionBar && hasRowCheckboxes;
527
- }
528
-
529
- initializeActionBar(actionBar) {
530
- // Set initial hidden state
531
- Object.assign(actionBar.style, {
532
- height: '0px',
533
- overflow: 'hidden',
534
- display: 'block',
535
- opacity: '0'
536
- });
537
-
538
- // Remove any visibility classes
539
- actionBar.classList.remove("p_xs", "is-visible", "show-action-card");
540
- actionBar.classList.add("p_none");
541
- }
542
-
543
- setupCheckboxListeners(table, actionBar) {
544
- // Only listen to row checkboxes (those with data-row-id), not all checkboxes
545
- const rowCheckboxes = table.querySelectorAll('label[data-row-id] input[type="checkbox"]');
546
-
547
- rowCheckboxes.forEach(checkbox => {
548
- checkbox.addEventListener('change', () => {
549
- // Use setTimeout to ensure this runs after the main checkbox logic
550
- setTimeout(() => {
551
- this.updateActionBarVisibility(table, actionBar);
552
- }, 0);
553
- });
554
- });
555
-
556
- // Special handling for select-all checkbox (only if it exists)
557
- const selectAllCheckbox = table.querySelector("#select-all-rows");
558
- if (selectAllCheckbox) {
559
- const selectAllInput = selectAllCheckbox.querySelector('input[type="checkbox"]');
560
- if (selectAllInput) {
561
- selectAllInput.addEventListener('change', () => {
562
- // Use setTimeout to ensure this runs after the main select-all logic
563
- setTimeout(() => {
564
- this.updateActionBarVisibility(table, actionBar);
565
- }, 10); // Slightly longer delay for select-all to ensure all row checkboxes are updated
566
- });
567
- }
568
- }
569
- }
570
-
571
- updateActionBarVisibility(table, actionBar) {
572
- // Only count row checkboxes (those with data-row-id), not all checkboxes
573
- const rowCheckboxes = table.querySelectorAll('label[data-row-id] input[type="checkbox"]');
574
-
575
- // Get all checked row checkboxes
576
- const selectedRowCheckboxes = Array.from(rowCheckboxes).filter(cb => cb.checked);
577
-
578
- // Get the selected count
579
- const selectedCount = selectedRowCheckboxes.length;
580
-
581
- if (selectedCount > 0) {
582
- this.showActionBar(actionBar, selectedCount);
583
- } else {
584
- this.hideActionBar(actionBar);
585
- }
586
- }
587
-
588
- showActionBar(actionBar, selectedCount) {
589
- // Show action bar directly
590
- actionBar.style.height = 'auto';
591
- actionBar.style.overflow = 'visible';
592
- actionBar.style.opacity = '1';
593
- actionBar.style.transitionProperty = 'all';
594
- actionBar.style.transitionTimingFunction = 'ease-in-out';
595
- actionBar.classList.remove("p_none");
596
- actionBar.classList.add("p_xs", "is-visible", "show-action-card");
597
-
598
- // Update the count
599
- const countElement = actionBar.querySelector(".selected-count");
600
- if (countElement) {
601
- countElement.textContent = `${selectedCount} Selected`;
602
- }
603
- }
604
-
605
- hideActionBar(actionBar) {
606
- // Hide action bar directly
607
- actionBar.style.height = '0px';
608
- actionBar.style.overflow = 'hidden';
609
- actionBar.style.opacity = '0';
610
- actionBar.classList.add("p_none");
611
- actionBar.classList.remove("p_xs", "is-visible", "show-action-card");
612
- }
613
- }
614
-
615
- // Initialize the isolated action bar functionality
616
- new PbAdvancedTableActionBar();
617
-
618
509
  window.expandAllRows = (element) => {
619
510
  PbAdvancedTable.handleToggleAllHeaders(element);
620
511
  };
@@ -8,7 +8,7 @@
8
8
  }) do %>
9
9
  <%= pb_rails("flex", props: { align_items: "center", justify: "between" }) do %>
10
10
  <%= pb_rails("caption", props: { color: "light", padding_left: "xs", size: "xs" }) do %>
11
- <span class="selected-count"><%= object.selected_count %> Selected</span>
11
+ <span class="selected-count"></span>
12
12
  <% end %>
13
13
  <%= pb_rails("flex/flex_item") do %>
14
14
  <%= pb_rails("flex") do %>