playbook_ui 14.23.0.pre.alpha.PLAY2283multiheaderverticalbordersdoc9335 → 14.23.0.pre.alpha.PLAY2303optD9000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +6 -7
- data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +25 -24
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +10 -10
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +12 -11
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +4 -7
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +2 -78
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +7 -13
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +2 -14
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +0 -34
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table_action_bar.js +0 -16
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +0 -4
- data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +11 -4
- data/app/pb_kits/playbook/pb_advanced_table/index.js +125 -108
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +1 -7
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +4 -7
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +1 -5
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +4 -46
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +4 -13
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +5 -24
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.rb +1 -1
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.md +1 -1
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +1 -12
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +1 -1
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate_rails.md +1 -2
- data/app/pb_kits/playbook/pb_checkbox/index.js +26 -218
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.md +1 -1
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +1 -17
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +0 -6
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_radio_options.jsx +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_radio_options_react.md +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +2 -3
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +0 -24
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +1 -11
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_colors.jsx +15 -32
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_complex.jsx +9 -35
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_default.jsx +14 -26
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_disable_animation.jsx +15 -32
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_full_circle.jsx +17 -45
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_height.jsx +22 -59
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_live_data.jsx +9 -40
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_min_max.jsx +18 -50
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_pb_styles.jsx +30 -0
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_pb_styles.md +1 -0
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_sizing.jsx +18 -31
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_title.jsx +17 -34
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_units.jsx +23 -64
- data/app/pb_kits/playbook/pb_gauge/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_gauge/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_gauge/gaugeTheme.ts +1 -7
- data/app/pb_kits/playbook/pb_line_graph/docs/_description.md +3 -1
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_colors.jsx +17 -36
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_default.jsx +16 -31
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_height.jsx +31 -63
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend.jsx +16 -35
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_nonclickable.jsx +16 -41
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.jsx +62 -107
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.md +7 -4
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_pb_styles.jsx +52 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_pb_styles.md +1 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_line_graph/lineGraphTheme.ts +1 -16
- data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +9 -18
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +1 -3
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +0 -3
- data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +0 -4
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default_rails.md +1 -3
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default_react.md +1 -3
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +0 -3
- data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +0 -2
- 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/select.rb +2 -4
- data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb +0 -1
- data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.scss +0 -0
- data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.tsx +202 -0
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_continuous.jsx +69 -0
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_default.jsx +71 -0
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_multi_beacon.jsx +110 -0
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_no_beacon.jsx +76 -0
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_no_overlay.jsx +76 -0
- data/app/pb_kits/playbook/pb_walkthrough/docs/_walkthrough_styled.jsx +76 -0
- data/app/pb_kits/playbook/pb_walkthrough/docs/example.yml +10 -0
- data/app/pb_kits/playbook/pb_walkthrough/docs/index.js +6 -0
- data/app/pb_kits/playbook/pb_walkthrough/walkthrough.test.jsx +34 -0
- data/dist/chunks/_circle_chart-BZmlhBs2.js +1 -0
- data/dist/chunks/_typeahead-B1tu_vWi.js +22 -0
- data/dist/chunks/_weekday_stacked-CKk0dR5s.js +45 -0
- data/dist/chunks/lib-DYpq0k8j.js +29 -0
- data/dist/chunks/{pb_form_validation-D3b0JKHH.js → pb_form_validation-BUOKwfvW.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +10 -3
- 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 +26 -38
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_vertical_border.html.erb +0 -43
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_vertical_border.jsx +0 -64
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling.html.erb +0 -46
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling_rails.md +0 -7
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column.jsx +0 -55
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column.md +0 -6
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column_for_multi_column.jsx +0 -80
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column_for_multi_column.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header.jsx +0 -107
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.html.erb +0 -51
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.md +0 -1
- data/app/pb_kits/playbook/pb_dropdown/_dropdown_mixin.scss +0 -36
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_active_style_options.jsx +0 -90
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_active_style_options_react.md +0 -4
- data/app/pb_kits/playbook/pb_gauge/docs/_description.md +0 -1
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_colors_react.md +0 -2
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_complex_react.md +0 -1
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_units_react.md +0 -1
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_colors_react.md +0 -3
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_height.md +0 -3
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.html.erb +0 -75
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.jsx +0 -94
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.md +0 -3
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_strict_mode.html.erb +0 -10
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_strict_mode.jsx +0 -26
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_strict_mode.md +0 -3
- data/dist/chunks/_line_graph-D7DgMqnT.js +0 -1
- data/dist/chunks/_typeahead-BzYZCpJO.js +0 -6
- data/dist/chunks/_weekday_stacked-CCn-qLh_.js +0 -37
- data/dist/chunks/lib-CY5ZPzic.js +0 -29
- /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_row_styling_react.md → _advanced_table_row_styling.md} +0 -0
- /data/app/pb_kits/playbook/pb_gauge/docs/{_gauge_colors_rails.md → _gauge_colors.md} +0 -0
- /data/app/pb_kits/playbook/pb_gauge/docs/{_gauge_complex_rails.md → _gauge_complex.md} +0 -0
- /data/app/pb_kits/playbook/pb_line_graph/docs/{_line_graph_colors_rails.md → _line_graph_colors.md} +0 -0
@@ -6,8 +6,6 @@ module Playbook
|
|
6
6
|
prop :error, type: Playbook::Props::Boolean, default: false
|
7
7
|
prop :checked, type: Playbook::Props::Boolean, default: false
|
8
8
|
prop :indeterminate_main, type: Playbook::Props::Boolean, default: false
|
9
|
-
prop :indeterminate_main_labels, type: Playbook::Props::Array,
|
10
|
-
default: []
|
11
9
|
prop :indeterminate_parent
|
12
10
|
prop :text
|
13
11
|
prop :value
|
@@ -51,19 +49,10 @@ module Playbook
|
|
51
49
|
end
|
52
50
|
|
53
51
|
def data
|
54
|
-
|
52
|
+
Hash(prop(:data)).merge(
|
55
53
|
pb_checkbox_indeterminate_main: indeterminate_main,
|
56
54
|
pb_checkbox_indeterminate_parent: indeterminate_parent
|
57
55
|
)
|
58
|
-
|
59
|
-
if indeterminate_main && indeterminate_main_labels.size == 2
|
60
|
-
base_data.merge!(
|
61
|
-
pb_checkbox_indeterminate_main_label_check: indeterminate_main_labels[0],
|
62
|
-
pb_checkbox_indeterminate_main_label_uncheck: indeterminate_main_labels[1]
|
63
|
-
)
|
64
|
-
end
|
65
|
-
|
66
|
-
base_data
|
67
56
|
end
|
68
57
|
|
69
58
|
private
|
@@ -9,10 +9,10 @@
|
|
9
9
|
<tr>
|
10
10
|
<th>
|
11
11
|
<%= pb_rails("checkbox", props: {
|
12
|
+
text: "Uncheck All",
|
12
13
|
value: "checkbox-value",
|
13
14
|
name: "main-checkbox",
|
14
15
|
indeterminate_main: true,
|
15
|
-
indeterminate_main_labels: ["Check All Ice Cream", "Uncheck All Ice Cream"],
|
16
16
|
id: "indeterminate-checkbox"
|
17
17
|
}) %>
|
18
18
|
</th>
|
@@ -1,2 +1 @@
|
|
1
|
-
If you want to use indeterminate, "check/uncheck all" checkboxes, add `indeterminate_main: true` and an `id` to the main checkbox. Then, add an `indeterminate_parent` prop with the main checkbox's `id` to the children checkboxes.
|
2
|
-
If you want to customize the main checkbox labels, set an array `indeterminate_main_labels` with "Check All" and "Uncheck All" labels.
|
1
|
+
If you want to use indeterminate, "check/uncheck all" checkboxes, add `indeterminate_main: true` and an `id` to the main checkbox. Then, add an `indeterminate_parent` prop with the main checkbox's `id` to the children checkboxes.
|
@@ -10,239 +10,47 @@ export default class PbCheckbox extends PbEnhancedElement {
|
|
10
10
|
connect() {
|
11
11
|
const mainCheckboxWrapper = this.element;
|
12
12
|
const mainCheckbox = mainCheckboxWrapper.querySelector('input')
|
13
|
-
const
|
13
|
+
const childCheckboxes = document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
const
|
18
|
-
|
19
|
-
|
20
|
-
// Breadth-first search to find all nested descendants
|
21
|
-
while (queue.length > 0) {
|
22
|
-
const checkbox = queue.shift();
|
23
|
-
descendants.push(checkbox);
|
24
|
-
|
25
|
-
// Find children of this checkbox
|
26
|
-
const checkboxWrapper = checkbox.closest('[data-pb-checkbox-indeterminate-main="true"]');
|
27
|
-
if (checkboxWrapper) {
|
28
|
-
const childCheckboxes = document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${checkboxWrapper.id}"] input[type="checkbox"]`);
|
29
|
-
queue.push(...childCheckboxes);
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
// Also include any non-"main" checkboxes that have this as a parent
|
34
|
-
const nonMainChildCheckboxes = document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);
|
35
|
-
nonMainChildCheckboxes.forEach(cb => {
|
36
|
-
if (!descendants.includes(cb)) {
|
37
|
-
descendants.push(cb);
|
38
|
-
}
|
39
|
-
});
|
40
|
-
|
41
|
-
return descendants;
|
42
|
-
};
|
43
|
-
|
44
|
-
// Helper function to determine checkbox state
|
45
|
-
const getCheckboxState = (checkboxes) => {
|
46
|
-
const checkedCount = checkboxes.filter(cb => cb.checked).length;
|
47
|
-
const totalCount = checkboxes.length;
|
15
|
+
const updateMainCheckbox = () => {
|
16
|
+
// Count the number of checked child checkboxes
|
17
|
+
const checkedCount = Array.from(childCheckboxes).filter(cb => cb.checked).length;
|
18
|
+
// Determine if the main checkbox should be in an indeterminate state
|
19
|
+
const indeterminate = checkedCount > 0 && checkedCount < childCheckboxes.length;
|
48
20
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
indeterminate: !(checkedCount === totalCount || checkedCount === 0),
|
53
|
-
checkedCount,
|
54
|
-
totalCount
|
55
|
-
};
|
56
|
-
};
|
21
|
+
// Set the main checkbox states
|
22
|
+
mainCheckbox.indeterminate = indeterminate;
|
23
|
+
mainCheckbox.checked = checkedCount > 0;
|
57
24
|
|
58
|
-
|
59
|
-
|
60
|
-
checkbox.indeterminate = isIndeterminate;
|
61
|
-
checkbox.checked = isChecked;
|
62
|
-
};
|
25
|
+
// Determine the main checkbox label based on the number of checked checkboxes
|
26
|
+
const text = checkedCount === 0 ? 'Check All' : 'Uncheck All';
|
63
27
|
|
64
|
-
|
65
|
-
|
66
|
-
const
|
67
|
-
const uncheckAllLabel = wrapper.dataset.pbCheckboxIndeterminateMainLabelUncheck ?? 'Uncheck All';
|
68
|
-
const text = checkedCount === 0 ? checkAllLabel : uncheckAllLabel;
|
28
|
+
// Determine the icon class to add and remove based on the number of checked checkboxes
|
29
|
+
const iconClassToAdd = checkedCount === 0 ? 'pb_checkbox_checkmark' : 'pb_checkbox_indeterminate';
|
30
|
+
const iconClassToRemove = checkedCount === 0 ? 'pb_checkbox_indeterminate' : 'pb_checkbox_checkmark';
|
69
31
|
|
70
|
-
// Update label
|
71
|
-
|
72
|
-
if (bodyKitElement) {
|
73
|
-
bodyKitElement.textContent = text;
|
74
|
-
}
|
32
|
+
// Update main checkbox label
|
33
|
+
mainCheckboxWrapper.getElementsByClassName('pb_body_kit')[0].textContent = text;
|
75
34
|
|
76
|
-
//
|
77
|
-
|
78
|
-
|
79
|
-
const iconClassToAdd = isIndeterminate ? 'pb_checkbox_indeterminate' : 'pb_checkbox_checkmark';
|
80
|
-
const iconClassToRemove = isIndeterminate ? 'pb_checkbox_checkmark' : 'pb_checkbox_indeterminate';
|
81
|
-
iconSpan.classList.add(iconClassToAdd);
|
82
|
-
iconSpan.classList.remove(iconClassToRemove);
|
83
|
-
}
|
35
|
+
// Add and remove the icon class to the main checkbox wrapper
|
36
|
+
mainCheckboxWrapper.querySelector('[data-pb-checkbox-icon-span]').classList.add(iconClassToAdd);
|
37
|
+
mainCheckboxWrapper.querySelector('[data-pb-checkbox-icon-span]').classList.remove(iconClassToRemove);
|
84
38
|
|
85
|
-
// Toggle icon
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
if (indeterminateIcon) {
|
90
|
-
indeterminateIcon.classList.toggle('hidden', !isIndeterminate);
|
91
|
-
}
|
92
|
-
if (checkIcon) {
|
93
|
-
checkIcon.classList.toggle('hidden', isIndeterminate);
|
94
|
-
}
|
95
|
-
};
|
96
|
-
|
97
|
-
// Main function to update this checkbox's state
|
98
|
-
const updateMainCheckbox = () => {
|
99
|
-
const allDescendantCheckboxes = getAllDescendantCheckboxes();
|
100
|
-
const state = getCheckboxState(allDescendantCheckboxes);
|
101
|
-
|
102
|
-
updateCheckboxVisualState(mainCheckbox, state.indeterminate, state.allChecked);
|
103
|
-
updateCheckboxLabelAndIcons(mainCheckboxWrapper, state.indeterminate, state.checkedCount);
|
104
|
-
};
|
105
|
-
|
106
|
-
// Function to update parent checkboxes recursively
|
107
|
-
const updateParentCheckboxes = () => {
|
108
|
-
const parentId = mainCheckboxWrapper.dataset.pbCheckboxIndeterminateParent;
|
109
|
-
if (parentId) {
|
110
|
-
const parentCheckbox = document.getElementById(parentId);
|
111
|
-
if (parentCheckbox) {
|
112
|
-
const parentWrapper = parentCheckbox.closest('[data-pb-checkbox-indeterminate-main="true"]');
|
113
|
-
if (parentWrapper) {
|
114
|
-
const parentInstance = parentWrapper.pbCheckboxInstance;
|
115
|
-
if (parentInstance && parentInstance.updateMainCheckbox) {
|
116
|
-
parentInstance.updateMainCheckbox();
|
117
|
-
parentInstance.updateParentCheckboxes();
|
118
|
-
}
|
119
|
-
}
|
120
|
-
}
|
121
|
-
}
|
39
|
+
// Toggle the visibility of the checkbox icon based on the indeterminate state
|
40
|
+
mainCheckboxWrapper.getElementsByClassName("indeterminate_icon")[0].classList.toggle('hidden', !indeterminate);
|
41
|
+
mainCheckboxWrapper.getElementsByClassName("check_icon")[0].classList.toggle('hidden', indeterminate);
|
122
42
|
};
|
123
43
|
|
124
|
-
//
|
125
|
-
const setupNonMainCheckboxUpdates = () => {
|
126
|
-
const allCheckboxesWithChildren = document.querySelectorAll('input[type="checkbox"]');
|
127
|
-
allCheckboxesWithChildren.forEach(cb => {
|
128
|
-
const checkboxWrapper = cb.closest('[data-pb-checkbox-indeterminate-main="true"]');
|
129
|
-
if (checkboxWrapper && checkboxWrapper !== mainCheckboxWrapper) {
|
130
|
-
return; // Skip different "main" checkboxes
|
131
|
-
}
|
132
|
-
|
133
|
-
const childCheckboxes = document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${cb.id}"] input[type="checkbox"]`);
|
134
|
-
if (childCheckboxes.length > 0) {
|
135
|
-
childCheckboxes.forEach(childCb => {
|
136
|
-
childCb.addEventListener('change', () => {
|
137
|
-
const state = getCheckboxState(Array.from(childCheckboxes));
|
138
|
-
updateCheckboxVisualState(cb, state.indeterminate, state.allChecked);
|
139
|
-
|
140
|
-
// Trigger updates on all main checkboxes that might be affected
|
141
|
-
const mainCheckboxes = document.querySelectorAll('[data-pb-checkbox-indeterminate-main="true"]');
|
142
|
-
mainCheckboxes.forEach(mainCb => {
|
143
|
-
const mainInstance = mainCb.pbCheckboxInstance;
|
144
|
-
if (mainInstance && mainInstance.updateMainCheckbox) {
|
145
|
-
setTimeout(() => {
|
146
|
-
mainInstance.updateMainCheckbox();
|
147
|
-
}, 0);
|
148
|
-
}
|
149
|
-
});
|
150
|
-
});
|
151
|
-
});
|
152
|
-
}
|
153
|
-
});
|
154
|
-
};
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
// Initialize checkbox state
|
44
|
+
// Set indeterminate icon on main checkbox if initial children checkboxes are checked
|
159
45
|
updateMainCheckbox();
|
160
46
|
|
161
|
-
|
162
|
-
|
163
|
-
const allDescendantCheckboxes = getAllDescendantCheckboxes();
|
164
|
-
const state = getCheckboxState(allDescendantCheckboxes);
|
165
|
-
|
166
|
-
if (state.indeterminate) {
|
167
|
-
// If indeterminate, uncheck all descendants and the parent
|
168
|
-
allDescendantCheckboxes.forEach(cb => {
|
169
|
-
cb.checked = false;
|
170
|
-
// Dispatch custom event for programmatic changes- change styles in advanced table
|
171
|
-
cb.dispatchEvent(new Event('checkbox-programmatic-change', { bubbles: true }));
|
172
|
-
});
|
173
|
-
this.checked = false;
|
174
|
-
} else {
|
175
|
-
// Otherwise, set all descendants to the same state as this checkbox
|
176
|
-
allDescendantCheckboxes.forEach(cb => {
|
177
|
-
cb.checked = this.checked;
|
178
|
-
// Dispatch custom event for programmatic changes- change styles in advanced table
|
179
|
-
cb.dispatchEvent(new Event('checkbox-programmatic-change', { bubbles: true }));
|
180
|
-
});
|
181
|
-
}
|
182
|
-
|
183
|
-
// Update this checkbox first, then parents after a delay
|
47
|
+
this.element.querySelector('input').addEventListener('change', function() {
|
48
|
+
childCheckboxes.forEach(cb => cb.checked = this.checked);
|
184
49
|
updateMainCheckbox();
|
185
|
-
setTimeout(() => {
|
186
|
-
updateParentCheckboxes();
|
187
|
-
}, 0);
|
188
|
-
|
189
|
-
// Also trigger updates on all main checkboxes to ensure proper state propagation
|
190
|
-
triggerAllMainCheckboxUpdates();
|
191
50
|
});
|
192
51
|
|
193
|
-
|
194
|
-
directChildCheckboxes.forEach(cb => {
|
52
|
+
childCheckboxes.forEach(cb => {
|
195
53
|
cb.addEventListener('change', updateMainCheckbox);
|
196
54
|
});
|
197
|
-
|
198
|
-
// Handle deeper descendant changes
|
199
|
-
const allDescendantCheckboxes = getAllDescendantCheckboxes();
|
200
|
-
allDescendantCheckboxes.forEach(cb => {
|
201
|
-
if (!Array.from(directChildCheckboxes).includes(cb)) {
|
202
|
-
cb.addEventListener('change', updateMainCheckbox);
|
203
|
-
}
|
204
|
-
});
|
205
|
-
|
206
|
-
// Handle non-main child checkboxes
|
207
|
-
const allChildCheckboxes = document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);
|
208
|
-
allChildCheckboxes.forEach(cb => {
|
209
|
-
if (!allDescendantCheckboxes.includes(cb)) {
|
210
|
-
cb.addEventListener('change', updateMainCheckbox);
|
211
|
-
}
|
212
|
-
});
|
213
|
-
|
214
|
-
// Also trigger updates on all main checkboxes when any checkbox changes
|
215
|
-
let updateTimeout = null;
|
216
|
-
const triggerAllMainCheckboxUpdates = () => {
|
217
|
-
// Debounce the updates to prevent excessive calls
|
218
|
-
if (updateTimeout) {
|
219
|
-
clearTimeout(updateTimeout);
|
220
|
-
}
|
221
|
-
updateTimeout = setTimeout(() => {
|
222
|
-
const mainCheckboxes = document.querySelectorAll('[data-pb-checkbox-indeterminate-main="true"]');
|
223
|
-
mainCheckboxes.forEach(mainCb => {
|
224
|
-
const mainInstance = mainCb.pbCheckboxInstance;
|
225
|
-
if (mainInstance && mainInstance.updateMainCheckbox) {
|
226
|
-
mainInstance.updateMainCheckbox();
|
227
|
-
}
|
228
|
-
});
|
229
|
-
}, 10); // Small delay to batch updates
|
230
|
-
};
|
231
|
-
|
232
|
-
// Store the original updateMainCheckbox function and create a new one that also triggers updates
|
233
|
-
const originalUpdateMainCheckbox = updateMainCheckbox;
|
234
|
-
const enhancedUpdateMainCheckbox = () => {
|
235
|
-
originalUpdateMainCheckbox();
|
236
|
-
triggerAllMainCheckboxUpdates();
|
237
|
-
};
|
238
|
-
|
239
|
-
// Replace the updateMainCheckbox function
|
240
|
-
mainCheckboxWrapper.pbCheckboxInstance = {
|
241
|
-
updateMainCheckbox: enhancedUpdateMainCheckbox,
|
242
|
-
updateParentCheckboxes
|
243
|
-
};
|
244
|
-
|
245
|
-
// Setup updates for non-main checkboxes with children
|
246
|
-
setupNonMainCheckboxUpdates();
|
247
55
|
}
|
248
56
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
##### Prop
|
2
2
|
|
3
3
|
`align` **Type**: String | **Values**: left | center | right (defaults to center)
|
4
|
-
`verticalAlign` **Type**: String | **Values**: top | middle | bottom (defaults
|
4
|
+
`verticalAlign` **Type**: String | **Values**: top | middle | bottom (defaults middle)
|
5
5
|
`layout` **Type**: String | **Values**: horizontal | vertical | proximate (defaults to horizontal)
|
6
6
|
`x` **Type**: Number (defaults to 0)
|
7
7
|
`y` **Type**: Number (defaults to 0)
|
@@ -8,7 +8,6 @@
|
|
8
8
|
@import "../pb_textarea/textarea_mixin";
|
9
9
|
|
10
10
|
@import "./scss_partials/dropdown_animation";
|
11
|
-
@import "dropdown_mixin";
|
12
11
|
|
13
12
|
[class*="pb_dropdown"] {
|
14
13
|
.dropdown_wrapper {
|
@@ -99,23 +98,9 @@
|
|
99
98
|
[class^="pb_title_kit"], a {
|
100
99
|
color: $white !important;
|
101
100
|
}
|
102
|
-
border-bottom: 1px solid $border_light;
|
103
101
|
&:hover {
|
104
|
-
background-color: $product_1_background;
|
105
|
-
}
|
106
|
-
|
107
|
-
// activeStyle font color map
|
108
|
-
@each $name, $color in $font-colors {
|
109
|
-
&.font-#{$name} {
|
110
|
-
@include apply-font-color($color);
|
111
|
-
}
|
102
|
+
background-color: $product_1_background !important;
|
112
103
|
}
|
113
|
-
// activeStyle background color map (no difference between selected and selected+hover custom colors)
|
114
|
-
@each $name, $bg in $background-colors {
|
115
|
-
&.bg-#{$name} {
|
116
|
-
background-color: $bg;
|
117
|
-
}
|
118
|
-
}
|
119
104
|
}
|
120
105
|
}
|
121
106
|
|
@@ -282,7 +267,6 @@
|
|
282
267
|
}
|
283
268
|
&[class*="selected"] {
|
284
269
|
background-color: $primary;
|
285
|
-
border-bottom: rgba($white, 0.15);
|
286
270
|
}
|
287
271
|
}
|
288
272
|
}
|
@@ -39,10 +39,6 @@ type DropdownProps = {
|
|
39
39
|
options: GenericObject;
|
40
40
|
separators?: boolean;
|
41
41
|
variant?: "default" | "subtle";
|
42
|
-
activeStyle?: {
|
43
|
-
backgroundColor?: string;
|
44
|
-
fontColor?: string;
|
45
|
-
};
|
46
42
|
};
|
47
43
|
|
48
44
|
interface DropdownComponent
|
@@ -73,7 +69,6 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
73
69
|
options,
|
74
70
|
separators = true,
|
75
71
|
variant = "default",
|
76
|
-
activeStyle,
|
77
72
|
} = props;
|
78
73
|
|
79
74
|
const ariaProps = buildAriaProps(aria);
|
@@ -256,7 +251,6 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
256
251
|
>
|
257
252
|
<DropdownContext.Provider
|
258
253
|
value={{
|
259
|
-
activeStyle,
|
260
254
|
autocomplete,
|
261
255
|
dropdownContainerRef,
|
262
256
|
filteredOptions,
|
@@ -18,7 +18,6 @@ const DropdownCustomRadioOptions = (props) => {
|
|
18
18
|
return (
|
19
19
|
<div>
|
20
20
|
<Dropdown
|
21
|
-
activeStyle={{ backgroundColor: "bg_light", fontColor: "text_lt_default" }}
|
22
21
|
label="Select Item"
|
23
22
|
onSelect={(selectedItem) => setSelectedValue(selectedItem?.value)}
|
24
23
|
options={options}
|
@@ -1 +1 @@
|
|
1
|
-
Radio inputs can be used inside `Dropdown.Option` for a custom layout that mimics form-like selection within a dropdown.
|
1
|
+
Radio inputs can be used inside `Dropdown.Option` for a custom layout that mimics form-like selection within a dropdown.
|
@@ -16,7 +16,7 @@ examples:
|
|
16
16
|
- dropdown_with_search_rails: Custom Trigger Dropdown with Search
|
17
17
|
- dropdown_with_custom_padding: Custom Option Padding
|
18
18
|
- dropdown_with_custom_icon_options: Custom Icon Options
|
19
|
-
# - dropdown_with_custom_radio_options: Custom Radio Options # TODO: Update and publish doc ex in
|
19
|
+
# - dropdown_with_custom_radio_options: Custom Radio Options # TODO: Update and publish doc ex in [PLAY-2146](https://runway.powerhrg.com/backlog_items/PLAY-2146) (remove this comment afterwards)
|
20
20
|
- dropdown_error: Dropdown with Error
|
21
21
|
- dropdown_default_value: Default Value
|
22
22
|
- dropdown_multi_select_with_default: Multi Select Default Value
|
@@ -39,9 +39,8 @@ examples:
|
|
39
39
|
- dropdown_with_custom_trigger: Custom Trigger
|
40
40
|
- dropdown_with_search: Custom Trigger Dropdown with Search
|
41
41
|
- dropdown_with_custom_padding: Custom Option Padding
|
42
|
-
- dropdown_with_custom_active_style_options: Custom Active Style Options
|
43
42
|
- dropdown_with_custom_icon_options: Custom Icon Options
|
44
|
-
- dropdown_with_custom_radio_options: Custom Radio Options
|
43
|
+
# - dropdown_with_custom_radio_options: Custom Radio Options # TODO: Update and publish doc ex in [PLAY-2146](https://runway.powerhrg.com/backlog_items/PLAY-2146) (remove this comment afterwards)
|
45
44
|
- dropdown_error: Dropdown with Error
|
46
45
|
- dropdown_default_value: Default Value
|
47
46
|
- dropdown_multi_select_with_default: Multi Select Default Value
|
@@ -21,5 +21,4 @@ export { default as DropdownMultiSelectWithAutocomplete } from './_dropdown_mult
|
|
21
21
|
export { default as DropdownMultiSelectWithDefault } from './_dropdown_multi_select_with_default.jsx'
|
22
22
|
export { default as DropdownMultiSelectWithCustomOptions } from './_dropdown_multi_select_with_custom_options.jsx'
|
23
23
|
export {default as DropdownWithCustomIconOptions} from './_dropdown_with_custom_icon_options.jsx'
|
24
|
-
export {default as DropdownWithCustomRadioOptions} from './_dropdown_with_custom_radio_options.jsx'
|
25
|
-
export {default as DropdownWithCustomActiveStyleOptions} from './_dropdown_with_custom_active_style_options.jsx'
|
24
|
+
export {default as DropdownWithCustomRadioOptions} from './_dropdown_with_custom_radio_options.jsx'
|
@@ -369,28 +369,4 @@ test("defaultValue works with multiSelect", () => {
|
|
369
369
|
const option2 = Array.from(kit.querySelectorAll(".pb_dropdown_option_list"));
|
370
370
|
const firstOpt = options[0].label
|
371
371
|
expect(option2[0]).not.toHaveTextContent(firstOpt)
|
372
|
-
})
|
373
|
-
|
374
|
-
test("applies activeStyle backgroundColor and fontColor when selected", () => {
|
375
|
-
render(
|
376
|
-
<Dropdown
|
377
|
-
activeStyle={{
|
378
|
-
backgroundColor: "bg_light",
|
379
|
-
fontColor: "primary",
|
380
|
-
}}
|
381
|
-
data={{ testid: testId }}
|
382
|
-
options={options}
|
383
|
-
/>
|
384
|
-
)
|
385
|
-
|
386
|
-
const kit = screen.getByTestId(testId)
|
387
|
-
const option = kit.querySelectorAll(".pb_dropdown_option_list")[1]
|
388
|
-
|
389
|
-
fireEvent.click(option)
|
390
|
-
|
391
|
-
const selected = kit.querySelector(".pb_dropdown_option_selected")
|
392
|
-
|
393
|
-
expect(selected).toBeInTheDocument()
|
394
|
-
expect(selected).toHaveClass("bg-bg_light")
|
395
|
-
expect(selected).toHaveClass("font-primary")
|
396
372
|
})
|
@@ -41,7 +41,6 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
41
41
|
} = props;
|
42
42
|
|
43
43
|
const {
|
44
|
-
activeStyle,
|
45
44
|
filteredOptions,
|
46
45
|
filterItem,
|
47
46
|
focusedOptionIndex,
|
@@ -60,6 +59,7 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
60
59
|
? selected.some((item) => item.label === option?.label)
|
61
60
|
: (selected as GenericObject)?.label === option?.label;
|
62
61
|
|
62
|
+
|
63
63
|
if (!isItemMatchingFilter(option) || (multiSelect && isSelected)) {
|
64
64
|
return null;
|
65
65
|
}
|
@@ -70,14 +70,6 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
70
70
|
|
71
71
|
const selectedClass = isSelected ? "selected" : "list";
|
72
72
|
|
73
|
-
|
74
|
-
const bgTokenClass = activeStyle?.backgroundColor
|
75
|
-
? `bg-${activeStyle.backgroundColor}`
|
76
|
-
: "";
|
77
|
-
const fontTokenClass = activeStyle?.fontColor
|
78
|
-
? `font-${activeStyle.fontColor}`
|
79
|
-
: "";
|
80
|
-
|
81
73
|
const ariaProps = buildAriaProps(aria);
|
82
74
|
const dataProps = buildDataProps(data);
|
83
75
|
const htmlProps = buildHtmlProps(htmlOptions);
|
@@ -87,8 +79,6 @@ const DropdownOption = (props: DropdownOptionProps) => {
|
|
87
79
|
selectedClass,
|
88
80
|
focusedClass,
|
89
81
|
),
|
90
|
-
bgTokenClass,
|
91
|
-
fontTokenClass,
|
92
82
|
globalProps(props),
|
93
83
|
className
|
94
84
|
);
|
@@ -1,36 +1,19 @@
|
|
1
1
|
import React from 'react'
|
2
|
-
import
|
3
|
-
import Highcharts from "highcharts"
|
4
|
-
import HighchartsReact from "highcharts-react-official"
|
5
|
-
import HighchartsMore from "highcharts/highcharts-more"
|
6
|
-
import SolidGauge from "highcharts/modules/solid-gauge"
|
7
|
-
import colors from '../../tokens/exports/_colors.module.scss'
|
2
|
+
import Gauge from '../../pb_gauge/_gauge'
|
8
3
|
|
9
|
-
|
10
|
-
|
4
|
+
const data = [
|
5
|
+
{ name: 'Name', value: 67 },
|
6
|
+
]
|
11
7
|
|
12
|
-
const
|
8
|
+
const GaugeColors = (props) => (
|
9
|
+
<div>
|
10
|
+
<Gauge
|
11
|
+
chartData={data}
|
12
|
+
id="gauge-colors"
|
13
|
+
{...props}
|
14
|
+
colors={['data-7']}
|
15
|
+
/>
|
16
|
+
</div>
|
17
|
+
)
|
13
18
|
|
14
|
-
|
15
|
-
series: [{ data: data }],
|
16
|
-
plotOptions: {
|
17
|
-
solidgauge: {
|
18
|
-
borderColor: colors.data_7,
|
19
|
-
}
|
20
|
-
},
|
21
|
-
};
|
22
|
-
|
23
|
-
const GaugeColors = () => {
|
24
|
-
const options = Highcharts.merge({}, gaugeTheme, baseOptions);
|
25
|
-
|
26
|
-
return (
|
27
|
-
<div>
|
28
|
-
<HighchartsReact
|
29
|
-
highcharts={Highcharts}
|
30
|
-
options={options}
|
31
|
-
/>
|
32
|
-
</div>
|
33
|
-
);
|
34
|
-
};
|
35
|
-
|
36
|
-
export default GaugeColors;
|
19
|
+
export default GaugeColors
|
@@ -2,44 +2,14 @@ import React from "react";
|
|
2
2
|
|
3
3
|
import Flex from '../../pb_flex/_flex'
|
4
4
|
import FlexItem from '../../pb_flex/_flex_item'
|
5
|
+
import Gauge from '../../pb_gauge/_gauge'
|
5
6
|
import Card from '../../pb_card/_card'
|
6
7
|
import Caption from '../../pb_caption/_caption'
|
7
8
|
import Body from '../../pb_body/_body'
|
8
9
|
import SectionSeparator from '../../pb_section_separator/_section_separator'
|
9
10
|
import Title from '../../pb_title/_title'
|
10
|
-
import gaugeTheme from '../gaugeTheme'
|
11
|
-
import Highcharts from "highcharts"
|
12
|
-
import HighchartsReact from "highcharts-react-official"
|
13
|
-
import HighchartsMore from "highcharts/highcharts-more"
|
14
|
-
import SolidGauge from "highcharts/modules/solid-gauge"
|
15
|
-
import colors from '../../tokens/exports/_colors.module.scss'
|
16
|
-
import typography from '../../tokens/exports/_typography.module.scss'
|
17
11
|
|
18
|
-
|
19
|
-
SolidGauge(Highcharts);
|
20
|
-
|
21
|
-
const data = [{ name: "Name", y: 10 }];
|
22
|
-
|
23
|
-
const baseOptions = {
|
24
|
-
series: [{ data: data }],
|
25
|
-
chart: {
|
26
|
-
height: "150",
|
27
|
-
},
|
28
|
-
plotOptions: {
|
29
|
-
series: {
|
30
|
-
animation: false,
|
31
|
-
},
|
32
|
-
solidgauge: {
|
33
|
-
dataLabels: {
|
34
|
-
format:
|
35
|
-
`<span class="fix">{y:,f}</span>` +
|
36
|
-
`<span style="fill: ${colors.text_lt_light}; font-size: ${typography.text_larger};">%</span>`,
|
37
|
-
},
|
38
|
-
},
|
39
|
-
},
|
40
|
-
};
|
41
|
-
|
42
|
-
const options = Highcharts.merge({}, gaugeTheme, baseOptions);
|
12
|
+
const data = [{ name: "Name", value: 10 }];
|
43
13
|
|
44
14
|
const GaugeComplex = (props) => (
|
45
15
|
<Flex
|
@@ -130,9 +100,13 @@ const GaugeComplex = (props) => (
|
|
130
100
|
shrink
|
131
101
|
{...props}
|
132
102
|
>
|
133
|
-
<
|
134
|
-
|
135
|
-
|
103
|
+
<Gauge
|
104
|
+
chartData={data}
|
105
|
+
disableAnimation
|
106
|
+
height="150"
|
107
|
+
id="gauge-complex"
|
108
|
+
suffix="%"
|
109
|
+
{...props}
|
136
110
|
/>
|
137
111
|
</FlexItem>
|
138
112
|
</Flex>
|
@@ -1,30 +1,18 @@
|
|
1
1
|
import React from 'react'
|
2
|
-
import
|
3
|
-
import Highcharts from "highcharts"
|
4
|
-
import HighchartsReact from "highcharts-react-official"
|
5
|
-
import HighchartsMore from "highcharts/highcharts-more"
|
6
|
-
import SolidGauge from "highcharts/modules/solid-gauge"
|
2
|
+
import Gauge from '../../pb_gauge/_gauge'
|
7
3
|
|
8
|
-
|
9
|
-
|
4
|
+
const data = [
|
5
|
+
{ name: 'Name', value: 45 },
|
6
|
+
]
|
10
7
|
|
11
|
-
const
|
8
|
+
const GaugeDefault = (props) => (
|
9
|
+
<div>
|
10
|
+
<Gauge
|
11
|
+
chartData={data}
|
12
|
+
id="gauge-default"
|
13
|
+
{...props}
|
14
|
+
/>
|
15
|
+
</div>
|
16
|
+
)
|
12
17
|
|
13
|
-
|
14
|
-
series: [{ data: data }],
|
15
|
-
};
|
16
|
-
|
17
|
-
const GaugeDefault = () => {
|
18
|
-
const options = Highcharts.merge({}, gaugeTheme, baseOptions);
|
19
|
-
|
20
|
-
return (
|
21
|
-
<div>
|
22
|
-
<HighchartsReact
|
23
|
-
highcharts={Highcharts}
|
24
|
-
options={options}
|
25
|
-
/>
|
26
|
-
</div>
|
27
|
-
);
|
28
|
-
};
|
29
|
-
|
30
|
-
export default GaugeDefault;
|
18
|
+
export default GaugeDefault
|