playbook_ui 14.24.0.pre.alpha.PLAY19989342 → 14.24.0.pre.alpha.play23649479

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +4 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +1 -2
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +34 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +56 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_vertical_border.html.erb +43 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_vertical_border.jsx +64 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.jsx +60 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.md +3 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row.jsx +57 -0
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row.md +1 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +4 -0
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +4 -1
  14. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +1 -1
  15. data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.rb +1 -1
  16. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +26 -175
  17. data/app/pb_kits/playbook/pb_bar_graph/barGraph.test.js +1 -2
  18. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.html.erb +1 -1
  19. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +12 -78
  20. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_default.html.erb +21 -9
  21. data/app/pb_kits/playbook/pb_pagination/_pagination.test.jsx +212 -0
  22. data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +8 -1
  23. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_external_control.jsx +112 -0
  24. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_external_control_react.md +3 -0
  25. data/app/pb_kits/playbook/pb_pagination/docs/example.yml +1 -0
  26. data/app/pb_kits/playbook/pb_pagination/docs/index.js +1 -0
  27. data/app/pb_kits/playbook/pb_table/styles/_vertical_border.scss +49 -1
  28. data/dist/chunks/_line_graph-BsZ3DcJo.js +1 -0
  29. data/dist/chunks/{_typeahead-BzYZCpJO.js → _typeahead-CKvqSXWH.js} +2 -2
  30. data/dist/chunks/{_weekday_stacked-CJIFKKe7.js → _weekday_stacked-tedYzlIq.js} +2 -2
  31. data/dist/chunks/{lib-CY5ZPzic.js → lib-BplzvaaY.js} +2 -2
  32. data/dist/chunks/{pb_form_validation-D3b0JKHH.js → pb_form_validation-CA_noofR.js} +1 -1
  33. data/dist/chunks/vendor.js +1 -1
  34. data/dist/menu.yml +2 -2
  35. data/dist/playbook-doc.js +1 -1
  36. data/dist/playbook-rails-react-bindings.js +1 -1
  37. data/dist/playbook-rails.js +1 -1
  38. data/dist/playbook.css +1 -1
  39. data/lib/playbook/version.rb +1 -1
  40. metadata +16 -7
  41. data/dist/chunks/_line_graph-D7DgMqnT.js +0 -1
@@ -20,9 +20,8 @@ const testId = 'bargraph1';
20
20
  test('bargraph uses exact classname', () => {
21
21
  render(
22
22
  <BarGraph
23
- className='super_important_class'
23
+ containerProps={{ className: 'super_important_class' }}
24
24
  data={{ testid: testId }}
25
- id='bar-default'
26
25
  />
27
26
  );
28
27
 
@@ -1 +1 @@
1
- <%= react_component('BarGraph', object.chart_options) %>
1
+ <%= react_component('BarGraph', object.react_props) %>
@@ -3,91 +3,25 @@
3
3
  module Playbook
4
4
  module PbBarGraph
5
5
  class BarGraph < Playbook::KitBase
6
- prop :align, type: Playbook::Props::Enum,
7
- values: %w[left right center],
8
- default: "center"
9
- prop :axis_title
10
- prop :axis_format
11
- prop :chart_data, type: Playbook::Props::Array,
12
- default: []
13
- prop :custom_options, default: {}
14
- prop :orientation, type: Playbook::Props::Enum,
15
- values: %w[vertical horizontal],
16
- default: "vertical"
17
- prop :point_start, type: Playbook::Props::Numeric
18
- prop :stacking
19
- prop :subtitle
20
- prop :title
21
- prop :x_axis_categories, type: Playbook::Props::Array,
22
- default: []
23
- prop :y_axis_min, type: Playbook::Props::Numeric
24
- prop :y_axis_max, type: Playbook::Props::Numeric
25
- prop :legend, type: Playbook::Props::Boolean,
26
- default: false
27
- prop :toggle_legend_click, type: Playbook::Props::Boolean,
28
- default: true
29
- prop :height
30
- prop :colors, type: Playbook::Props::Array,
31
- default: []
32
- prop :layout, type: Playbook::Props::Enum,
33
- values: %w[horizontal vertical proximate],
34
- default: "horizontal"
35
- prop :vertical_align, type: Playbook::Props::Enum,
36
- values: %w[top middle bottom],
37
- default: "bottom"
38
- prop :x, type: Playbook::Props::Numeric
39
- prop :y, type: Playbook::Props::Numeric
6
+ prop :options, default: {}
7
+ prop :container_props, default: {}
40
8
 
41
- def chart_type
42
- orientation == "horizontal" ? "bar" : "column"
9
+ def chart_options
10
+ options
43
11
  end
44
12
 
45
- def standard_options
13
+ def react_props
46
14
  {
47
- align: align,
48
- id: id,
49
- className: classname,
50
- chartData: chart_data,
51
- dark: dark ? "dark" : "",
52
- type: chart_type,
53
- title: title,
54
- stacking: stacking,
55
- subTitle: subtitle,
56
- axisTitle: axis_title,
57
- axisFormat: axis_format,
58
- pointStart: point_start,
59
- xAxisCategories: x_axis_categories,
60
- yAxisMin: y_axis_min,
61
- yAxisMax: y_axis_max,
62
- legend: legend,
63
- toggleLegendClick: toggle_legend_click,
64
- height: height,
65
- colors: colors,
66
- layout: layout,
67
- verticalAlign: vertical_align,
68
- x: x,
69
- y: y,
15
+ options: options,
16
+ containerProps: container_props_hash,
70
17
  }
71
18
  end
72
19
 
73
- def chart_options
74
- standard_options.deep_merge(custom_options)
75
- end
76
-
77
- def vertical_align_props
78
- if vertical_align
79
- if object.vertical_align
80
- original_result = super
81
- class_to_remove = "vertical_align_#{object.vertical_align}"
82
-
83
- modified_result = original_result.gsub(class_to_remove, "").strip
84
- modified_result.empty? ? nil : modified_result
85
- else
86
- super
87
- end
88
- else
89
- super
90
- end
20
+ def container_props_hash
21
+ container_props.merge({
22
+ id: id,
23
+ className: classname,
24
+ }).compact
91
25
  end
92
26
 
93
27
  def classname
@@ -15,12 +15,24 @@
15
15
  data: [1111,677,3245,500,200]
16
16
  }] %>
17
17
 
18
- <%= pb_rails("bar_graph", props: {
19
- axis_title: 'Number of Employees',
20
- chart_data: data,
21
- id: "bar-default",
22
- y_axis_min: 0,
23
- x_axis_categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
24
- subtitle: 'Source: thesolarfoundation.com',
25
- title: 'Solar Employment Growth by Sector, 2010-2016',
26
- }) %>
18
+
19
+ <% chart_options = {
20
+ series: data,
21
+ title: {
22
+ text: 'Solar Employment Growth by Sector, 2010-2016',
23
+ },
24
+ subtitle: {
25
+ text: 'Source: thesolarfoundation.com',
26
+ },
27
+ xAxis: {
28
+ categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
29
+ },
30
+ yAxis: {
31
+ title: {
32
+ text: 'Number of Employees',
33
+ },
34
+ },
35
+ }
36
+ %>
37
+
38
+ <%= pb_rails("bar_graph", props: {options: chart_options}) %>
@@ -0,0 +1,212 @@
1
+ import React from 'react'
2
+ import { ensureAccessible, renderKit, render, fireEvent, screen } from '../utilities/test-utils'
3
+ import Pagination from './_pagination'
4
+
5
+ const defaultProps = {
6
+ data: { testid: 'pagination-test' },
7
+ total: 10,
8
+ current: 1,
9
+ range: 5,
10
+ }
11
+
12
+ describe('Pagination Component', () => {
13
+ test('returns namespaced class name', () => {
14
+ const kit = renderKit(Pagination, defaultProps)
15
+ expect(kit).toBeInTheDocument()
16
+ expect(kit).toHaveClass('pb_paginate')
17
+ })
18
+
19
+ it("should be accessible", async () => {
20
+ ensureAccessible(Pagination, defaultProps)
21
+ })
22
+
23
+ test('renders with default props', () => {
24
+ render(<Pagination {...defaultProps} />)
25
+
26
+ const pagination = screen.getByTestId('pagination-test')
27
+ expect(pagination).toBeInTheDocument()
28
+ expect(pagination).toHaveClass('pb_paginate')
29
+ })
30
+
31
+ test('renders pagination buttons correctly', () => {
32
+ render(<Pagination {...defaultProps} />)
33
+
34
+ expect(screen.getByText('1')).toBeInTheDocument()
35
+ expect(screen.getByText('2')).toBeInTheDocument()
36
+ expect(screen.getByText('3')).toBeInTheDocument()
37
+ expect(screen.getByText('4')).toBeInTheDocument()
38
+ expect(screen.getByText('5')).toBeInTheDocument()
39
+
40
+ // Check for navigation arrows by looking for the li elements with specific classes
41
+ const leftArrow = document.querySelector('.pagination-left')
42
+ const rightArrow = document.querySelector('.pagination-right')
43
+ expect(leftArrow).toBeInTheDocument()
44
+ expect(rightArrow).toBeInTheDocument()
45
+ })
46
+
47
+ test('highlights current page as active', () => {
48
+ render(<Pagination {...defaultProps}
49
+ current={3}
50
+ />)
51
+
52
+ const activePage = screen.getByText('3')
53
+ expect(activePage).toHaveClass('active')
54
+ })
55
+
56
+ test('calls onChange when page is clicked', () => {
57
+ const mockOnChange = jest.fn()
58
+ render(<Pagination {...defaultProps}
59
+ onChange={mockOnChange}
60
+ />)
61
+
62
+ const pageButton = screen.getByText('3')
63
+ fireEvent.click(pageButton)
64
+
65
+ expect(mockOnChange).toHaveBeenCalledWith(3)
66
+ })
67
+
68
+ test('disables left arrow on first page', () => {
69
+ render(<Pagination {...defaultProps}
70
+ current={1}
71
+ />)
72
+
73
+ const leftArrow = document.querySelector('.pagination-left')
74
+ expect(leftArrow).toHaveClass('disabled')
75
+ })
76
+
77
+ test('disables right arrow on last page', () => {
78
+ render(<Pagination {...defaultProps}
79
+ current={10}
80
+ />)
81
+
82
+ const rightArrow = document.querySelector('.pagination-right')
83
+ expect(rightArrow).toHaveClass('disabled')
84
+ })
85
+
86
+ test('does not render when total is 1 or less', () => {
87
+ const { container } = render(<Pagination {...defaultProps}
88
+ total={1}
89
+ />)
90
+
91
+ expect(container.firstChild).toBeNull()
92
+ })
93
+
94
+ test('renders with custom className', () => {
95
+ render(<Pagination {...defaultProps}
96
+ className="custom-class"
97
+ />)
98
+
99
+ const pagination = screen.getByTestId('pagination-test')
100
+ expect(pagination).toHaveClass('custom-class')
101
+ })
102
+
103
+ test('renders with custom id', () => {
104
+ render(<Pagination {...defaultProps}
105
+ id="custom-id"
106
+ />)
107
+
108
+ const pagination = screen.getByTestId('pagination-test')
109
+ expect(pagination).toHaveAttribute('id', 'custom-id')
110
+ })
111
+
112
+ test('renders with custom range', () => {
113
+ render(<Pagination {...defaultProps}
114
+ range={3}
115
+ />)
116
+
117
+ expect(screen.getByText('1')).toBeInTheDocument()
118
+ expect(screen.getByText('2')).toBeInTheDocument()
119
+ expect(screen.getByText('3')).toBeInTheDocument()
120
+ expect(screen.getByText('9')).toBeInTheDocument()
121
+ expect(screen.getByText('10')).toBeInTheDocument()
122
+ })
123
+
124
+ test('handles large number of pages correctly', () => {
125
+ render(<Pagination {...defaultProps}
126
+ current={50}
127
+ range={5}
128
+ total={100}
129
+ />)
130
+
131
+ const pagination = screen.getByTestId('pagination-test')
132
+ expect(pagination).toBeInTheDocument()
133
+ expect(pagination).toHaveClass('pb_paginate')
134
+
135
+
136
+ expect(screen.getByText('48')).toBeInTheDocument()
137
+ expect(screen.getByText('49')).toBeInTheDocument()
138
+ expect(screen.getByText('50')).toBeInTheDocument()
139
+ expect(screen.getByText('51')).toBeInTheDocument()
140
+ expect(screen.getByText('52')).toBeInTheDocument()
141
+ })
142
+
143
+ test('syncs with external current prop changes', () => {
144
+ const { rerender } = render(<Pagination {...defaultProps}
145
+ current={1}
146
+ />)
147
+
148
+ expect(screen.getByText('1')).toHaveClass('active')
149
+
150
+ rerender(<Pagination {...defaultProps}
151
+ current={3}
152
+ />)
153
+
154
+ expect(screen.getByText('3')).toHaveClass('active')
155
+ expect(screen.getByText('1')).not.toHaveClass('active')
156
+ })
157
+
158
+ test('validates current prop is within valid range', () => {
159
+ const { rerender } = render(<Pagination {...defaultProps}
160
+ current={1}
161
+ />)
162
+
163
+ rerender(<Pagination {...defaultProps}
164
+ current={0}
165
+ />)
166
+
167
+ expect(screen.getByText('1')).toHaveClass('active')
168
+
169
+ rerender(<Pagination {...defaultProps}
170
+ current={15}
171
+ />)
172
+
173
+ expect(screen.getByText('1')).toHaveClass('active')
174
+ })
175
+
176
+ test('handles htmlOptions props', () => {
177
+ const htmlOptions = { 'data-test': 'test-value' }
178
+ render(<Pagination {...defaultProps}
179
+ htmlOptions={htmlOptions}
180
+ />)
181
+
182
+ const pagination = screen.getByTestId('pagination-test')
183
+ expect(pagination).toHaveAttribute('data-test', 'test-value')
184
+ })
185
+
186
+ test('renders first and last page buttons when range is small', () => {
187
+ render(<Pagination {...defaultProps}
188
+ current={10}
189
+ range={3}
190
+ total={20}
191
+ />)
192
+
193
+ expect(screen.getByText('1')).toBeInTheDocument()
194
+ expect(screen.getByText('20')).toBeInTheDocument()
195
+
196
+ expect(screen.getByText('9')).toBeInTheDocument()
197
+ expect(screen.getByText('10')).toBeInTheDocument()
198
+ expect(screen.getByText('11')).toBeInTheDocument()
199
+ })
200
+
201
+ test('renders second and second-to-last page buttons when needed', () => {
202
+ render(<Pagination {...defaultProps}
203
+ current={10}
204
+ range={3}
205
+ total={20}
206
+ />)
207
+
208
+ expect(screen.getByText('2')).toBeInTheDocument()
209
+
210
+ expect(screen.getByText('19')).toBeInTheDocument()
211
+ })
212
+ })
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React, { useState, useEffect } from "react";
2
2
  import classnames from 'classnames'
3
3
  import { GlobalProps, globalProps } from '../utilities/globalProps'
4
4
  import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
@@ -123,6 +123,13 @@ const Pagination = ( props: PaginationProps) => {
123
123
 
124
124
  return buttons;
125
125
  };
126
+
127
+ // Sync internal state with external current prop
128
+ useEffect(() => {
129
+ if (current >= 1 && current <= total) {
130
+ setCurrentPage(current);
131
+ }
132
+ }, [current, total]);
126
133
 
127
134
 
128
135
  const ariaProps = buildAriaProps(aria)
@@ -0,0 +1,112 @@
1
+ import React, { useState } from "react";
2
+ import Flex from '../../pb_flex/_flex'
3
+ import Pagination from '../../pb_pagination/_pagination'
4
+ import Select from '../../pb_select/_select'
5
+ import Table from '../../pb_table/_table'
6
+
7
+ import { data } from "./data";
8
+
9
+ const PaginationExternalControl = (props) => {
10
+ const [totalItems, setTotalItems] = useState(20);
11
+ const [itemsPerPage, setItemsPerPage] = useState(5);
12
+ const [currentPage, setCurrentPage] = useState(1);
13
+
14
+ const totalPages = Math.ceil(totalItems / itemsPerPage);
15
+
16
+ const handlePageChange = (page) => {
17
+ setCurrentPage(page);
18
+ };
19
+
20
+ const limitedData = data.slice(0, totalItems);
21
+ const startIndex = (currentPage - 1) * itemsPerPage;
22
+ const paginatedItems = limitedData.slice(startIndex, startIndex + itemsPerPage);
23
+
24
+ const handleTotalItemsChange = (event) => {
25
+ const value = Number(event.target.value);
26
+ setTotalItems(value);
27
+ setCurrentPage(1);
28
+ };
29
+
30
+ const handleItemsPerPageChange = (event) => {
31
+ const value = Number(event.target.value);
32
+ setItemsPerPage(value);
33
+ setCurrentPage(1);
34
+ };
35
+
36
+ return (
37
+ <>
38
+ <Flex gap="sm">
39
+ <Select
40
+ label="Total Items"
41
+ onChange={handleTotalItemsChange}
42
+ options={[
43
+ { value: "5", text: "5" },
44
+ { value: "10", text: "10" },
45
+ { value: "20", text: "20" }
46
+ ]}
47
+ size="sm"
48
+ value={String(totalItems)}
49
+ {...props}
50
+ />
51
+
52
+ <Select
53
+ label="Items per Page"
54
+ onChange={handleItemsPerPageChange}
55
+ options={[
56
+ { value: "3", text: "3" },
57
+ { value: "5", text: "5" },
58
+ { value: "10", text: "10" }
59
+ ]}
60
+ size="sm"
61
+ value={String(itemsPerPage)}
62
+ {...props}
63
+ />
64
+ </Flex>
65
+
66
+ <Pagination
67
+ current={currentPage}
68
+ key={`pagination-top-${currentPage}`}
69
+ marginBottom="xs"
70
+ onChange={handlePageChange}
71
+ range={5}
72
+ total={totalPages}
73
+ {...props}
74
+ />
75
+ <Table
76
+ marginBottom="xs"
77
+ responsive="none"
78
+ size="sm"
79
+ {...props}
80
+ >
81
+ <Table.Head>
82
+ <Table.Row>
83
+ <Table.Header>{"Column 1"}</Table.Header>
84
+ <Table.Header>{"Column 2"}</Table.Header>
85
+ <Table.Header>{"Column 3"}</Table.Header>
86
+ <Table.Header>{"Column 4"}</Table.Header>
87
+ <Table.Header>{"Column 5"}</Table.Header>
88
+ </Table.Row>
89
+ </Table.Head>
90
+ <Table.Body>
91
+ {paginatedItems.map((row, index) => (
92
+ <Table.Row key={index}>
93
+ {row.map((cell, cellIndex) => (
94
+ <Table.Cell key={cellIndex}>{cell}</Table.Cell>
95
+ ))}
96
+ </Table.Row>
97
+ ))}
98
+ </Table.Body>
99
+ </Table>
100
+ <Pagination
101
+ current={currentPage}
102
+ key={`pagination-bottom-${currentPage}`}
103
+ onChange={handlePageChange}
104
+ range={5}
105
+ total={totalPages}
106
+ {...props}
107
+ />
108
+ </>
109
+ )
110
+ }
111
+
112
+ export default PaginationExternalControl
@@ -0,0 +1,3 @@
1
+ The Pagination component supports external control of the current page. This allows for programmatically reseting or changing the current page when filters or other criteria change, without needing to unmount and remount the component.
2
+
3
+ In this example, changing the "Total Items" or "Items per Page" dropdowns will automatically reset the pagination to page 1, demonstrating how external control works. The pagination component will update its internal state to reflect the new `current` prop value.
@@ -6,3 +6,4 @@ examples:
6
6
  react:
7
7
  - pagination_default: Default
8
8
  - pagination_page_change: Page Change
9
+ - pagination_external_control: External Control
@@ -1,2 +1,3 @@
1
1
  export { default as PaginationDefault } from './_pagination_default.jsx'
2
2
  export { default as PaginationPageChange } from './_pagination_page_change.jsx'
3
+ export { default as PaginationExternalControl } from './_pagination_external_control.jsx'
@@ -7,7 +7,7 @@
7
7
  thead tr:not(:first-child) th {
8
8
  border-right: 1px solid $border_light !important;
9
9
  }
10
-
10
+
11
11
  @media screen and (min-width: $screen-xs-min) {
12
12
  tr:hover, .pb_table_tr:hover {
13
13
  td:last-child, .pb_table_td:last-child {
@@ -15,5 +15,53 @@
15
15
  }
16
16
  }
17
17
  }
18
+
19
+ // Firefox-specific fix for sticky elements
20
+ @-moz-document url-prefix() {
21
+ // Target sticky headers
22
+ &.sticky-header {
23
+ th:not(:last-child) {
24
+ border-right: none !important;
25
+ box-shadow: 1px 0 0 0 $border_light !important;
26
+ }
27
+
28
+ .pb_advanced_table_body {
29
+ .pinned-row {
30
+ td:not(:first-child):not(:last-child) {
31
+ border-right: none !important;
32
+ box-shadow: 1px 0 0 0 $border_light !important;
33
+ }
34
+ }
35
+ }
36
+ }
37
+
38
+ // Target sticky left columns
39
+ &.sticky-left-column {
40
+ td[style="left"], th[style="left"] {
41
+ border-right: none !important;
42
+ box-shadow: 1px 0 0 0 $border_light !important;
43
+ }
44
+ }
45
+
46
+ // Target sticky right columns
47
+ &.sticky-right-column {
48
+ td[style="right"], th[style="right"] {
49
+ border-right: none !important;
50
+ box-shadow: 1px 0 0 0 $border_light !important;
51
+ }
52
+ }
53
+
54
+ // Handle hover states in Firefox
55
+ @media screen and (min-width: $screen-xs-min) {
56
+ tr:hover, .pb_table_tr:hover {
57
+ td:last-child, .pb_table_td:last-child {
58
+ &[style="left"], &[style="right"] {
59
+ border-right: none !important;
60
+ box-shadow: 1px 0 0 0 darken($border_light, 10%) !important;
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
18
66
  }
19
67
  }
@@ -0,0 +1 @@
1
+ import{jsx,Fragment,jsxs}from"react/jsx-runtime";import{useMemo,useState,useEffect}from"react";import{b as buildDataProps,H as Highcharts,c as HighchartsReact,d as buildAriaProps,e as buildHtmlProps,f as HighchartsMore,g as classnames,h as globalProps,S as SolidGauge,i as buildCss}from"./_typeahead-CKvqSXWH.js";import{b as barGraphTheme,c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-BplzvaaY.js";const BarGraph=({options:options,containerProps:containerProps={},data:data={}})=>{const dataProps=buildDataProps(data);const mergedOptions=useMemo((()=>{if(!options||typeof options!=="object"){console.error("❌ Invalid options passed to <BarGraph />",options);return{}}return Highcharts.merge({},barGraphTheme,options)}),[options]);return jsx(HighchartsReact,{containerProps:{...containerProps,...dataProps},highcharts:Highcharts,options:mergedOptions})};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 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};