playbook_ui_docs 14.21.0.pre.rc.1 → 14.21.0.pre.rc.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54482cd9b345026db8ec02d853abb2a14ef109bd819acf0109a7477743e0ba1a
|
4
|
+
data.tar.gz: 480b28777b97c0a3d4ed00b9624eba547a3b12366119be3833505c73f75dac4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd73ac1cbafe0bed9dacf92d74d98ee927cb437b5b432cd484b6180d3df3413e9968f56b5f71551ba132ae75c6b81f5a963b844e7c7da99689ca62512753e818
|
7
|
+
data.tar.gz: bc975080506feea78e5ff2103f7e3ca7895a26f91e31f0402cf165a4faeb3d93729189d978f21c6552fea1e15dff9b972e496f7332119028a7d2c56d8ea6b0c5
|
@@ -18,7 +18,7 @@
|
|
18
18
|
checked: true,
|
19
19
|
value: "checkbox-value",
|
20
20
|
name: "main-checkbox-selectable",
|
21
|
-
|
21
|
+
indeterminate_main: true,
|
22
22
|
id: "checkbox-selectable"
|
23
23
|
}) %>
|
24
24
|
<% end %>
|
@@ -33,7 +33,7 @@
|
|
33
33
|
<% checkboxes.each_with_index do |checkbox, index| %>
|
34
34
|
<%= pb_rails("table/table_row") do %>
|
35
35
|
<%= pb_rails("table/table_cell") do %>
|
36
|
-
<%= pb_rails("checkbox", props: { checked: checkbox[:checked], id: "#{checkbox[:id]}-selectable-checkbox", name: "#{checkbox[:id]}-selectable-checkbox", on_change: "updateCheckboxes(#{index})", value: "check-box value" }) %>
|
36
|
+
<%= pb_rails("checkbox", props: { checked: checkbox[:checked], id: "#{checkbox[:id]}-selectable-checkbox", name: "#{checkbox[:id]}-selectable-checkbox", on_change: "updateCheckboxes(#{index})", value: "check-box value", indeterminate_parent: "checkbox-selectable" }) %>
|
37
37
|
<% end %>
|
38
38
|
<%= pb_rails("table/table_cell") do %>
|
39
39
|
<%= pb_rails("image", props: { alt: "picture of a misty forest", size: "xs", url: "https://unsplash.it/500/400/?image=634" }) %>
|
@@ -45,52 +45,4 @@
|
|
45
45
|
<% end %>
|
46
46
|
<% end %>
|
47
47
|
<% end %>
|
48
|
-
<% end %>
|
49
|
-
|
50
|
-
<script>
|
51
|
-
document.addEventListener('DOMContentLoaded', function() {
|
52
|
-
const mainCheckboxWrapper = document.getElementById('checkbox-selectable');
|
53
|
-
const mainCheckbox = document.getElementsByName("main-checkbox-selectable")[0];
|
54
|
-
const childCheckboxes = document.querySelectorAll('input[type="checkbox"][id$="selectable-checkbox"]');
|
55
|
-
const deleteButton = document.getElementById('delete-button');
|
56
|
-
|
57
|
-
const updateDeleteButton = () => {
|
58
|
-
const anyChecked = Array.from(childCheckboxes).some(checkbox => checkbox.checked);
|
59
|
-
deleteButton.style.display = anyChecked ? 'block' : 'none';
|
60
|
-
};
|
61
|
-
|
62
|
-
const updateMainCheckbox = () => {
|
63
|
-
// Count the number of checked child checkboxes
|
64
|
-
const checkedCount = Array.from(childCheckboxes).filter(cb => cb.checked).length;
|
65
|
-
// Determine if the main checkbox should be in an indeterminate state
|
66
|
-
const indeterminate = checkedCount > 0 && checkedCount < childCheckboxes.length;
|
67
|
-
|
68
|
-
// Set the main checkbox states
|
69
|
-
mainCheckbox.indeterminate = indeterminate;
|
70
|
-
mainCheckbox.checked = checkedCount > 0;
|
71
|
-
|
72
|
-
// Determine the icon class to add and remove based on the number of checked checkboxes
|
73
|
-
const iconClassToAdd = checkedCount === 0 ? 'pb_checkbox_checkmark' : 'pb_checkbox_indeterminate';
|
74
|
-
const iconClassToRemove = checkedCount === 0 ? 'pb_checkbox_indeterminate' : 'pb_checkbox_checkmark';
|
75
|
-
|
76
|
-
// Add and remove the icon class to the main checkbox wrapper
|
77
|
-
mainCheckboxWrapper.querySelector('[data-pb-checkbox-icon-span]').classList.add(iconClassToAdd);
|
78
|
-
mainCheckboxWrapper.querySelector('[data-pb-checkbox-icon-span]').classList.remove(iconClassToRemove);
|
79
|
-
|
80
|
-
// Toggle the visibility of the checkbox icon based on the indeterminate state
|
81
|
-
mainCheckboxWrapper.getElementsByClassName("indeterminate_icon")[0].classList.toggle('hidden', !indeterminate);
|
82
|
-
mainCheckboxWrapper.getElementsByClassName("check_icon")[0].classList.toggle('hidden', indeterminate);
|
83
|
-
|
84
|
-
updateDeleteButton();
|
85
|
-
};
|
86
|
-
|
87
|
-
mainCheckbox.addEventListener('change', function() {
|
88
|
-
childCheckboxes.forEach(cb => cb.checked = this.checked);
|
89
|
-
updateMainCheckbox();
|
90
|
-
});
|
91
|
-
|
92
|
-
childCheckboxes.forEach(cb => {
|
93
|
-
cb.addEventListener('change', updateMainCheckbox);
|
94
|
-
});
|
95
|
-
});
|
96
|
-
</script>
|
48
|
+
<% end %>
|