playbook_ui 15.4.0.pre.alpha.PLAY2465improvetruncation12292 → 15.4.0.pre.alpha.revert5471PLAY2622richtexteditortiptaponlyrails12345
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_date_picker/date_picker_helper.ts +44 -3
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.html.erb +2 -2
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_description.md +3 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_default.md +1 -0
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_legend_position.html.erb +1 -1
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_pb_bar_graph_legend_position.md +11 -0
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_description.md +3 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_custom_tooltip.md +2 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_pb_circle_chart_default.md +1 -0
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_description.md +3 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.md +2 -2
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_default.md +1 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_description.md +3 -1
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.md +1 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.html.erb +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +8 -61
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_focus.html.erb +2 -10
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.html.erb +11 -19
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_simple.html.erb +1 -5
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_sticky.html.erb +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +2 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +7 -16
- data/app/pb_kits/playbook/utilities/_truncate.scss +0 -2
- data/dist/chunks/{_line_graph-eQNOB_GQ.js → _line_graph-DDvq7zE7.js} +1 -1
- data/dist/chunks/_typeahead-D2bVH5Fk.js +6 -0
- data/dist/chunks/{_weekday_stacked-CvJHyUq6.js → _weekday_stacked-DB8t2C4f.js} +1 -1
- data/dist/chunks/{lib-BCrK6CFU.js → lib-COXg9aPA.js} +1 -1
- data/dist/chunks/{pb_form_validation-Cj4vdjWI.js → pb_form_validation-DR765aoq.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +19 -1
- 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 +12 -10
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default_rails.md +0 -7
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_inline_rails.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_sticky_rails.md +0 -1
- data/dist/chunks/_typeahead-vbfetkuE.js +0 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 775ff7cb95fa6eff452bd26bf288dc9d6ff69a05f6517a3021073fd20b7fdd49
|
|
4
|
+
data.tar.gz: 66a3eaadd79c3c7db0d2661fd7d530d4b00fedc51cb0a7f86563a246936aedd5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 07d7b573b42fbfd810956554c60c3052ec817174a4fec20e1c88d48d5ce8ba7b7be5e113e0342629cccde21eb0023035f099513d28bc79e6160aafba66243e02
|
|
7
|
+
data.tar.gz: d5429dcaf8a8dd41019c85cb9e00ef1db7ec0c830808488ab659701b39b9775ac5ef6506740ea9a6720b01b3c1408ae846d76072ab0f9e4889d41bf00fe5ccf7
|
|
@@ -182,6 +182,33 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
const positionCalendarIfNeeded = (fp: Instance) => {
|
|
186
|
+
const cal = document.querySelector(`#cal-${pickerId}`) as HTMLElement
|
|
187
|
+
if (!cal) return
|
|
188
|
+
|
|
189
|
+
const inputRect = fp.input.getBoundingClientRect()
|
|
190
|
+
const h = cal.getBoundingClientRect().height || 300
|
|
191
|
+
const spaceBelow = window.innerHeight - inputRect.bottom
|
|
192
|
+
const spaceAbove = inputRect.top
|
|
193
|
+
|
|
194
|
+
if (spaceBelow < h + 10 && spaceAbove >= h + 10) {
|
|
195
|
+
if (staticPosition) {
|
|
196
|
+
cal.style.top = 'auto'
|
|
197
|
+
cal.style.bottom = 'calc(100% + 5px)'
|
|
198
|
+
} else {
|
|
199
|
+
cal.style.position = 'fixed'
|
|
200
|
+
cal.style.top = `${Math.max(10, inputRect.top - h - 5)}px`
|
|
201
|
+
cal.style.left = `${inputRect.left}px`
|
|
202
|
+
}
|
|
203
|
+
} else if (staticPosition) {
|
|
204
|
+
cal.style.top = ''
|
|
205
|
+
cal.style.bottom = ''
|
|
206
|
+
} else {
|
|
207
|
+
Object.assign(cal.style, { position: '', top: '', left: '', bottom: '', right: '', transform: '' })
|
|
208
|
+
fp._positionCalendar()
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
185
212
|
const setPlugins = (thisRangesEndToday: boolean, customQuickPickDates: any) => {
|
|
186
213
|
const pluginList = []
|
|
187
214
|
|
|
@@ -239,6 +266,9 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
|
239
266
|
}
|
|
240
267
|
}
|
|
241
268
|
|
|
269
|
+
// Store resize / position handler reference for cleanup
|
|
270
|
+
let resizeRepositionHandlerRef: (() => void) | null = null
|
|
271
|
+
|
|
242
272
|
// ===========================================================
|
|
243
273
|
// | Flatpickr initializer w/ config |
|
|
244
274
|
// ===========================================================
|
|
@@ -260,13 +290,24 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
|
260
290
|
minDate: setMinDate,
|
|
261
291
|
mode,
|
|
262
292
|
nextArrow: '<i class="far fa-angle-right"></i>',
|
|
263
|
-
onOpen: [() => {
|
|
293
|
+
onOpen: [(_selectedDates, _dateStr, fp) => {
|
|
264
294
|
calendarResizer()
|
|
265
|
-
|
|
295
|
+
if (resizeRepositionHandlerRef) {
|
|
296
|
+
window.removeEventListener('resize', resizeRepositionHandlerRef)
|
|
297
|
+
}
|
|
298
|
+
resizeRepositionHandlerRef = () => {
|
|
299
|
+
calendarResizer()
|
|
300
|
+
positionCalendarIfNeeded(fp)
|
|
301
|
+
}
|
|
302
|
+
window.addEventListener('resize', resizeRepositionHandlerRef)
|
|
266
303
|
if (!staticPosition && scrollContainer) attachToScroll(scrollContainer)
|
|
304
|
+
positionCalendarIfNeeded(fp)
|
|
267
305
|
}],
|
|
268
306
|
onClose: [(selectedDates, dateStr) => {
|
|
269
|
-
|
|
307
|
+
if (resizeRepositionHandlerRef) {
|
|
308
|
+
window.removeEventListener('resize', resizeRepositionHandlerRef)
|
|
309
|
+
resizeRepositionHandlerRef = null
|
|
310
|
+
}
|
|
270
311
|
if (!staticPosition && scrollContainer) detachFromScroll(scrollContainer as HTMLElement)
|
|
271
312
|
onClose(selectedDates, dateStr)
|
|
272
313
|
}],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<%= pb_rails("button", props: { text: "Open Complex Dialog", data:{"open-dialog": "dialog-complex"} }) %>
|
|
2
2
|
|
|
3
3
|
<%= pb_rails("dialog", props: { id:"dialog-complex", size: "lg", full_height: true }) do %>
|
|
4
|
-
|
|
4
|
+
<%= pb_form_with(scope: :example, method: :get, url: "", options: { remote: true }) do |form| %>
|
|
5
5
|
<%= pb_rails("dialog/dialog_header", props: { id: "dialog-complex" } ) do %>
|
|
6
6
|
<%= pb_rails("body", props: { text: "What do you need us to take care of?" }) %>
|
|
7
7
|
<% end %>
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
|
|
14
14
|
<% end %>
|
|
15
15
|
<%= pb_rails("dialog/dialog_footer", props: {cancel_button: "Back", confirm_button: "Send my Issue", confirm_button_id:"confirm-complex", id: "dialog-complex"}) %>
|
|
16
|
-
|
|
16
|
+
<% end %>
|
|
17
17
|
<% end %>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
**In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo.**
|
|
2
|
+
|
|
3
|
+
This kit is a wrapper around the Highcharts library. It applies styling and default settings but does NOT ship Highcharts. Once 'highcharts' and 'highcharts-react-official are installed into your repo, any prop or functionality provided by Highcharts can be used with this kit without requiring specific props from Playbook. The doc examples below showcase a few common usecases but are not a comprehensive list of all the functionalities possible.
|
|
2
4
|
|
|
3
5
|
See the [highcharts API docs](https://api.highcharts.com/highcharts/) for a comprehensive look at what is possible.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo.
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
%>
|
|
38
38
|
|
|
39
|
-
<%= pb_rails("title", props: {size: 4, text: "align |
|
|
39
|
+
<%= pb_rails("title", props: {size: 4, text: "align | verticalAlign", padding_top: "sm", padding_bottom: "sm"})%>
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
<%= pb_rails("pb_bar_graph", props: {options: chart_options_right}) %>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Highcharts provides many options for customizing the legend display. This example showcases the following:
|
|
2
|
+
|
|
3
|
+
`align` can be used to align the legend left, right or center (defaults to center)
|
|
4
|
+
|
|
5
|
+
`verticalAlign` can be used to place the legend above the graph. Options are top, middle, bottom with default set to bottom
|
|
6
|
+
|
|
7
|
+
`layout` determines the position of the legend items. Options are horizontal, vertical or proximate with default set to horizontal `layout: proximate` will place the legend items as close as possible to the graphs they're representing. It will also determine whether to place the legend above/below or on the side of the plot area, if the legend is in a corner.
|
|
8
|
+
|
|
9
|
+
`x` offsets the legend relative to its horizontal alignment. Negative x moves it to the left, positive x moves it to the right (defaults to 0)
|
|
10
|
+
|
|
11
|
+
`y` offsets the legend relative to its vertical alignment. Negative y moves it up, positive y moves it down (defaults to 0)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
**In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo.**
|
|
2
|
+
|
|
3
|
+
This kit is a wrapper around the Highcharts library. It applies styling and default settings but does NOT ship Highcharts. Once 'highcharts' and 'highcharts-react-official are installed into your repo, any prop or functionality provided by Highcharts can be used with this kit without requiring specific props from Playbook. The doc examples below showcase a few common usecases but are not a comprehensive list of all the functionalities possible.
|
|
2
4
|
|
|
3
5
|
See the [highcharts API docs](https://api.highcharts.com/highcharts/) for a comprehensive look at what is possible.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Tooltip options from Highcharts:
|
|
2
|
+
|
|
2
3
|
`headerFormat` **Type**: String | when set to null will disable the header.
|
|
3
4
|
`pointFormat` **Type**: String | defines the HTML template for each data point and supports custom HTML when `useHTML` is enabled.
|
|
4
5
|
`useHTML` **Type**: boolean (default false) | enables HTML rendering in tooltips.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
**In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo.**
|
|
2
|
+
|
|
3
|
+
This kit is a wrapper around the Highcharts library. It applies styling and default settings but does NOT ship Highcharts. Once 'highcharts' and 'highcharts-react-official are installed into your repo, any prop or functionality provided by Highcharts can be used with this kit without requiring specific props from Playbook. The doc examples below showcase a few common usecases but are not a comprehensive list of all the functionalities possible.
|
|
2
4
|
|
|
3
5
|
See the [highcharts API docs](https://api.highcharts.com/highcharts/) for a comprehensive look at what is possible.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Highcharts allows for any custom colors to be used. Custom data colors allow for color customization to match the needs of business requirements.
|
|
2
2
|
|
|
3
|
-
For React, pass the
|
|
3
|
+
For React, pass the option `plotOptions.solidgauge.borderColor` with a Playbook token like `colors.` + `data_1 | data_2 | data_3 | data_4 | data_5 | data_6 | data_7 | data_8`. HEX colors are also available `eg: #CA0095`
|
|
4
4
|
|
|
5
|
-
For Rails, the
|
|
5
|
+
For Rails, the option `plotOptions.solidgauge.borderColor` can only be used with HEX values as shown.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
**In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo.**
|
|
2
|
+
|
|
3
|
+
This kit is a wrapper around the Highcharts library. It applies styling and default settings but does NOT ship Highcharts. Once 'highcharts' and 'highcharts-react-official are installed into your repo, any prop or functionality provided by Highcharts can be used with this kit without requiring specific props from Playbook. The doc examples below showcase a few common usecases but are not a comprehensive list of all the functionalities possible.
|
|
2
4
|
|
|
3
5
|
See the [highcharts API docs](https://api.highcharts.com/highcharts/) for a comprehensive look at what is possible.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo.
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
} %>
|
|
39
39
|
|
|
40
|
-
<%= pb_rails("title", props: {size: 4, text: "align |
|
|
40
|
+
<%= pb_rails("title", props: {size: 4, text: "align | verticalAlign", padding_top: "sm", padding_bottom: "sm"})%>
|
|
41
41
|
<%= pb_rails("pb_line_graph", props: {options: chartOptionsFirst}) %>
|
|
42
42
|
|
|
43
43
|
<% chartOptionsSecond = {
|
|
@@ -96,7 +96,7 @@ const EditorToolbar = ({ editor, extensions, simple, sticky }: any): React.React
|
|
|
96
96
|
<SectionSeparator orientation="vertical" />
|
|
97
97
|
<ToolbarNodes editor={editor} />
|
|
98
98
|
{
|
|
99
|
-
extensions &&
|
|
99
|
+
extensions && (
|
|
100
100
|
<>
|
|
101
101
|
<MoreExtensionsDropdown extensions={extensions}/>
|
|
102
102
|
</>
|
|
@@ -2,10 +2,6 @@ import React, { useEffect, useState, useRef } from 'react'
|
|
|
2
2
|
import classnames from 'classnames'
|
|
3
3
|
import { TrixEditor } from 'react-trix'
|
|
4
4
|
|
|
5
|
-
import { useEditor, EditorContent } from '@tiptap/react'
|
|
6
|
-
import StarterKit from '@tiptap/starter-kit'
|
|
7
|
-
import Link from '@tiptap/extension-link'
|
|
8
|
-
|
|
9
5
|
import inlineFocus from './inlineFocus'
|
|
10
6
|
import useFocus from './useFocus'
|
|
11
7
|
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
|
@@ -52,8 +48,7 @@ type RichTextEditorProps = {
|
|
|
52
48
|
sticky?: boolean,
|
|
53
49
|
template: string,
|
|
54
50
|
value?: string,
|
|
55
|
-
maxWidth?: string
|
|
56
|
-
railsEditor?: boolean
|
|
51
|
+
maxWidth?: string
|
|
57
52
|
} & GlobalProps
|
|
58
53
|
|
|
59
54
|
const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
@@ -86,27 +81,6 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
86
81
|
[showToolbarOnFocus, setShowToolbarOnFocus] = useState(false),
|
|
87
82
|
containerRef = useRef<HTMLDivElement>(null)
|
|
88
83
|
|
|
89
|
-
const isRails = !advancedEditor && props.railsEditor === true
|
|
90
|
-
|
|
91
|
-
// TipTap editor for Rails (hook always runs per React rules, but only used when isRails is true)
|
|
92
|
-
const railsTipTapEditor = useEditor({
|
|
93
|
-
extensions: [StarterKit, Link],
|
|
94
|
-
content: value || '',
|
|
95
|
-
onUpdate: ({ editor }) => {
|
|
96
|
-
if (!isRails) return
|
|
97
|
-
|
|
98
|
-
const html = editor.getHTML()
|
|
99
|
-
const text = editor.getText()
|
|
100
|
-
onChange(html, text)
|
|
101
|
-
|
|
102
|
-
// Update hidden input for TipTap Rails form submission
|
|
103
|
-
const hiddenInput = document.getElementById(`hidden-input-${props.id || 'rich-text-editor'}`)
|
|
104
|
-
if (hiddenInput) {
|
|
105
|
-
(hiddenInput as HTMLInputElement).value = html ?? ''
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
}, [isRails, value])
|
|
109
|
-
|
|
110
84
|
const htmlProps = buildHtmlProps(htmlOptions)
|
|
111
85
|
|
|
112
86
|
const handleOnEditorReady = (editorInstance: Editor) => {
|
|
@@ -166,8 +140,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
166
140
|
}
|
|
167
141
|
|
|
168
142
|
useEffect(() => {
|
|
169
|
-
|
|
170
|
-
if (!tiptapEditor || !focus) return
|
|
143
|
+
if (!advancedEditor || !focus) return
|
|
171
144
|
|
|
172
145
|
const handleFocus = () => setShowToolbarOnFocus(true)
|
|
173
146
|
|
|
@@ -176,7 +149,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
176
149
|
setShowToolbarOnFocus(false)
|
|
177
150
|
}
|
|
178
151
|
|
|
179
|
-
const editorElement =
|
|
152
|
+
const editorElement = advancedEditor?.view?.dom
|
|
180
153
|
if (editorElement) {
|
|
181
154
|
editorElement.addEventListener('focus', handleFocus)
|
|
182
155
|
}
|
|
@@ -189,7 +162,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
189
162
|
}
|
|
190
163
|
document.removeEventListener('mousedown', handleClickOutside)
|
|
191
164
|
}
|
|
192
|
-
}, [advancedEditor,
|
|
165
|
+
}, [advancedEditor, focus])
|
|
193
166
|
|
|
194
167
|
//============= end focus prop with advanced editor=================
|
|
195
168
|
|
|
@@ -200,17 +173,6 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
200
173
|
editor.insertHTML(template)
|
|
201
174
|
}, [editor, template])
|
|
202
175
|
|
|
203
|
-
// Handle value prop changes for Rails TipTap editor
|
|
204
|
-
useEffect(() => {
|
|
205
|
-
if (!railsTipTapEditor) return
|
|
206
|
-
const currentContent = railsTipTapEditor.getHTML()
|
|
207
|
-
const newValue = value || ''
|
|
208
|
-
|
|
209
|
-
if (currentContent !== newValue) {
|
|
210
|
-
railsTipTapEditor.commands.setContent(newValue)
|
|
211
|
-
}
|
|
212
|
-
}, [railsTipTapEditor, value])
|
|
213
|
-
|
|
214
176
|
useEffect(() => {
|
|
215
177
|
if (!editor?.element) return
|
|
216
178
|
editor.element.addEventListener('click', ({ target }: Event) => {
|
|
@@ -238,11 +200,8 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
238
200
|
className
|
|
239
201
|
)
|
|
240
202
|
|
|
241
|
-
// Get the TipTap editor instance (either passed from React or auto-initialized for Rails)
|
|
242
|
-
const tipTapEditor = advancedEditor || (isRails ? railsTipTapEditor : null)
|
|
243
|
-
|
|
244
203
|
// Determine if toolbar should be shown
|
|
245
|
-
const shouldShowToolbar = focus &&
|
|
204
|
+
const shouldShowToolbar = focus && advancedEditor ? showToolbarOnFocus : advancedEditorToolbar
|
|
246
205
|
|
|
247
206
|
return (
|
|
248
207
|
<div
|
|
@@ -253,32 +212,20 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
253
212
|
ref={focus ? containerRef : undefined}
|
|
254
213
|
>
|
|
255
214
|
{
|
|
256
|
-
|
|
257
|
-
tipTapEditor ? (
|
|
215
|
+
advancedEditor ? (
|
|
258
216
|
<div
|
|
259
217
|
className={classnames("pb_rich_text_editor_advanced_container", {
|
|
260
218
|
["toolbar-active"]: shouldShowToolbar,
|
|
261
219
|
})}
|
|
262
220
|
>
|
|
263
221
|
{shouldShowToolbar && (
|
|
264
|
-
<EditorToolbar editor={
|
|
222
|
+
<EditorToolbar editor={advancedEditor}
|
|
265
223
|
extensions={extensions}
|
|
266
224
|
simple={simple}
|
|
267
225
|
sticky={sticky}
|
|
268
226
|
/>
|
|
269
227
|
)}
|
|
270
|
-
|
|
271
|
-
{railsTipTapEditor ? <EditorContent editor={tipTapEditor} /> : <>{children}</>}
|
|
272
|
-
|
|
273
|
-
{/* Set up hidden input for TipTap Rails form submission */}
|
|
274
|
-
{railsTipTapEditor && (
|
|
275
|
-
<input
|
|
276
|
-
id={`hidden-input-${props.id || 'rich-text-editor'}`}
|
|
277
|
-
name={name || 'content'}
|
|
278
|
-
type="hidden"
|
|
279
|
-
value={tipTapEditor?.getHTML() ?? ''}
|
|
280
|
-
/>
|
|
281
|
-
)}
|
|
228
|
+
{ children }
|
|
282
229
|
</div>
|
|
283
230
|
) : (
|
|
284
231
|
<TrixEditor
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
<%= pb_rails("rich_text_editor", props: {
|
|
2
|
-
id: "focus-editor-1",
|
|
3
|
-
focus: true,
|
|
4
|
-
value: "Click inside to see the toolbar. Click outside to hide it."
|
|
5
|
-
}) %>
|
|
1
|
+
<%= pb_rails("rich_text_editor", props: {focus: true}) %>
|
|
6
2
|
<br>
|
|
7
|
-
<%= pb_rails("rich_text_editor", props: {
|
|
8
|
-
id: "focus-editor-2",
|
|
9
|
-
focus: true,
|
|
10
|
-
value: "When the optional focus prop is set to true, the toolbar will only show once you click in to the RichTextEditor."
|
|
11
|
-
}) %>
|
|
3
|
+
<%= pb_rails("rich_text_editor", props: {focus: true}) %>
|
|
@@ -1,38 +1,30 @@
|
|
|
1
|
-
<%= pb_rails("rich_text_editor", props: {
|
|
2
|
-
id: "content-preview-editor",
|
|
3
|
-
margin_bottom: "md",
|
|
4
|
-
value: "Add text here, format it, and press \"Preview Output\" to see what your stylized output will look like on the page."
|
|
5
|
-
}) %>
|
|
6
|
-
|
|
7
|
-
<%= pb_rails("button", props: { id: "preview-button", text: "Preview Output", variant: "secondary" }) %>
|
|
8
1
|
|
|
2
|
+
<%= pb_rails("rich_text_editor", props: { id: "content-preview-editor" }) %>
|
|
9
3
|
<div id="card-obfuscation" style="display:none">
|
|
10
4
|
<%= pb_rails("card", props: { margin_top: "md", max_width: "md", padding: "sm" }) do %>
|
|
11
|
-
<div id="content-preview" class="
|
|
5
|
+
<div id="content-preview" class="trix-content">
|
|
12
6
|
</div>
|
|
13
7
|
<% end %>
|
|
14
8
|
</div>
|
|
9
|
+
<%= pb_rails("button", props: { id: "preview-button", variant: "secondary", margin_top: "md" }) do %>
|
|
10
|
+
<span>Preview Output</span>
|
|
11
|
+
<% end %>
|
|
15
12
|
|
|
16
13
|
<script>
|
|
17
14
|
document.addEventListener('DOMContentLoaded', () => {
|
|
18
15
|
function handleButtonClick() {
|
|
19
|
-
// Find the specific TipTap editor container by ID
|
|
20
16
|
const editorContainer = [...document.querySelectorAll('[data-pb-react-props]')]
|
|
21
17
|
.find(element => element.getAttribute('data-pb-react-props')?.includes('"id":"content-preview-editor"'))
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// Find the TipTap editor content
|
|
29
|
-
const tiptapEditor = editorContainer.querySelector('.ProseMirror')
|
|
19
|
+
const editorElement = editorContainer?.querySelector('trix-editor')
|
|
20
|
+
const inputId = editorElement?.getAttribute('input')
|
|
21
|
+
const inputElement = inputId && document.getElementById(inputId)
|
|
22
|
+
|
|
23
|
+
const editorContent = inputElement?.value || ''
|
|
30
24
|
const previewArea = document.getElementById('content-preview')
|
|
31
25
|
const cardDiv = document.getElementById('card-obfuscation')
|
|
32
26
|
|
|
33
|
-
if (
|
|
34
|
-
// Get the HTML content from the TipTap editor
|
|
35
|
-
const editorContent = tiptapEditor.innerHTML || ''
|
|
27
|
+
if (previewArea && cardDiv) {
|
|
36
28
|
previewArea.innerHTML = editorContent
|
|
37
29
|
cardDiv.style.display = 'block'
|
|
38
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= pb_rails("rich_text_editor", props: {id: "sticky
|
|
1
|
+
<%= pb_rails("rich_text_editor", props: {id: "sticky", sticky: true, value: "In this example, when you scroll down, the rich text editor's toolbar will scroll along with the page and it will no longer be visible at the top of the page. Dummy text to enable scroll.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis."}) %>
|
|
@@ -3,10 +3,10 @@ examples:
|
|
|
3
3
|
rails:
|
|
4
4
|
- rich_text_editor_default: Default
|
|
5
5
|
- rich_text_editor_simple: Simple
|
|
6
|
-
|
|
6
|
+
- rich_text_editor_attributes: Attributes
|
|
7
7
|
- rich_text_editor_focus: Focus
|
|
8
8
|
- rich_text_editor_sticky: Sticky
|
|
9
|
-
|
|
9
|
+
- rich_text_editor_templates: Templates
|
|
10
10
|
# - rich_text_editor_toolbar_bottom: Toolbar Bottom
|
|
11
11
|
- rich_text_editor_inline: Inline
|
|
12
12
|
- rich_text_editor_preview: Preview
|
|
@@ -18,15 +18,9 @@ module Playbook
|
|
|
18
18
|
default: false
|
|
19
19
|
|
|
20
20
|
prop :value
|
|
21
|
+
prop :template
|
|
21
22
|
prop :placeholder
|
|
22
23
|
prop :input_options
|
|
23
|
-
prop :advanced_editor_toolbar, type: Playbook::Props::Boolean,
|
|
24
|
-
default: true
|
|
25
|
-
prop :extensions, type: Playbook::Props::HashArray,
|
|
26
|
-
default: []
|
|
27
|
-
prop :max_width, type: Playbook::Props::Enum,
|
|
28
|
-
values: %w[xs sm md lg xl],
|
|
29
|
-
default: "md"
|
|
30
24
|
|
|
31
25
|
def classname
|
|
32
26
|
generate_classname("pb_rich_text_editor_kit", simple_class, focus_class, sticky_class, separator: " ")
|
|
@@ -46,20 +40,17 @@ module Playbook
|
|
|
46
40
|
|
|
47
41
|
def rich_text_options
|
|
48
42
|
{
|
|
49
|
-
advancedEditorToolbar: advanced_editor_toolbar,
|
|
50
|
-
className: classname,
|
|
51
|
-
extensions: extensions,
|
|
52
|
-
focus: focus,
|
|
53
43
|
id: id,
|
|
54
44
|
inline: inline,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
placeholder: placeholder,
|
|
58
|
-
railsEditor: true,
|
|
45
|
+
className: classname,
|
|
46
|
+
focus: focus,
|
|
59
47
|
simple: simple,
|
|
60
48
|
sticky: sticky,
|
|
61
49
|
toolbarBottom: toolbar_bottom,
|
|
62
|
-
value: value
|
|
50
|
+
value: value,
|
|
51
|
+
template: template,
|
|
52
|
+
placeholder: placeholder,
|
|
53
|
+
inputOptions: input_options,
|
|
63
54
|
}
|
|
64
55
|
end
|
|
65
56
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx,Fragment,jsxs}from"react/jsx-runtime";import{useState,useEffect}from"react";import{f as buildAriaProps,g as buildDataProps,h as buildHtmlProps,H as HighchartsReact,i as Highcharts,j as classnames,k as globalProps,l as HighchartsMore,S as SolidGauge,m as buildCss}from"./_typeahead-vbfetkuE.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-BCrK6CFU.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{f as buildAriaProps,g as buildDataProps,h as buildHtmlProps,H as HighchartsReact,i as Highcharts,j as classnames,k as globalProps,l as HighchartsMore,S as SolidGauge,m as buildCss}from"./_typeahead-D2bVH5Fk.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-COXg9aPA.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};
|