playbook_ui 10.21.0.pre.alpha.na1 → 10.21.1.pre.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +1 -0
- data/app/pb_kits/playbook/pb_avatar/{_avatar.jsx → _avatar.tsx} +12 -13
- data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx +1 -1
- data/app/pb_kits/playbook/pb_background/_background.jsx +8 -3
- data/app/pb_kits/playbook/pb_background/_background.scss +24 -8
- data/app/pb_kits/playbook/pb_background/background.rb +6 -6
- data/app/pb_kits/playbook/pb_background/docs/_background_image.html.erb +50 -2
- data/app/pb_kits/playbook/pb_background/docs/_background_image.jsx +71 -28
- data/app/pb_kits/playbook/pb_background/docs/_background_image.md +1 -0
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +5 -1
- data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +1 -0
- data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumb_item.jsx +1 -1
- data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumbs.jsx +1 -1
- data/app/pb_kits/playbook/pb_button/_button.jsx +5 -4
- data/app/pb_kits/playbook/pb_button/_button.scss +18 -1
- data/app/pb_kits/playbook/pb_button/button.rb +11 -3
- data/app/pb_kits/playbook/pb_button/button.test.js +13 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_size.html.erb +3 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_size.jsx +26 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_size.md +1 -0
- data/app/pb_kits/playbook/pb_button/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_button/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_button_toolbar/_button_toolbar.jsx +1 -1
- data/app/pb_kits/playbook/pb_caption/_caption.jsx +1 -1
- data/app/pb_kits/playbook/pb_card/_card.jsx +1 -1
- data/app/pb_kits/playbook/pb_card/card.html.erb +1 -1
- data/app/pb_kits/playbook/pb_card/card.rb +88 -0
- data/app/pb_kits/playbook/pb_card/card_body.rb +1 -1
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.jsx +1 -1
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +3 -0
- data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +1 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.jsx +1 -1
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.jsx +1 -1
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.jsx +1 -1
- data/app/pb_kits/playbook/pb_currency/_currency.jsx +24 -3
- data/app/pb_kits/playbook/pb_currency/currency.rb +12 -3
- data/app/pb_kits/playbook/pb_currency/currency.test.js +35 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_abbreviated.html.erb +27 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_abbreviated.jsx +44 -0
- data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.html.erb +1 -1
- data/app/pb_kits/playbook/pb_currency/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_currency/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.js +215 -0
- data/app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx +1 -1
- data/app/pb_kits/playbook/pb_dialog/_dialog.jsx +1 -1
- data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_body.jsx +1 -1
- data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_footer.jsx +1 -1
- data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx +1 -1
- data/app/pb_kits/playbook/pb_distribution_bar/_distribution_bar.jsx +1 -1
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.jsx +17 -10
- data/app/pb_kits/playbook/pb_file_upload/fileupload.test.js +40 -0
- data/app/pb_kits/playbook/pb_filter/Filter/FilterBackground.jsx +1 -1
- data/app/pb_kits/playbook/pb_flex/_flex.jsx +1 -1
- data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +1 -1
- data/app/pb_kits/playbook/pb_flex/docs/_flex_align.jsx +1 -1
- data/app/pb_kits/playbook/pb_flex/flex_item.rb +2 -24
- data/app/pb_kits/playbook/pb_form_group/_form_group.jsx +1 -1
- data/app/pb_kits/playbook/pb_form_group/_form_group.scss +2 -0
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +2 -2
- data/app/pb_kits/playbook/pb_gauge/_gauge.jsx +3 -0
- data/app/pb_kits/playbook/pb_gauge/gauge.rb +1 -0
- data/app/pb_kits/playbook/pb_highlight/_highlight.jsx +1 -1
- data/app/pb_kits/playbook/pb_icon/_icon.jsx +1 -1
- data/app/pb_kits/playbook/pb_icon/icon.rb +1 -1
- data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx +1 -1
- data/app/pb_kits/playbook/pb_image/_image.scss +3 -3
- data/app/pb_kits/playbook/pb_image/{_image.jsx → _image.tsx} +11 -15
- data/app/pb_kits/playbook/pb_image/docs/{_default_image.jsx → _default_image.tsx} +1 -1
- data/app/pb_kits/playbook/pb_image/docs/index.js +4 -4
- data/app/pb_kits/playbook/pb_image/image.rb +1 -1
- data/app/pb_kits/playbook/pb_image/image.test.js +1 -1
- data/app/pb_kits/playbook/pb_label_pill/_label_pill.jsx +1 -1
- data/app/pb_kits/playbook/pb_layout/_layout.jsx +1 -1
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +5 -1
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_height.jsx +1 -0
- data/app/pb_kits/playbook/pb_line_graph/line_graph.rb +1 -0
- data/app/pb_kits/playbook/pb_list/_list.jsx +1 -1
- data/app/pb_kits/playbook/pb_list/_list_item.jsx +1 -1
- data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx +1 -1
- data/app/pb_kits/playbook/pb_online_status/{_online_status.jsx → _online_status.tsx} +4 -6
- data/app/pb_kits/playbook/pb_passphrase/_passphrase.jsx +2 -1
- data/app/pb_kits/playbook/pb_pill/_pill.jsx +1 -1
- data/app/pb_kits/playbook/pb_popover/_popover.jsx +3 -5
- data/app/pb_kits/playbook/pb_popover/docs/_popover_close.html.erb +7 -7
- data/app/pb_kits/playbook/pb_popover/index.js +4 -9
- data/app/pb_kits/playbook/pb_popover/popover.html.erb +1 -1
- data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.jsx +1 -1
- data/app/pb_kits/playbook/pb_progress_step/_progress_step.jsx +1 -1
- data/app/pb_kits/playbook/pb_radio/_radio.jsx +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.jsx +83 -93
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.jsx +15 -8
- data/app/pb_kits/playbook/pb_table/_table.jsx +1 -1
- data/app/pb_kits/playbook/pb_table/_table_row.jsx +1 -1
- data/app/pb_kits/playbook/pb_text_input/_text_input.jsx +4 -1
- data/app/pb_kits/playbook/pb_text_input/_text_input.scss +1 -1
- data/app/pb_kits/playbook/pb_text_input/text_input.test.js +14 -0
- data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +1 -0
- data/app/pb_kits/playbook/pb_time/_time.jsx +1 -1
- data/app/pb_kits/playbook/pb_title/_title.jsx +1 -1
- data/app/pb_kits/playbook/pb_toggle/_toggle.jsx +1 -1
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +1 -1
- data/app/pb_kits/playbook/pb_user_badge/_user_badge.jsx +1 -1
- data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.jsx +1 -1
- data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx +1 -1
- data/app/pb_kits/playbook/plugins/pb_chart.js +8 -4
- data/app/pb_kits/playbook/utilities/_align_content.scss +29 -0
- data/app/pb_kits/playbook/utilities/_align_items.scss +35 -0
- data/app/pb_kits/playbook/utilities/_align_self.scss +29 -0
- data/app/pb_kits/playbook/utilities/_flex.scss +15 -0
- data/app/pb_kits/playbook/utilities/_flex_direction.scss +19 -0
- data/app/pb_kits/playbook/utilities/_flex_grow.scss +9 -0
- data/app/pb_kits/playbook/utilities/_flex_shrink.scss +9 -0
- data/app/pb_kits/playbook/utilities/_flex_wrap.scss +14 -0
- data/app/pb_kits/playbook/utilities/_flexbox.scss +11 -0
- data/app/pb_kits/playbook/utilities/_justify_content.scss +23 -0
- data/app/pb_kits/playbook/utilities/_justify_self.scss +19 -0
- data/app/pb_kits/playbook/utilities/_order.scss +55 -0
- data/app/pb_kits/playbook/utilities/globalProps.ts +274 -0
- data/app/pb_kits/playbook/utilities/{props.js → props.ts} +9 -7
- data/lib/playbook/align_content.rb +29 -0
- data/lib/playbook/align_items.rb +29 -0
- data/lib/playbook/align_self.rb +29 -0
- data/lib/playbook/classnames.rb +11 -0
- data/lib/playbook/flex.rb +29 -0
- data/lib/playbook/flex_direction.rb +29 -0
- data/lib/playbook/flex_grow.rb +29 -0
- data/lib/playbook/flex_shrink.rb +29 -0
- data/lib/playbook/flex_wrap.rb +29 -0
- data/lib/playbook/justify_content.rb +29 -0
- data/lib/playbook/justify_self.rb +29 -0
- data/lib/playbook/kit_base.rb +22 -0
- data/lib/playbook/order.rb +29 -0
- data/lib/playbook/version.rb +2 -2
- metadata +40 -9
- data/app/pb_kits/playbook/types.js +0 -4
- data/app/pb_kits/playbook/utilities/globalProps.js +0 -97
@@ -1,23 +1,23 @@
|
|
1
1
|
<%= pb_rails("flex", props: {classname: "flex-container", spacing: "between"}) do %>
|
2
2
|
<span>
|
3
|
-
<%= pb_rails("button", props: { text: "Click Inside", variant: "secondary", id:
|
3
|
+
<%= pb_rails("button", props: { text: "Click Inside", variant: "secondary", id: "inside-popover-1" }) %>
|
4
4
|
<%= pb_rails("popover", props: {
|
5
5
|
close_on_click: "inside",
|
6
6
|
trigger_element_id: "inside-popover-1",
|
7
7
|
tooltip_id: "inside-tooltip-1",
|
8
|
-
position:
|
8
|
+
position: "bottom",
|
9
9
|
offset: true
|
10
10
|
}) do %>
|
11
11
|
Click on me!
|
12
12
|
<% end %>
|
13
13
|
</span>
|
14
14
|
<span>
|
15
|
-
<%= pb_rails("button", props: { text: "Click Outside", variant: "secondary", id:
|
15
|
+
<%= pb_rails("button", props: { text: "Click Outside", variant: "secondary", id: "outside-popover-1" }) %>
|
16
16
|
<%= pb_rails("popover", props: {
|
17
17
|
close_on_click: "outside",
|
18
18
|
trigger_element_id: "outside-popover-1",
|
19
19
|
tooltip_id: "outside-tooltip-1",
|
20
|
-
position:
|
20
|
+
position: "left",
|
21
21
|
offset: true
|
22
22
|
}) do %>
|
23
23
|
Click anywhere but me!
|
@@ -27,16 +27,16 @@
|
|
27
27
|
<%= pb_rails("button", props: {
|
28
28
|
text: "Click Anywhere",
|
29
29
|
variant: "secondary",
|
30
|
-
id:
|
30
|
+
id: "any-popover-1"
|
31
31
|
}) %>
|
32
32
|
<%= pb_rails("popover", props: {
|
33
33
|
close_on_click: "any",
|
34
34
|
trigger_element_id: "any-popover-1",
|
35
35
|
tooltip_id: "any-tooltip-1",
|
36
|
-
position:
|
36
|
+
position: "top",
|
37
37
|
offset: true
|
38
38
|
}) do %>
|
39
39
|
Click anything!
|
40
40
|
<% end %>
|
41
41
|
</span>
|
42
|
-
<% end %>
|
42
|
+
<% end %>
|
@@ -36,15 +36,14 @@ export default class PbPopover extends PbEnhancedElement {
|
|
36
36
|
}
|
37
37
|
|
38
38
|
setTimeout(() => {
|
39
|
-
this.popper.update()
|
40
39
|
this.toggleTooltip()
|
40
|
+
this.popper.update()
|
41
41
|
}, 0)
|
42
42
|
})
|
43
43
|
}
|
44
44
|
|
45
45
|
checkCloseTooltip() {
|
46
46
|
document.querySelector('body').addEventListener('click', ({ target }) => {
|
47
|
-
const isTriggerElement = target.closest(`#${this.triggerElementId}`) !== null
|
48
47
|
const isTooltipElement = target.closest(`#${this.tooltipId}`) !== null
|
49
48
|
|
50
49
|
switch (this.closeOnClick) {
|
@@ -52,21 +51,17 @@ export default class PbPopover extends PbEnhancedElement {
|
|
52
51
|
this.hideTooltip()
|
53
52
|
break
|
54
53
|
case 'outside':
|
55
|
-
if (isTooltipElement) {
|
56
|
-
this.checkCloseTooltip()
|
57
|
-
} else {
|
54
|
+
if (!isTooltipElement) {
|
58
55
|
this.hideTooltip()
|
59
56
|
}
|
60
57
|
break
|
61
58
|
case 'inside':
|
62
|
-
if (isTooltipElement
|
59
|
+
if (isTooltipElement) {
|
63
60
|
this.hideTooltip()
|
64
|
-
} else {
|
65
|
-
this.checkCloseTooltip()
|
66
61
|
}
|
67
62
|
break
|
68
63
|
}
|
69
|
-
},
|
64
|
+
}, true)
|
70
65
|
}
|
71
66
|
|
72
67
|
hideTooltip() {
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class: object.classname,
|
4
4
|
data: object.data,
|
5
5
|
id: object.id) do %>
|
6
|
-
<div class="pb_popover_tooltip" id="<%= object.tooltip_id %>" role="tooltip" style="<%= object.z_index_helper %>">
|
6
|
+
<div class="pb_popover_tooltip hide" id="<%= object.tooltip_id %>" role="tooltip" style="<%= object.z_index_helper %>">
|
7
7
|
<div class="pb_popover_body <%= object.width_height_class_helper %> <%= object.popover_spacing_helper %>" style="<%= object.width_height_helper %>">
|
8
8
|
<%= content.presence %>
|
9
9
|
</div>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import React from 'react'
|
3
3
|
import classnames from 'classnames'
|
4
4
|
import { buildCss } from '../utilities/props'
|
5
|
-
import { globalProps } from '../utilities/globalProps
|
5
|
+
import { globalProps } from '../utilities/globalProps'
|
6
6
|
|
7
7
|
type ProgressSimpleProps = {
|
8
8
|
align?: "left" | "center" | "right",
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import React from 'react'
|
4
4
|
import classnames from 'classnames'
|
5
5
|
import { buildCss } from '../utilities/props'
|
6
|
-
import { globalProps } from '../utilities/globalProps
|
6
|
+
import { globalProps } from '../utilities/globalProps'
|
7
7
|
|
8
8
|
type ProgressStepProps = {
|
9
9
|
className?: string,
|
@@ -5,7 +5,7 @@ import React, { forwardRef } from 'react'
|
|
5
5
|
import Body from '../pb_body/_body.jsx'
|
6
6
|
import classnames from 'classnames'
|
7
7
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
8
|
-
import { globalProps } from '../utilities/globalProps
|
8
|
+
import { globalProps } from '../utilities/globalProps'
|
9
9
|
|
10
10
|
type RadioProps = {
|
11
11
|
aria?: object,
|
@@ -1,11 +1,12 @@
|
|
1
1
|
/* @flow */
|
2
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
2
3
|
|
3
|
-
import React, { useEffect,
|
4
|
+
import React, { useEffect, useState } from 'react'
|
4
5
|
import classnames from 'classnames'
|
5
6
|
import inlineFocus from './inlineFocus'
|
6
7
|
import useFocus from './useFocus'
|
7
8
|
import { globalProps } from '../utilities/globalProps'
|
8
|
-
import { buildAriaProps, buildDataProps } from '../utilities/props'
|
9
|
+
import { buildAriaProps, buildDataProps, noop } from '../utilities/props'
|
9
10
|
|
10
11
|
try {
|
11
12
|
const Trix = require('trix')
|
@@ -15,6 +16,8 @@ try {
|
|
15
16
|
}
|
16
17
|
} catch (_e) { /* do nothing */ }
|
17
18
|
|
19
|
+
import { TrixEditor } from "react-trix"
|
20
|
+
|
18
21
|
type RichTextEditorProps = {
|
19
22
|
aria?: object,
|
20
23
|
toolbarBottom?: Boolean,
|
@@ -24,7 +27,7 @@ type RichTextEditorProps = {
|
|
24
27
|
id?: string,
|
25
28
|
inline?: boolean,
|
26
29
|
name?: string,
|
27
|
-
onChange: (string) => void,
|
30
|
+
onChange: (html: string, text: string) => void,
|
28
31
|
placeholder?: string,
|
29
32
|
simple?: boolean,
|
30
33
|
sticky?: boolean,
|
@@ -39,129 +42,116 @@ const RichTextEditor = (props: RichTextEditorProps) => {
|
|
39
42
|
className,
|
40
43
|
data = {},
|
41
44
|
focus = false,
|
42
|
-
id,
|
43
45
|
inline = false,
|
44
46
|
name,
|
45
|
-
onChange,
|
47
|
+
onChange = noop,
|
46
48
|
placeholder,
|
47
49
|
simple = false,
|
48
50
|
sticky = false,
|
49
51
|
template = '',
|
50
52
|
value = '',
|
51
53
|
} = props
|
52
|
-
const trixRef = useRef()
|
53
|
-
const ariaProps = buildAriaProps(aria)
|
54
|
-
const dataProps = buildDataProps(data)
|
55
54
|
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
const ariaProps = buildAriaProps(aria),
|
56
|
+
dataProps = buildDataProps(data),
|
57
|
+
[editor, setEditor] = useState()
|
59
58
|
|
60
|
-
|
59
|
+
const handleOnEditorReady = (editorInstance) => setEditor(editorInstance),
|
60
|
+
element = editor?.element
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
// DOM manipulation must wait for editor to be ready
|
63
|
+
if (editor) {
|
64
|
+
const toolbarElement = element.parentElement.querySelector('trix-toolbar'),
|
65
|
+
blockCodeButton = toolbarElement.querySelector('[data-trix-attribute=code]')
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
|
67
|
+
let inlineCodeButton = toolbarElement.querySelector('[data-trix-attribute=inlineCode]')
|
68
|
+
if (!inlineCodeButton) inlineCodeButton = blockCodeButton.cloneNode(true)
|
70
69
|
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
// set button attributes
|
71
|
+
inlineCodeButton.dataset.trixAttribute = 'inlineCode'
|
72
|
+
blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
|
74
73
|
|
75
|
-
|
76
|
-
if (range[0] == range[1]) return 'block'
|
74
|
+
if (toolbarBottom) editor.element.after(toolbarElement)
|
77
75
|
|
78
|
-
|
79
|
-
|
80
|
-
|
76
|
+
const getCodeFormattingType = (): string => {
|
77
|
+
if (editor.attributeIsActive('code')) return 'block'
|
78
|
+
if (editor.attributeIsActive('inlineCode')) return 'inline'
|
81
79
|
|
82
|
-
|
83
|
-
|
84
|
-
blockCodeButton.hidden = type == 'inline'
|
85
|
-
inlineCodeButton.hidden = type == 'block'
|
86
|
-
})
|
80
|
+
const range = editor.getSelectedRange()
|
81
|
+
if (range[0] == range[1]) return 'block'
|
87
82
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
trixRef.current.addEventListener('trix-change', (event) => {
|
92
|
-
onChange && onChange(event.target.innerHTML)
|
93
|
-
})
|
94
|
-
}, [trixRef])
|
95
|
-
|
96
|
-
useEffect(() => {
|
97
|
-
const editor = trixRef.current.editorController.editor
|
98
|
-
if (template) {
|
99
|
-
editor.loadHTML('')
|
100
|
-
editor.setSelectedRange([0, 0])
|
101
|
-
editor.insertHTML(template)
|
83
|
+
const text = editor.getSelectedDocument().toString().trim()
|
84
|
+
return /\n/.test(text) ? 'block' : 'inline'
|
102
85
|
}
|
103
|
-
}, [template])
|
104
|
-
|
105
|
-
focus
|
106
|
-
? (document.addEventListener('trix-focus', useFocus),
|
107
|
-
document.addEventListener('trix-blur', useFocus),
|
108
|
-
useFocus())
|
109
|
-
: null
|
110
|
-
|
111
|
-
document.addEventListener('trix-focus', inlineFocus)
|
112
|
-
document.addEventListener('trix-blur', inlineFocus)
|
113
86
|
|
114
|
-
|
115
|
-
|
116
|
-
|
87
|
+
// DOM event listeners
|
88
|
+
element.addEventListener('trix-selection-change', () => {
|
89
|
+
const type = getCodeFormattingType()
|
90
|
+
blockCodeButton.hidden = type == 'inline'
|
91
|
+
inlineCodeButton.hidden = type == 'block'
|
92
|
+
})
|
117
93
|
|
118
|
-
|
119
|
-
|
94
|
+
focus
|
95
|
+
? (document.addEventListener('trix-focus', useFocus),
|
96
|
+
document.addEventListener('trix-blur', useFocus),
|
97
|
+
useFocus())
|
98
|
+
: null
|
120
99
|
|
121
|
-
|
100
|
+
document.addEventListener('trix-focus', inlineFocus)
|
101
|
+
document.addEventListener('trix-blur', inlineFocus)
|
122
102
|
}
|
123
103
|
|
124
|
-
|
125
|
-
|
126
|
-
|
104
|
+
useEffect(() => {
|
105
|
+
if (!editor || !template) return
|
106
|
+
editor.loadHTML('')
|
107
|
+
editor.setSelectedRange([0, 0])
|
108
|
+
editor.insertHTML(template)
|
109
|
+
}, [editor, template])
|
127
110
|
|
128
111
|
useEffect(() => {
|
129
|
-
|
130
|
-
|
112
|
+
if (!element) return
|
113
|
+
element.addEventListener('click', ({target}) => {
|
114
|
+
const trixEditorContainer = target.closest('.pb_rich_text_editor_kit')
|
115
|
+
if (!trixEditorContainer) return
|
131
116
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
117
|
+
const anchorElement = target.closest('a')
|
118
|
+
if (!anchorElement) return
|
119
|
+
|
120
|
+
if (anchorElement.hasAttribute('href')) window.open(anchorElement.href)
|
121
|
+
})
|
122
|
+
}, [element])
|
123
|
+
|
124
|
+
const richTextEditorClass = 'pb_rich_text_editor_kit',
|
125
|
+
simpleClass = simple ? 'simple' : '',
|
126
|
+
focusClass = focus ? 'focus-editor-targets' : '',
|
127
|
+
stickyClass = sticky ? 'sticky' : '',
|
128
|
+
inlineClass = inline ? 'inline' : '',
|
129
|
+
toolbarBottomClass = toolbarBottom ? 'toolbar-bottom' : ''
|
130
|
+
|
131
|
+
let css = classnames(globalProps(props), className)
|
132
|
+
css = classnames(
|
133
|
+
richTextEditorClass,
|
134
|
+
simpleClass,
|
135
|
+
focusClass,
|
136
|
+
stickyClass,
|
137
|
+
inlineClass,
|
138
|
+
toolbarBottomClass,
|
139
|
+
css
|
140
|
+
)
|
139
141
|
|
140
142
|
return (
|
141
143
|
<div
|
142
144
|
{...ariaProps}
|
143
145
|
{...dataProps}
|
144
|
-
className={
|
145
|
-
RichTextEditorClass,
|
146
|
-
SimpleClass,
|
147
|
-
FocusClass,
|
148
|
-
StickyClass,
|
149
|
-
InlineClass,
|
150
|
-
ToolbarBottomClass,
|
151
|
-
css
|
152
|
-
)}
|
146
|
+
className={css}
|
153
147
|
>
|
154
|
-
<
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
/>
|
160
|
-
<trix-editor
|
161
|
-
input={id}
|
162
|
-
name={name}
|
148
|
+
<TrixEditor
|
149
|
+
className=""
|
150
|
+
fileParamName={name}
|
151
|
+
onChange={onChange}
|
152
|
+
onEditorReady={handleOnEditorReady}
|
163
153
|
placeholder={placeholder}
|
164
|
-
|
154
|
+
value={value}
|
165
155
|
/>
|
166
156
|
</div>
|
167
157
|
)
|
@@ -1 +1 @@
|
|
1
|
-
<%= pb_rails("rich_text_editor", props: {id: "default"}) %>
|
1
|
+
<%= pb_rails("rich_text_editor", props: {id: "default", value: "Add your text here. You can format your text, add links, quotes, and bullets."}) %>
|
@@ -1,12 +1,19 @@
|
|
1
|
-
import React from 'react'
|
1
|
+
import React, { useState } from 'react'
|
2
2
|
import { RichTextEditor } from '../../'
|
3
3
|
|
4
|
-
const RichTextEditorDefault = (props) =>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
const RichTextEditorDefault = (props) => {
|
5
|
+
const [value, setValue] = useState('Add your text here. You can format your text, add links, quotes, and bullets.'),
|
6
|
+
handleOnChange = (html) => setValue(html)
|
7
|
+
|
8
|
+
return (
|
9
|
+
<div>
|
10
|
+
<RichTextEditor
|
11
|
+
onChange={handleOnChange}
|
12
|
+
value={value}
|
13
|
+
{...props}
|
14
|
+
/>
|
15
|
+
</div>
|
16
|
+
)
|
17
|
+
}
|
11
18
|
|
12
19
|
export default RichTextEditorDefault
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import React, { type Node } from 'react'
|
4
4
|
import classnames from 'classnames'
|
5
5
|
import { buildAriaProps, buildDataProps } from '../utilities/props'
|
6
|
-
import { globalProps } from '../utilities/globalProps
|
6
|
+
import { globalProps } from '../utilities/globalProps'
|
7
7
|
import PbTable from './'
|
8
8
|
|
9
9
|
type TableProps = {
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import React from 'react'
|
3
3
|
import classnames from 'classnames'
|
4
4
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
5
|
-
import { globalProps } from '../utilities/globalProps
|
5
|
+
import { globalProps } from '../utilities/globalProps'
|
6
6
|
|
7
7
|
type TableRowPropTypes = {
|
8
8
|
aria?: object,
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import React, { forwardRef } from 'react'
|
3
3
|
import classnames from 'classnames'
|
4
4
|
|
5
|
-
import { globalProps } from '../utilities/globalProps
|
5
|
+
import { globalProps } from '../utilities/globalProps'
|
6
6
|
import { buildAriaProps, buildDataProps } from '../utilities/props'
|
7
7
|
|
8
8
|
import Flex from '../pb_flex/_flex'
|
@@ -75,6 +75,8 @@ const TextInput = (props: TextInputProps, ref: React.ElementRef<"input">) => {
|
|
75
75
|
globalProps(props),
|
76
76
|
className,
|
77
77
|
])
|
78
|
+
const uniqueTextInputKey = `${id ? id : ''}${Math.ceil(Math.random() * 100000)}`
|
79
|
+
|
78
80
|
const addOnIcon = (
|
79
81
|
<Icon
|
80
82
|
className="add-on-icon"
|
@@ -89,6 +91,7 @@ const TextInput = (props: TextInputProps, ref: React.ElementRef<"input">) => {
|
|
89
91
|
className="text_input"
|
90
92
|
disabled={disabled}
|
91
93
|
id={id}
|
94
|
+
key={uniqueTextInputKey}
|
92
95
|
name={name}
|
93
96
|
onChange={onChange}
|
94
97
|
placeholder={placeholder}
|
@@ -4,12 +4,12 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
[class^=pb_text_input_kit] {
|
7
|
+
margin-bottom: $space_sm;
|
7
8
|
.pb_text_input_kit_label {
|
8
9
|
margin-bottom: $space_xs;
|
9
10
|
display: block;
|
10
11
|
}
|
11
12
|
.text_input_wrapper {
|
12
|
-
margin-bottom: $space_sm;
|
13
13
|
display: block;
|
14
14
|
input::placeholder,
|
15
15
|
.text_input .placeholder {
|
@@ -75,3 +75,17 @@ test('returns additional class name', () => {
|
|
75
75
|
const kit = screen.getByTestId(testId)
|
76
76
|
expect(kit).toHaveClass(`${kitClass} dark error`)
|
77
77
|
})
|
78
|
+
|
79
|
+
test('returns additional class name', () => {
|
80
|
+
render(
|
81
|
+
<TextInput
|
82
|
+
data={{ testid: testId }}
|
83
|
+
label="First Name"
|
84
|
+
marginBottom="lg"
|
85
|
+
placeholder="Enter first name"
|
86
|
+
/>
|
87
|
+
)
|
88
|
+
|
89
|
+
const kit = screen.getByTestId(testId)
|
90
|
+
expect(kit).toHaveClass(`${kitClass} mb_lg`)
|
91
|
+
})
|
@@ -5,7 +5,7 @@ import classnames from 'classnames'
|
|
5
5
|
|
6
6
|
import DateTime from '../pb_kit/dateTime.js'
|
7
7
|
import { buildCss } from '../utilities/props'
|
8
|
-
import { globalProps } from '../utilities/globalProps
|
8
|
+
import { globalProps } from '../utilities/globalProps'
|
9
9
|
|
10
10
|
import Body from '../pb_body/_body'
|
11
11
|
import Caption from '../pb_caption/_caption'
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import React from 'react'
|
4
4
|
import classnames from 'classnames'
|
5
5
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
6
|
-
import { deprecatedProps, globalProps } from '../utilities/globalProps
|
6
|
+
import { deprecatedProps, globalProps } from '../utilities/globalProps'
|
7
7
|
|
8
8
|
type TitleProps = {
|
9
9
|
aria?: object,
|
@@ -6,7 +6,7 @@ import AsyncSelect from 'react-select/async'
|
|
6
6
|
import CreateableSelect from 'react-select/creatable'
|
7
7
|
import AsyncCreateableSelect from 'react-select/async-creatable'
|
8
8
|
import { get, isString, uniqueId } from 'lodash'
|
9
|
-
import { globalProps } from '../utilities/globalProps
|
9
|
+
import { globalProps } from '../utilities/globalProps'
|
10
10
|
import classnames from 'classnames'
|
11
11
|
|
12
12
|
import Control from './components/Control'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import React from 'react'
|
3
3
|
import classnames from 'classnames'
|
4
4
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
5
|
-
import { globalProps } from '../utilities/globalProps
|
5
|
+
import { globalProps } from '../utilities/globalProps'
|
6
6
|
|
7
7
|
type UserBadgeProps = {
|
8
8
|
aria?: object,
|
@@ -6,7 +6,7 @@
|
|
6
6
|
import React from 'react'
|
7
7
|
import classnames from 'classnames'
|
8
8
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
9
|
-
import { globalProps } from '../utilities/globalProps
|
9
|
+
import { globalProps } from '../utilities/globalProps'
|
10
10
|
import Joyride from 'react-joyride'
|
11
11
|
import Button from '../pb_button/_button'
|
12
12
|
import Flex from '../pb_flex/_flex'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
import React from 'react'
|
4
4
|
import classnames from 'classnames'
|
5
|
-
import { globalProps } from '../utilities/globalProps
|
5
|
+
import { globalProps } from '../utilities/globalProps'
|
6
6
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
7
7
|
|
8
8
|
import Caption from '../pb_caption/_caption'
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import Highcharts from 'highcharts'
|
2
2
|
|
3
3
|
import { highchartsTheme } from '../pb_dashboard/pbChartsLightTheme'
|
4
|
+
import { highchartsDarkTheme } from '../pb_dashboard/pbChartsDarkTheme'
|
4
5
|
import colors from '../tokens/exports/_colors.scss'
|
5
6
|
|
6
7
|
import pie from 'highcharts/modules/variable-pie'
|
@@ -67,10 +68,14 @@ class pbChart {
|
|
67
68
|
}
|
68
69
|
}
|
69
70
|
|
71
|
+
setupTheme() {
|
72
|
+
this.options.dark ? Highcharts.setOptions(highchartsDarkTheme) : Highcharts.setOptions(highchartsTheme)
|
73
|
+
}
|
74
|
+
|
70
75
|
setupGauge(options) {
|
71
76
|
highchartsMore(Highcharts)
|
72
77
|
solidGauge(Highcharts)
|
73
|
-
|
78
|
+
this.setupTheme()
|
74
79
|
|
75
80
|
Highcharts.chart(this.defaults.id, {
|
76
81
|
chart: {
|
@@ -140,7 +145,7 @@ class pbChart {
|
|
140
145
|
}
|
141
146
|
|
142
147
|
setupPieChart(options) {
|
143
|
-
|
148
|
+
this.setupTheme()
|
144
149
|
Highcharts.chart(this.defaults.id, {
|
145
150
|
title: {
|
146
151
|
text: this.defaults.title,
|
@@ -187,8 +192,7 @@ class pbChart {
|
|
187
192
|
}
|
188
193
|
|
189
194
|
setupChart(options) {
|
190
|
-
|
191
|
-
|
195
|
+
this.setupTheme()
|
192
196
|
const configOptions = {
|
193
197
|
title: {
|
194
198
|
text: this.defaults.title,
|
@@ -0,0 +1,29 @@
|
|
1
|
+
.align_content_start {
|
2
|
+
display: flex;
|
3
|
+
align-content: start !important;
|
4
|
+
}
|
5
|
+
|
6
|
+
.align_content_end {
|
7
|
+
display: flex;
|
8
|
+
align-content: end !important;
|
9
|
+
}
|
10
|
+
|
11
|
+
.align_content_center {
|
12
|
+
display: flex;
|
13
|
+
align-content: center !important;
|
14
|
+
}
|
15
|
+
|
16
|
+
.align_content_space_between {
|
17
|
+
display: flex;
|
18
|
+
align-content: space-between !important;
|
19
|
+
}
|
20
|
+
|
21
|
+
.align_content_space_around {
|
22
|
+
display: flex;
|
23
|
+
align-content: space-around !important;
|
24
|
+
}
|
25
|
+
|
26
|
+
.align_content_space_evenly {
|
27
|
+
display: flex;
|
28
|
+
align-content: space-evenly !important;
|
29
|
+
}
|