playbook_ui 14.22.0.pre.alpha.play2261highchartsbargraphimportedstyles8730 → 14.22.0.pre.alpha.popoverkittransitionpoppertofloatingui8781

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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_badge/_badge.scss +5 -6
  3. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_colors.jsx +1 -1
  4. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_default.jsx +1 -1
  5. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_height.jsx +1 -1
  6. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_horizontal.jsx +1 -1
  7. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend.jsx +1 -1
  8. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_non_clickable.jsx +1 -1
  9. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.jsx +1 -1
  10. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_negative_numbers.jsx +1 -2
  11. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_secondary_y_axis.jsx +1 -1
  12. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_spline.jsx +1 -2
  13. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_stacked.jsx +1 -1
  14. data/app/pb_kits/playbook/pb_popover/index.ts +33 -15
  15. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_click_open.html.erb +14 -0
  16. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_click_open_rails.md +1 -0
  17. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -0
  18. data/app/pb_kits/playbook/pb_tooltip/index.js +59 -36
  19. data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +9 -2
  20. data/dist/chunks/{_bar_graph-iq9-hk-x.js → _bar_graph-B9HqVkQv.js} +1 -1
  21. data/dist/chunks/_typeahead-CiAYz-Py.js +22 -0
  22. data/dist/chunks/{_weekday_stacked-bjb7ElwG.js → _weekday_stacked-_I9XNGZe.js} +1 -1
  23. data/dist/chunks/lib-BTYFzEXV.js +29 -0
  24. data/dist/chunks/{pb_form_validation-BCfG-8Zp.js → pb_form_validation-Cn7GCWm0.js} +1 -1
  25. data/dist/chunks/vendor.js +1 -1
  26. data/dist/playbook-doc.js +1 -1
  27. data/dist/playbook-rails-react-bindings.js +1 -1
  28. data/dist/playbook-rails.js +1 -1
  29. data/dist/playbook.css +1 -1
  30. data/lib/playbook/version.rb +1 -1
  31. metadata +10 -8
  32. data/dist/chunks/_typeahead-DeLOYzLb.js +0 -22
  33. data/dist/chunks/lib-GtpYwIew.js +0 -29
  34. /data/app/pb_kits/playbook/pb_tooltip/docs/{_tooltip_click_open.md → _tooltip_click_open_react.md} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d54d5b30f8aa5a3674fbcf5e138889fa5621bf8f0ce5b4fa55106804e4dbb43e
4
- data.tar.gz: 5ea3e7bdd1b718cfb5a6795512874bb12b012627edd9b82b82a04f2ca27f683f
3
+ metadata.gz: aaa5efb301fe3d2e5fe096cc4847b47a7ef28e9adbd0edb2b42af60952f3c4a7
4
+ data.tar.gz: a8e3efff80e1f486b9cd5c22e8e25049253cf3c2b97d2572eebf85d7a42e281a
5
5
  SHA512:
6
- metadata.gz: 9b544a9e3c00e1a0cc07bc8f676349059100aad6ed934eefe690853543695c75f13e9a422da64cdd479f9d75375c6e6eab9829e0b8da497844928652e15e195c
7
- data.tar.gz: 6f03c79d01b1bd9ab12a6be7c13cda2c02ad0f5d27d18eb64975d51d26b04cfddbf7c7faf694661c7c5f76afc65d6295076237726cdca20f007c68a25e67845a
6
+ metadata.gz: 67538842d0766d061a241b6e505aa4bbf0235f921260ba4824012ec60114feaf2a98bd8900938d27b7ea6ac742adbe1bbd9a3400aec549c46b48680cb645d045
7
+ data.tar.gz: db70f14c940d42d04704b4e4342aad75407aed4566d5ab643bd74b03e5cbd2859e5f527b21f4d9581f0025e5ec220f7f3d8bb34d34abef03896b89b02cdf770b
@@ -5,7 +5,7 @@
5
5
  @import "../tokens/typography";
6
6
 
7
7
  [class^=pb_badge_kit] {
8
- $pb_badge_height: 18px;
8
+ $pb_badge_height_rounded: 16px;
9
9
 
10
10
  display: inline-flex;
11
11
  align-items: center;
@@ -13,7 +13,6 @@
13
13
  border-radius: $border_rad_light;
14
14
  padding: 0 $space_xs/2;
15
15
  border-width: 1px;
16
- border-style: solid;
17
16
  border-color: $card_light;
18
17
  white-space: nowrap;
19
18
 
@@ -31,10 +30,10 @@
31
30
  }
32
31
 
33
32
  &[class*=_rounded] {
34
- height: $pb_badge_height;
35
- min-height: $pb_badge_height;
36
- min-width: $pb_badge_height;
37
- border-radius: $pb_badge_height / 2;
33
+ height: $pb_badge_height_rounded;
34
+ min-height: $pb_badge_height_rounded;
35
+ min-width: $pb_badge_height_rounded;
36
+ border-radius: $pb_badge_height_rounded / 2;
38
37
  }
39
38
 
40
39
  &[class*=_notification] {
@@ -1,9 +1,9 @@
1
1
  import React from 'react'
2
2
  import colors from '../../tokens/exports/_colors.module.scss'
3
+ import barGraphTheme from '../barGraphTheme';
3
4
  import Highcharts from "highcharts";
4
5
  import HighchartsReact from "highcharts-react-official";
5
6
 
6
- import barGraphTheme from '../barGraphTheme';
7
7
 
8
8
 
9
9
  const chartData = [{
@@ -1,8 +1,8 @@
1
1
  import React from 'react'
2
+ import barGraphTheme from '../barGraphTheme';
2
3
  import Highcharts from "highcharts";
3
4
  import HighchartsReact from "highcharts-react-official";
4
5
 
5
- import barGraphTheme from '../barGraphTheme';
6
6
 
7
7
  const chartData = [{
8
8
  name: 'Installation',
@@ -1,8 +1,8 @@
1
1
  import React from 'react'
2
+ import barGraphTheme from '../barGraphTheme';
2
3
  import Highcharts from "highcharts";
3
4
  import HighchartsReact from "highcharts-react-official";
4
5
 
5
- import barGraphTheme from '../barGraphTheme';
6
6
 
7
7
  const chartData = [{
8
8
  name: 'Number of Installations',
@@ -1,8 +1,8 @@
1
1
  import React from 'react'
2
+ import barGraphTheme from '../barGraphTheme';
2
3
  import Highcharts from "highcharts";
3
4
  import HighchartsReact from "highcharts-react-official";
4
5
 
5
- import barGraphTheme from '../barGraphTheme';
6
6
 
7
7
  const chartOptions = {
8
8
  chart: {
@@ -1,8 +1,8 @@
1
1
  import React from 'react'
2
+ import barGraphTheme from '../barGraphTheme';
2
3
  import Highcharts from "highcharts";
3
4
  import HighchartsReact from "highcharts-react-official";
4
5
 
5
- import barGraphTheme from '../barGraphTheme';
6
6
 
7
7
  const chartData = [{
8
8
  name: 'Number of Installations',
@@ -1,8 +1,8 @@
1
1
  import React from 'react'
2
+ import barGraphTheme from '../barGraphTheme';
2
3
  import Highcharts from "highcharts";
3
4
  import HighchartsReact from "highcharts-react-official";
4
5
 
5
- import barGraphTheme from '../barGraphTheme';
6
6
 
7
7
  const chartData = [{
8
8
  name: 'Number of Installations',
@@ -1,10 +1,10 @@
1
1
  import React from 'react'
2
+ import barGraphTheme from '../barGraphTheme';
2
3
  import Highcharts from "highcharts";
3
4
  import HighchartsReact from "highcharts-react-official";
4
5
 
5
6
  import Title from "../../pb_title/_title"
6
7
 
7
- import barGraphTheme from '../barGraphTheme';
8
8
 
9
9
  const chartData = [{
10
10
  name: 'Installation',
@@ -1,9 +1,8 @@
1
1
  import React from 'react'
2
-
2
+ import barGraphTheme from '../barGraphTheme';
3
3
  import Highcharts from "highcharts";
4
4
  import HighchartsReact from "highcharts-react-official";
5
5
 
6
- import barGraphTheme from '../barGraphTheme';
7
6
 
8
7
  const chartData = [{
9
8
  name: 'Installation',
@@ -1,9 +1,9 @@
1
1
  import React from 'react'
2
+ import barGraphTheme from '../barGraphTheme';
2
3
  import Highcharts from "highcharts"
3
4
  import HighchartsReact from "highcharts-react-official"
4
5
 
5
6
 
6
- import barGraphTheme from '../barGraphTheme';
7
7
  import colors from '../../tokens/exports/_colors.module.scss'
8
8
  import typography from '../../tokens/exports/_typography.module.scss'
9
9
 
@@ -1,9 +1,8 @@
1
1
  import React from 'react'
2
-
2
+ import barGraphTheme from '../barGraphTheme';
3
3
  import Highcharts from "highcharts";
4
4
  import HighchartsReact from "highcharts-react-official";
5
5
 
6
- import barGraphTheme from '../barGraphTheme';
7
6
 
8
7
  const chartData = [{
9
8
  name: 'Number of Installations',
@@ -1,8 +1,8 @@
1
1
  import React from 'react'
2
+ import barGraphTheme from '../barGraphTheme';
2
3
  import Highcharts from "highcharts";
3
4
  import HighchartsReact from "highcharts-react-official";
4
5
 
5
- import barGraphTheme from '../barGraphTheme';
6
6
 
7
7
  const chartData = [{
8
8
  name: 'Installation',
@@ -1,12 +1,12 @@
1
1
  import PbEnhancedElement from '../pb_enhanced_element'
2
- import { createPopper, Instance, Placement } from '@popperjs/core'
2
+ import { computePosition, offset, flip, shift, autoUpdate, Placement } from '@floating-ui/dom'
3
3
 
4
4
  const POPOVER_OFFSET_Y = [0, 20]
5
5
 
6
6
  export default class PbPopover extends PbEnhancedElement {
7
- popper: Instance
8
7
  _triggerElement: HTMLElement
9
8
  _tooltip: HTMLElement
9
+ cleanupAutoUpdate: () => void
10
10
  element: HTMLElement
11
11
  static get selector() {
12
12
  return '[data-pb-popover-kit]'
@@ -31,18 +31,15 @@ export default class PbPopover extends PbEnhancedElement {
31
31
  }
32
32
  this.moveTooltip()
33
33
 
34
- this.popper = createPopper (this.triggerElement, this.tooltip, {
35
- placement: this.position as Placement,
36
- strategy: 'fixed',
37
- modifiers: [
38
- {
39
- name: 'offset',
40
- options: {
41
- offset: this.offset,
42
- },
43
- },
44
- ],
45
- })
34
+ // Initial position
35
+ this.updatePosition()
36
+
37
+ // Update position (i.e., scroll or resize)
38
+ this.cleanupAutoUpdate = autoUpdate(
39
+ this.triggerElement,
40
+ this.tooltip,
41
+ () => this.updatePosition()
42
+ )
46
43
 
47
44
  this.triggerElement.addEventListener('click', (event: Event) => {
48
45
  event.preventDefault()
@@ -54,11 +51,32 @@ export default class PbPopover extends PbEnhancedElement {
54
51
 
55
52
  setTimeout(() => {
56
53
  this.toggleTooltip()
57
- this.popper.update()
54
+ this.updatePosition()
58
55
  }, 0)
59
56
  })
60
57
  }
61
58
 
59
+ updatePosition() {
60
+ computePosition(this.triggerElement, this.tooltip, {
61
+ placement: this.position as Placement,
62
+ strategy: 'fixed',
63
+ middleware: [
64
+ offset(() => {
65
+ const [ crossAxis, mainAxis ] = this.offset
66
+ return { mainAxis, crossAxis }
67
+ }),
68
+ flip(),
69
+ shift(),
70
+ ],
71
+ }).then(({ x, y }) => {
72
+ Object.assign(this.tooltip.style, {
73
+ left: `${x}px`,
74
+ top: `${y}px`,
75
+ position: 'fixed',
76
+ })
77
+ })
78
+ }
79
+
62
80
  checkCloseTooltip() {
63
81
  document.querySelector('body').addEventListener('click', ({ target } ) => {
64
82
  const isTooltipElement = (target as HTMLElement).closest(`#${this.tooltipId}`) !== null
@@ -0,0 +1,14 @@
1
+ <%= pb_rails("button", props: {
2
+ text: "Click to Open",
3
+ id: "click-tooltip-trigger-1",
4
+ variant: "primary"
5
+ }) %>
6
+
7
+ <%= pb_rails("tooltip", props: {
8
+ trigger_element_selector: "#click-tooltip-trigger-1",
9
+ tooltip_id: "click-tooltip-1",
10
+ position: "top",
11
+ use_click_to_open: true
12
+ }) do %>
13
+ Tooltip opened by click! Click trigger again to close.
14
+ <% end %>
@@ -0,0 +1 @@
1
+ Set the prop `use_click_to_open` as `true` so that the tooltip will only appear when an item is clicked rather than hovered over.
@@ -9,6 +9,7 @@ examples:
9
9
  - tooltip_with_icon_circle: Icon Circle Tooltip
10
10
  - tooltip_delay_rails: Delay
11
11
  - tooltip_show_tooltip: Show Tooltip
12
+ - tooltip_click_open: Click to Open
12
13
 
13
14
  react:
14
15
  - tooltip_default_react: Default
@@ -19,60 +19,75 @@ export default class PbTooltip extends PbEnhancedElement {
19
19
  }
20
20
 
21
21
  this.triggerElements.forEach((trigger) => {
22
- const method = this.triggerMethod
22
+ const method = this.effectiveTriggerMethod
23
23
  const interactionEnabled = this.tooltipInteraction
24
24
 
25
25
  if (method === 'click') {
26
- trigger.addEventListener('click', () => {
27
- this.showTooltip(trigger)
28
- })
29
- } else {
30
- trigger.addEventListener('mouseenter', () => {
31
- clearSafeZoneListener(this)
32
- clearTimeout(this.mouseleaveTimeout)
33
- this.currentTrigger = trigger
34
- const delayOpen = this.delayOpen ? parseInt(this.delayOpen) : TOOLTIP_TIMEOUT
35
- this.mouseenterTimeout = setTimeout(() => {
36
- this.showTooltip(trigger)
37
- if (interactionEnabled) {
38
- this.checkCloseTooltip(trigger)
26
+ trigger.addEventListener('click', (e) => {
27
+ if (this.useClickToOpen) {
28
+ e.preventDefault()
29
+ if (this.isTooltipVisible()) {
30
+ this.hideTooltip()
31
+ } else {
32
+ this.showTooltip(trigger)
39
33
  }
40
- }, delayOpen)
34
+ } else {
35
+ this.showTooltip(trigger)
36
+ }
41
37
  })
38
+ } else {
39
+ if (!this.useClickToOpen) {
40
+ trigger.addEventListener('mouseenter', () => {
41
+ clearSafeZoneListener(this)
42
+ clearTimeout(this.mouseleaveTimeout)
43
+ this.currentTrigger = trigger
44
+ const delayOpen = this.delayOpen ? parseInt(this.delayOpen) : TOOLTIP_TIMEOUT
45
+ this.mouseenterTimeout = setTimeout(() => {
46
+ this.showTooltip(trigger)
47
+ if (interactionEnabled) {
48
+ this.checkCloseTooltip(trigger)
49
+ }
50
+ }, delayOpen)
51
+ })
42
52
 
43
- trigger.addEventListener('mouseleave', () => {
44
- clearTimeout(this.mouseenterTimeout)
45
- if (this.delayClose) {
46
- const delayClose = parseInt(this.delayClose)
47
- this.mouseleaveTimeout = setTimeout(() => {
53
+ trigger.addEventListener('mouseleave', () => {
54
+ clearTimeout(this.mouseenterTimeout)
55
+ if (this.delayClose) {
56
+ const delayClose = parseInt(this.delayClose)
57
+ this.mouseleaveTimeout = setTimeout(() => {
58
+ if (interactionEnabled) {
59
+ this.attachSafeZoneListener()
60
+ } else {
61
+ this.hideTooltip()
62
+ }
63
+ }, delayClose)
64
+ } else {
48
65
  if (interactionEnabled) {
49
66
  this.attachSafeZoneListener()
50
67
  } else {
51
68
  this.hideTooltip()
52
69
  }
53
- }, delayClose)
54
- } else {
55
- if (interactionEnabled) {
56
- this.attachSafeZoneListener()
57
- } else {
58
- this.hideTooltip()
59
70
  }
60
- }
61
- })
62
-
63
- if (interactionEnabled) {
64
- this.tooltip.addEventListener('mouseenter', () => {
65
- clearSafeZoneListener(this)
66
71
  })
67
72
 
68
- this.tooltip.addEventListener('mouseleave', () => {
69
- this.attachSafeZoneListener()
70
- })
73
+ if (interactionEnabled) {
74
+ this.tooltip.addEventListener('mouseenter', () => {
75
+ clearSafeZoneListener(this)
76
+ })
77
+
78
+ this.tooltip.addEventListener('mouseleave', () => {
79
+ this.attachSafeZoneListener()
80
+ })
81
+ }
71
82
  }
72
83
  }
73
84
  })
74
85
  }
75
86
 
87
+ isTooltipVisible() {
88
+ return this.tooltip && this.tooltip.classList.contains('show')
89
+ }
90
+
76
91
  attachSafeZoneListener() {
77
92
  clearSafeZoneListener(this)
78
93
  this.safeZoneHandler = (e) => {
@@ -145,7 +160,7 @@ export default class PbTooltip extends PbEnhancedElement {
145
160
 
146
161
  this.tooltip.classList.add('show')
147
162
 
148
- if (this.triggerMethod === 'click') {
163
+ if (this.effectiveTriggerMethod === 'click' && !this.useClickToOpen) {
149
164
  clearTimeout(this.autoHideTimeout)
150
165
  this.autoHideTimeout = setTimeout(() => {
151
166
  this.hideTooltip()
@@ -224,6 +239,14 @@ export default class PbTooltip extends PbEnhancedElement {
224
239
  return this.element.dataset.pbTooltipTriggerMethod || 'hover'
225
240
  }
226
241
 
242
+ get useClickToOpen() {
243
+ return this.element.dataset.pbTooltipUseClickToOpen === 'true'
244
+ }
245
+
246
+ get effectiveTriggerMethod() {
247
+ return this.useClickToOpen ? 'click' : this.triggerMethod
248
+ }
249
+
227
250
  get tooltipInteraction() {
228
251
  return this.element.dataset.pbTooltipInteraction === 'true'
229
252
  }
@@ -21,6 +21,8 @@ module Playbook
21
21
  prop :trigger_method, type: Playbook::Props::Enum,
22
22
  values: %w[hover click],
23
23
  default: "hover"
24
+ prop :use_click_to_open, type: Playbook::Props::Boolean,
25
+ default: false
24
26
  prop :width
25
27
 
26
28
  def classname
@@ -46,6 +48,10 @@ module Playbook
46
48
  out
47
49
  end
48
50
 
51
+ def effective_trigger_method
52
+ use_click_to_open ? "click" : (trigger_method || "hover")
53
+ end
54
+
49
55
  def data
50
56
  data = Hash(values[:data]).merge(
51
57
  pb_tooltip_kit: true,
@@ -54,8 +60,9 @@ module Playbook
54
60
  pb_tooltip_trigger_element_id: trigger_element_id,
55
61
  pb_tooltip_tooltip_id: tooltip_id,
56
62
  pb_tooltip_show_tooltip: true,
57
- pb_tooltip_trigger_method: trigger_method,
58
- pb_tooltip_interaction: interaction
63
+ pb_tooltip_trigger_method: effective_trigger_method,
64
+ pb_tooltip_interaction: interaction,
65
+ pb_tooltip_use_click_to_open: use_click_to_open
59
66
  )
60
67
  data = data.merge(pb_tooltip_delay_open: delay_open) if delay_open
61
68
  data = data.merge(pb_tooltip_delay_close: delay_close) if delay_close
@@ -1 +1 @@
1
- import{jsx}from"react/jsx-runtime";import{useState,useEffect}from"react";import{b as buildAriaProps,a as buildDataProps,c as buildHtmlProps,m as mapColors,H as HighchartsReact,d as Highcharts,e as classnames,g as globalProps}from"./_typeahead-DeLOYzLb.js";import{h as highchartsTheme,m as merge,a as highchartsDarkTheme}from"./lib-GtpYwIew.js";const BarGraph=({aria:aria={},data:data={},align:align="center",axisTitle:axisTitle,dark:dark=false,chartData:chartData,className:className="pb_bar_graph",colors:colors,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:colors!==void 0&&colors.length>0?mapColors(colors):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})};export{BarGraph as B};
1
+ import{jsx}from"react/jsx-runtime";import{useState,useEffect}from"react";import{b as buildAriaProps,a as buildDataProps,c as buildHtmlProps,m as mapColors,H as HighchartsReact,d as Highcharts,e as classnames,g as globalProps}from"./_typeahead-CiAYz-Py.js";import{h as highchartsTheme,m as merge,a as highchartsDarkTheme}from"./lib-BTYFzEXV.js";const BarGraph=({aria:aria={},data:data={},align:align="center",axisTitle:axisTitle,dark:dark=false,chartData:chartData,className:className="pb_bar_graph",colors:colors,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:colors!==void 0&&colors.length>0?mapColors(colors):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})};export{BarGraph as B};