playbook_ui 15.3.0.pre.alpha.PLAY260211784 → 15.3.0.pre.alpha.play259311731

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9528e20265ec599841465a4f6c953fb34de67ad0dba9c819fb04fe534375b6ae
4
- data.tar.gz: 1cfcdf630ea9270851715627df63def4e289a6686f3ded140b85fca3a002a444
3
+ metadata.gz: ffcc9cd701358929b90b6a4de99034138c4f04b90909aaff546fa9a4c8c1c73c
4
+ data.tar.gz: 6728bf7227bdd1440d3b415dd561a518793fdc02ef54cda3b212f8526a237811
5
5
  SHA512:
6
- metadata.gz: 395b7638271c16f3d2c002568922a547a3a4aa00ffbf16031ff1db80974778e7c4808331d0fdf4661e08495a062ad17ab3b4927839b2181117880cd1559261fa
7
- data.tar.gz: b7db478765b4067420071751e676a333704f1d418d72b903fb65347e47c39c0fba1087ab3aea8fcdd9a89a3b1c853c766c55db75949af4fa0cd8c8d868618efc
6
+ metadata.gz: 0e8fa30daf530ffa258a9a131c7eacdf6d401f5b64b47b7396752adb348a15e6612505d5c4caf65fa189fcd67eae631d6e23f21ea2111861bd696314ce1db181
7
+ data.tar.gz: 85a6aebcf6d61d4b75c0c556f580b1a68e17e46d9b57519636d3ca636e485aec1b0e15c7652886db25cd6aaa747dd35be6f44e25bade49e059b864a255540e54
@@ -250,21 +250,6 @@ export function useTableState({
250
250
  }
251
251
  }, [pagination, inlineRowLoading, paginationProps?.pageIndex, paginationProps?.pageSize]);
252
252
 
253
- // Call the callback with the new page index when localPagination.pageIndex changes (with inlineRowLoading)
254
- useEffect(() => {
255
- if (pagination && inlineRowLoading && paginationProps?.onPageChange) {
256
- paginationProps.onPageChange(localPagination.pageIndex);
257
- }
258
- }, [localPagination.pageIndex, pagination, inlineRowLoading, paginationProps]);
259
-
260
- // Call the callback with the new page index when localPagination.pageIndex changes (without inlineRowLoading)
261
- useEffect(() => {
262
- if (pagination && !inlineRowLoading && paginationProps?.onPageChange) {
263
- const currentPageIndex = table.getState().pagination.pageIndex;
264
- paginationProps.onPageChange(currentPageIndex);
265
- }
266
- }, [table.getState().pagination.pageIndex, pagination, inlineRowLoading, paginationProps]);
267
-
268
253
  // Check if table has any sub-rows
269
254
  const hasAnySubRows = table.getRowModel().rows.some(row => row.subRows && row.subRows.length > 0);
270
255
  const selectedRowsLength = Object.keys(table.getState().rowSelection).length;
@@ -38,10 +38,7 @@ const AdvancedTablePaginationWithProps = (props) => {
38
38
  const paginationProps = {
39
39
  pageIndex: 1,
40
40
  pageSize: 10,
41
- range: 2,
42
- onPageChange: (pageIndex) => {
43
- console.log('Current page index:', pageIndex);
44
- }
41
+ range: 2
45
42
  }
46
43
 
47
44
  return (
@@ -1,6 +1,5 @@
1
- `paginationProps` is an optional prop that can be used to further customize pagination for the AdvancedTable. This prop is an object with the following optional items:
1
+ `paginationProps` is an optional prop that can be used to further customize pagination for the AdvancedTable. This prop is an object with 2 optional items:
2
2
 
3
3
  - `pageIndex`: An optional prop to set which page is set to open on initial load. Default is '0'
4
4
  - `pageSize`: An optional prop to set total number of rows for each page before the Table paginates. Default is '20'
5
- - `range`: The range prop determines how many pages to display in the Pagination component. Regardless of this value, the first two and last two pages are always visible to facilitate navigation to the beginning and end of the pagination. If these always-visible pages fall within the specified range, they are included in the display. If they fall outside the range, the pagination will show additional pages up to the number defined by the range prop. See [here for more details](https://playbook.powerapp.cloud/kits/pagination/react#default). Default is set to '5'
6
- - `onPageChange`: A callback function that gives to access to the current page index.
5
+ - `range`: The range prop determines how many pages to display in the Pagination component. Regardless of this value, the first two and last two pages are always visible to facilitate navigation to the beginning and end of the pagination. If these always-visible pages fall within the specified range, they are included in the display. If they fall outside the range, the pagination will show additional pages up to the number defined by the range prop. See [here for more details](https://playbook.powerapp.cloud/kits/pagination/react#default). Default is set to '5'
@@ -171,4 +171,45 @@ test('typeahead with defaultValue with focus behavior', async () => {
171
171
  expect(focusedOption).toBeInTheDocument()
172
172
  expect(focusedOption).toHaveTextContent('Red')
173
173
  })
174
+ })
175
+
176
+ test('typeahead with grouped options and defaultValue focus behavior', async () => {
177
+ const groupedOptions = [
178
+ {
179
+ label: "Warm Colors",
180
+ options: [
181
+ { label: "Red", value: "#FF0000" },
182
+ { label: "Orange", value: "#FFA500" },
183
+ { label: "Yellow", value: "#FFFF00" }
184
+ ]
185
+ },
186
+ {
187
+ label: "Cool Colors",
188
+ options: [
189
+ { label: "Blue", value: "#0000FF" },
190
+ { label: "Teal", value: "#008080" },
191
+ { label: "Cyan", value: "#00FFFF" }
192
+ ]
193
+ },
194
+ {
195
+ label: "Fun Shades",
196
+ options: [
197
+ { label: "Pink", value: "#FFC0CB" },
198
+ { label: "Magenta", value: "#FF00FF" },
199
+ { label: "Purple", value: "#800080" }
200
+ ]
201
+ }
202
+ ]
203
+
204
+ render(
205
+ <Typeahead
206
+ data={{ testid: 'grouped-options-focus-test' }}
207
+ defaultValue={[{ label: "Pink", value: "#FFC0CB" }]}
208
+ options={groupedOptions}
209
+ />
210
+ )
211
+
212
+ const kit = screen.getByTestId('grouped-options-focus-test')
213
+ const inputDiv = kit.querySelector(".typeahead-kit-select__single-value")
214
+ expect(inputDiv).toHaveTextContent("Pink")
174
215
  })
@@ -144,6 +144,18 @@ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
144
144
  // Create a ref to access React Select instance
145
145
  const selectRef = useRef<any>(null)
146
146
 
147
+ // Helper function to flatten grouped options if custom groups are used
148
+ const flattenOptions = (options: any[]): any[] => {
149
+ if (!options) return []
150
+
151
+ return options.reduce((acc, option) => {
152
+ if (option.options && Array.isArray(option.options)) {
153
+ return [...acc, ...option.options]
154
+ }
155
+ return [...acc, option]
156
+ }, [])
157
+ }
158
+
147
159
  // Configure focus on selected option using React Select's API
148
160
  const handleMenuOpen = () => {
149
161
  setTimeout(() => {
@@ -159,17 +171,18 @@ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
159
171
 
160
172
  const options = props.options
161
173
  if (options) {
162
- // Find the index of the current value
163
- const focusedIndex = options.findIndex((option: any) => {
174
+ // Flatten grouped options to find the matching option and find matching option
175
+ const flatOptions = flattenOptions(options)
176
+
177
+ const targetOption = flatOptions.find((option: any) => {
164
178
  const optionValue = props.getOptionValue ? props.getOptionValue(option) : option.value
165
179
  const currentOptionValue = props.getOptionValue ? props.getOptionValue(currentValue) : currentValue.value
166
180
  return optionValue === currentOptionValue
167
181
  })
168
182
 
169
- if (focusedIndex >= 0 && options[focusedIndex]) {
183
+ if (targetOption) {
170
184
  // Use React Select's internal state to set focused option
171
185
  if (selectRef.current && selectRef.current.setState) {
172
- const targetOption = options[focusedIndex]
173
186
  selectRef.current.setState({
174
187
  focusedOption: targetOption,
175
188
  focusedValue: null
@@ -179,11 +192,12 @@ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
179
192
  setTimeout(() => {
180
193
  if (selectRef.current && selectRef.current.menuListRef) {
181
194
  const menuElement = selectRef.current.menuListRef
182
- if (menuElement && menuElement.children && menuElement.children[focusedIndex]) {
183
- // Calculate the position of the selected option and scroll the menu container
184
- const optionElement = menuElement.children[focusedIndex] as HTMLElement
185
- const optionTop = optionElement.offsetTop
186
- const optionHeight = optionElement.offsetHeight
195
+ // Find the focused option using React Select's class
196
+ const focusedElement = menuElement.querySelector('.typeahead-kit-select__option--is-focused')
197
+
198
+ if (focusedElement) {
199
+ const optionTop = focusedElement.offsetTop
200
+ const optionHeight = focusedElement.offsetHeight
187
201
  const menuHeight = menuElement.clientHeight
188
202
 
189
203
  // Set the menu's scrollTop to position the selected option in the middle
@@ -0,0 +1,64 @@
1
+ <%
2
+ grouped_options = [
3
+ {
4
+ label: "Warm Colors",
5
+ options: [
6
+ { label: "Red", value: "#FF0000" },
7
+ { label: "Orange", value: "#FFA500" },
8
+ { label: "Yellow", value: "#FFFF00" },
9
+ { label: "Coral", value: "#FF7F50" },
10
+ { label: "Gold", value: "#FFD700" }
11
+ ]
12
+ },
13
+ {
14
+ label: "Cool Colors",
15
+ options: [
16
+ { label: "Blue", value: "#0000FF" },
17
+ { label: "Teal", value: "#008080" },
18
+ { label: "Cyan", value: "#00FFFF" },
19
+ { label: "Navy", value: "#000080" },
20
+ { label: "Turquoise", value: "#40E0D0" }
21
+ ]
22
+ },
23
+ {
24
+ label: "Neutrals",
25
+ options: [
26
+ { label: "White", value: "#FFFFFF" },
27
+ { label: "Black", value: "#000000" },
28
+ { label: "Gray", value: "#808080" },
29
+ { label: "Beige", value: "#F5F5DC" },
30
+ { label: "Silver", value: "#C0C0C0" }
31
+ ]
32
+ },
33
+ {
34
+ label: "Earth Tones",
35
+ options: [
36
+ { label: "Brown", value: "#A52A2A" },
37
+ { label: "Olive", value: "#808000" },
38
+ { label: "Forest Green", value: "#228B22" },
39
+ { label: "Tan", value: "#D2B48C" },
40
+ { label: "Maroon", value: "#800000" }
41
+ ]
42
+ },
43
+ {
44
+ label: "Fun Shades",
45
+ options: [
46
+ { label: "Pink", value: "#FFC0CB" },
47
+ { label: "Magenta", value: "#FF00FF" },
48
+ { label: "Lime", value: "#00FF00" },
49
+ { label: "Purple", value: "#800080" },
50
+ { label: "Indigo", value: "#4B0082" }
51
+ ]
52
+ }
53
+ ]
54
+ %>
55
+
56
+ <%= pb_rails("typeahead", props: {
57
+ default_options:[{ label: "Pink", value: "#FFC0CB" }],
58
+ id: "typeahead-custom-options",
59
+ options: grouped_options,
60
+ label: "Colors",
61
+ name: :foo,
62
+ is_multi: false
63
+ })
64
+ %>
@@ -0,0 +1,70 @@
1
+ import React from 'react'
2
+
3
+ import Typeahead from '../_typeahead'
4
+
5
+ const groupedOptions = [
6
+ {
7
+ label: "Warm Colors",
8
+ options: [
9
+ { label: "Red", value: "#FF0000" },
10
+ { label: "Orange", value: "#FFA500" },
11
+ { label: "Yellow", value: "#FFFF00" },
12
+ { label: "Coral", value: "#FF7F50" },
13
+ { label: "Gold", value: "#FFD700" }
14
+ ]
15
+ },
16
+ {
17
+ label: "Cool Colors",
18
+ options: [
19
+ { label: "Blue", value: "#0000FF" },
20
+ { label: "Teal", value: "#008080" },
21
+ { label: "Cyan", value: "#00FFFF" },
22
+ { label: "Navy", value: "#000080" },
23
+ { label: "Turquoise", value: "#40E0D0" }
24
+ ]
25
+ },
26
+ {
27
+ label: "Neutrals",
28
+ options: [
29
+ { label: "White", value: "#FFFFFF" },
30
+ { label: "Black", value: "#000000" },
31
+ { label: "Gray", value: "#808080" },
32
+ { label: "Beige", value: "#F5F5DC" },
33
+ { label: "Silver", value: "#C0C0C0" }
34
+ ]
35
+ },
36
+ {
37
+ label: "Earth Tones",
38
+ options: [
39
+ { label: "Brown", value: "#A52A2A" },
40
+ { label: "Olive", value: "#808000" },
41
+ { label: "Forest Green", value: "#228B22" },
42
+ { label: "Tan", value: "#D2B48C" },
43
+ { label: "Maroon", value: "#800000" }
44
+ ]
45
+ },
46
+ {
47
+ label: "Fun Shades",
48
+ options: [
49
+ { label: "Pink", value: "#FFC0CB" },
50
+ { label: "Magenta", value: "#FF00FF" },
51
+ { label: "Lime", value: "#00FF00" },
52
+ { label: "Purple", value: "#800080" },
53
+ { label: "Indigo", value: "#4B0082" }
54
+ ]
55
+ }
56
+ ]
57
+
58
+ const TypeaheadCustomOptions = (props) => {
59
+ return (
60
+ <Typeahead
61
+ defaultValue={[{ label: "Pink", value: "#FFC0CB" }]}
62
+ label="Colors"
63
+ options={groupedOptions}
64
+ {...props}
65
+ />
66
+ )
67
+ }
68
+
69
+ export default TypeaheadCustomOptions
70
+
@@ -0,0 +1 @@
1
+ Grouped options can also be achieved with the Typeahead as seen here.
@@ -2,6 +2,7 @@ examples:
2
2
  rails:
3
3
  - typeahead_default: Default
4
4
  - typeahead_default_options: With Default Options
5
+ - typeahead_custom_options: With Grouped Options
5
6
  - typeahead_with_context: With Context
6
7
  - typeahead_with_pills: With Pills
7
8
  - typeahead_without_pills: Without Pills (Single Select)
@@ -21,6 +22,7 @@ examples:
21
22
  react:
22
23
  - typeahead_default: Default
23
24
  - typeahead_default_value: With Default Value
25
+ - typeahead_custom_options: With Grouped Options
24
26
  - typeahead_react_hook: React Hook
25
27
  - typeahead_with_highlight: With Highlight
26
28
  - typeahead_with_pills: With Pills
@@ -16,4 +16,5 @@ export { default as TypeaheadTruncatedText } from './_typeahead_truncated_text.j
16
16
  export { default as TypeaheadReactHook } from './_typeahead_react_hook.jsx'
17
17
  export { default as TypeaheadDisabled } from './_typeahead_disabled.jsx'
18
18
  export { default as TypeaheadPreserveInput } from './_typeahead_preserve_input.jsx'
19
- export { default as TypeaheadDefaultValue } from './_typeahead_default_value.jsx'
19
+ export { default as TypeaheadDefaultValue } from './_typeahead_default_value.jsx'
20
+ export { default as TypeaheadCustomOptions } from './_typeahead_custom_options.jsx'
@@ -1 +1 @@
1
- import{jsx,Fragment,jsxs}from"react/jsx-runtime";import{useState,useEffect}from"react";import{f as buildAriaProps,g as buildDataProps,h as buildHtmlProps,H as HighchartsReact,i as Highcharts,j as classnames,k as globalProps,l as HighchartsMore,S as SolidGauge,m as buildCss}from"./_typeahead-U8AjZIIW.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-CGxXTQ75.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{f as buildAriaProps,g as buildDataProps,h as buildHtmlProps,H as HighchartsReact,i as Highcharts,j as classnames,k as globalProps,l as HighchartsMore,S as SolidGauge,m as buildCss}from"./_typeahead--U_6fwUM.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-CGxXTQ75.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};