playbook_ui 14.23.0.pre.rc.1 → 14.23.0.pre.rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +7 -6
- data/app/pb_kits/playbook/pb_badge/_badge.scss +5 -6
- data/app/pb_kits/playbook/pb_bar_graph/barGraphTheme.ts +106 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_colors.jsx +33 -15
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_default.jsx +33 -15
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_height.jsx +52 -22
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_height.md +3 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_horizontal.jsx +12 -16
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend.jsx +31 -15
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_non_clickable.jsx +39 -16
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.jsx +86 -38
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_negative_numbers.jsx +32 -15
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_secondary_y_axis.jsx +72 -22
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_secondary_y_axis.md +1 -1
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_spline.jsx +31 -15
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_stacked.jsx +37 -16
- data/app/pb_kits/playbook/pb_bar_graph/docs/_description.md +1 -3
- data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +1 -3
- data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +0 -2
- data/app/pb_kits/playbook/pb_body/docs/_body_truncate.jsx +3 -3
- data/app/pb_kits/playbook/pb_body/docs/_body_truncate_react.md +4 -0
- data/app/pb_kits/playbook/pb_circle_chart/circleChartTheme.ts +36 -1
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_block.jsx +71 -26
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_colors.jsx +29 -16
- data/app/pb_kits/playbook/pb_circle_chart/docs/{_circle_chart_colors.md → _circle_chart_colors_rails.md} +1 -1
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_colors_react.md +2 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_custom_tooltip.jsx +28 -16
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_custom_tooltip.md +4 -2
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_default.jsx +23 -15
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_inner_sizes.jsx +81 -51
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.jsx +103 -75
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.md +3 -6
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_live_data.jsx +19 -13
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_rounded.jsx +30 -17
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_labels.jsx +34 -20
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_legend_kit.jsx +29 -20
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_title.jsx +28 -20
- data/app/pb_kits/playbook/pb_circle_chart/docs/_description.md +1 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_circle_chart/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +12 -4
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +5 -2
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +27 -17
- data/app/pb_kits/playbook/pb_title/docs/_title_truncate.jsx +3 -3
- data/app/pb_kits/playbook/pb_title/docs/_title_truncate_react.md +4 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_click_open.html.erb +14 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_click_open_rails.md +1 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_tooltip/index.js +59 -36
- data/app/pb_kits/playbook/pb_tooltip/tooltip.rb +9 -2
- data/dist/chunks/_circle_chart-BZmlhBs2.js +1 -0
- data/dist/chunks/{_typeahead-B7FRYVtS.js → _typeahead-B1tu_vWi.js} +3 -3
- data/dist/chunks/{_weekday_stacked-ClwpVoVy.js → _weekday_stacked-CKk0dR5s.js} +1 -1
- data/dist/chunks/{lib-Carqm8Ip.js → lib-DYpq0k8j.js} +1 -1
- data/dist/chunks/{pb_form_validation-DqRmTS8m.js → pb_form_validation-BUOKwfvW.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +68 -8
- data/dist/playbook-doc.js +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +19 -16
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom.jsx +0 -72
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom.md +0 -6
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.jsx +0 -64
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_pb_styles.md +0 -1
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_pb_styles.jsx +0 -38
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_pb_styles.md +0 -1
- /data/app/pb_kits/playbook/pb_body/docs/{_body_truncate.md → _body_truncate_rails.md} +0 -0
- /data/app/pb_kits/playbook/pb_title/docs/{_title_truncate.md → _title_truncate_rails.md} +0 -0
- /data/app/pb_kits/playbook/pb_tooltip/docs/{_tooltip_click_open.md → _tooltip_click_open_react.md} +0 -0
@@ -6,14 +6,16 @@ export interface ItemType {
|
|
6
6
|
|
7
7
|
export interface InitialStateType {
|
8
8
|
items: ItemType[];
|
9
|
-
dragData: { id: string; initialGroup: string };
|
9
|
+
dragData: { id: string; initialGroup: string, originId?: string };
|
10
10
|
isDragging: string;
|
11
11
|
activeContainer: string;
|
12
12
|
}
|
13
13
|
|
14
14
|
export type ActionType =
|
15
15
|
| { type: 'SET_ITEMS'; payload: ItemType[] }
|
16
|
-
| { type: 'SET_DRAG_DATA'; payload: {
|
16
|
+
| { type: 'SET_DRAG_DATA'; payload: {
|
17
|
+
originId: string; id: string; initialGroup: string
|
18
|
+
} }
|
17
19
|
| { type: 'SET_IS_DRAGGING'; payload: string }
|
18
20
|
| { type: 'SET_ACTIVE_CONTAINER'; payload: string }
|
19
21
|
| { type: 'CHANGE_CATEGORY'; payload: { itemId: string; container: string } }
|
@@ -35,4 +37,5 @@ export type ActionType =
|
|
35
37
|
onDrop?: (container: string) => void;
|
36
38
|
onDragOver?: (e: Event, container: string) => void;
|
37
39
|
dropZone?: DropZoneConfig | string; // Can accept string for backward compatibility
|
40
|
+
providerId?: string;
|
38
41
|
}
|
@@ -68,7 +68,7 @@ const containOnlyNumbers = (value: string) => {
|
|
68
68
|
return /^[()+\-\ .\d]*$/g.test(value)
|
69
69
|
}
|
70
70
|
|
71
|
-
const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.
|
71
|
+
const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>) => {
|
72
72
|
const {
|
73
73
|
aria = {},
|
74
74
|
className,
|
@@ -106,15 +106,16 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
106
106
|
className
|
107
107
|
)
|
108
108
|
|
109
|
-
const inputRef = useRef<HTMLInputElement>()
|
109
|
+
const inputRef = useRef<HTMLInputElement | null>(null)
|
110
110
|
const itiRef = useRef<any>(null);
|
111
111
|
const [inputValue, setInputValue] = useState(value)
|
112
112
|
const [error, setError] = useState(props.error)
|
113
113
|
const [dropDownIsOpen, setDropDownIsOpen] = useState(false)
|
114
114
|
const [selectedData, setSelectedData] = useState()
|
115
|
+
const [hasTyped, setHasTyped] = useState(false)
|
115
116
|
|
116
117
|
useEffect(() => {
|
117
|
-
if (error
|
118
|
+
if ((error ?? '').length > 0) {
|
118
119
|
onValidate(false)
|
119
120
|
} else {
|
120
121
|
onValidate(true)
|
@@ -131,6 +132,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
131
132
|
clearField() {
|
132
133
|
setInputValue("")
|
133
134
|
setError("")
|
135
|
+
setHasTyped(false)
|
134
136
|
},
|
135
137
|
inputNode() {
|
136
138
|
return inputRef.current
|
@@ -201,6 +203,8 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
201
203
|
}
|
202
204
|
|
203
205
|
const validateErrors = () => {
|
206
|
+
if (!hasTyped && !error) return
|
207
|
+
|
204
208
|
if (itiRef.current) isValid(itiRef.current.isValidNumber())
|
205
209
|
if (validateOnlyNumbers(itiRef.current)) return
|
206
210
|
if (validateTooLongNumber(itiRef.current)) return
|
@@ -214,6 +218,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
214
218
|
}
|
215
219
|
|
216
220
|
const handleOnChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
|
221
|
+
if (!hasTyped) setHasTyped(true)
|
217
222
|
setInputValue(evt.target.value)
|
218
223
|
let phoneNumberData
|
219
224
|
if (formatAsYouType) {
|
@@ -259,16 +264,17 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
259
264
|
|
260
265
|
itiRef.current = telInputInit;
|
261
266
|
|
262
|
-
inputRef.current
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
inputRef.current.addEventListener("open:countrydropdown", () => setDropDownIsOpen(true))
|
270
|
-
inputRef.current.addEventListener("close:countrydropdown", () => setDropDownIsOpen(false))
|
267
|
+
if (inputRef.current) {
|
268
|
+
inputRef.current.addEventListener("countrychange", (evt: Event) => {
|
269
|
+
const phoneNumberData = getCurrentSelectedData(telInputInit, (evt.target as HTMLInputElement).value)
|
270
|
+
setSelectedData(phoneNumberData)
|
271
|
+
onChange(phoneNumberData)
|
272
|
+
validateErrors()
|
273
|
+
})
|
271
274
|
|
275
|
+
inputRef.current.addEventListener("open:countrydropdown", () => setDropDownIsOpen(true))
|
276
|
+
inputRef.current.addEventListener("close:countrydropdown", () => setDropDownIsOpen(false))
|
277
|
+
}
|
272
278
|
if (formatAsYouType) {
|
273
279
|
inputRef.current?.addEventListener("input", (evt) => {
|
274
280
|
handleOnChange(evt as unknown as React.ChangeEvent<HTMLInputElement>);
|
@@ -303,12 +309,16 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
303
309
|
{...htmlProps}
|
304
310
|
>
|
305
311
|
<TextInput
|
306
|
-
ref={
|
307
|
-
|
308
|
-
|
309
|
-
|
312
|
+
ref={inputNode => {
|
313
|
+
if (ref) {
|
314
|
+
if (typeof ref === 'function') {
|
315
|
+
ref(inputNode)
|
316
|
+
} else {
|
317
|
+
(ref as React.MutableRefObject<HTMLInputElement | null>).current = inputNode
|
318
|
+
}
|
310
319
|
}
|
311
|
-
|
320
|
+
inputRef.current = inputNode
|
321
|
+
}}
|
312
322
|
{...textInputProps}
|
313
323
|
/>
|
314
324
|
</div>
|
@@ -20,7 +20,7 @@ const TitleTruncate = (props) => {
|
|
20
20
|
marginBottom="md"
|
21
21
|
size={4}
|
22
22
|
text={lorem}
|
23
|
-
truncate=
|
23
|
+
truncate={1}
|
24
24
|
{...props}
|
25
25
|
/>
|
26
26
|
|
@@ -32,7 +32,7 @@ const TitleTruncate = (props) => {
|
|
32
32
|
marginBottom="md"
|
33
33
|
size={4}
|
34
34
|
text={lorem}
|
35
|
-
truncate=
|
35
|
+
truncate={2}
|
36
36
|
{...props}
|
37
37
|
/>
|
38
38
|
|
@@ -43,7 +43,7 @@ const TitleTruncate = (props) => {
|
|
43
43
|
<Title
|
44
44
|
size={4}
|
45
45
|
text={lorem}
|
46
|
-
truncate=
|
46
|
+
truncate={3}
|
47
47
|
{...props}
|
48
48
|
/>
|
49
49
|
</Flex>
|
@@ -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.
|
@@ -19,60 +19,75 @@ export default class PbTooltip extends PbEnhancedElement {
|
|
19
19
|
}
|
20
20
|
|
21
21
|
this.triggerElements.forEach((trigger) => {
|
22
|
-
const method = this.
|
22
|
+
const method = this.effectiveTriggerMethod
|
23
23
|
const interactionEnabled = this.tooltipInteraction
|
24
24
|
|
25
25
|
if (method === 'click') {
|
26
|
-
trigger.addEventListener('click', () => {
|
27
|
-
this.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
}
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
69
|
-
this.
|
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.
|
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:
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
import{jsx,Fragment,jsxs}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,f as HighchartsMore}from"./_typeahead-B1tu_vWi.js";import{h as highchartsTheme,m as merge,a as highchartsDarkTheme}from"./lib-DYpq0k8j.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})};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:colors=[],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:colors.length>0?mapColors(colors):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})})};export{BarGraph as B,CircleChart as C};
|