playbook_ui 14.24.0.pre.rc.5 → 14.24.0.pre.rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +24 -25
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +11 -11
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +5 -2
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +25 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +4 -1
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +34 -0
- 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_sort_per_column.jsx +55 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column.md +6 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column_for_multi_column.jsx +80 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_per_column_for_multi_column.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +4 -11
- data/app/pb_kits/playbook/pb_advanced_table/index.js +108 -125
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +5 -4
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +10 -4
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +21 -4
- data/app/pb_kits/playbook/pb_checkbox/index.js +220 -30
- data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +18 -9
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +3 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.html.erb +75 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.jsx +94 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.md +3 -0
- 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 +3 -0
- data/dist/chunks/{_line_graph-BfCo79KE.js → _line_graph-D7DgMqnT.js} +1 -1
- data/dist/chunks/{_typeahead-Db4YQA5c.js → _typeahead-BzYZCpJO.js} +2 -2
- data/dist/chunks/{_weekday_stacked-9aguRqOv.js → _weekday_stacked-CCn-qLh_.js} +2 -2
- data/dist/chunks/{lib-DnQyMxO1.js → lib-CY5ZPzic.js} +2 -2
- data/dist/chunks/{pb_form_validation-kl-4Jv4t.js → pb_form_validation-D3b0JKHH.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +14 -7
@@ -10,49 +10,239 @@ 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 directChildCheckboxes = document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
const
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
15
|
+
// Helper function to get all descendant checkboxes
|
16
|
+
const getAllDescendantCheckboxes = () => {
|
17
|
+
const descendants = [];
|
18
|
+
const queue = [...directChildCheckboxes];
|
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
|
+
};
|
29
43
|
|
30
|
-
|
31
|
-
|
32
|
-
const
|
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;
|
48
|
+
|
49
|
+
return {
|
50
|
+
allChecked: checkedCount === totalCount,
|
51
|
+
noneChecked: checkedCount === 0,
|
52
|
+
indeterminate: !(checkedCount === totalCount || checkedCount === 0),
|
53
|
+
checkedCount,
|
54
|
+
totalCount
|
55
|
+
};
|
56
|
+
};
|
33
57
|
|
34
|
-
|
35
|
-
|
58
|
+
// Helper function to update checkbox visual state
|
59
|
+
const updateCheckboxVisualState = (checkbox, isIndeterminate, isChecked) => {
|
60
|
+
checkbox.indeterminate = isIndeterminate;
|
61
|
+
checkbox.checked = isChecked;
|
62
|
+
};
|
63
|
+
|
64
|
+
// Helper function to update checkbox label and icons
|
65
|
+
const updateCheckboxLabelAndIcons = (wrapper, isIndeterminate, checkedCount) => {
|
66
|
+
const checkAllLabel = wrapper.dataset.pbCheckboxIndeterminateMainLabelCheck ?? 'Check All';
|
67
|
+
const uncheckAllLabel = wrapper.dataset.pbCheckboxIndeterminateMainLabelUncheck ?? 'Uncheck All';
|
68
|
+
const text = checkedCount === 0 ? checkAllLabel : uncheckAllLabel;
|
69
|
+
|
70
|
+
// Update label
|
71
|
+
const bodyKitElement = wrapper.getElementsByClassName('pb_body_kit')[0];
|
72
|
+
if (bodyKitElement) {
|
73
|
+
bodyKitElement.textContent = text;
|
74
|
+
}
|
75
|
+
|
76
|
+
// Update icons
|
77
|
+
const iconSpan = wrapper.querySelector('[data-pb-checkbox-icon-span]');
|
78
|
+
if (iconSpan) {
|
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
|
+
}
|
36
84
|
|
37
|
-
//
|
38
|
-
|
39
|
-
|
85
|
+
// Toggle icon visibility
|
86
|
+
const indeterminateIcon = wrapper.getElementsByClassName("indeterminate_icon")[0];
|
87
|
+
const checkIcon = wrapper.getElementsByClassName("check_icon")[0];
|
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);
|
40
101
|
|
41
|
-
|
42
|
-
mainCheckboxWrapper.
|
43
|
-
mainCheckboxWrapper.getElementsByClassName("check_icon")[0].classList.toggle('hidden', indeterminate);
|
102
|
+
updateCheckboxVisualState(mainCheckbox, state.indeterminate, state.allChecked);
|
103
|
+
updateCheckboxLabelAndIcons(mainCheckboxWrapper, state.indeterminate, state.checkedCount);
|
44
104
|
};
|
45
105
|
|
46
|
-
//
|
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
|
+
}
|
122
|
+
};
|
123
|
+
|
124
|
+
// Function to update non-main checkboxes when their children change
|
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
|
47
159
|
updateMainCheckbox();
|
48
160
|
|
49
|
-
|
50
|
-
|
161
|
+
// Handle main checkbox change - propagate to all descendants
|
162
|
+
mainCheckbox.addEventListener('change', function() {
|
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
|
51
184
|
updateMainCheckbox();
|
185
|
+
setTimeout(() => {
|
186
|
+
updateParentCheckboxes();
|
187
|
+
}, 0);
|
188
|
+
|
189
|
+
// Also trigger updates on all main checkboxes to ensure proper state propagation
|
190
|
+
triggerAllMainCheckboxUpdates();
|
52
191
|
});
|
53
192
|
|
54
|
-
|
193
|
+
// Handle child checkbox changes
|
194
|
+
directChildCheckboxes.forEach(cb => {
|
55
195
|
cb.addEventListener('change', updateMainCheckbox);
|
56
196
|
});
|
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();
|
57
247
|
}
|
58
248
|
}
|
@@ -143,7 +143,8 @@ export const recursiveCheckParent = (
|
|
143
143
|
|
144
144
|
export const getExpandedItems = (
|
145
145
|
treeData: { [key: string]: string }[],
|
146
|
-
selectedIds: string[]
|
146
|
+
selectedIds: string[],
|
147
|
+
showCheckedChildren = true
|
147
148
|
): any[] => {
|
148
149
|
const expandedItems: any[] = [];
|
149
150
|
|
@@ -152,19 +153,27 @@ export const getExpandedItems = (
|
|
152
153
|
const item = items[i];
|
153
154
|
const itemAncestors = [...ancestors, item];
|
154
155
|
|
156
|
+
// Always honor explicit expanded: true
|
155
157
|
if (item.expanded) {
|
156
158
|
expandedItems.push(item.id);
|
157
159
|
}
|
158
|
-
|
159
|
-
|
160
|
+
|
161
|
+
// Only expand based on selected items if showCheckedChildren is true
|
162
|
+
if (showCheckedChildren) {
|
163
|
+
if (selectedIds && selectedIds.length && selectedIds.includes(item.id)) {
|
164
|
+
expandedItems.push(...itemAncestors.map((ancestor: any) => ancestor.id));
|
165
|
+
}
|
166
|
+
if (Array.isArray(item.children)) {
|
167
|
+
const hasCheckedChildren = item.children.some(
|
168
|
+
(child: { [key: string]: string }) => child.checked
|
169
|
+
);
|
170
|
+
if (hasCheckedChildren) {
|
171
|
+
expandedItems.push(...itemAncestors.map((ancestor: any) => ancestor.id));
|
172
|
+
}
|
173
|
+
}
|
160
174
|
}
|
175
|
+
|
161
176
|
if (Array.isArray(item.children)) {
|
162
|
-
const hasCheckedChildren = item.children.some(
|
163
|
-
(child: { [key: string]: string }) => child.checked
|
164
|
-
);
|
165
|
-
if (hasCheckedChildren) {
|
166
|
-
expandedItems.push(...itemAncestors.map((ancestor) => ancestor.id));
|
167
|
-
}
|
168
177
|
traverse(item.children, itemAncestors);
|
169
178
|
}
|
170
179
|
}
|
@@ -47,6 +47,7 @@ type MultiLevelSelectProps = {
|
|
47
47
|
name?: string
|
48
48
|
required?: boolean
|
49
49
|
returnAllSelected?: boolean
|
50
|
+
showCheckedChildren?: boolean
|
50
51
|
treeData?: { [key: string]: string; }[] | any
|
51
52
|
onChange?: (event: { target: { name?: string; value: any } }) => void
|
52
53
|
onSelect?: (prop: { [key: string]: any }) => void
|
@@ -71,6 +72,7 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
71
72
|
label,
|
72
73
|
required = false,
|
73
74
|
returnAllSelected = false,
|
75
|
+
showCheckedChildren = true,
|
74
76
|
treeData,
|
75
77
|
onChange = () => null,
|
76
78
|
onSelect = () => null,
|
@@ -104,7 +106,7 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
|
|
104
106
|
// State for default return
|
105
107
|
const [defaultReturn, setDefaultReturn] = useState([]);
|
106
108
|
// Get expanded items from treeData
|
107
|
-
const initialExpandedItems = getExpandedItems(treeData, selectedIds);
|
109
|
+
const initialExpandedItems = getExpandedItems(treeData, selectedIds, showCheckedChildren);
|
108
110
|
// Initialize state with expanded items
|
109
111
|
const [expanded, setExpanded] = useState(initialExpandedItems);
|
110
112
|
|
@@ -0,0 +1,75 @@
|
|
1
|
+
<% treeData = [{
|
2
|
+
label: "Power Home Remodeling",
|
3
|
+
value: "powerHomeRemodeling",
|
4
|
+
id: "100",
|
5
|
+
expanded: true,
|
6
|
+
children: [
|
7
|
+
{
|
8
|
+
label: "People",
|
9
|
+
value: "people",
|
10
|
+
id: "101",
|
11
|
+
children: [
|
12
|
+
{
|
13
|
+
label: "Talent Acquisition",
|
14
|
+
value: "talentAcquisition",
|
15
|
+
id: "102",
|
16
|
+
},
|
17
|
+
{
|
18
|
+
label: "Business Affairs",
|
19
|
+
value: "businessAffairs",
|
20
|
+
id: "103",
|
21
|
+
children: [
|
22
|
+
{
|
23
|
+
label: "Initiatives",
|
24
|
+
value: "initiatives",
|
25
|
+
id: "104",
|
26
|
+
},
|
27
|
+
{
|
28
|
+
label: "Learning & Development",
|
29
|
+
value: "learningAndDevelopment",
|
30
|
+
id: "105",
|
31
|
+
},
|
32
|
+
],
|
33
|
+
},
|
34
|
+
{
|
35
|
+
label: "People Experience",
|
36
|
+
value: "peopleExperience",
|
37
|
+
id: "106",
|
38
|
+
},
|
39
|
+
],
|
40
|
+
},
|
41
|
+
{
|
42
|
+
label: "Contact Center",
|
43
|
+
value: "contactCenter",
|
44
|
+
id: "107",
|
45
|
+
children: [
|
46
|
+
{
|
47
|
+
label: "Appointment Management",
|
48
|
+
value: "appointmentManagement",
|
49
|
+
id: "108",
|
50
|
+
},
|
51
|
+
{
|
52
|
+
label: "Customer Service",
|
53
|
+
value: "customerService",
|
54
|
+
id: "109",
|
55
|
+
},
|
56
|
+
{
|
57
|
+
label: "Energy",
|
58
|
+
value: "energy",
|
59
|
+
id: "110",
|
60
|
+
},
|
61
|
+
],
|
62
|
+
},
|
63
|
+
],
|
64
|
+
}] %>
|
65
|
+
|
66
|
+
<% # Pre-selected node IDs to demonstrate the functionality %>
|
67
|
+
<% preSelectedIds = ["102", "104", "109"] %>
|
68
|
+
|
69
|
+
<%= pb_rails("multi_level_select", props: {
|
70
|
+
id: "multi-level-select-show-checked-children-rails",
|
71
|
+
name: "my_array",
|
72
|
+
tree_data: treeData,
|
73
|
+
selected_ids: preSelectedIds,
|
74
|
+
show_checked_children: false
|
75
|
+
}) %>
|
data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.jsx
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import MultiLevelSelect from "../_multi_level_select";
|
3
|
+
|
4
|
+
const treeData = [
|
5
|
+
{
|
6
|
+
label: "Power Home Remodeling",
|
7
|
+
value: "powerHomeRemodeling",
|
8
|
+
id: "powerhome1",
|
9
|
+
expanded: true,
|
10
|
+
children: [
|
11
|
+
{
|
12
|
+
label: "People",
|
13
|
+
value: "people",
|
14
|
+
id: "people1",
|
15
|
+
children: [
|
16
|
+
{
|
17
|
+
label: "Talent Acquisition",
|
18
|
+
value: "talentAcquisition",
|
19
|
+
id: "talent1",
|
20
|
+
},
|
21
|
+
{
|
22
|
+
label: "Business Affairs",
|
23
|
+
value: "businessAffairs",
|
24
|
+
id: "business1",
|
25
|
+
children: [
|
26
|
+
{
|
27
|
+
label: "Initiatives",
|
28
|
+
value: "initiatives",
|
29
|
+
id: "initiative1",
|
30
|
+
},
|
31
|
+
{
|
32
|
+
label: "Learning & Development",
|
33
|
+
value: "learningAndDevelopment",
|
34
|
+
id: "development1",
|
35
|
+
},
|
36
|
+
],
|
37
|
+
},
|
38
|
+
{
|
39
|
+
label: "People Experience",
|
40
|
+
value: "peopleExperience",
|
41
|
+
id: "experience1",
|
42
|
+
},
|
43
|
+
],
|
44
|
+
},
|
45
|
+
{
|
46
|
+
label: "Contact Center",
|
47
|
+
value: "contactCenter",
|
48
|
+
id: "contact1",
|
49
|
+
children: [
|
50
|
+
{
|
51
|
+
label: "Appointment Management",
|
52
|
+
value: "appointmentManagement",
|
53
|
+
id: "appointment1",
|
54
|
+
},
|
55
|
+
{
|
56
|
+
label: "Customer Service",
|
57
|
+
value: "customerService",
|
58
|
+
id: "customer1",
|
59
|
+
},
|
60
|
+
{
|
61
|
+
label: "Energy",
|
62
|
+
value: "energy",
|
63
|
+
id: "energy1",
|
64
|
+
},
|
65
|
+
],
|
66
|
+
},
|
67
|
+
],
|
68
|
+
},
|
69
|
+
];
|
70
|
+
|
71
|
+
// Pre-selected node IDs to demonstrate the functionality
|
72
|
+
const preSelectedIds = ["talent1", "initiative1", "customer1"];
|
73
|
+
|
74
|
+
const MultiLevelSelectShowCheckedChildren = (props) => {
|
75
|
+
return (
|
76
|
+
<div>
|
77
|
+
<MultiLevelSelect
|
78
|
+
id='multiselect-checked-children'
|
79
|
+
onSelect={(selectedNodes) =>
|
80
|
+
console.log(
|
81
|
+
"Selected Items",
|
82
|
+
selectedNodes
|
83
|
+
)
|
84
|
+
}
|
85
|
+
selectedIds={preSelectedIds}
|
86
|
+
showCheckedChildren={false}
|
87
|
+
treeData={treeData}
|
88
|
+
{...props}
|
89
|
+
/>
|
90
|
+
</div>
|
91
|
+
)
|
92
|
+
};
|
93
|
+
|
94
|
+
export default MultiLevelSelectShowCheckedChildren;
|
data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.md
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
If you wish to control the auto-expansion of nodes with selected descendants in your multi-level select, you can utilize `showCheckedChildren/show_checked_children`. This prop (set to 'true' by default) controls whether items will be expanded on first render. When set to true, a node with selected descendants will automatically render as expanded so the selected nodes are visible. If you do NOT wish for this to be the case, you can set this prop to false.
|
2
|
+
|
3
|
+
The prop will still honor any `expanded` attribute set up within your tree data.
|
@@ -13,4 +13,4 @@ export { default as MultiLevelSelectDisabledOptions } from './_multi_level_selec
|
|
13
13
|
export { default as MultiLevelSelectDisabledOptionsParent } from './_multi_level_select_disabled_options_parent.jsx'
|
14
14
|
export { default as MultiLevelSelectDisabledOptionsParentDefault } from './_multi_level_select_disabled_options_parent_default.jsx'
|
15
15
|
export { default as MultiLevelSelectDisabledOptionsDefault } from './_multi_level_select_disabled_options_default.jsx'
|
16
|
-
export { default as MultiLevelSelectLabel } from './_multi_level_select_label.jsx'
|
16
|
+
export { default as MultiLevelSelectLabel } from './_multi_level_select_label.jsx'
|
@@ -32,6 +32,8 @@ module Playbook
|
|
32
32
|
default: ""
|
33
33
|
prop :label, type: Playbook::Props::String,
|
34
34
|
default: ""
|
35
|
+
prop :show_checked_children, type: Playbook::Props::Boolean,
|
36
|
+
default: true
|
35
37
|
|
36
38
|
def classname
|
37
39
|
generate_classname("pb_multi_level_select")
|
@@ -54,6 +56,7 @@ module Playbook
|
|
54
56
|
variant: variant,
|
55
57
|
pillColor: pill_color,
|
56
58
|
wrapped: wrapped,
|
59
|
+
showCheckedChildren: show_checked_children,
|
57
60
|
}
|
58
61
|
end
|
59
62
|
end
|
@@ -1 +1 @@
|
|
1
|
-
import{jsx,Fragment,jsxs}from"react/jsx-runtime";import{useState,useEffect}from"react";import{b as buildAriaProps,c as buildDataProps,d as buildHtmlProps,H as HighchartsReact,e as Highcharts,f as classnames,g as globalProps,h as HighchartsMore,S as SolidGauge,i as buildCss}from"./_typeahead-Db4YQA5c.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-DnQyMxO1.js";const mapColors=array=>{const regex=/(data)\-[1-8]/;const newArray=array.map((item=>regex.test(item)?`${colors[`data_${item[item.length-1]}`]}`:item));return newArray};const BarGraph=({aria:aria={},data:data={},align:align="center",axisTitle:axisTitle,dark:dark=false,chartData:chartData,className:className="pb_bar_graph",colors:colors2,htmlOptions:htmlOptions={},customOptions:customOptions={},axisFormat:axisFormat,id:id,pointStart:pointStart,stacking:stacking,subTitle:subTitle,type:type="column",title:title="Title",xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,legend:legend=false,toggleLegendClick:toggleLegendClick=true,height:height,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:[{labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat&&axisFormat[0]?axisFormat[0].format:""},min:yAxisMin,max:yAxisMax,opposite:false,title:{text:Array.isArray(axisTitle)?axisTitle.length>0?axisTitle[0].name:null:axisTitle},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]}],xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{stacking:stacking,pointStart:pointStart,borderWidth:stacking?0:"",events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(Array.isArray(axisTitle)&&axisTitle.length>1&&axisTitle[1].name){staticOptions.yAxis.push({labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat[1].format},min:yAxisMin,max:yAxisMax,opposite:true,title:{text:axisTitle[1].name},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]})}if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const alignBlockElement=event=>{const itemToMove=document.querySelector(`#wrapper-circle-chart-${event.target.renderTo.id} .pb-circle-chart-block`);const chartContainer=document.querySelector(`#${event.target.renderTo.id}`);if(itemToMove!==null&&chartContainer!==null){itemToMove.style.height=`${event.target.chartHeight}px`;itemToMove.style.width=`${event.target.chartWidth}px`;if(chartContainer.firstChild!==null){chartContainer.firstChild.before(itemToMove)}}};const CircleChart=({align:align="center",aria:aria={},rounded:rounded=false,borderColor:borderColor=(rounded?null:""),borderWidth:borderWidth=(rounded?20:null),chartData:chartData,children:children,className:className,colors:colors2=[],customOptions:customOptions={},dark:dark=false,data:data={},dataLabelHtml:dataLabelHtml="<div>{point.name}</div>",dataLabels:dataLabels=false,height:height,htmlOptions:htmlOptions={},id:id,innerSize:innerSize="md",legend:legend=false,maxPointSize:maxPointSize=null,minPointSize:minPointSize=null,startAngle:startAngle=null,style:style="pie",title:title,tooltipHtml:tooltipHtml,useHtml:useHtml=false,zMin:zMin=null,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{headerFormat:null,pointFormat:tooltipHtml?tooltipHtml:'<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',useHTML:useHtml}});const innerSizes={sm:"35%",md:"50%",lg:"85%",none:"0%"};const innerSizeFormat=size=>innerSizes[size];const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={title:{text:title},chart:{height:height,type:style,events:{render:event=>alignBlockElement(event),redraw:event=>alignBlockElement(event)}},legend:{align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},plotOptions:{pie:{colors:colors2.length>0?mapColors(colors2):highchartsTheme.colors,dataLabels:{enabled:dataLabels,connectorShape:"straight",connectorWidth:3,format:dataLabelHtml},showInLegend:legend}},series:[{minPointSize:minPointSize,maxPointSize:maxPointSize,innerSize:borderWidth==20?"100%":innerSizeFormat(innerSize),data:formattedChartData,zMin:zMin,startAngle:startAngle,borderWidth:borderWidth,borderColor:borderColor}],credits:false};setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(Fragment,{children:children?jsxs("div",{id:`wrapper-circle-chart-${id}`,children:[jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options}),jsx("div",{className:"pb-circle-chart-block",children:children})]}):jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})})};const Gauge=({aria:aria={},chartData:chartData,customOptions:customOptions={},dark:dark=false,data:data={},disableAnimation:disableAnimation=false,fullCircle:fullCircle=false,height:height=null,htmlOptions:htmlOptions={},id:id,max:max=100,min:min=0,prefix:prefix="",showLabels:showLabels=false,style:style="solidgauge",suffix:suffix="",title:title="",tooltipHtml:tooltipHtml='<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',colors:colors$1=[],minorTickInterval:minorTickInterval=null,circumference:circumference=(fullCircle?[0,360]:[-100,100]),...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);SolidGauge(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{pointFormat:tooltipHtml,followPointer:true}});const css=buildCss({pb_gauge_kit:true});const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={chart:{events:{load(){setTimeout(this.reflow.bind(this),0)}},type:style,height:height},title:{text:title},yAxis:{min:min,max:max,lineWidth:0,tickWidth:0,minorTickInterval:minorTickInterval,tickAmount:2,tickPositions:[min,max],labels:{y:26,enabled:showLabels}},credits:false,series:[{data:formattedChartData}],pane:{center:["50%","50%"],size:"90%",startAngle:circumference[0],endAngle:circumference[1],background:{borderWidth:20,innerRadius:"90%",outerRadius:"90%",shape:"arc",className:"gauge-pane"}},colors:colors$1!==void 0&&colors$1.length>0?mapColors(colors$1):highchartsTheme.colors,plotOptions:{series:{animation:!disableAnimation},solidgauge:{borderColor:colors$1!==void 0&&colors$1.length===1?mapColors(colors$1).join():highchartsTheme.colors[0],borderWidth:20,radius:90,innerRadius:"90%",dataLabels:{borderWidth:0,color:colors.text_lt_default,enabled:true,format:`<span class="prefix${dark?" dark":""}">${prefix}</span><span class="fix${dark?" dark":""}">{y:,f}</span><span class="suffix${dark?" dark":""}">${suffix}</span>`,style:{fontFamily:typography.font_family_base,fontWeight:typography.regular,fontSize:typography.heading_2},y:-26}}}};setOptions(merge(staticOptions,customOptions));if(document.querySelector(".prefix")){document.querySelectorAll(".prefix").forEach((prefix2=>{prefix2.setAttribute("y","28")}));document.querySelectorAll(".fix").forEach((fix=>fix.setAttribute("y","38")))}}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(css,globalProps(props)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const LineGraph=({aria:aria={},data:data={},align:align="center",className:className="pb_bar_graph",customOptions:customOptions={},dark:dark=false,gradient:gradient=false,type:type="line",htmlOptions:htmlOptions={},id:id,legend:legend=false,toggleLegendClick:toggleLegendClick=true,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,axisTitle:axisTitle,xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,chartData:chartData,pointStart:pointStart,subTitle:subTitle,title:title,height:height,colors:colors2=[],...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:{min:yAxisMin,max:yAxisMax,title:{text:axisTitle}},xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{pointStart:pointStart,events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};export{BarGraph as B,CircleChart as C,Gauge as G,LineGraph as L};
|
1
|
+
import{jsx,Fragment,jsxs}from"react/jsx-runtime";import{useState,useEffect}from"react";import{b as buildAriaProps,c as buildDataProps,d as buildHtmlProps,H as HighchartsReact,e as Highcharts,f as classnames,g as globalProps,h as HighchartsMore,S as SolidGauge,i as buildCss}from"./_typeahead-BzYZCpJO.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-CY5ZPzic.js";const mapColors=array=>{const regex=/(data)\-[1-8]/;const newArray=array.map((item=>regex.test(item)?`${colors[`data_${item[item.length-1]}`]}`:item));return newArray};const BarGraph=({aria:aria={},data:data={},align:align="center",axisTitle:axisTitle,dark:dark=false,chartData:chartData,className:className="pb_bar_graph",colors:colors2,htmlOptions:htmlOptions={},customOptions:customOptions={},axisFormat:axisFormat,id:id,pointStart:pointStart,stacking:stacking,subTitle:subTitle,type:type="column",title:title="Title",xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,legend:legend=false,toggleLegendClick:toggleLegendClick=true,height:height,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:[{labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat&&axisFormat[0]?axisFormat[0].format:""},min:yAxisMin,max:yAxisMax,opposite:false,title:{text:Array.isArray(axisTitle)?axisTitle.length>0?axisTitle[0].name:null:axisTitle},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]}],xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{stacking:stacking,pointStart:pointStart,borderWidth:stacking?0:"",events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(Array.isArray(axisTitle)&&axisTitle.length>1&&axisTitle[1].name){staticOptions.yAxis.push({labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat[1].format},min:yAxisMin,max:yAxisMax,opposite:true,title:{text:axisTitle[1].name},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]})}if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const alignBlockElement=event=>{const itemToMove=document.querySelector(`#wrapper-circle-chart-${event.target.renderTo.id} .pb-circle-chart-block`);const chartContainer=document.querySelector(`#${event.target.renderTo.id}`);if(itemToMove!==null&&chartContainer!==null){itemToMove.style.height=`${event.target.chartHeight}px`;itemToMove.style.width=`${event.target.chartWidth}px`;if(chartContainer.firstChild!==null){chartContainer.firstChild.before(itemToMove)}}};const CircleChart=({align:align="center",aria:aria={},rounded:rounded=false,borderColor:borderColor=(rounded?null:""),borderWidth:borderWidth=(rounded?20:null),chartData:chartData,children:children,className:className,colors:colors2=[],customOptions:customOptions={},dark:dark=false,data:data={},dataLabelHtml:dataLabelHtml="<div>{point.name}</div>",dataLabels:dataLabels=false,height:height,htmlOptions:htmlOptions={},id:id,innerSize:innerSize="md",legend:legend=false,maxPointSize:maxPointSize=null,minPointSize:minPointSize=null,startAngle:startAngle=null,style:style="pie",title:title,tooltipHtml:tooltipHtml,useHtml:useHtml=false,zMin:zMin=null,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{headerFormat:null,pointFormat:tooltipHtml?tooltipHtml:'<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',useHTML:useHtml}});const innerSizes={sm:"35%",md:"50%",lg:"85%",none:"0%"};const innerSizeFormat=size=>innerSizes[size];const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={title:{text:title},chart:{height:height,type:style,events:{render:event=>alignBlockElement(event),redraw:event=>alignBlockElement(event)}},legend:{align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},plotOptions:{pie:{colors:colors2.length>0?mapColors(colors2):highchartsTheme.colors,dataLabels:{enabled:dataLabels,connectorShape:"straight",connectorWidth:3,format:dataLabelHtml},showInLegend:legend}},series:[{minPointSize:minPointSize,maxPointSize:maxPointSize,innerSize:borderWidth==20?"100%":innerSizeFormat(innerSize),data:formattedChartData,zMin:zMin,startAngle:startAngle,borderWidth:borderWidth,borderColor:borderColor}],credits:false};setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(Fragment,{children:children?jsxs("div",{id:`wrapper-circle-chart-${id}`,children:[jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options}),jsx("div",{className:"pb-circle-chart-block",children:children})]}):jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})})};const Gauge=({aria:aria={},chartData:chartData,customOptions:customOptions={},dark:dark=false,data:data={},disableAnimation:disableAnimation=false,fullCircle:fullCircle=false,height:height=null,htmlOptions:htmlOptions={},id:id,max:max=100,min:min=0,prefix:prefix="",showLabels:showLabels=false,style:style="solidgauge",suffix:suffix="",title:title="",tooltipHtml:tooltipHtml='<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',colors:colors$1=[],minorTickInterval:minorTickInterval=null,circumference:circumference=(fullCircle?[0,360]:[-100,100]),...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);SolidGauge(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{pointFormat:tooltipHtml,followPointer:true}});const css=buildCss({pb_gauge_kit:true});const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={chart:{events:{load(){setTimeout(this.reflow.bind(this),0)}},type:style,height:height},title:{text:title},yAxis:{min:min,max:max,lineWidth:0,tickWidth:0,minorTickInterval:minorTickInterval,tickAmount:2,tickPositions:[min,max],labels:{y:26,enabled:showLabels}},credits:false,series:[{data:formattedChartData}],pane:{center:["50%","50%"],size:"90%",startAngle:circumference[0],endAngle:circumference[1],background:{borderWidth:20,innerRadius:"90%",outerRadius:"90%",shape:"arc",className:"gauge-pane"}},colors:colors$1!==void 0&&colors$1.length>0?mapColors(colors$1):highchartsTheme.colors,plotOptions:{series:{animation:!disableAnimation},solidgauge:{borderColor:colors$1!==void 0&&colors$1.length===1?mapColors(colors$1).join():highchartsTheme.colors[0],borderWidth:20,radius:90,innerRadius:"90%",dataLabels:{borderWidth:0,color:colors.text_lt_default,enabled:true,format:`<span class="prefix${dark?" dark":""}">${prefix}</span><span class="fix${dark?" dark":""}">{y:,f}</span><span class="suffix${dark?" dark":""}">${suffix}</span>`,style:{fontFamily:typography.font_family_base,fontWeight:typography.regular,fontSize:typography.heading_2},y:-26}}}};setOptions(merge(staticOptions,customOptions));if(document.querySelector(".prefix")){document.querySelectorAll(".prefix").forEach((prefix2=>{prefix2.setAttribute("y","28")}));document.querySelectorAll(".fix").forEach((fix=>fix.setAttribute("y","38")))}}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(css,globalProps(props)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const LineGraph=({aria:aria={},data:data={},align:align="center",className:className="pb_bar_graph",customOptions:customOptions={},dark:dark=false,gradient:gradient=false,type:type="line",htmlOptions:htmlOptions={},id:id,legend:legend=false,toggleLegendClick:toggleLegendClick=true,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,axisTitle:axisTitle,xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,chartData:chartData,pointStart:pointStart,subTitle:subTitle,title:title,height:height,colors:colors2=[],...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:{min:yAxisMin,max:yAxisMax,title:{text:axisTitle}},xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{pointStart:pointStart,events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};export{BarGraph as B,CircleChart as C,Gauge as G,LineGraph as L};
|