playbook_ui 14.23.0.pre.alpha.PLAY2121enableexpandedfield9266 → 14.23.0.pre.alpha.PLAY2138advtableselectablerowsindeterminatecheckboxes9287

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +1 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.html.erb +1 -1
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.html.erb +1 -1
  5. data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +4 -11
  6. data/app/pb_kits/playbook/pb_advanced_table/index.js +103 -124
  7. data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +5 -4
  8. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +10 -4
  9. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +21 -4
  10. data/app/pb_kits/playbook/pb_checkbox/index.js +220 -30
  11. data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +9 -18
  12. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +1 -3
  13. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -1
  14. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +0 -3
  15. data/dist/chunks/{_line_graph-BiyE0S8z.js → _line_graph-BfCo79KE.js} +1 -1
  16. data/dist/chunks/{_typeahead-DLOArcQt.js → _typeahead-Db4YQA5c.js} +1 -1
  17. data/dist/chunks/{_weekday_stacked-Cn4h5RuU.js → _weekday_stacked-9aguRqOv.js} +1 -1
  18. data/dist/chunks/vendor.js +1 -1
  19. data/dist/playbook-doc.js +1 -1
  20. data/dist/playbook-rails-react-bindings.js +1 -1
  21. data/dist/playbook-rails.js +1 -1
  22. data/lib/playbook/version.rb +1 -1
  23. metadata +5 -8
  24. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.html.erb +0 -75
  25. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.jsx +0 -94
  26. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.md +0 -3
@@ -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 childCheckboxes = document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);
13
+ const directChildCheckboxes = document.querySelectorAll(`[data-pb-checkbox-indeterminate-parent="${this.element.id}"] input[type="checkbox"]`);
14
14
 
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;
20
-
21
- // Set the main checkbox states
22
- mainCheckbox.indeterminate = indeterminate;
23
- mainCheckbox.checked = checkedCount > 0;
24
-
25
- // Determine the main checkbox label based on the number of checked checkboxes
26
- const checkAllLabel = mainCheckboxWrapper.dataset.pbCheckboxIndeterminateMainLabelCheck ?? 'Check All'
27
- const uncheckAllLabel = mainCheckboxWrapper.dataset.pbCheckboxIndeterminateMainLabelUncheck ?? 'Uncheck All'
28
- const text = checkedCount === 0 ? checkAllLabel : uncheckAllLabel;
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
- // Determine the icon class to add and remove based on the number of checked checkboxes
31
- const iconClassToAdd = checkedCount === 0 ? 'pb_checkbox_checkmark' : 'pb_checkbox_indeterminate';
32
- const iconClassToRemove = checkedCount === 0 ? 'pb_checkbox_indeterminate' : 'pb_checkbox_checkmark';
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
- // Update main checkbox label
35
- mainCheckboxWrapper.getElementsByClassName('pb_body_kit')[0].textContent = text;
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
- // Add and remove the icon class to the main checkbox wrapper
38
- mainCheckboxWrapper.querySelector('[data-pb-checkbox-icon-span]').classList.add(iconClassToAdd);
39
- mainCheckboxWrapper.querySelector('[data-pb-checkbox-icon-span]').classList.remove(iconClassToRemove);
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
- // Toggle the visibility of the checkbox icon based on the indeterminate state
42
- mainCheckboxWrapper.getElementsByClassName("indeterminate_icon")[0].classList.toggle('hidden', !indeterminate);
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
- // Set indeterminate icon on main checkbox if initial children checkboxes are checked
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
- this.element.querySelector('input').addEventListener('change', function() {
50
- childCheckboxes.forEach(cb => cb.checked = this.checked);
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
- childCheckboxes.forEach(cb => {
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,8 +143,7 @@ export const recursiveCheckParent = (
143
143
 
144
144
  export const getExpandedItems = (
145
145
  treeData: { [key: string]: string }[],
146
- selectedIds: string[],
147
- showCheckedChildren = true
146
+ selectedIds: string[]
148
147
  ): any[] => {
149
148
  const expandedItems: any[] = [];
150
149
 
@@ -153,27 +152,19 @@ export const getExpandedItems = (
153
152
  const item = items[i];
154
153
  const itemAncestors = [...ancestors, item];
155
154
 
156
- // Always honor explicit expanded: true
157
155
  if (item.expanded) {
158
156
  expandedItems.push(item.id);
159
157
  }
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
- }
158
+ if (selectedIds && selectedIds.length && selectedIds.includes(item.id)) {
159
+ expandedItems.push(...itemAncestors.map((ancestor) => ancestor.id));
174
160
  }
175
-
176
161
  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
+ }
177
168
  traverse(item.children, itemAncestors);
178
169
  }
179
170
  }
@@ -47,7 +47,6 @@ type MultiLevelSelectProps = {
47
47
  name?: string
48
48
  required?: boolean
49
49
  returnAllSelected?: boolean
50
- showCheckedChildren?: boolean
51
50
  treeData?: { [key: string]: string; }[] | any
52
51
  onChange?: (event: { target: { name?: string; value: any } }) => void
53
52
  onSelect?: (prop: { [key: string]: any }) => void
@@ -72,7 +71,6 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
72
71
  label,
73
72
  required = false,
74
73
  returnAllSelected = false,
75
- showCheckedChildren = true,
76
74
  treeData,
77
75
  onChange = () => null,
78
76
  onSelect = () => null,
@@ -106,7 +104,7 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
106
104
  // State for default return
107
105
  const [defaultReturn, setDefaultReturn] = useState([]);
108
106
  // Get expanded items from treeData
109
- const initialExpandedItems = getExpandedItems(treeData, selectedIds, showCheckedChildren);
107
+ const initialExpandedItems = getExpandedItems(treeData, selectedIds);
110
108
  // Initialize state with expanded items
111
109
  const [expanded, setExpanded] = useState(initialExpandedItems);
112
110
 
@@ -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,8 +32,6 @@ 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
37
35
 
38
36
  def classname
39
37
  generate_classname("pb_multi_level_select")
@@ -56,7 +54,6 @@ module Playbook
56
54
  variant: variant,
57
55
  pillColor: pill_color,
58
56
  wrapped: wrapped,
59
- showCheckedChildren: show_checked_children,
60
57
  }
61
58
  end
62
59
  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-DLOArcQt.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-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};