playbook_ui 15.0.0.pre.alpha.popovertesting10431 → 15.0.0
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_circle_icon_button/_circle_icon_button.tsx +0 -2
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +0 -1
- data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +0 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +4 -48
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default.html.erb +1 -24
- data/app/pb_kits/playbook/pb_dialog/_close_icon.tsx +1 -5
- data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +8 -6
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +1 -1
- data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +65 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +2 -2
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +2 -13
- data/app/pb_kits/playbook/pb_icon/icon.rb +1 -9
- data/app/pb_kits/playbook/pb_icon_circle/icon_circle.html.erb +1 -1
- data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.tsx +1 -3
- data/app/pb_kits/playbook/pb_loading_inline/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_loading_inline/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_loading_inline/loading_inline.html.erb +1 -1
- data/app/pb_kits/playbook/pb_loading_inline/loading_inline.rb +0 -11
- data/app/pb_kits/playbook/pb_popover/index.ts +66 -120
- data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +0 -3
- data/app/pb_kits/playbook/pb_text_input/docs/example.yml +0 -3
- data/app/pb_kits/playbook/pb_text_input/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +3 -2
- data/app/pb_kits/playbook/pb_text_input/text_input.test.js +0 -38
- data/dist/chunks/{_line_graph-smu35i9u.js → _line_graph-CIyKqNGy.js} +1 -1
- data/dist/chunks/_typeahead-B-mDRLxH.js +6 -0
- data/dist/chunks/_weekday_stacked-B_lp1Spt.js +37 -0
- data/dist/chunks/{lib-82dcKEqL.js → lib-DgtxnJqa.js} +2 -2
- data/dist/chunks/{pb_form_validation-CYLBbwKB.js → pb_form_validation-_NsOWfBS.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +2 -2
- metadata +8 -12
- data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_variant.html.erb +0 -5
- data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_variant.jsx +0 -24
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_autocomplete.html.erb +0 -41
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_autocomplete.jsx +0 -80
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_autocomplete.md +0 -1
- data/dist/chunks/_typeahead-C5hUPymw.js +0 -6
- data/dist/chunks/_weekday_stacked-BXuXb72b.js +0 -37
@@ -1,182 +1,128 @@
|
|
1
1
|
import PbEnhancedElement from '../pb_enhanced_element'
|
2
|
-
import { createPopper, Instance, Placement
|
2
|
+
import { createPopper, Instance, Placement } from '@popperjs/core'
|
3
3
|
|
4
4
|
const POPOVER_OFFSET_Y = [0, 20]
|
5
5
|
|
6
6
|
export default class PbPopover extends PbEnhancedElement {
|
7
|
-
popper
|
8
|
-
_triggerElement
|
9
|
-
_tooltip
|
10
|
-
element
|
11
|
-
|
12
|
-
private _onDocClick!: (e: MouseEvent) => void
|
13
|
-
private _docListenerAttached = false
|
14
|
-
private _baseModifiers: Options['modifiers'] = []
|
15
|
-
private _isShown = false
|
16
|
-
|
7
|
+
popper: Instance
|
8
|
+
_triggerElement: HTMLElement
|
9
|
+
_tooltip: HTMLElement
|
10
|
+
element: HTMLElement
|
17
11
|
static get selector() {
|
18
12
|
return '[data-pb-popover-kit]'
|
19
13
|
}
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
moveTooltip() {
|
16
|
+
let container: HTMLElement | null = document.querySelector('body');
|
17
|
+
|
18
|
+
if (this.appendTo === "parent") {
|
19
|
+
container = this.element.parentElement && this.element.parentElement
|
20
|
+
} else if (this.appendTo) {
|
21
|
+
container = document.querySelector(this.appendTo)
|
22
|
+
}
|
25
23
|
|
24
|
+
container.appendChild(this.tooltip);
|
25
|
+
}
|
26
|
+
|
27
|
+
connect() {
|
26
28
|
if (!this.triggerElement || !this.tooltip) {
|
27
29
|
console.warn('Popover requires both trigger and tooltip elements to be defined.')
|
28
30
|
return
|
29
31
|
}
|
32
|
+
this.moveTooltip()
|
30
33
|
|
31
|
-
this.
|
32
|
-
|
33
|
-
// Prepare Popper with event listeners disabled by default
|
34
|
-
this._baseModifiers = [
|
35
|
-
{ name: 'offset', options: { offset: this.offset } },
|
36
|
-
{ name: 'eventListeners', enabled: false },
|
37
|
-
]
|
38
|
-
|
39
|
-
this.popper = createPopper(this.triggerElement, this.tooltip, {
|
40
|
-
placement: (this.position as Placement) || 'bottom',
|
34
|
+
this.popper = createPopper (this.triggerElement, this.tooltip, {
|
35
|
+
placement: this.position as Placement,
|
41
36
|
strategy: 'fixed',
|
42
|
-
modifiers:
|
37
|
+
modifiers: [
|
38
|
+
{
|
39
|
+
name: 'offset',
|
40
|
+
options: {
|
41
|
+
offset: this.offset,
|
42
|
+
},
|
43
|
+
},
|
44
|
+
],
|
43
45
|
})
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
// Attach a single delegated doc listener per instance
|
49
|
-
document.addEventListener('click', this._onDocClick, true)
|
50
|
-
this._docListenerAttached = true
|
51
|
-
}
|
52
|
-
|
53
|
-
disconnect() {
|
54
|
-
if (this._docListenerAttached) {
|
55
|
-
document.removeEventListener('click', this._onDocClick, true)
|
56
|
-
this._docListenerAttached = false
|
57
|
-
}
|
58
|
-
if (this.triggerElement) {
|
59
|
-
this.triggerElement.removeEventListener('click', this.handleTriggerClick as any)
|
60
|
-
}
|
61
|
-
if (this.popper) this.popper.destroy()
|
62
|
-
}
|
63
|
-
|
64
|
-
// --- event handlers ---
|
65
|
-
|
66
|
-
private handleTriggerClick = (event: Event) => {
|
67
|
-
event.preventDefault()
|
68
|
-
event.stopPropagation()
|
47
|
+
this.triggerElement.addEventListener('click', (event: Event) => {
|
48
|
+
event.preventDefault()
|
49
|
+
event.stopPropagation()
|
69
50
|
|
70
|
-
|
71
|
-
|
72
|
-
if (this._isShown) {
|
73
|
-
this.hideTooltip()
|
74
|
-
} else {
|
75
|
-
this.showTooltip()
|
51
|
+
if (!this.tooltip.classList.contains('show')) {
|
52
|
+
this.checkCloseTooltip()
|
76
53
|
}
|
54
|
+
|
55
|
+
setTimeout(() => {
|
56
|
+
this.toggleTooltip()
|
57
|
+
this.popper.update()
|
58
|
+
}, 0)
|
77
59
|
})
|
78
60
|
}
|
79
61
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
const insideTooltip = !!target && !!target.closest(`#${this.tooltipId}`)
|
85
|
-
const insideTrigger = !!target && !!target.closest(`#${this.triggerElementId}`)
|
62
|
+
checkCloseTooltip() {
|
63
|
+
document.querySelector('body').addEventListener('click', ({ target } ) => {
|
64
|
+
const isTooltipElement = (target as HTMLElement).closest(`#${this.tooltipId}`) !== null
|
65
|
+
const isTriggerElement = (target as HTMLElement).closest(`#${this.triggerElementId}`) !== null
|
86
66
|
|
87
|
-
|
67
|
+
switch (this.closeOnClick) {
|
88
68
|
case 'any':
|
89
|
-
if (
|
69
|
+
if (isTooltipElement || !isTooltipElement && !isTriggerElement) {
|
70
|
+
this.hideTooltip()
|
71
|
+
}
|
90
72
|
break
|
91
73
|
case 'outside':
|
92
|
-
if (!
|
74
|
+
if (!isTooltipElement && !isTriggerElement) {
|
75
|
+
this.hideTooltip()
|
76
|
+
}
|
93
77
|
break
|
94
78
|
case 'inside':
|
95
|
-
if (
|
79
|
+
if (isTooltipElement) {
|
80
|
+
this.hideTooltip()
|
81
|
+
}
|
96
82
|
break
|
97
|
-
|
98
|
-
|
99
|
-
break
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
// --- show/hide ---
|
104
|
-
|
105
|
-
showTooltip() {
|
106
|
-
if (!this.tooltip) return
|
107
|
-
this.tooltip.classList.add('show')
|
108
|
-
this.tooltip.classList.remove('hide')
|
109
|
-
this._isShown = true
|
110
|
-
this.setEventListenersEnabled(true)
|
111
|
-
// force immediate position calc (faster than awaiting .update())
|
112
|
-
this.popper.forceUpdate()
|
83
|
+
}
|
84
|
+
}, true)
|
113
85
|
}
|
114
86
|
|
115
87
|
hideTooltip() {
|
116
|
-
if (!this.tooltip) return
|
117
88
|
this.tooltip.classList.remove('show')
|
118
89
|
this.tooltip.classList.add('hide')
|
119
|
-
this._isShown = false
|
120
|
-
this.setEventListenersEnabled(false)
|
121
90
|
}
|
122
91
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
const appendTo = this.appendTo
|
127
|
-
let container: HTMLElement = document.body
|
128
|
-
|
129
|
-
if (appendTo === 'parent' && this.element.parentElement) {
|
130
|
-
container = this.element.parentElement
|
131
|
-
} else if (appendTo && appendTo !== 'parent') {
|
132
|
-
const el = document.querySelector(appendTo)
|
133
|
-
if (el instanceof HTMLElement) container = el
|
134
|
-
}
|
135
|
-
|
136
|
-
if (this.tooltip && this.tooltip.parentElement !== container) {
|
137
|
-
container.appendChild(this.tooltip)
|
138
|
-
}
|
139
|
-
}
|
140
|
-
|
141
|
-
private setEventListenersEnabled(enabled: boolean) {
|
142
|
-
// Toggle Popper's scroll/resize listeners only when visible (perf win)
|
143
|
-
const mods = (this._baseModifiers || []).map((m) =>
|
144
|
-
m.name === 'eventListeners' ? { ...m, enabled } : m
|
145
|
-
)
|
146
|
-
this.popper.setOptions((opts) => ({ ...opts, modifiers: mods }))
|
92
|
+
toggleTooltip() {
|
93
|
+
this.tooltip.classList.toggle('show')
|
94
|
+
this.tooltip.classList.toggle('hide')
|
147
95
|
}
|
148
96
|
|
149
|
-
// --- getters ---
|
150
|
-
|
151
97
|
get triggerElement() {
|
152
|
-
return this._triggerElement
|
98
|
+
return this._triggerElement = (this._triggerElement || document.querySelector(`#${this.triggerElementId}`))
|
153
99
|
}
|
154
100
|
|
155
101
|
get tooltip() {
|
156
|
-
return this._tooltip
|
102
|
+
return this._tooltip = (this._tooltip || this.element.querySelector(`#${this.tooltipId}`))
|
157
103
|
}
|
158
104
|
|
159
105
|
get position() {
|
160
|
-
return this.element.dataset.pbPopoverPosition
|
106
|
+
return this.element.dataset.pbPopoverPosition
|
161
107
|
}
|
162
108
|
|
163
109
|
get triggerElementId() {
|
164
|
-
return this.element.dataset.pbPopoverTriggerElementId
|
110
|
+
return this.element.dataset.pbPopoverTriggerElementId
|
165
111
|
}
|
166
112
|
|
167
113
|
get tooltipId() {
|
168
|
-
return this.element.dataset.pbPopoverTooltipId
|
114
|
+
return this.element.dataset.pbPopoverTooltipId
|
169
115
|
}
|
170
116
|
|
171
|
-
get offset()
|
117
|
+
get offset() {
|
172
118
|
return this.element.dataset.pbPopoverOffset === 'true' ? POPOVER_OFFSET_Y : [0, 0]
|
173
119
|
}
|
174
120
|
|
175
|
-
get closeOnClick()
|
176
|
-
return this.element.dataset.pbPopoverCloseOnClick
|
121
|
+
get closeOnClick() {
|
122
|
+
return this.element.dataset.pbPopoverCloseOnClick
|
177
123
|
}
|
178
124
|
|
179
125
|
get appendTo() {
|
180
|
-
return this.element.dataset.pbPopoverAppendTo
|
126
|
+
return this.element.dataset.pbPopoverAppendTo;
|
181
127
|
}
|
182
128
|
}
|
@@ -36,7 +36,6 @@ type TextInputProps = {
|
|
36
36
|
alignment?: "right" | "left",
|
37
37
|
border?: boolean,
|
38
38
|
},
|
39
|
-
autoComplete?: boolean | string,
|
40
39
|
} & GlobalProps
|
41
40
|
|
42
41
|
const TextInput = (props: TextInputProps, ref: React.LegacyRef<HTMLInputElement>) => {
|
@@ -60,7 +59,6 @@ const TextInput = (props: TextInputProps, ref: React.LegacyRef<HTMLInputElement>
|
|
60
59
|
type = 'text',
|
61
60
|
value = '',
|
62
61
|
children = null,
|
63
|
-
autoComplete = true,
|
64
62
|
} = props
|
65
63
|
|
66
64
|
const ariaProps = buildAriaProps(aria)
|
@@ -144,7 +142,6 @@ const TextInput = (props: TextInputProps, ref: React.LegacyRef<HTMLInputElement>
|
|
144
142
|
childInput ? React.cloneElement(children, { className: "text_input" }) :
|
145
143
|
(<input
|
146
144
|
{...domSafeProps(props)}
|
147
|
-
autoComplete={typeof autoComplete === "string" ? autoComplete : ( autoComplete ? undefined : "off" )}
|
148
145
|
className="text_input"
|
149
146
|
disabled={disabled}
|
150
147
|
id={id}
|
@@ -9,8 +9,6 @@ examples:
|
|
9
9
|
- text_input_no_label: No Label
|
10
10
|
- text_input_options: Input Options
|
11
11
|
- text_input_mask: Mask
|
12
|
-
- text_input_autocomplete: Autocomplete
|
13
|
-
|
14
12
|
react:
|
15
13
|
- text_input_default: Default
|
16
14
|
- text_input_error: With Error
|
@@ -21,7 +19,6 @@ examples:
|
|
21
19
|
- text_input_no_label: No Label
|
22
20
|
- text_input_mask: Mask
|
23
21
|
- text_input_sanitize: Sanitized Masked Input
|
24
|
-
- text_input_autocomplete: Autocomplete
|
25
22
|
|
26
23
|
|
27
24
|
swift:
|
@@ -7,4 +7,3 @@ export { default as TextInputInline } from './_text_input_inline.jsx'
|
|
7
7
|
export { default as TextInputNoLabel } from './_text_input_no_label.jsx'
|
8
8
|
export { default as TextInputMask } from './_text_input_mask.jsx'
|
9
9
|
export { default as TextInputSanitize } from './_text_input_sanitize.jsx'
|
10
|
-
export { default as TextInputAutocomplete } from './_text_input_autocomplete.jsx'
|
@@ -15,7 +15,8 @@ module Playbook
|
|
15
15
|
"cvv" => '\d{3,4}',
|
16
16
|
}.freeze
|
17
17
|
|
18
|
-
prop :autocomplete,
|
18
|
+
prop :autocomplete, type: Playbook::Props::Boolean,
|
19
|
+
default: true
|
19
20
|
prop :disabled, type: Playbook::Props::Boolean,
|
20
21
|
default: false
|
21
22
|
prop :error
|
@@ -68,7 +69,7 @@ module Playbook
|
|
68
69
|
|
69
70
|
def all_input_options
|
70
71
|
{
|
71
|
-
autocomplete: autocomplete
|
72
|
+
autocomplete: autocomplete ? nil : "off",
|
72
73
|
class: "text_input #{input_options.dig(:classname) || ''}",
|
73
74
|
data: validation_data,
|
74
75
|
disabled: disabled,
|
@@ -306,41 +306,3 @@ test('returns masked CVV value', () => {
|
|
306
306
|
|
307
307
|
expect(input.value).toBe('')
|
308
308
|
})
|
309
|
-
|
310
|
-
test('adds autocomplete string attribute', () => {
|
311
|
-
render(
|
312
|
-
<TextInput
|
313
|
-
autoComplete="family-name"
|
314
|
-
data={{ testid: testId }}
|
315
|
-
/>
|
316
|
-
)
|
317
|
-
|
318
|
-
const kit = screen.getByTestId(testId)
|
319
|
-
const input = within(kit).getByRole('textbox')
|
320
|
-
expect(input).toHaveAttribute("autocomplete", "family-name")
|
321
|
-
})
|
322
|
-
|
323
|
-
test('adds autocomplete "off" attribute', () => {
|
324
|
-
render(
|
325
|
-
<TextInput
|
326
|
-
autoComplete={false}
|
327
|
-
data={{ testid: testId }}
|
328
|
-
/>
|
329
|
-
)
|
330
|
-
|
331
|
-
const kit = screen.getByTestId(testId)
|
332
|
-
const input = within(kit).getByRole('textbox')
|
333
|
-
expect(input).toHaveAttribute("autocomplete", "off")
|
334
|
-
})
|
335
|
-
|
336
|
-
test('does not add autocomplete attribute otherwise', () => {
|
337
|
-
render(
|
338
|
-
<TextInput
|
339
|
-
data={{ testid: testId }}
|
340
|
-
/>
|
341
|
-
)
|
342
|
-
|
343
|
-
const kit = screen.getByTestId(testId)
|
344
|
-
const input = within(kit).getByRole('textbox')
|
345
|
-
expect(input).not.toHaveAttribute("autocomplete")
|
346
|
-
})
|
@@ -1 +1 @@
|
|
1
|
-
import{jsx,Fragment,jsxs}from"react/jsx-runtime";import{useState,useEffect}from"react";import{b as buildAriaProps,c as buildDataProps,d as buildHtmlProps,H as HighchartsReact,e as Highcharts,f as classnames,g as globalProps,h as HighchartsMore,S as SolidGauge,i as buildCss}from"./_typeahead-C5hUPymw.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-82dcKEqL.js";const mapColors=array=>{const regex=/(data)\-[1-8]/;const newArray=array.map((item=>regex.test(item)?`${colors[`data_${item[item.length-1]}`]}`:item));return newArray};const BarGraph=({aria:aria={},data:data={},align:align="center",axisTitle:axisTitle,dark:dark=false,chartData:chartData,className:className="pb_bar_graph",colors:colors2,htmlOptions:htmlOptions={},customOptions:customOptions={},axisFormat:axisFormat,id:id,pointStart:pointStart,stacking:stacking,subTitle:subTitle,type:type="column",title:title="Title",xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,legend:legend=false,toggleLegendClick:toggleLegendClick=true,height:height,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:[{labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat&&axisFormat[0]?axisFormat[0].format:""},min:yAxisMin,max:yAxisMax,opposite:false,title:{text:Array.isArray(axisTitle)?axisTitle.length>0?axisTitle[0].name:null:axisTitle},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]}],xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{stacking:stacking,pointStart:pointStart,borderWidth:stacking?0:"",events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(Array.isArray(axisTitle)&&axisTitle.length>1&&axisTitle[1].name){staticOptions.yAxis.push({labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat[1].format},min:yAxisMin,max:yAxisMax,opposite:true,title:{text:axisTitle[1].name},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]})}if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const alignBlockElement=event=>{const itemToMove=document.querySelector(`#wrapper-circle-chart-${event.target.renderTo.id} .pb-circle-chart-block`);const chartContainer=document.querySelector(`#${event.target.renderTo.id}`);if(itemToMove!==null&&chartContainer!==null){itemToMove.style.height=`${event.target.chartHeight}px`;itemToMove.style.width=`${event.target.chartWidth}px`;if(chartContainer.firstChild!==null){chartContainer.firstChild.before(itemToMove)}}};const CircleChart=({align:align="center",aria:aria={},rounded:rounded=false,borderColor:borderColor=(rounded?null:""),borderWidth:borderWidth=(rounded?20:null),chartData:chartData,children:children,className:className,colors:colors2=[],customOptions:customOptions={},dark:dark=false,data:data={},dataLabelHtml:dataLabelHtml="<div>{point.name}</div>",dataLabels:dataLabels=false,height:height,htmlOptions:htmlOptions={},id:id,innerSize:innerSize="md",legend:legend=false,maxPointSize:maxPointSize=null,minPointSize:minPointSize=null,startAngle:startAngle=null,style:style="pie",title:title,tooltipHtml:tooltipHtml,useHtml:useHtml=false,zMin:zMin=null,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{headerFormat:null,pointFormat:tooltipHtml?tooltipHtml:'<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',useHTML:useHtml}});const innerSizes={sm:"35%",md:"50%",lg:"85%",none:"0%"};const innerSizeFormat=size=>innerSizes[size];const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={title:{text:title},chart:{height:height,type:style,events:{render:event=>alignBlockElement(event),redraw:event=>alignBlockElement(event)}},legend:{align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},plotOptions:{pie:{colors:colors2.length>0?mapColors(colors2):highchartsTheme.colors,dataLabels:{enabled:dataLabels,connectorShape:"straight",connectorWidth:3,format:dataLabelHtml},showInLegend:legend}},series:[{minPointSize:minPointSize,maxPointSize:maxPointSize,innerSize:borderWidth==20?"100%":innerSizeFormat(innerSize),data:formattedChartData,zMin:zMin,startAngle:startAngle,borderWidth:borderWidth,borderColor:borderColor}],credits:false};setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(Fragment,{children:children?jsxs("div",{id:`wrapper-circle-chart-${id}`,children:[jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options}),jsx("div",{className:"pb-circle-chart-block",children:children})]}):jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})})};const Gauge=({aria:aria={},chartData:chartData,customOptions:customOptions={},dark:dark=false,data:data={},disableAnimation:disableAnimation=false,fullCircle:fullCircle=false,height:height=null,htmlOptions:htmlOptions={},id:id,max:max=100,min:min=0,prefix:prefix="",showLabels:showLabels=false,style:style="solidgauge",suffix:suffix="",title:title="",tooltipHtml:tooltipHtml='<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',colors:colors$1=[],minorTickInterval:minorTickInterval=null,circumference:circumference=(fullCircle?[0,360]:[-100,100]),...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);SolidGauge(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{pointFormat:tooltipHtml,followPointer:true}});const css=buildCss({pb_gauge_kit:true});const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={chart:{events:{load(){setTimeout(this.reflow.bind(this),0)}},type:style,height:height},title:{text:title},yAxis:{min:min,max:max,lineWidth:0,tickWidth:0,minorTickInterval:minorTickInterval,tickAmount:2,tickPositions:[min,max],labels:{y:26,enabled:showLabels}},credits:false,series:[{data:formattedChartData}],pane:{center:["50%","50%"],size:"90%",startAngle:circumference[0],endAngle:circumference[1],background:{borderWidth:20,innerRadius:"90%",outerRadius:"90%",shape:"arc",className:"gauge-pane"}},colors:colors$1!==void 0&&colors$1.length>0?mapColors(colors$1):highchartsTheme.colors,plotOptions:{series:{animation:!disableAnimation},solidgauge:{borderColor:colors$1!==void 0&&colors$1.length===1?mapColors(colors$1).join():highchartsTheme.colors[0],borderWidth:20,radius:90,innerRadius:"90%",dataLabels:{borderWidth:0,color:colors.text_lt_default,enabled:true,format:`<span class="prefix${dark?" dark":""}">${prefix}</span><span class="fix${dark?" dark":""}">{y:,f}</span><span class="suffix${dark?" dark":""}">${suffix}</span>`,style:{fontFamily:typography.font_family_base,fontWeight:typography.regular,fontSize:typography.heading_2},y:-26}}}};setOptions(merge(staticOptions,customOptions));if(document.querySelector(".prefix")){document.querySelectorAll(".prefix").forEach((prefix2=>{prefix2.setAttribute("y","28")}));document.querySelectorAll(".fix").forEach((fix=>fix.setAttribute("y","38")))}}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(css,globalProps(props)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const LineGraph=({aria:aria={},data:data={},align:align="center",className:className="pb_bar_graph",customOptions:customOptions={},dark:dark=false,gradient:gradient=false,type:type="line",htmlOptions:htmlOptions={},id:id,legend:legend=false,toggleLegendClick:toggleLegendClick=true,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,axisTitle:axisTitle,xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,chartData:chartData,pointStart:pointStart,subTitle:subTitle,title:title,height:height,colors:colors2=[],...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:{min:yAxisMin,max:yAxisMax,title:{text:axisTitle}},xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{pointStart:pointStart,events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};export{BarGraph as B,CircleChart as C,Gauge as G,LineGraph as L};
|
1
|
+
import{jsx,Fragment,jsxs}from"react/jsx-runtime";import{useState,useEffect}from"react";import{b as buildAriaProps,c as buildDataProps,d as buildHtmlProps,H as HighchartsReact,e as Highcharts,f as classnames,g as globalProps,h as HighchartsMore,S as SolidGauge,i as buildCss}from"./_typeahead-B-mDRLxH.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-DgtxnJqa.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};
|