playbook_ui 15.0.0.pre.alpha.play2377bargraphscaffoldnewkit10368 → 15.0.0.pre.alpha.popovertesting10431
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/_playbook.scss +0 -1
- data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.tsx +2 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +1 -0
- data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +1 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +48 -4
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default.html.erb +24 -1
- data/app/pb_kits/playbook/pb_dialog/_close_icon.tsx +5 -1
- data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +6 -8
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +1 -1
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +2 -2
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +13 -2
- data/app/pb_kits/playbook/pb_icon/icon.rb +9 -1
- 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 +3 -1
- data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_variant.html.erb +5 -0
- data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_variant.jsx +24 -0
- data/app/pb_kits/playbook/pb_loading_inline/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_loading_inline/docs/index.js +1 -0
- 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 +11 -0
- data/app/pb_kits/playbook/pb_popover/index.ts +120 -66
- data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +3 -0
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_autocomplete.html.erb +41 -0
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_autocomplete.jsx +80 -0
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_autocomplete.md +1 -0
- data/app/pb_kits/playbook/pb_text_input/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_text_input/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +2 -3
- data/app/pb_kits/playbook/pb_text_input/text_input.test.js +38 -0
- data/dist/chunks/{_line_graph-BNXbOd7G.js → _line_graph-smu35i9u.js} +1 -1
- data/dist/chunks/_typeahead-C5hUPymw.js +6 -0
- data/dist/chunks/_weekday_stacked-BXuXb72b.js +37 -0
- data/dist/chunks/{lib-CY5ZPzic.js → lib-82dcKEqL.js} +1 -1
- data/dist/chunks/{pb_form_validation-D3b0JKHH.js → pb_form_validation-CYLBbwKB.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +1 -9
- 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 +1 -1
- metadata +12 -41
- data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +0 -65
- data/app/pb_kits/playbook/pb_pb_bar_graph/_pb_bar_graph.scss +0 -0
- data/app/pb_kits/playbook/pb_pb_bar_graph/_pb_bar_graph.tsx +0 -62
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_colors.html.erb +0 -35
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_colors.jsx +0 -49
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_colors_rails.md +0 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_colors_react.md +0 -2
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_default.html.erb +0 -38
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_default.jsx +0 -51
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_height.html.erb +0 -46
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_height.jsx +0 -62
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_height.md +0 -3
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_horizontal.html.erb +0 -47
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_horizontal.jsx +0 -60
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_legend.html.erb +0 -25
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_legend.jsx +0 -36
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_legend_non_clickable.jsx +0 -44
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_legend_position.html.erb +0 -100
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_legend_position.jsx +0 -126
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_negative_numbers.html.erb +0 -32
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_negative_numbers.jsx +0 -48
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_secondary_y_axis.html.erb +0 -68
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_secondary_y_axis.jsx +0 -81
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_spline.html.erb +0 -31
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_spline.jsx +0 -42
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_spline.md +0 -2
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_stacked.html.erb +0 -35
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_stacked.jsx +0 -51
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/example.yml +0 -27
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/index.js +0 -11
- data/app/pb_kits/playbook/pb_pb_bar_graph/pbBarGraphTheme.ts +0 -106
- data/app/pb_kits/playbook/pb_pb_bar_graph/pb_bar_graph.html.erb +0 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/pb_bar_graph.rb +0 -28
- data/app/pb_kits/playbook/pb_pb_bar_graph/pbbargraph.test.jsx +0 -31
- data/dist/chunks/_typeahead-_OUsjdM2.js +0 -6
- data/dist/chunks/_weekday_stacked-B3B3vRAT.js +0 -37
@@ -1,128 +1,182 @@
|
|
1
1
|
import PbEnhancedElement from '../pb_enhanced_element'
|
2
|
-
import { createPopper, Instance, Placement } from '@popperjs/core'
|
2
|
+
import { createPopper, Instance, Placement, Options } 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
|
-
static get selector() {
|
12
|
-
return '[data-pb-popover-kit]'
|
13
|
-
}
|
7
|
+
popper!: Instance
|
8
|
+
_triggerElement!: HTMLElement | null
|
9
|
+
_tooltip!: HTMLElement | null
|
10
|
+
element!: HTMLElement
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
container = this.element.parentElement && this.element.parentElement
|
20
|
-
} else if (this.appendTo) {
|
21
|
-
container = document.querySelector(this.appendTo)
|
22
|
-
}
|
12
|
+
private _onDocClick!: (e: MouseEvent) => void
|
13
|
+
private _docListenerAttached = false
|
14
|
+
private _baseModifiers: Options['modifiers'] = []
|
15
|
+
private _isShown = false
|
23
16
|
|
24
|
-
|
17
|
+
static get selector() {
|
18
|
+
return '[data-pb-popover-kit]'
|
25
19
|
}
|
26
20
|
|
27
21
|
connect() {
|
22
|
+
// Resolve elements once with fast APIs
|
23
|
+
this._triggerElement = document.getElementById(this.triggerElementId) as HTMLElement | null
|
24
|
+
this._tooltip = (this.element.querySelector(`#${this.tooltipId}`) as HTMLElement | null)
|
25
|
+
|
28
26
|
if (!this.triggerElement || !this.tooltip) {
|
29
27
|
console.warn('Popover requires both trigger and tooltip elements to be defined.')
|
30
28
|
return
|
31
29
|
}
|
32
|
-
this.moveTooltip()
|
33
30
|
|
34
|
-
this.
|
35
|
-
|
31
|
+
this.moveTooltipOnce()
|
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',
|
36
41
|
strategy: 'fixed',
|
37
|
-
modifiers:
|
38
|
-
{
|
39
|
-
name: 'offset',
|
40
|
-
options: {
|
41
|
-
offset: this.offset,
|
42
|
-
},
|
43
|
-
},
|
44
|
-
],
|
42
|
+
modifiers: this._baseModifiers,
|
45
43
|
})
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
// Bind handlers once
|
46
|
+
this._onDocClick = this.handleDocumentClick.bind(this)
|
47
|
+
this.triggerElement.addEventListener('click', this.handleTriggerClick, { passive: true })
|
48
|
+
// Attach a single delegated doc listener per instance
|
49
|
+
document.addEventListener('click', this._onDocClick, true)
|
50
|
+
this._docListenerAttached = true
|
51
|
+
}
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
-
|
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()
|
54
69
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
70
|
+
// toggle with a microtask to let layout settle
|
71
|
+
Promise.resolve().then(() => {
|
72
|
+
if (this._isShown) {
|
73
|
+
this.hideTooltip()
|
74
|
+
} else {
|
75
|
+
this.showTooltip()
|
76
|
+
}
|
59
77
|
})
|
60
78
|
}
|
61
79
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
80
|
+
private handleDocumentClick(e: MouseEvent) {
|
81
|
+
if (!this.tooltip || !this.triggerElement) return
|
82
|
+
|
83
|
+
const target = e.target as HTMLElement | null
|
84
|
+
const insideTooltip = !!target && !!target.closest(`#${this.tooltipId}`)
|
85
|
+
const insideTrigger = !!target && !!target.closest(`#${this.triggerElementId}`)
|
66
86
|
|
67
|
-
|
87
|
+
switch (this.closeOnClick) {
|
68
88
|
case 'any':
|
69
|
-
if (
|
70
|
-
this.hideTooltip()
|
71
|
-
}
|
89
|
+
if (insideTooltip || (!insideTooltip && !insideTrigger)) this.hideTooltip()
|
72
90
|
break
|
73
91
|
case 'outside':
|
74
|
-
if (!
|
75
|
-
this.hideTooltip()
|
76
|
-
}
|
92
|
+
if (!insideTooltip && !insideTrigger) this.hideTooltip()
|
77
93
|
break
|
78
94
|
case 'inside':
|
79
|
-
if (
|
80
|
-
this.hideTooltip()
|
81
|
-
}
|
95
|
+
if (insideTooltip) this.hideTooltip()
|
82
96
|
break
|
83
|
-
|
84
|
-
|
97
|
+
default:
|
98
|
+
// no auto-close
|
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()
|
85
113
|
}
|
86
114
|
|
87
115
|
hideTooltip() {
|
116
|
+
if (!this.tooltip) return
|
88
117
|
this.tooltip.classList.remove('show')
|
89
118
|
this.tooltip.classList.add('hide')
|
119
|
+
this._isShown = false
|
120
|
+
this.setEventListenersEnabled(false)
|
90
121
|
}
|
91
122
|
|
92
|
-
|
93
|
-
|
94
|
-
|
123
|
+
// --- helpers ---
|
124
|
+
|
125
|
+
private moveTooltipOnce() {
|
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 }))
|
95
147
|
}
|
96
148
|
|
149
|
+
// --- getters ---
|
150
|
+
|
97
151
|
get triggerElement() {
|
98
|
-
return this._triggerElement
|
152
|
+
return this._triggerElement
|
99
153
|
}
|
100
154
|
|
101
155
|
get tooltip() {
|
102
|
-
return this._tooltip
|
156
|
+
return this._tooltip
|
103
157
|
}
|
104
158
|
|
105
159
|
get position() {
|
106
|
-
return this.element.dataset.pbPopoverPosition
|
160
|
+
return this.element.dataset.pbPopoverPosition || 'bottom'
|
107
161
|
}
|
108
162
|
|
109
163
|
get triggerElementId() {
|
110
|
-
return this.element.dataset.pbPopoverTriggerElementId
|
164
|
+
return this.element.dataset.pbPopoverTriggerElementId as string
|
111
165
|
}
|
112
166
|
|
113
167
|
get tooltipId() {
|
114
|
-
return this.element.dataset.pbPopoverTooltipId
|
168
|
+
return this.element.dataset.pbPopoverTooltipId as string
|
115
169
|
}
|
116
170
|
|
117
|
-
get offset() {
|
171
|
+
get offset(): [number, number] {
|
118
172
|
return this.element.dataset.pbPopoverOffset === 'true' ? POPOVER_OFFSET_Y : [0, 0]
|
119
173
|
}
|
120
174
|
|
121
|
-
get closeOnClick() {
|
122
|
-
return this.element.dataset.pbPopoverCloseOnClick
|
175
|
+
get closeOnClick(): 'any' | 'outside' | 'inside' | undefined {
|
176
|
+
return this.element.dataset.pbPopoverCloseOnClick as any
|
123
177
|
}
|
124
178
|
|
125
179
|
get appendTo() {
|
126
|
-
return this.element.dataset.pbPopoverAppendTo
|
180
|
+
return this.element.dataset.pbPopoverAppendTo
|
127
181
|
}
|
128
182
|
}
|
@@ -36,6 +36,7 @@ type TextInputProps = {
|
|
36
36
|
alignment?: "right" | "left",
|
37
37
|
border?: boolean,
|
38
38
|
},
|
39
|
+
autoComplete?: boolean | string,
|
39
40
|
} & GlobalProps
|
40
41
|
|
41
42
|
const TextInput = (props: TextInputProps, ref: React.LegacyRef<HTMLInputElement>) => {
|
@@ -59,6 +60,7 @@ const TextInput = (props: TextInputProps, ref: React.LegacyRef<HTMLInputElement>
|
|
59
60
|
type = 'text',
|
60
61
|
value = '',
|
61
62
|
children = null,
|
63
|
+
autoComplete = true,
|
62
64
|
} = props
|
63
65
|
|
64
66
|
const ariaProps = buildAriaProps(aria)
|
@@ -142,6 +144,7 @@ const TextInput = (props: TextInputProps, ref: React.LegacyRef<HTMLInputElement>
|
|
142
144
|
childInput ? React.cloneElement(children, { className: "text_input" }) :
|
143
145
|
(<input
|
144
146
|
{...domSafeProps(props)}
|
147
|
+
autoComplete={typeof autoComplete === "string" ? autoComplete : ( autoComplete ? undefined : "off" )}
|
145
148
|
className="text_input"
|
146
149
|
disabled={disabled}
|
147
150
|
id={id}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<%= pb_rails("text_input", props: {
|
2
|
+
autocomplete: false,
|
3
|
+
label: "autocomplete='off'",
|
4
|
+
name: "firstName",
|
5
|
+
placeholder: "Enter first name",
|
6
|
+
}) %>
|
7
|
+
|
8
|
+
<%= pb_rails("text_input", props: {
|
9
|
+
label: "no autocomplete attribute (let browser decide- basically 'on')",
|
10
|
+
name: "lastName",
|
11
|
+
placeholder: "Enter last name"
|
12
|
+
}) %>
|
13
|
+
|
14
|
+
<%= pb_rails("text_input", props: {
|
15
|
+
autocomplete: true,
|
16
|
+
label: "autocomplete='on'",
|
17
|
+
name: "phone",
|
18
|
+
type: "phone",
|
19
|
+
placeholder: "Enter phone number"
|
20
|
+
}) %>
|
21
|
+
|
22
|
+
<%= pb_rails("body", props: { margin_bottom: "sm" }) do %>
|
23
|
+
The following have the same autocomplete attributes (email), but have
|
24
|
+
different name attributes (email and emailAlt). Many browsers will
|
25
|
+
open autocomplete based on name attributes instead of autocomplete:
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
<%= pb_rails("text_input", props: {
|
29
|
+
autocomplete: "email",
|
30
|
+
label: "autocomplete='email' name='email'",
|
31
|
+
name: "email",
|
32
|
+
placeholder: "Enter email address"
|
33
|
+
}) %>
|
34
|
+
|
35
|
+
<%= pb_rails("text_input", props: {
|
36
|
+
autocomplete: "email",
|
37
|
+
label: "autocomplete='email' name='emailAlt'",
|
38
|
+
name: "emailAlt",
|
39
|
+
type: "email",
|
40
|
+
placeholder: "Enter email address"
|
41
|
+
}) %>
|
@@ -0,0 +1,80 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
|
3
|
+
import TextInput from '../../pb_text_input/_text_input'
|
4
|
+
import Body from '../../pb_body/_body'
|
5
|
+
|
6
|
+
|
7
|
+
const TextInputAutocomplete = (props) => {
|
8
|
+
const [formFields, setFormFields] = useState({
|
9
|
+
firstName: "",
|
10
|
+
lastName: "",
|
11
|
+
phone: "",
|
12
|
+
emailTest: "",
|
13
|
+
email: "",
|
14
|
+
});
|
15
|
+
|
16
|
+
const handleOnChangeFormField = ({ target }) => {
|
17
|
+
const { name, value } = target;
|
18
|
+
setFormFields({ ...formFields, [name]: value });
|
19
|
+
};
|
20
|
+
|
21
|
+
return (
|
22
|
+
<div>
|
23
|
+
<TextInput
|
24
|
+
autoComplete={false}
|
25
|
+
label="autocomplete='off'"
|
26
|
+
name="firstName"
|
27
|
+
onChange={handleOnChangeFormField}
|
28
|
+
placeholder="Enter first name"
|
29
|
+
value={formFields.firstName}
|
30
|
+
{...props}
|
31
|
+
/>
|
32
|
+
<TextInput
|
33
|
+
label="no autocomplete attribute (let browser decide- basically 'on')"
|
34
|
+
name="lastName"
|
35
|
+
onChange={handleOnChangeFormField}
|
36
|
+
placeholder="Enter last name"
|
37
|
+
value={formFields.lastName}
|
38
|
+
{...props}
|
39
|
+
/>
|
40
|
+
<TextInput
|
41
|
+
autoComplete
|
42
|
+
label="autocomplete='on'"
|
43
|
+
name="phone"
|
44
|
+
onChange={handleOnChangeFormField}
|
45
|
+
placeholder="Enter phone number"
|
46
|
+
type="phone"
|
47
|
+
value={formFields.phone}
|
48
|
+
{...props}
|
49
|
+
/>
|
50
|
+
<Body marginBottom="sm">
|
51
|
+
The following have the same autocomplete attributes (email), but have
|
52
|
+
different name attributes (email and emailAlt). Many browsers will
|
53
|
+
open autocomplete based on name attributes instead of autocomplete:
|
54
|
+
</Body>
|
55
|
+
<TextInput
|
56
|
+
autoComplete="email"
|
57
|
+
label="autocomplete='email' name='email'"
|
58
|
+
name="email"
|
59
|
+
onChange={handleOnChangeFormField}
|
60
|
+
placeholder="Enter email address"
|
61
|
+
type="email"
|
62
|
+
value={formFields.email}
|
63
|
+
{...props}
|
64
|
+
/>
|
65
|
+
<TextInput
|
66
|
+
autoComplete="email"
|
67
|
+
label="autocomplete='email' name='emailAlt'"
|
68
|
+
marginTop="sm"
|
69
|
+
name="emailTest"
|
70
|
+
onChange={handleOnChangeFormField}
|
71
|
+
placeholder="Enter email address"
|
72
|
+
type="email"
|
73
|
+
value={formFields.emailTest}
|
74
|
+
{...props}
|
75
|
+
/>
|
76
|
+
</div>
|
77
|
+
);
|
78
|
+
};
|
79
|
+
|
80
|
+
export default TextInputAutocomplete;
|
@@ -0,0 +1 @@
|
|
1
|
+
Set this prop to `false` or `"off"` to remove autocomplete from text inputs. You can also set it to a string, but browsers will often defer to other attributes like `name`.
|
@@ -9,6 +9,8 @@ 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
|
+
|
12
14
|
react:
|
13
15
|
- text_input_default: Default
|
14
16
|
- text_input_error: With Error
|
@@ -19,6 +21,7 @@ examples:
|
|
19
21
|
- text_input_no_label: No Label
|
20
22
|
- text_input_mask: Mask
|
21
23
|
- text_input_sanitize: Sanitized Masked Input
|
24
|
+
- text_input_autocomplete: Autocomplete
|
22
25
|
|
23
26
|
|
24
27
|
swift:
|
@@ -7,3 +7,4 @@ 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,8 +15,7 @@ module Playbook
|
|
15
15
|
"cvv" => '\d{3,4}',
|
16
16
|
}.freeze
|
17
17
|
|
18
|
-
prop :autocomplete,
|
19
|
-
default: true
|
18
|
+
prop :autocomplete, default: true
|
20
19
|
prop :disabled, type: Playbook::Props::Boolean,
|
21
20
|
default: false
|
22
21
|
prop :error
|
@@ -69,7 +68,7 @@ module Playbook
|
|
69
68
|
|
70
69
|
def all_input_options
|
71
70
|
{
|
72
|
-
autocomplete: autocomplete ? nil : "off",
|
71
|
+
autocomplete: autocomplete == true ? nil : (autocomplete.presence || "off"),
|
73
72
|
class: "text_input #{input_options.dig(:classname) || ''}",
|
74
73
|
data: validation_data,
|
75
74
|
disabled: disabled,
|
@@ -306,3 +306,41 @@ 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{c as buildAriaProps,d as buildDataProps,e as buildHtmlProps,H as HighchartsReact,f as Highcharts,g as classnames,h as globalProps,i as HighchartsMore,S as SolidGauge,j as buildCss}from"./_typeahead-_OUsjdM2.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-CY5ZPzic.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-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};
|