playbook_ui 14.20.0.pre.alpha.play2224scrollbarfix7991 → 14.20.0.pre.alpha.revert4453PBNTR933reactdraggablebugdragbtwnexamples7854
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/_advanced_table.scss +0 -18
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +0 -3
- 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/_advanced_table_beta.md +2 -6
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx +1 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_advanced_table/index.js +12 -155
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +0 -4
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +12 -8
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +6 -3
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +48 -2
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +17 -58
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +2 -108
- data/app/pb_kits/playbook/pb_dropdown/index.js +0 -24
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +0 -4
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_only_countries.jsx +1 -1
- data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -4
- data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +0 -3
- data/app/pb_kits/playbook/pb_select/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_select/docs/index.js +0 -1
- data/dist/chunks/{_typeahead-CRW6dJbW.js → _typeahead-C-CI5Vgw.js} +2 -2
- data/dist/chunks/{_weekday_stacked-DoXl8xrB.js → _weekday_stacked-BCiM3zWM.js} +2 -2
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +1 -1
- 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 +1 -1
- metadata +4 -18
- 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_checkbox/docs/_checkbox_indeterminate_rails.md +0 -1
- data/app/pb_kits/playbook/pb_checkbox/index.js +0 -56
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_exclude_countries.html.erb +0 -4
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_exclude_countries.jsx +0 -15
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_exclude_countries.md +0 -1
- data/app/pb_kits/playbook/pb_select/docs/_select_custom_select_subheaders.html.erb +0 -12
- data/app/pb_kits/playbook/pb_select/docs/_select_custom_select_subheaders.jsx +0 -31
- data/app/pb_kits/playbook/pb_select/docs/_select_custom_select_subheaders.md +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d810ce992ce83180c727b57ffd2015356b7860a523383f4a8810b4b964c6ea1e
|
4
|
+
data.tar.gz: 7674cda91f367bc7ad377806520109d2ffd1cd9076e51c34fb5f1e3baf37120c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5d3b8da029137dbf003df505ec900c151d0986db08089339e685d89a7a38ba4b830bf745ea5701aa439bdd2df0f9febcd5728caf65a642be9f1e58579fca37e
|
7
|
+
data.tar.gz: 8304eed6d900e0a9f052b7dec2066c713606a906b7f749bd47b36553dfb0ac2df3e8ecf4f76ca1c15d80a88398dfa0b5efc954d7ca0ca109d94eb8aa5292c01f
|
@@ -87,16 +87,6 @@
|
|
87
87
|
}
|
88
88
|
}
|
89
89
|
|
90
|
-
&.advanced-table-hide-scrollbar {
|
91
|
-
&::-webkit-scrollbar {
|
92
|
-
display: none !important;
|
93
|
-
}
|
94
|
-
|
95
|
-
-ms-overflow-style: none !important;
|
96
|
-
scrollbar-width: none !important;
|
97
|
-
}
|
98
|
-
|
99
|
-
|
100
90
|
.row-selection-actions-card {
|
101
91
|
border-bottom-right-radius: 0px !important;
|
102
92
|
border-bottom-left-radius: 0px !important;
|
@@ -378,10 +368,6 @@
|
|
378
368
|
box-shadow: 1px 0px 0px 0px var(--column-border-color) !important;
|
379
369
|
}
|
380
370
|
|
381
|
-
.pb_table_td:nth-child(2) {
|
382
|
-
box-shadow: inset 1px 0px 0px 0px var(--column-border-color) !important;
|
383
|
-
}
|
384
|
-
|
385
371
|
// Color for collapsible trail
|
386
372
|
.collapsible-trail {
|
387
373
|
background-color: $border_light !important;
|
@@ -578,10 +564,6 @@
|
|
578
564
|
box-shadow: $shadow_deep !important;
|
579
565
|
}
|
580
566
|
|
581
|
-
.pb_table_td:nth-child(2) {
|
582
|
-
box-shadow: 0 0 0 0 !important;
|
583
|
-
}
|
584
|
-
|
585
567
|
.pb_advanced_table_header,
|
586
568
|
.pb_advanced_table_body {
|
587
569
|
th.sticky-left,
|
@@ -53,7 +53,6 @@ type AdvancedTableProps = {
|
|
53
53
|
pagination?: boolean,
|
54
54
|
paginationProps?: GenericObject
|
55
55
|
responsive?: "scroll" | "none",
|
56
|
-
scrollBarNone?: boolean,
|
57
56
|
selectableRows?: boolean,
|
58
57
|
showActionsBar?: boolean,
|
59
58
|
sortControl?: GenericObject
|
@@ -93,7 +92,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
93
92
|
pagination = false,
|
94
93
|
paginationProps,
|
95
94
|
responsive = "scroll",
|
96
|
-
scrollBarNone= false,
|
97
95
|
showActionsBar = true,
|
98
96
|
selectableRows,
|
99
97
|
sortControl,
|
@@ -247,7 +245,6 @@ const AdvancedTable = (props: AdvancedTableProps) => {
|
|
247
245
|
},
|
248
246
|
{'advanced-table-sticky-left-columns': stickyLeftColumn && stickyLeftColumn.length > 0},
|
249
247
|
columnGroupBorderColor ? `column-group-border-${columnGroupBorderColor}` : '',
|
250
|
-
scrollBarNone ? 'advanced-table-hide-scrollbar' : '',
|
251
248
|
globalProps(props),
|
252
249
|
className
|
253
250
|
);
|
@@ -1,18 +1,10 @@
|
|
1
1
|
<%= pb_content_tag do %>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
<%= pb_rails("table", props: { size: "sm", data_table: true, number_spacing:"tabular", responsive:"none", dark: dark, classname: object.loading ? "content-loading" : "" }.merge(object.table_props)) do %>
|
11
|
-
<% if content.present? %>
|
12
|
-
<% content.presence %>
|
13
|
-
<% else %>
|
14
|
-
<%= pb_rails("advanced_table/table_header", props: { column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, show_actions_bar: object.show_actions_bar }) %>
|
15
|
-
<%= pb_rails("advanced_table/table_body", props: { id: object.id, table_data: object.table_data, column_definitions: object.column_definitions, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, enable_toggle_expansion: object.enable_toggle_expansion }) %>
|
16
|
-
<% end %>
|
17
|
-
<% end %>
|
2
|
+
<%= pb_rails("table", props: { size: "sm", data_table: true, number_spacing:"tabular", responsive:"none", dark: dark, classname: object.loading ? "content-loading" : "" }.merge(object.table_props)) do %>
|
3
|
+
<% if content.present? %>
|
4
|
+
<% content.presence %>
|
5
|
+
<% else %>
|
6
|
+
<%= pb_rails("advanced_table/table_header", props: { column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows }) %>
|
7
|
+
<%= pb_rails("advanced_table/table_body", props: { id: object.id, table_data: object.table_data, column_definitions: object.column_definitions, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, enable_toggle_expansion: object.enable_toggle_expansion }) %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
18
10
|
<% end %>
|
@@ -25,10 +25,6 @@ module Playbook
|
|
25
25
|
default: "auto"
|
26
26
|
prop :selectable_rows, type: Playbook::Props::Boolean,
|
27
27
|
default: false
|
28
|
-
prop :show_actions_bar, type: Playbook::Props::Boolean,
|
29
|
-
default: true
|
30
|
-
prop :actions, type: Playbook::Props::Array,
|
31
|
-
default: []
|
32
28
|
|
33
29
|
def classname
|
34
30
|
additional_classes = [responsive_classname, max_height_classname]
|
@@ -51,11 +47,6 @@ module Playbook
|
|
51
47
|
def selected_rows_length
|
52
48
|
selected_rows.length
|
53
49
|
end
|
54
|
-
|
55
|
-
def is_action_bar_visible
|
56
|
-
# Action bar visibility is controlled by JS based on selection
|
57
|
-
false
|
58
|
-
end
|
59
50
|
end
|
60
51
|
end
|
61
52
|
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has
|
2
|
-
|
3
|
-
### id
|
4
|
-
|
5
|
-
A unique `id` is required to allow the table functionality to work properly. Without it, certain functions like the action bar will not be able to properly reference the correct table.
|
1
|
+
The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has two required props__:
|
6
2
|
|
7
3
|
### table_data
|
8
4
|
|
@@ -17,6 +13,6 @@ Column definitions are the single most important part of building a table as the
|
|
17
13
|
- `accessor`: this is the key from your data for the value you want rendered in that column
|
18
14
|
- `label`: this is what will be rendered as the column header label
|
19
15
|
|
20
|
-
There is also one optional item that is only required if the table has nested data:
|
16
|
+
There is also one optional item that is only required if the table has nested data:
|
21
17
|
|
22
18
|
- `cellAccessors`: This is an array of strings that represent keys from your data object. This is only required for the first column in case of nested data. If you have nested data, the AdvancedTable needs to know what to render in that first column for nested items. This array represents the nested data in the order you want it rendered.
|
@@ -39,13 +39,9 @@ const AdvancedTableDefault = (props) => {
|
|
39
39
|
<div>
|
40
40
|
<AdvancedTable
|
41
41
|
columnDefinitions={columnDefinitions}
|
42
|
-
maxHeight="xs"
|
43
|
-
overflow="auto"
|
44
|
-
responsive="scroll"
|
45
|
-
scrollBarNone
|
46
42
|
tableData={MOCK_DATA}
|
47
43
|
{...props}
|
48
|
-
|
44
|
+
/>
|
49
45
|
</div>
|
50
46
|
)
|
51
47
|
}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<br />
|
4
4
|
<br />
|
5
5
|
|
6
|
-
The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has two required props__:
|
6
|
+
The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, __the kit has two required props__:
|
7
7
|
|
8
8
|
### tableData
|
9
9
|
|
@@ -30,4 +30,4 @@
|
|
30
30
|
}
|
31
31
|
] %>
|
32
32
|
|
33
|
-
<%= pb_rails("advanced_table", props: { id: "table_props_table", table_data: @table_data, column_definitions: column_definitions
|
33
|
+
<%= pb_rails("advanced_table", props: { id: "table_props_table", table_data: @table_data, column_definitions: column_definitions, table_props: { vertical_border: true, container: false }}) %>
|
@@ -15,8 +15,6 @@ examples:
|
|
15
15
|
- advanced_table_column_border_color_rails: Column Group Border Color
|
16
16
|
- advanced_table_selectable_rows_rails: Selectable Rows
|
17
17
|
- advanced_table_selectable_rows_no_subrows_rails: Selectable Rows (No Subrows)
|
18
|
-
- advanced_table_selectable_rows_actions_rails: Selectable Rows (With Actions)
|
19
|
-
- advanced_table_selectable_rows_header_rails: Selectable Rows (No Actions Bar)
|
20
18
|
|
21
19
|
react:
|
22
20
|
- advanced_table_default: Default (Required Props)
|
@@ -79,7 +79,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
79
79
|
}
|
80
80
|
if (!allChildrenChecked) {
|
81
81
|
parentRow.classList.remove("bg-row-selection");
|
82
|
-
|
82
|
+
|
83
83
|
if (this.isRowExpanded(parentRow)) {
|
84
84
|
parentRow.classList.remove("bg-silver");
|
85
85
|
parentRow.classList.add("bg-white");
|
@@ -201,15 +201,15 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
201
201
|
this.toggleElement(this.target);
|
202
202
|
}
|
203
203
|
});
|
204
|
-
|
204
|
+
|
205
205
|
this.hideCloseIcon();
|
206
|
-
|
206
|
+
|
207
207
|
const table = this.element.closest("table");
|
208
|
-
|
208
|
+
|
209
209
|
// Prevent duplicate initialization
|
210
210
|
if (table.dataset.pbAdvancedTableInitialized) return;
|
211
211
|
table.dataset.pbAdvancedTableInitialized = "true";
|
212
|
-
|
212
|
+
|
213
213
|
// Bind checkbox change handlers for all row checkboxes
|
214
214
|
const checkboxLabels = table.querySelectorAll("label[data-row-id]");
|
215
215
|
checkboxLabels.forEach((label) => {
|
@@ -219,7 +219,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
219
219
|
this.handleCheckboxClick(event);
|
220
220
|
});
|
221
221
|
});
|
222
|
-
|
222
|
+
|
223
223
|
// Bind nested row expansion logic
|
224
224
|
const nestedButtons = table.querySelectorAll("[data-advanced-table]");
|
225
225
|
nestedButtons.forEach((button) => {
|
@@ -233,18 +233,18 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
233
233
|
}
|
234
234
|
});
|
235
235
|
});
|
236
|
-
|
236
|
+
|
237
237
|
// Bind select-all logic for this table
|
238
238
|
const selectAllCheckbox = table.querySelector("#select-all-rows");
|
239
239
|
if (selectAllCheckbox) {
|
240
240
|
selectAllCheckbox.addEventListener("change", () => {
|
241
241
|
const checkboxInput = selectAllCheckbox.querySelector('input[type="checkbox"]');
|
242
242
|
const checkAll = checkboxInput.checked;
|
243
|
-
|
243
|
+
|
244
244
|
const checkboxes = Array.from(
|
245
245
|
table.querySelectorAll("label[data-row-id] input[type='checkbox']")
|
246
246
|
);
|
247
|
-
|
247
|
+
|
248
248
|
checkboxes.forEach((cb) => {
|
249
249
|
cb.checked = checkAll;
|
250
250
|
const rowId = cb.id;
|
@@ -260,14 +260,14 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
260
260
|
rowEl?.classList.add("bg-white");
|
261
261
|
}
|
262
262
|
});
|
263
|
-
|
263
|
+
|
264
264
|
checkboxes.forEach((cb) => this.updateParentCheckboxes(cb));
|
265
|
-
|
265
|
+
|
266
266
|
this.updateTableSelectedRowsAttribute();
|
267
267
|
});
|
268
268
|
}
|
269
269
|
}
|
270
|
-
|
270
|
+
|
271
271
|
|
272
272
|
hideCloseIcon() {
|
273
273
|
const closeIcon = this.element.querySelector(UP_ARROW_SELECTOR);
|
@@ -449,149 +449,6 @@ export default class PbAdvancedTable extends PbEnhancedElement {
|
|
449
449
|
}
|
450
450
|
}
|
451
451
|
|
452
|
-
// Isolate action bar functionality so it doesn't mix with existing functionality
|
453
|
-
class PbAdvancedTableActionBar {
|
454
|
-
constructor() {
|
455
|
-
this.init();
|
456
|
-
}
|
457
|
-
|
458
|
-
init() {
|
459
|
-
// Initialize action bars for all advanced tables with action bars
|
460
|
-
document.addEventListener('DOMContentLoaded', () => {
|
461
|
-
this.setupActionBars();
|
462
|
-
});
|
463
|
-
|
464
|
-
// Also run immediately in case DOM is already loaded
|
465
|
-
if (document.readyState === 'loading') {
|
466
|
-
// DOM is still loading
|
467
|
-
} else {
|
468
|
-
// DOM is already loaded
|
469
|
-
this.setupActionBars();
|
470
|
-
}
|
471
|
-
}
|
472
|
-
|
473
|
-
setupActionBars() {
|
474
|
-
const advancedTables = document.querySelectorAll('.pb_advanced_table');
|
475
|
-
|
476
|
-
advancedTables.forEach(table => {
|
477
|
-
// Only proceed if this table has both selectable rows AND an action bar
|
478
|
-
if (!this.shouldEnableActionBar(table)) return;
|
479
|
-
|
480
|
-
const actionBar = table.querySelector('.row-selection-actions-card');
|
481
|
-
if (!actionBar) return; // Skip tables without action bars
|
482
|
-
|
483
|
-
// Initialize action bar styles
|
484
|
-
this.initializeActionBar(actionBar);
|
485
|
-
|
486
|
-
// Set up checkbox listeners for this table
|
487
|
-
this.setupCheckboxListeners(table, actionBar);
|
488
|
-
});
|
489
|
-
}
|
490
|
-
|
491
|
-
shouldEnableActionBar(table) {
|
492
|
-
// Check if the table has selectable rows
|
493
|
-
const hasSelectableRows = table.querySelector('input[type="checkbox"]') !== null;
|
494
|
-
|
495
|
-
// Check if the table has a row selection action bar (not other types of action bars)
|
496
|
-
const hasRowSelectionActionBar = table.querySelector('.row-selection-actions-card') !== null;
|
497
|
-
|
498
|
-
// Additional check: look for the presence of row checkboxes with data-row-id
|
499
|
-
const hasRowCheckboxes = table.querySelector('label[data-row-id] input[type="checkbox"]') !== null;
|
500
|
-
|
501
|
-
// Only enable if ALL conditions are met:
|
502
|
-
// 1. Has selectable checkboxes
|
503
|
-
// 2. Has the specific row selection action bar
|
504
|
-
// 3. Has row checkboxes (not just other types of checkboxes)
|
505
|
-
return hasSelectableRows && hasRowSelectionActionBar && hasRowCheckboxes;
|
506
|
-
}
|
507
|
-
|
508
|
-
initializeActionBar(actionBar) {
|
509
|
-
// Set initial hidden state
|
510
|
-
Object.assign(actionBar.style, {
|
511
|
-
height: '0px',
|
512
|
-
overflow: 'hidden',
|
513
|
-
display: 'block',
|
514
|
-
opacity: '0'
|
515
|
-
});
|
516
|
-
|
517
|
-
// Remove any visibility classes
|
518
|
-
actionBar.classList.remove("p_xs", "is-visible", "show-action-card");
|
519
|
-
actionBar.classList.add("p_none");
|
520
|
-
}
|
521
|
-
|
522
|
-
setupCheckboxListeners(table, actionBar) {
|
523
|
-
// Only listen to row checkboxes (those with data-row-id), not all checkboxes
|
524
|
-
const rowCheckboxes = table.querySelectorAll('label[data-row-id] input[type="checkbox"]');
|
525
|
-
|
526
|
-
rowCheckboxes.forEach(checkbox => {
|
527
|
-
checkbox.addEventListener('change', () => {
|
528
|
-
// Use setTimeout to ensure this runs after the main checkbox logic
|
529
|
-
setTimeout(() => {
|
530
|
-
this.updateActionBarVisibility(table, actionBar);
|
531
|
-
}, 0);
|
532
|
-
});
|
533
|
-
});
|
534
|
-
|
535
|
-
// Special handling for select-all checkbox (only if it exists)
|
536
|
-
const selectAllCheckbox = table.querySelector("#select-all-rows");
|
537
|
-
if (selectAllCheckbox) {
|
538
|
-
const selectAllInput = selectAllCheckbox.querySelector('input[type="checkbox"]');
|
539
|
-
if (selectAllInput) {
|
540
|
-
selectAllInput.addEventListener('change', () => {
|
541
|
-
// Use setTimeout to ensure this runs after the main select-all logic
|
542
|
-
setTimeout(() => {
|
543
|
-
this.updateActionBarVisibility(table, actionBar);
|
544
|
-
}, 10); // Slightly longer delay for select-all to ensure all row checkboxes are updated
|
545
|
-
});
|
546
|
-
}
|
547
|
-
}
|
548
|
-
}
|
549
|
-
|
550
|
-
updateActionBarVisibility(table, actionBar) {
|
551
|
-
// Only count row checkboxes (those with data-row-id), not all checkboxes
|
552
|
-
const rowCheckboxes = table.querySelectorAll('label[data-row-id] input[type="checkbox"]');
|
553
|
-
|
554
|
-
// Get all checked row checkboxes
|
555
|
-
const selectedRowCheckboxes = Array.from(rowCheckboxes).filter(cb => cb.checked);
|
556
|
-
|
557
|
-
// Get the selected count
|
558
|
-
const selectedCount = selectedRowCheckboxes.length;
|
559
|
-
|
560
|
-
if (selectedCount > 0) {
|
561
|
-
this.showActionBar(actionBar, selectedCount);
|
562
|
-
} else {
|
563
|
-
this.hideActionBar(actionBar);
|
564
|
-
}
|
565
|
-
}
|
566
|
-
|
567
|
-
showActionBar(actionBar, selectedCount) {
|
568
|
-
// Show action bar directly
|
569
|
-
actionBar.style.height = 'auto';
|
570
|
-
actionBar.style.overflow = 'visible';
|
571
|
-
actionBar.style.opacity = '1';
|
572
|
-
actionBar.classList.remove("p_none");
|
573
|
-
actionBar.classList.add("p_xs", "is-visible", "show-action-card");
|
574
|
-
|
575
|
-
// Update the count
|
576
|
-
const countElement = actionBar.querySelector(".selected-count");
|
577
|
-
if (countElement) {
|
578
|
-
countElement.textContent = `${selectedCount} Selected`;
|
579
|
-
}
|
580
|
-
}
|
581
|
-
|
582
|
-
hideActionBar(actionBar) {
|
583
|
-
// Hide action bar directly
|
584
|
-
actionBar.style.height = '0px';
|
585
|
-
actionBar.style.overflow = 'hidden';
|
586
|
-
actionBar.style.opacity = '0';
|
587
|
-
actionBar.classList.add("p_none");
|
588
|
-
actionBar.classList.remove("p_xs", "is-visible", "show-action-card");
|
589
|
-
}
|
590
|
-
}
|
591
|
-
|
592
|
-
// Initialize the isolated action bar functionality
|
593
|
-
new PbAdvancedTableActionBar();
|
594
|
-
|
595
452
|
window.expandAllRows = (element) => {
|
596
453
|
PbAdvancedTable.handleToggleAllHeaders(element);
|
597
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: {
|
@@ -1,12 +1,16 @@
|
|
1
|
-
<%= pb_content_tag(:label
|
2
|
-
pb_checkbox_indeterminate_main: object.indeterminate_main,
|
3
|
-
pb_checkbox_indeterminate_parent: object.indeterminate_parent,
|
4
|
-
}) do %>
|
1
|
+
<%= pb_content_tag(:label) do %>
|
5
2
|
<%= content.presence || object.input %>
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
<% if object.indeterminate %>
|
4
|
+
<span data-pb-checkbox-icon-span="true" class="pb_checkbox_indeterminate">
|
5
|
+
<%= pb_rails("icon", props: { icon: "minus", classname: "indeterminate_icon", fixed_width: true}) %>
|
6
|
+
<%= pb_rails("icon", props: { icon: "check", classname: "check_icon hidden", fixed_width: true}) %>
|
7
|
+
</span>
|
8
|
+
<% else %>
|
9
|
+
<span data-pb-checkbox-icon-span="true" class="pb_checkbox_checkmark">
|
10
|
+
<%= pb_rails("icon", props: { icon: "check", classname: "check_icon", fixed_width: true}) %>
|
11
|
+
<%= pb_rails("icon", props: { icon: "minus", classname: "indeterminate_icon hidden", fixed_width: true}) %>
|
12
|
+
</span>
|
13
|
+
<% end %>
|
10
14
|
<span class="pb_checkbox_label">
|
11
15
|
<%= pb_rails("body", props: { status: object.checkbox_label_status, text: object.text, dark: object.dark, margin_right: object.form_spacing ? "xs" : "" }) %>
|
12
16
|
</span>
|
@@ -5,8 +5,7 @@ module Playbook
|
|
5
5
|
class Checkbox < Playbook::KitBase
|
6
6
|
prop :error, type: Playbook::Props::Boolean, default: false
|
7
7
|
prop :checked, type: Playbook::Props::Boolean, default: false
|
8
|
-
prop :
|
9
|
-
prop :indeterminate_parent
|
8
|
+
prop :indeterminate, type: Playbook::Props::Boolean, default: false
|
10
9
|
prop :text
|
11
10
|
prop :value
|
12
11
|
prop :name
|
@@ -20,7 +19,7 @@ module Playbook
|
|
20
19
|
default: false
|
21
20
|
|
22
21
|
def classname
|
23
|
-
generate_classname("pb_checkbox_kit", checked_class) + error_class
|
22
|
+
generate_classname("pb_checkbox_kit", checked_class) + indeterminate_class + error_class
|
24
23
|
end
|
25
24
|
|
26
25
|
def input
|
@@ -40,6 +39,10 @@ module Playbook
|
|
40
39
|
def checked_class
|
41
40
|
checked ? "on" : "off"
|
42
41
|
end
|
42
|
+
|
43
|
+
def indeterminate_class
|
44
|
+
indeterminate ? " indeterminate" : ""
|
45
|
+
end
|
43
46
|
end
|
44
47
|
end
|
45
48
|
end
|
@@ -9,10 +9,11 @@
|
|
9
9
|
<tr>
|
10
10
|
<th>
|
11
11
|
<%= pb_rails("checkbox", props: {
|
12
|
+
checked: true,
|
12
13
|
text: "Uncheck All",
|
13
14
|
value: "checkbox-value",
|
14
15
|
name: "main-checkbox",
|
15
|
-
|
16
|
+
indeterminate: true,
|
16
17
|
id: "indeterminate-checkbox"
|
17
18
|
}) %>
|
18
19
|
</th>
|
@@ -29,10 +30,55 @@
|
|
29
30
|
value: checkbox[:id],
|
30
31
|
name: "#{checkbox[:id]}-indeterminate-checkbox",
|
31
32
|
id: "#{checkbox[:id]}-indeterminate-checkbox",
|
32
|
-
indeterminate_parent: "indeterminate-checkbox",
|
33
33
|
}) %>
|
34
34
|
</td>
|
35
35
|
</tr>
|
36
36
|
<% end %>
|
37
37
|
</tbody>
|
38
38
|
<% end %>
|
39
|
+
|
40
|
+
<script>
|
41
|
+
document.addEventListener('DOMContentLoaded', function() {
|
42
|
+
const mainCheckboxWrapper = document.getElementById('indeterminate-checkbox');
|
43
|
+
const mainCheckbox = document.getElementsByName("main-checkbox")[0];
|
44
|
+
const childCheckboxes = document.querySelectorAll('input[type="checkbox"][id$="indeterminate-checkbox"]');
|
45
|
+
|
46
|
+
const updateMainCheckbox = () => {
|
47
|
+
// Count the number of checked child checkboxes
|
48
|
+
const checkedCount = Array.from(childCheckboxes).filter(cb => cb.checked).length;
|
49
|
+
// Determine if the main checkbox should be in an indeterminate state
|
50
|
+
const indeterminate = checkedCount > 0 && checkedCount < childCheckboxes.length;
|
51
|
+
|
52
|
+
// Set the main checkbox states
|
53
|
+
mainCheckbox.indeterminate = indeterminate;
|
54
|
+
mainCheckbox.checked = checkedCount > 0;
|
55
|
+
|
56
|
+
// Determine the main checkbox label based on the number of checked checkboxes
|
57
|
+
const text = checkedCount === 0 ? 'Check All' : 'Uncheck All';
|
58
|
+
|
59
|
+
// Determine the icon class to add and remove based on the number of checked checkboxes
|
60
|
+
const iconClassToAdd = checkedCount === 0 ? 'pb_checkbox_checkmark' : 'pb_checkbox_indeterminate';
|
61
|
+
const iconClassToRemove = checkedCount === 0 ? 'pb_checkbox_indeterminate' : 'pb_checkbox_checkmark';
|
62
|
+
|
63
|
+
// Update main checkbox label
|
64
|
+
mainCheckboxWrapper.getElementsByClassName('pb_body_kit')[0].textContent = text;
|
65
|
+
|
66
|
+
// Add and remove the icon class to the main checkbox wrapper
|
67
|
+
mainCheckboxWrapper.querySelector('[data-pb-checkbox-icon-span]').classList.add(iconClassToAdd);
|
68
|
+
mainCheckboxWrapper.querySelector('[data-pb-checkbox-icon-span]').classList.remove(iconClassToRemove);
|
69
|
+
|
70
|
+
// Toggle the visibility of the checkbox icon based on the indeterminate state
|
71
|
+
mainCheckboxWrapper.getElementsByClassName("indeterminate_icon")[0].classList.toggle('hidden', !indeterminate);
|
72
|
+
mainCheckboxWrapper.getElementsByClassName("check_icon")[0].classList.toggle('hidden', indeterminate);
|
73
|
+
};
|
74
|
+
|
75
|
+
mainCheckbox.addEventListener('change', function() {
|
76
|
+
childCheckboxes.forEach(cb => cb.checked = this.checked);
|
77
|
+
updateMainCheckbox();
|
78
|
+
});
|
79
|
+
|
80
|
+
childCheckboxes.forEach(cb => {
|
81
|
+
cb.addEventListener('change', updateMainCheckbox);
|
82
|
+
});
|
83
|
+
});
|
84
|
+
</script>
|