playbook_ui 15.2.0.pre.alpha.PLAY2589advancedtableinlinerowloadingtoggleicon11644 → 15.2.0.pre.alpha.PLAY236711331
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 -2
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +1 -3
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +0 -59
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.md +1 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb +3 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_subrow_headers.html.erb +3 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.jsx +0 -16
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.md +2 -11
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling_react.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/index.js +1 -5
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +6 -6
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +6 -6
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +2 -3
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +5 -49
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern.jsx +1 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +1 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +3 -5
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_description.md +0 -2
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +1 -4
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.test.js +0 -10
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_description.md +1 -1
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +6 -25
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +2 -41
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +20 -60
- data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +0 -36
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +2 -8
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +0 -6
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.test.js +1 -127
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +1 -35
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +2 -71
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +0 -1
- data/app/pb_kits/playbook/tokens/_positioning.scss +0 -1
- data/app/pb_kits/playbook/utilities/_positioning.scss +1 -6
- data/app/pb_kits/playbook/utilities/globalProps.ts +1 -3
- data/dist/chunks/{_line_graph-D5MBnrO9.js → _line_graph-AKTV-rqw.js} +1 -1
- data/dist/chunks/_typeahead-DCInCM2E.js +6 -0
- data/dist/chunks/{_weekday_stacked-BQrF2byq.js → _weekday_stacked-ByJl1kOQ.js} +3 -3
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +0 -6
- data/dist/playbook-doc.js +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/pb_forms_helper.rb +6 -7
- data/lib/playbook/version.rb +1 -1
- data/lib/playbook/z_index.rb +1 -1
- metadata +5 -64
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb +0 -39
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row_rails.html.erb +0 -51
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_per_row_rails.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_rails.html.erb +0 -40
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control_rails.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data_inline_loading_empty_children.js +0 -42
- data/app/pb_kits/playbook/pb_pb_bar_graph/docs/_description.md +0 -3
- data/app/pb_kits/playbook/pb_pb_circle_chart/docs/_description.md +0 -3
- data/app/pb_kits/playbook/pb_pb_gauge_chart/_pb_gauge_chart.scss +0 -3
- data/app/pb_kits/playbook/pb_pb_gauge_chart/_pb_gauge_chart.tsx +0 -69
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_description.md +0 -3
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.html.erb +0 -12
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.jsx +0 -24
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_color.md +0 -5
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.html.erb +0 -45
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.jsx +0 -119
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_complex.md +0 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_default.html.erb +0 -5
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_default.jsx +0 -17
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_disable_animation.html.erb +0 -12
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_disable_animation.jsx +0 -24
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_full_circle.html.erb +0 -23
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_full_circle.jsx +0 -37
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_height.html.erb +0 -40
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_height.jsx +0 -56
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_live_data.jsx +0 -64
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.html.erb +0 -27
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.jsx +0 -40
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_min_max.md +0 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.html.erb +0 -19
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.jsx +0 -65
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_sizing.md +0 -3
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_title.html.erb +0 -14
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_title.jsx +0 -27
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.html.erb +0 -39
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.jsx +0 -58
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/_pb_gauge_chart_units.md +0 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/example.yml +0 -29
- data/app/pb_kits/playbook/pb_pb_gauge_chart/docs/index.js +0 -11
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pbGaugeGraphTheme.ts +0 -91
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.html.erb +0 -1
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.rb +0 -25
- data/app/pb_kits/playbook/pb_pb_gauge_chart/pb_gauge_chart.test.jsx +0 -80
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_attributes.jsx +0 -38
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_attributes.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_focus.jsx +0 -34
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_focus.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_inline.jsx +0 -37
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_inline.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_simple.jsx +0 -37
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_sticky.jsx +0 -38
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_sticky.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_templates.jsx +0 -69
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_templates.md +0 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default_options.html.erb +0 -36
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default_options.md +0 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default_value.jsx +0 -41
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default_value.md +0 -1
- data/dist/chunks/_typeahead-BjYBazGq.js +0 -6
|
@@ -60,10 +60,7 @@ module Playbook
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def classname
|
|
63
|
-
|
|
64
|
-
# IMPORTANT: the AutoClose class must be the last class in the string for JS to read it correctly
|
|
65
|
-
# Changing the order will break the auto_close functionality
|
|
66
|
-
generate_classname("pb_fixed_confirmation_toast_kit", status, multi_line_class) + close_class + position_class + icon_class + default_z_index + auto_close_class
|
|
63
|
+
generate_classname("pb_fixed_confirmation_toast_kit", status, multi_line_class) + close_class + position_class + auto_close_class + icon_class
|
|
67
64
|
end
|
|
68
65
|
end
|
|
69
66
|
end
|
|
@@ -75,14 +75,4 @@ test('renders position when provided', () => {
|
|
|
75
75
|
/>
|
|
76
76
|
);
|
|
77
77
|
expect(container.querySelector('.positioned_toast')).toBeInTheDocument();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test('renders max zIndex by default', () => {
|
|
81
|
-
const { container } = render(<FixedConfirmationToast />);
|
|
82
|
-
expect(container.querySelector('.z_index_max')).toBeInTheDocument();
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('applies custom zIndex when provided', () => {
|
|
86
|
-
const { container } = render(<FixedConfirmationToast zIndex={10} />);
|
|
87
|
-
expect(container.querySelector('.z_index_10')).toBeInTheDocument();
|
|
88
78
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
This kit is a wrapper around the Highcharts library. It applies styling and default settings but does NOT ship Highcharts. In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo. Once done, any prop or functionality provided by Highcharts can be used with this kit without requiring
|
|
1
|
+
This kit is a wrapper around the Highcharts library. It applies styling and default settings but does NOT ship Highcharts. In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo. Once done, any prop or functionality provided by Highcharts can be used with this kit without requiring specifc props from Playbook. The doc examples below showcase a few common usecases but are not a comprehensive list of all the functionalities possible.
|
|
2
2
|
|
|
3
3
|
See the [highcharts API docs](https://api.highcharts.com/highcharts/) for a comprehensive look at what is possible.
|
|
@@ -314,18 +314,14 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
|
|
|
314
314
|
|
|
315
315
|
const handleOnChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
|
|
316
316
|
if (!hasTyped) setHasTyped(true)
|
|
317
|
-
|
|
318
317
|
setInputValue(evt.target.value)
|
|
319
|
-
|
|
320
318
|
let phoneNumberData
|
|
321
|
-
|
|
322
319
|
if (formatAsYouType) {
|
|
323
320
|
const formattedPhoneNumberData = getCurrentSelectedData(itiRef.current, evt.target.value)
|
|
324
321
|
phoneNumberData = {...formattedPhoneNumberData, number: unformatNumber(formattedPhoneNumberData.number)}
|
|
325
322
|
} else {
|
|
326
323
|
phoneNumberData = getCurrentSelectedData(itiRef.current, evt.target.value)
|
|
327
324
|
}
|
|
328
|
-
|
|
329
325
|
setSelectedData(phoneNumberData)
|
|
330
326
|
onChange(phoneNumberData)
|
|
331
327
|
isValid(itiRef.current.isValidNumber())
|
|
@@ -374,26 +370,11 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
|
|
|
374
370
|
|
|
375
371
|
inputRef.current.addEventListener("open:countrydropdown", () => setDropDownIsOpen(true))
|
|
376
372
|
inputRef.current.addEventListener("close:countrydropdown", () => setDropDownIsOpen(false))
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
const formattedValue = target.value
|
|
383
|
-
|
|
384
|
-
// Update internal state
|
|
385
|
-
setInputValue(formattedValue)
|
|
386
|
-
setHasTyped(true)
|
|
387
|
-
|
|
388
|
-
// Get phone number data with unformatted number
|
|
389
|
-
const formattedPhoneNumberData = getCurrentSelectedData(telInputInit, formattedValue)
|
|
390
|
-
const phoneNumberData = {...formattedPhoneNumberData, number: unformatNumber(formattedPhoneNumberData.number)}
|
|
391
|
-
|
|
392
|
-
setSelectedData(phoneNumberData)
|
|
393
|
-
onChange(phoneNumberData)
|
|
394
|
-
isValid(telInputInit.isValidNumber())
|
|
395
|
-
})
|
|
396
|
-
}
|
|
373
|
+
}
|
|
374
|
+
if (formatAsYouType) {
|
|
375
|
+
inputRef.current?.addEventListener("input", (evt) => {
|
|
376
|
+
handleOnChange(evt as unknown as React.ChangeEvent<HTMLInputElement>);
|
|
377
|
+
});
|
|
397
378
|
}
|
|
398
379
|
}, [])
|
|
399
380
|
|
|
@@ -408,7 +389,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
|
|
|
408
389
|
label,
|
|
409
390
|
name,
|
|
410
391
|
onBlur: validateErrors,
|
|
411
|
-
onChange:
|
|
392
|
+
onChange: handleOnChange,
|
|
412
393
|
value: inputValue
|
|
413
394
|
}
|
|
414
395
|
|
|
@@ -11,7 +11,7 @@ import { ToolbarTypes } from "./EditorTypes";
|
|
|
11
11
|
import ToolbarHistoryItems from "./ToolbarHistory";
|
|
12
12
|
import MoreExtensionsDropdown from "./MoreExtensionsDropdown";
|
|
13
13
|
|
|
14
|
-
const EditorToolbar = ({ editor, extensions
|
|
14
|
+
const EditorToolbar = ({ editor, extensions }: any): React.ReactElement => {
|
|
15
15
|
const toolbaritems = [
|
|
16
16
|
{
|
|
17
17
|
icon: "bold",
|
|
@@ -33,50 +33,15 @@ const EditorToolbar = ({ editor, extensions, simple, sticky }: any): React.React
|
|
|
33
33
|
},
|
|
34
34
|
]
|
|
35
35
|
|
|
36
|
-
const simpleToolbaritems = [
|
|
37
|
-
{
|
|
38
|
-
icon: "bold",
|
|
39
|
-
text: "Bold",
|
|
40
|
-
classname:`toolbar_button ${editor.isActive('bold') ? 'is-active' : ''}`,
|
|
41
|
-
onclick:()=>editor.chain().focus().toggleBold().run(),
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
icon: "italic",
|
|
45
|
-
text: "Italic",
|
|
46
|
-
classname:`toolbar_button ${editor.isActive('italic') ? 'is-active' : ''}`,
|
|
47
|
-
onclick:() => editor.chain().focus().toggleItalic().run(),
|
|
48
|
-
},
|
|
49
|
-
]
|
|
50
|
-
|
|
51
36
|
return (
|
|
52
37
|
<Background backgroundColor="white"
|
|
53
|
-
className=
|
|
54
|
-
|
|
38
|
+
className="toolbar"
|
|
55
39
|
>
|
|
56
40
|
<Flex flex="0"
|
|
57
41
|
justify="between"
|
|
58
42
|
paddingX="sm"
|
|
59
43
|
paddingY="xxs"
|
|
60
44
|
>
|
|
61
|
-
{
|
|
62
|
-
simple ? (
|
|
63
|
-
<>
|
|
64
|
-
<Flex className="toolbar_block">
|
|
65
|
-
{simpleToolbaritems && simpleToolbaritems.map(
|
|
66
|
-
({ icon, text, classname, onclick}: ToolbarTypes, index: number) => (
|
|
67
|
-
<EditorButton
|
|
68
|
-
classname={classname}
|
|
69
|
-
icon={icon}
|
|
70
|
-
key={index}
|
|
71
|
-
onclick={onclick}
|
|
72
|
-
text={text}
|
|
73
|
-
/>
|
|
74
|
-
)
|
|
75
|
-
)}
|
|
76
|
-
</Flex>
|
|
77
|
-
</>
|
|
78
|
-
) : (
|
|
79
|
-
<>
|
|
80
45
|
<FlexItem className="toolbar_block"
|
|
81
46
|
displayFlex
|
|
82
47
|
>
|
|
@@ -104,10 +69,6 @@ const EditorToolbar = ({ editor, extensions, simple, sticky }: any): React.React
|
|
|
104
69
|
}
|
|
105
70
|
</FlexItem>
|
|
106
71
|
<ToolbarHistoryItems editor={editor} />
|
|
107
|
-
</>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
72
|
</Flex>
|
|
112
73
|
</Background>
|
|
113
74
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useState
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
2
|
import classnames from 'classnames'
|
|
3
3
|
import { TrixEditor } from 'react-trix'
|
|
4
4
|
|
|
@@ -77,9 +77,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
77
77
|
|
|
78
78
|
const ariaProps = buildAriaProps(aria),
|
|
79
79
|
dataProps = buildDataProps(data),
|
|
80
|
-
[editor, setEditor] = useState<Editor>()
|
|
81
|
-
[showToolbarOnFocus, setShowToolbarOnFocus] = useState(false),
|
|
82
|
-
containerRef = useRef<HTMLDivElement>(null)
|
|
80
|
+
[editor, setEditor] = useState<Editor>()
|
|
83
81
|
|
|
84
82
|
const htmlProps = buildHtmlProps(htmlOptions)
|
|
85
83
|
|
|
@@ -130,42 +128,6 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
130
128
|
document.addEventListener('trix-blur', inlineFocus)
|
|
131
129
|
}
|
|
132
130
|
|
|
133
|
-
//===========focus prop with advanced editor=================
|
|
134
|
-
const isClickInPopover = (event: Event): boolean => {
|
|
135
|
-
return !!(event.target as Element).closest('.pb_tiptap_toolbar_dropdown_popover')
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const isClickInContainer = (event: Event): boolean => {
|
|
139
|
-
return !!(containerRef.current && containerRef.current.contains(event.target as Node))
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
useEffect(() => {
|
|
143
|
-
if (!advancedEditor || !focus) return
|
|
144
|
-
|
|
145
|
-
const handleFocus = () => setShowToolbarOnFocus(true)
|
|
146
|
-
|
|
147
|
-
const handleClickOutside = (event: Event) => {
|
|
148
|
-
if (isClickInContainer(event) || isClickInPopover(event)) return
|
|
149
|
-
setShowToolbarOnFocus(false)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const editorElement = advancedEditor?.view?.dom
|
|
153
|
-
if (editorElement) {
|
|
154
|
-
editorElement.addEventListener('focus', handleFocus)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
document.addEventListener('mousedown', handleClickOutside)
|
|
158
|
-
|
|
159
|
-
return () => {
|
|
160
|
-
if (editorElement) {
|
|
161
|
-
editorElement.removeEventListener('focus', handleFocus)
|
|
162
|
-
}
|
|
163
|
-
document.removeEventListener('mousedown', handleClickOutside)
|
|
164
|
-
}
|
|
165
|
-
}, [advancedEditor, focus])
|
|
166
|
-
|
|
167
|
-
//============= end focus prop with advanced editor=================
|
|
168
|
-
|
|
169
131
|
useEffect(() => {
|
|
170
132
|
if (!editor || !template) return
|
|
171
133
|
editor.loadHTML('')
|
|
@@ -186,43 +148,41 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
186
148
|
})
|
|
187
149
|
}, [editor])
|
|
188
150
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
'
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
151
|
+
const richTextEditorClass = 'pb_rich_text_editor_kit',
|
|
152
|
+
simpleClass = simple ? 'simple' : '',
|
|
153
|
+
focusClass = focus ? 'focus-editor-targets' : '',
|
|
154
|
+
stickyClass = sticky ? 'sticky' : '',
|
|
155
|
+
inlineClass = inline ? 'inline' : '',
|
|
156
|
+
toolbarBottomClass = toolbarBottom ? 'toolbar-bottom' : ''
|
|
157
|
+
|
|
158
|
+
let css = classnames(globalProps(props, { maxWidth }), className)
|
|
159
|
+
css = classnames(
|
|
160
|
+
richTextEditorClass,
|
|
161
|
+
simpleClass,
|
|
162
|
+
focusClass,
|
|
163
|
+
stickyClass,
|
|
164
|
+
inlineClass,
|
|
165
|
+
toolbarBottomClass,
|
|
166
|
+
css
|
|
201
167
|
)
|
|
202
168
|
|
|
203
|
-
// Determine if toolbar should be shown
|
|
204
|
-
const shouldShowToolbar = focus && advancedEditor ? showToolbarOnFocus : advancedEditorToolbar
|
|
205
|
-
|
|
206
169
|
return (
|
|
207
170
|
<div
|
|
208
171
|
{...ariaProps}
|
|
209
172
|
{...dataProps}
|
|
210
173
|
{...htmlProps}
|
|
211
174
|
className={css}
|
|
212
|
-
ref={focus ? containerRef : undefined}
|
|
213
175
|
>
|
|
214
176
|
{
|
|
215
177
|
advancedEditor ? (
|
|
216
178
|
<div
|
|
217
179
|
className={classnames("pb_rich_text_editor_advanced_container", {
|
|
218
|
-
["toolbar-active"]:
|
|
180
|
+
["toolbar-active"]: advancedEditorToolbar,
|
|
219
181
|
})}
|
|
220
182
|
>
|
|
221
|
-
{
|
|
183
|
+
{advancedEditorToolbar && (
|
|
222
184
|
<EditorToolbar editor={advancedEditor}
|
|
223
185
|
extensions={extensions}
|
|
224
|
-
simple={simple}
|
|
225
|
-
sticky={sticky}
|
|
226
186
|
/>
|
|
227
187
|
)}
|
|
228
188
|
{ children }
|
|
@@ -9,37 +9,6 @@
|
|
|
9
9
|
@import "previewer_mixin";
|
|
10
10
|
|
|
11
11
|
[class^="pb_rich_text_editor_kit"] {
|
|
12
|
-
&.inline {
|
|
13
|
-
.toolbar {
|
|
14
|
-
opacity: 0;
|
|
15
|
-
transition: all 0.3s ease-in-out 0s;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
&:focus-within .toolbar {
|
|
19
|
-
opacity: 100;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.ProseMirror {
|
|
23
|
-
border: 1px solid transparent;
|
|
24
|
-
transition: all 0.3s ease-in-out 0s;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&:focus-within .ProseMirror {
|
|
28
|
-
border: 1px solid $border_light;
|
|
29
|
-
border-top: none;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
&:hover {
|
|
33
|
-
.toolbar {
|
|
34
|
-
opacity: 100;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.ProseMirror {
|
|
38
|
-
border: 1px solid $border_light;
|
|
39
|
-
border-top: none;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
12
|
.toolbar_button {
|
|
44
13
|
display: flex;
|
|
45
14
|
align-items: center;
|
|
@@ -73,11 +42,6 @@
|
|
|
73
42
|
}
|
|
74
43
|
}
|
|
75
44
|
|
|
76
|
-
.pb_rich_text_editor_tiptap_toolbar_sticky {
|
|
77
|
-
position: sticky;
|
|
78
|
-
top: 0;
|
|
79
|
-
z-index: 10;
|
|
80
|
-
}
|
|
81
45
|
.toolbar {
|
|
82
46
|
border-radius: $border_rad_heaviest $border_rad_heaviest 0 0;
|
|
83
47
|
border: 1px solid $border_light;
|
|
@@ -7,7 +7,7 @@ examples:
|
|
|
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
|
|
13
13
|
|
|
@@ -17,17 +17,11 @@ examples:
|
|
|
17
17
|
- rich_text_editor_more_extensions: Advanced (Extra Extensions)
|
|
18
18
|
- rich_text_editor_toolbar_disabled: Advanced (Toolbar disabled)
|
|
19
19
|
- rich_text_editor_simple: Simple
|
|
20
|
-
- rich_text_editor_advanced_simple: Advanced (Simple)
|
|
21
20
|
- rich_text_editor_attributes: Attributes
|
|
22
|
-
- rich_text_editor_advanced_attributes: Advanced (Attributes)
|
|
23
21
|
- rich_text_editor_focus: Focus
|
|
24
|
-
- rich_text_editor_advanced_focus: Advanced (Focus)
|
|
25
22
|
- rich_text_editor_sticky: Sticky
|
|
26
|
-
- rich_text_editor_advanced_sticky: Advanced (Sticky)
|
|
27
23
|
- rich_text_editor_templates: Templates
|
|
28
|
-
-
|
|
29
|
-
# - rich_text_editor_toolbar_bottom: Toolbar Bottom
|
|
24
|
+
- rich_text_editor_toolbar_bottom: Toolbar Bottom
|
|
30
25
|
- rich_text_editor_inline: Inline
|
|
31
|
-
- rich_text_editor_advanced_inline: Advanced (Inline)
|
|
32
26
|
- rich_text_editor_preview: Preview
|
|
33
27
|
- rich_text_editor_advanced_preview: Advanced Preview
|
|
@@ -11,9 +11,3 @@ export { default as RichTextEditorAdvancedDefault } from './_rich_text_editor_ad
|
|
|
11
11
|
export { default as RichTextEditorMoreExtensions } from './_rich_text_editor_more_extensions.jsx'
|
|
12
12
|
export { default as RichTextEditorToolbarDisabled } from './_rich_text_editor_toolbar_disabled.jsx'
|
|
13
13
|
export { default as RichTextEditorAdvancedPreview } from './_rich_text_editor_advanced_preview.jsx'
|
|
14
|
-
export { default as RichTextEditorAdvancedSimple } from './_rich_text_editor_advanced_simple.jsx'
|
|
15
|
-
export { default as RichTextEditorAdvancedFocus } from './_rich_text_editor_advanced_focus.jsx'
|
|
16
|
-
export { default as RichTextEditorAdvancedTemplates } from './_rich_text_editor_advanced_templates.jsx'
|
|
17
|
-
export { default as RichTextEditorAdvancedAttributes } from './_rich_text_editor_advanced_attributes.jsx'
|
|
18
|
-
export { default as RichTextEditorAdvancedSticky } from './_rich_text_editor_advanced_sticky.jsx'
|
|
19
|
-
export { default as RichTextEditorAdvancedInline } from './_rich_text_editor_advanced_inline.jsx'
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { render, screen
|
|
3
|
-
import { useEditor, EditorContent } from "@tiptap/react"
|
|
4
|
-
import StarterKit from "@tiptap/starter-kit"
|
|
2
|
+
import { render, screen } from '../utilities/test-utils'
|
|
5
3
|
|
|
6
4
|
import RichTextEditor from './_rich_text_editor'
|
|
7
5
|
|
|
@@ -64,127 +62,3 @@ test('returns "Dark" class name', () => {
|
|
|
64
62
|
const kit = screen.getByTestId(testId)
|
|
65
63
|
expect(kit).toHaveClass(`${kitClass} dark`)
|
|
66
64
|
})
|
|
67
|
-
|
|
68
|
-
// TipTap testing
|
|
69
|
-
const TestAdvancedEditor = ({ toolbarOnFocus = false, ...props }) => {
|
|
70
|
-
const editor = useEditor({
|
|
71
|
-
extensions: [StarterKit],
|
|
72
|
-
content: '<p>Test content</p>',
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
if (!editor) return null
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<RichTextEditor
|
|
79
|
-
advancedEditor={editor}
|
|
80
|
-
data={{ testid: testId }}
|
|
81
|
-
toolbarOnFocus={toolbarOnFocus}
|
|
82
|
-
{...props}
|
|
83
|
-
>
|
|
84
|
-
<EditorContent editor={editor} />
|
|
85
|
-
</RichTextEditor>
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
describe('Advanced TipTap Editor works as expected', () => {
|
|
90
|
-
test('renders advanced editor with toolbar', () => {
|
|
91
|
-
render(<TestAdvancedEditor />)
|
|
92
|
-
|
|
93
|
-
const kit = screen.getByTestId(testId)
|
|
94
|
-
expect(kit).toHaveClass(kitClass)
|
|
95
|
-
|
|
96
|
-
// Check for advanced container
|
|
97
|
-
const advancedContainer = kit.querySelector('.pb_rich_text_editor_advanced_container')
|
|
98
|
-
expect(advancedContainer).toBeInTheDocument()
|
|
99
|
-
|
|
100
|
-
// Check for toolbar
|
|
101
|
-
const toolbar = kit.querySelector('.toolbar')
|
|
102
|
-
expect(toolbar).toBeInTheDocument()
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
test('renders advanced editor without toolbar when advancedEditorToolbar is false', () => {
|
|
106
|
-
render(<TestAdvancedEditor advancedEditorToolbar={false} />)
|
|
107
|
-
|
|
108
|
-
const kit = screen.getByTestId(testId)
|
|
109
|
-
const toolbar = kit.querySelector('.toolbar')
|
|
110
|
-
expect(toolbar).not.toBeInTheDocument()
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
test('shows/hides toolbar on focus when focus is enabled', async () => {
|
|
114
|
-
render(<TestAdvancedEditor focus />)
|
|
115
|
-
|
|
116
|
-
const kit = screen.getByTestId(testId)
|
|
117
|
-
|
|
118
|
-
// Initially toolbar should be hidden
|
|
119
|
-
let toolbar = kit.querySelector('.toolbar')
|
|
120
|
-
expect(toolbar).not.toBeInTheDocument()
|
|
121
|
-
|
|
122
|
-
const editorElement = kit.querySelector('.ProseMirror')
|
|
123
|
-
// Focus the editor
|
|
124
|
-
fireEvent.focus(editorElement)
|
|
125
|
-
|
|
126
|
-
// Toolbar should now be visible
|
|
127
|
-
await waitFor(() => {
|
|
128
|
-
toolbar = kit.querySelector('.toolbar')
|
|
129
|
-
expect(toolbar).toBeInTheDocument()
|
|
130
|
-
})
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
test('supports simple prop with advanced editor', () => {
|
|
135
|
-
render(<TestAdvancedEditor simple />)
|
|
136
|
-
|
|
137
|
-
const kit = screen.getByTestId(testId)
|
|
138
|
-
const toolbar = kit.querySelector('.toolbar')
|
|
139
|
-
expect(toolbar).toBeInTheDocument()
|
|
140
|
-
const toolbarDropdown = kit.querySelector('.editor_dropdown_button')
|
|
141
|
-
expect(toolbarDropdown).not.toBeInTheDocument()
|
|
142
|
-
expect(kit).toHaveClass(`${kitClass} simple`)
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
test('supports sticky prop with advanced editor', () => {
|
|
146
|
-
render(<TestAdvancedEditor sticky />)
|
|
147
|
-
|
|
148
|
-
const kit = screen.getByTestId(testId)
|
|
149
|
-
const stickyToolbar = kit.querySelector('.pb_rich_text_editor_tiptap_toolbar_sticky')
|
|
150
|
-
expect(stickyToolbar).toBeInTheDocument()
|
|
151
|
-
expect(kit).toHaveClass(`${kitClass} sticky`)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
test('applies aria-label when provided', () => {
|
|
155
|
-
const ariaLabel = 'Rich Text Editor'
|
|
156
|
-
render(<TestAdvancedEditor aria={{ label: ariaLabel }} />)
|
|
157
|
-
|
|
158
|
-
const kit = screen.getByTestId(testId)
|
|
159
|
-
expect(kit).toHaveAttribute('aria-label', ariaLabel)
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
test('supports inline prop with advanced editor', () => {
|
|
163
|
-
render(<TestAdvancedEditor inline />)
|
|
164
|
-
|
|
165
|
-
const kit = screen.getByTestId(testId)
|
|
166
|
-
const toolbar = kit.querySelector('.toolbar')
|
|
167
|
-
expect(toolbar).toBeInTheDocument()
|
|
168
|
-
expect(kit).toHaveClass(`${kitClass} inline`)
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
describe('TipTap Editor Functionality', () => {
|
|
172
|
-
test('can type and update content', async () => {
|
|
173
|
-
render(<TestAdvancedEditor />)
|
|
174
|
-
|
|
175
|
-
const kit = screen.getByTestId(testId)
|
|
176
|
-
const editorContent = kit.querySelector('.ProseMirror')
|
|
177
|
-
|
|
178
|
-
// Focus and type in the editor
|
|
179
|
-
fireEvent.focus(editorContent)
|
|
180
|
-
fireEvent.input(editorContent, {
|
|
181
|
-
target: { textContent: 'New content' }
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
await waitFor(() => {
|
|
185
|
-
expect(editorContent).toHaveTextContent('New content')
|
|
186
|
-
})
|
|
187
|
-
})
|
|
188
|
-
})
|
|
189
|
-
})
|
|
190
|
-
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { render, screen
|
|
2
|
+
import { render, screen } from '../utilities/test-utils'
|
|
3
3
|
import Typeahead from './_typeahead'
|
|
4
4
|
|
|
5
5
|
const options = [
|
|
@@ -137,38 +137,4 @@ test('typeahead with colored pills', () => {
|
|
|
137
137
|
const kit = screen.getByTestId('pills-color-test')
|
|
138
138
|
const pill = kit.querySelector(".pb_form_pill_kit.pb_form_pill_neutral")
|
|
139
139
|
expect(pill).toBeInTheDocument()
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
test('typeahead with defaultValue with focus behavior', async () => {
|
|
143
|
-
render(
|
|
144
|
-
<Typeahead
|
|
145
|
-
data={{ testid: 'default-value-focus-test' }}
|
|
146
|
-
defaultValue={[options[1]]}
|
|
147
|
-
options={options}
|
|
148
|
-
/>
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
const kit = screen.getByTestId('default-value-focus-test')
|
|
152
|
-
const inputDiv = kit.querySelector(".typeahead-kit-select__single-value")
|
|
153
|
-
expect(inputDiv).toHaveTextContent("Red")
|
|
154
|
-
|
|
155
|
-
// Test that the control can receive focus
|
|
156
|
-
const control = kit.querySelector('.typeahead-kit-select__control')
|
|
157
|
-
expect(control).toBeInTheDocument()
|
|
158
|
-
|
|
159
|
-
// Simulate opening the menu by clicking the control
|
|
160
|
-
fireEvent.mouseDown(control)
|
|
161
|
-
|
|
162
|
-
// Wait for menu to appear
|
|
163
|
-
await waitFor(() => {
|
|
164
|
-
const menu = kit.querySelector('.typeahead-kit-select__menu')
|
|
165
|
-
expect(menu).toBeInTheDocument()
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
// Check that the correct option has the focused class
|
|
169
|
-
await waitFor(() => {
|
|
170
|
-
const focusedOption = kit.querySelector('.typeahead-kit-select__option--is-focused')
|
|
171
|
-
expect(focusedOption).toBeInTheDocument()
|
|
172
|
-
expect(focusedOption).toHaveTextContent('Red')
|
|
173
|
-
})
|
|
174
140
|
})
|