playbook_ui 16.1.0.pre.rc.2 → 16.1.0.pre.rc.3
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_background/docs/_background_responsive.jsx +30 -0
- data/app/pb_kits/playbook/pb_background/docs/_background_responsive.md +1 -0
- data/app/pb_kits/playbook/pb_background/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_background/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_with_required_indicator.html.erb +3 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_input_display.html.erb +74 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_input_display.jsx +87 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_input_display.md +3 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +35 -33
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +33 -6
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_required_indicator.jsx +35 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_required_indicator.md +3 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.html.erb +10 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.jsx +21 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.md +3 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +5 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.test.js +33 -18
- data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +29 -11
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_required_indicator.html.erb +5 -0
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_required_indicator.jsx +25 -0
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_required_indicator.md +3 -0
- data/app/pb_kits/playbook/pb_textarea/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_textarea/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_textarea/index.ts +12 -5
- data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +6 -0
- data/app/pb_kits/playbook/pb_textarea/textarea.rb +2 -0
- data/app/pb_kits/playbook/pb_textarea/textarea.test.js +18 -1
- data/app/pb_kits/playbook/utilities/test/globalProps/globalProps.integration.test.js +936 -0
- data/dist/chunks/{_pb_line_graph-hxi01lk7.js → _pb_line_graph-BgKF_zz1.js} +1 -1
- data/dist/chunks/{_typeahead-BgLnlhzP.js → _typeahead-B9a6ZsEP.js} +1 -1
- data/dist/chunks/{globalProps-DgYwLYNx.js → globalProps-BhVYCqRf.js} +1 -1
- data/dist/chunks/{lib-NLxTo8OB.js → lib-DD34ZrWL.js} +1 -1
- data/dist/chunks/vendor.js +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 23eaf43827afe3364cfd4d2e9ab5cbb7c1da29851e28c70e0efe069a291e68f6
|
|
4
|
+
data.tar.gz: '05591b93014ec55478edfa95fb2d7c48fa8a82c11969c6bd5847f79817a26f77'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 88d25759c335f9c4178ce237e328adbd87b7bf57e2c39882a4cb7af2783ee383a5f52cdc59011f165c199be881f159887e7a348fa1abd7f04ee0793a456585a9
|
|
7
|
+
data.tar.gz: 628e81663cc1b9bf316d5734530510cbc721fa0afafb83aa8c5ac81d8200833a7cca94b49c432dee979fda90631715274c14cd2ab49ca5eb05df745d8a0ab906
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import Background from '../../pb_background/_background'
|
|
3
|
+
|
|
4
|
+
const BackgroundResponsive = (props) => (
|
|
5
|
+
<>
|
|
6
|
+
<Background
|
|
7
|
+
alt="colorful background"
|
|
8
|
+
backgroundColor={{ xs: "primary", sm: "warning", md: "success", lg: "error", xl: "category_1" }}
|
|
9
|
+
className="background lazyload"
|
|
10
|
+
padding="xl"
|
|
11
|
+
{...props}
|
|
12
|
+
/>
|
|
13
|
+
<br/>
|
|
14
|
+
<Background
|
|
15
|
+
alt="colorful background"
|
|
16
|
+
className="background lazyload"
|
|
17
|
+
imageUrl={{
|
|
18
|
+
xs: "https://unsplash.it/500/400/?image=633",
|
|
19
|
+
sm: "https://images.unsplash.com/photo-1528459801416-a9e53bbf4e17?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80",
|
|
20
|
+
md: "https://unsplash.it/500/400/?image=633",
|
|
21
|
+
lg: "https://images.unsplash.com/photo-1528459801416-a9e53bbf4e17?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80",
|
|
22
|
+
xl: "https://unsplash.it/500/400/?image=633"
|
|
23
|
+
}}
|
|
24
|
+
padding="xl"
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
</>
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
export default BackgroundResponsive
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
The `backgroundColor`, `backgroundSize`, `backgroundPosition`, `backgroundRepeat`, and `imageUrl` props support responsive sizes. To use them, pass an object to the prop containing your values relative to responsive break points. To test this here, resize your browser window to responsively change these Backgrounds' `backgroundColor` and `imageUrl`.
|
|
@@ -7,3 +7,4 @@ export { default as BackgroundStatusSubtle } from './_background_status_subtle.j
|
|
|
7
7
|
export { default as BackgroundCategory } from './_background_category.jsx'
|
|
8
8
|
export { default as BackgroundSize } from './_background_size.jsx'
|
|
9
9
|
export { default as BackgroundOverlay } from './_background_overlay.jsx'
|
|
10
|
+
export { default as BackgroundResponsive } from './_background_responsive.jsx'
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<%= pb_form_with(scope: :example, url: "", method: :get, validate: true) do |form| %>
|
|
2
2
|
<%= form.text_field :example_text_field, props: { label: true, required: true, required_indicator: true } %>
|
|
3
3
|
<%= form.text_field :example_text_field_2, props: { label: "Text Field Custom Label", required: true, required_indicator: true } %>
|
|
4
|
+
<%= form.text_area :example_text_area, props: { label: true, required: true, required_indicator: true } %>
|
|
5
|
+
<%= form.text_area :example_text_area_2, props: { label: "Textarea Custom Label", required: true, required_indicator: true } %>
|
|
4
6
|
<%= form.email_field :example_email_field, props: { label: true, required: true, required_indicator: true } %>
|
|
5
7
|
<%= form.number_field :example_number_field, props: { label: true, required: true, required_indicator: true } %>
|
|
6
8
|
<%= form.search_field :example_search_field, props: { label: true, required: true, required_indicator: true } %>
|
|
@@ -11,4 +13,4 @@
|
|
|
11
13
|
<%= action.submit %>
|
|
12
14
|
<%= action.button props: { type: "reset", text: "Cancel", variant: "secondary" } %>
|
|
13
15
|
<% end %>
|
|
14
|
-
<% end %>
|
|
16
|
+
<% end %>
|
data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_input_display.html.erb
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<% treeData = [{
|
|
2
|
+
label: "Power Home Remodeling",
|
|
3
|
+
value: "powerHomeRemodeling",
|
|
4
|
+
id: "100",
|
|
5
|
+
expanded: true,
|
|
6
|
+
children: [
|
|
7
|
+
{
|
|
8
|
+
label: "People",
|
|
9
|
+
value: "people",
|
|
10
|
+
id: "101",
|
|
11
|
+
expanded: true,
|
|
12
|
+
children: [
|
|
13
|
+
{
|
|
14
|
+
label: "Talent Acquisition",
|
|
15
|
+
value: "talentAcquisition",
|
|
16
|
+
id: "102",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: "Business Affairs",
|
|
20
|
+
value: "businessAffairs",
|
|
21
|
+
id: "103",
|
|
22
|
+
children: [
|
|
23
|
+
{
|
|
24
|
+
label: "Initiatives",
|
|
25
|
+
value: "initiatives",
|
|
26
|
+
id: "104",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: "Learning & Development",
|
|
30
|
+
value: "learningAndDevelopment",
|
|
31
|
+
id: "105",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: "People Experience",
|
|
37
|
+
value: "peopleExperience",
|
|
38
|
+
id: "106",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: "Contact Center",
|
|
44
|
+
value: "contactCenter",
|
|
45
|
+
id: "107",
|
|
46
|
+
children: [
|
|
47
|
+
{
|
|
48
|
+
label: "Appointment Management",
|
|
49
|
+
value: "appointmentManagement",
|
|
50
|
+
id: "108",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: "Customer Service",
|
|
54
|
+
value: "customerService",
|
|
55
|
+
id: "109",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: "Energy",
|
|
59
|
+
value: "energy",
|
|
60
|
+
id: "110",
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
}] %>
|
|
66
|
+
|
|
67
|
+
<%= pb_rails("multi_level_select", props: {
|
|
68
|
+
id: "multi-level-select-input-display-none",
|
|
69
|
+
name: :foo,
|
|
70
|
+
tree_data: treeData,
|
|
71
|
+
input_display: "none",
|
|
72
|
+
return_all_selected: true,
|
|
73
|
+
})
|
|
74
|
+
%>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import MultiLevelSelect from "../_multi_level_select";
|
|
3
|
+
|
|
4
|
+
const treeData = [
|
|
5
|
+
{
|
|
6
|
+
label: "Power Home Remodeling",
|
|
7
|
+
value: "powerHomeRemodeling",
|
|
8
|
+
id: "powerhome1",
|
|
9
|
+
expanded: true,
|
|
10
|
+
children: [
|
|
11
|
+
{
|
|
12
|
+
label: "People",
|
|
13
|
+
value: "people",
|
|
14
|
+
id: "people1",
|
|
15
|
+
expanded: true,
|
|
16
|
+
children: [
|
|
17
|
+
{
|
|
18
|
+
label: "Talent Acquisition",
|
|
19
|
+
value: "talentAcquisition",
|
|
20
|
+
id: "talent1",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: "Business Affairs",
|
|
24
|
+
value: "businessAffairs",
|
|
25
|
+
id: "business1",
|
|
26
|
+
children: [
|
|
27
|
+
{
|
|
28
|
+
label: "Initiatives",
|
|
29
|
+
value: "initiatives",
|
|
30
|
+
id: "initiative1",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: "Learning & Development",
|
|
34
|
+
value: "learningAndDevelopment",
|
|
35
|
+
id: "development1",
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: "People Experience",
|
|
41
|
+
value: "peopleExperience",
|
|
42
|
+
id: "experience1",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: "Contact Center",
|
|
48
|
+
value: "contactCenter",
|
|
49
|
+
id: "contact1",
|
|
50
|
+
children: [
|
|
51
|
+
{
|
|
52
|
+
label: "Appointment Management",
|
|
53
|
+
value: "appointmentManagement",
|
|
54
|
+
id: "appointment1",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: "Customer Service",
|
|
58
|
+
value: "customerService",
|
|
59
|
+
id: "customer1",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: "Energy",
|
|
63
|
+
value: "energy",
|
|
64
|
+
id: "energy1",
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
const MultiLevelSelectInputDisplay = (props) => {
|
|
73
|
+
return (
|
|
74
|
+
<MultiLevelSelect
|
|
75
|
+
id="multi-level-select-input-display-none"
|
|
76
|
+
inputDisplay="none"
|
|
77
|
+
onSelect={(selectedNodes) =>
|
|
78
|
+
console.log("Selected Items", selectedNodes)
|
|
79
|
+
}
|
|
80
|
+
returnAllSelected
|
|
81
|
+
treeData={treeData}
|
|
82
|
+
{...props}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default MultiLevelSelectInputDisplay;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
Use the `inputDisplay`/`input_display` prop to optionally display only the count in the display as opposed to multiple pills. This prop is set to 'pills' by default.
|
|
2
|
+
|
|
3
|
+
**NOTE**: `inputDisplay`/`input_display` is particularly useful for larger trees that may return many pill selections, helping to keep the input field clean and compact. This prop should not be used with the Single Select variant.
|
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
examples:
|
|
2
2
|
rails:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
- multi_level_select_default: Default
|
|
4
|
+
- multi_level_select_single: Single Select
|
|
5
|
+
- multi_level_select_single_children_only: Single Select w/ Hidden Radios
|
|
6
|
+
- multi_level_select_return_all_selected: Return All Selected
|
|
7
|
+
- multi_level_select_input_display: With Input Display None
|
|
8
|
+
- multi_level_select_selected_ids: Selected Ids
|
|
9
|
+
- multi_level_select_with_form: With Form
|
|
10
|
+
- multi_level_select_color: With Pills (Custom Color)
|
|
11
|
+
- multi_level_select_reset: Reset Selection
|
|
12
|
+
- multi_level_select_label: With Label
|
|
13
|
+
- multi_level_select_error: Error
|
|
14
|
+
- multi_level_select_disabled: Disabled Input
|
|
15
|
+
- multi_level_select_disabled_options_default: Disabled Options (Default)
|
|
16
|
+
- multi_level_select_disabled_options: Disabled Options (Return All Selected)
|
|
17
|
+
- multi_level_select_disabled_options_parent_default: Disabled Parent Option (Default)
|
|
18
|
+
- multi_level_select_disabled_options_parent: Disabled Parent Option (Return All Selected)
|
|
19
|
+
- multi_level_select_single_disabled: Disabled Options (Single Select)
|
|
19
20
|
|
|
20
21
|
react:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
- multi_level_select_default: Default
|
|
23
|
+
- multi_level_select_react_hook: React Hook
|
|
24
|
+
- multi_level_select_single: Single Select
|
|
25
|
+
- multi_level_select_single_children_only: Single Select w/ Hidden Radios
|
|
26
|
+
- multi_level_select_return_all_selected: Return All Selected
|
|
27
|
+
- multi_level_select_input_display: With Input Display None
|
|
28
|
+
- multi_level_select_selected_ids_react: Selected Ids
|
|
29
|
+
- multi_level_select_color: With Pills (Custom Color)
|
|
30
|
+
- multi_level_select_with_children: Checkboxes With Children
|
|
31
|
+
- multi_level_select_with_children_with_radios: Single Select With Children
|
|
32
|
+
- multi_level_select_label: With Label
|
|
33
|
+
- multi_level_select_error: Error
|
|
34
|
+
- multi_level_select_disabled: Disabled Input
|
|
35
|
+
- multi_level_select_disabled_options_default: Disabled Options (Default)
|
|
36
|
+
- multi_level_select_disabled_options: Disabled Options (Return All Selected)
|
|
37
|
+
- multi_level_select_disabled_options_parent_default: Disabled Parent Option (Default)
|
|
38
|
+
- multi_level_select_disabled_options_parent: Disabled Parent Option (Return All Selected)
|
|
39
|
+
- multi_level_select_single_disabled: Disabled Options (Single Select)
|
|
@@ -4,6 +4,7 @@ export { default as MultiLevelSelectSingleChildrenOnly } from './_multi_level_se
|
|
|
4
4
|
export { default as MultiLevelSelectReturnAllSelected } from './_multi_level_select_return_all_selected.jsx'
|
|
5
5
|
export { default as MultiLevelSelectSelectedIdsReact } from "./_multi_level_select_selected_ids_react.jsx"
|
|
6
6
|
export { default as MultiLevelSelectColor } from './_multi_level_select_color.jsx'
|
|
7
|
+
export { default as MultiLevelSelectInputDisplay } from './_multi_level_select_input_display.jsx'
|
|
7
8
|
export { default as MultiLevelSelectWithChildren } from './_multi_level_select_with_children.jsx'
|
|
8
9
|
export { default as MultiLevelSelectWithChildrenWithRadios } from './_multi_level_select_with_children_with_radios.jsx'
|
|
9
10
|
export { default as MultiLevelSelectDisabled } from './_multi_level_select_disabled.jsx'
|
|
@@ -4,6 +4,8 @@ import { TrixEditor } from 'react-trix'
|
|
|
4
4
|
|
|
5
5
|
import inlineFocus from './inlineFocus'
|
|
6
6
|
import useFocus from './useFocus'
|
|
7
|
+
import Caption from '../pb_caption/_caption'
|
|
8
|
+
import colors from '../tokens/exports/_colors.module.scss'
|
|
7
9
|
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
|
8
10
|
import { buildAriaProps, buildDataProps, noop, buildHtmlProps } from '../utilities/props'
|
|
9
11
|
|
|
@@ -40,12 +42,14 @@ type RichTextEditorProps = {
|
|
|
40
42
|
inputOptions?: { [key: string]: string | number | boolean | (() => void) },
|
|
41
43
|
id?: string,
|
|
42
44
|
inline?: boolean,
|
|
45
|
+
label?: string,
|
|
43
46
|
extensions?: { [key: string]: string }[],
|
|
44
47
|
name?: string,
|
|
45
48
|
onChange: (html: string, text: string) => void,
|
|
46
49
|
placeholder?: string,
|
|
47
50
|
inputHeight?: "sm" | "md" | "lg",
|
|
48
51
|
inputMinHeight?: "sm" | "md" | "lg",
|
|
52
|
+
requiredIndicator?: boolean,
|
|
49
53
|
simple?: boolean,
|
|
50
54
|
sticky?: boolean,
|
|
51
55
|
template: string,
|
|
@@ -64,6 +68,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
64
68
|
data = {},
|
|
65
69
|
focus = false,
|
|
66
70
|
htmlOptions = {},
|
|
71
|
+
id,
|
|
67
72
|
inputOptions = {},
|
|
68
73
|
inline = false,
|
|
69
74
|
extensions,
|
|
@@ -76,7 +81,9 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
76
81
|
sticky = false,
|
|
77
82
|
template = '',
|
|
78
83
|
value = '',
|
|
79
|
-
maxWidth = "md"
|
|
84
|
+
maxWidth = "md",
|
|
85
|
+
requiredIndicator = false,
|
|
86
|
+
label,
|
|
80
87
|
} = props
|
|
81
88
|
|
|
82
89
|
const ariaProps = buildAriaProps(aria),
|
|
@@ -86,7 +93,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
86
93
|
containerRef = useRef<HTMLDivElement>(null)
|
|
87
94
|
|
|
88
95
|
const htmlProps = buildHtmlProps(htmlOptions)
|
|
89
|
-
|
|
96
|
+
|
|
90
97
|
const handleOnEditorReady = (editorInstance: Editor) => {
|
|
91
98
|
setEditor(editorInstance)
|
|
92
99
|
setTimeout(() => {
|
|
@@ -94,7 +101,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
94
101
|
if (oldId) {
|
|
95
102
|
const hiddenInput = document.getElementById(oldId)
|
|
96
103
|
if (hiddenInput) {
|
|
97
|
-
const newId = (inputOptions.id as string) || oldId
|
|
104
|
+
const newId = (inputOptions.id as string) || oldId
|
|
98
105
|
hiddenInput.id = newId
|
|
99
106
|
editorInstance.element.setAttribute('input', newId)
|
|
100
107
|
|
|
@@ -119,7 +126,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
119
126
|
// set button attributes
|
|
120
127
|
inlineCodeButton.dataset.trixAttribute = 'inlineCode'
|
|
121
128
|
blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
|
|
122
|
-
}
|
|
129
|
+
}
|
|
123
130
|
|
|
124
131
|
if (toolbarBottom) editor.element.after(toolbarElement)
|
|
125
132
|
|
|
@@ -147,7 +154,7 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
147
154
|
if (!advancedEditor || !focus) return
|
|
148
155
|
|
|
149
156
|
const handleFocus = () => setShowToolbarOnFocus(true)
|
|
150
|
-
|
|
157
|
+
|
|
151
158
|
const handleClickOutside = (event: Event) => {
|
|
152
159
|
if (isClickInContainer(event) || isClickInPopover(event)) return
|
|
153
160
|
setShowToolbarOnFocus(false)
|
|
@@ -215,9 +222,29 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
|
215
222
|
className={css}
|
|
216
223
|
ref={focus ? containerRef : undefined}
|
|
217
224
|
>
|
|
225
|
+
{label && (
|
|
226
|
+
<label htmlFor={id}>
|
|
227
|
+
{
|
|
228
|
+
requiredIndicator ? (
|
|
229
|
+
<Caption className="pb_text_input_kit_label"
|
|
230
|
+
marginBottom="xs"
|
|
231
|
+
>
|
|
232
|
+
{label} <span style={{ color: `${colors.error}` }}>*</span>
|
|
233
|
+
</Caption>
|
|
234
|
+
) : (
|
|
235
|
+
<Caption
|
|
236
|
+
className="pb_text_input_kit_label"
|
|
237
|
+
marginBottom="xs"
|
|
238
|
+
text={label}
|
|
239
|
+
/>
|
|
240
|
+
)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
</label>
|
|
244
|
+
)}
|
|
218
245
|
{
|
|
219
246
|
advancedEditor ? (
|
|
220
|
-
<div
|
|
247
|
+
<div
|
|
221
248
|
className={classnames(
|
|
222
249
|
"pb_rich_text_editor_advanced_container",
|
|
223
250
|
{ [`input_height_${inputHeight}`]: !!inputHeight,[`input_min_height_${inputMinHeight}`]: !!inputMinHeight ,["toolbar-active"]: shouldShowToolbar }
|
data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_required_indicator.jsx
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import RichTextEditor from '../../pb_rich_text_editor/_rich_text_editor'
|
|
3
|
+
import { useEditor, EditorContent } from "@tiptap/react"
|
|
4
|
+
import StarterKit from "@tiptap/starter-kit"
|
|
5
|
+
import Link from '@tiptap/extension-link'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const RichTextEditorAdvancedRequiredIndicator = (props) => {
|
|
9
|
+
|
|
10
|
+
const editor = useEditor({
|
|
11
|
+
extensions: [
|
|
12
|
+
StarterKit,
|
|
13
|
+
Link
|
|
14
|
+
],
|
|
15
|
+
content:"Add your text here. You can format your text, add links, quotes, and bullets."
|
|
16
|
+
})
|
|
17
|
+
if (!editor) {
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div>
|
|
23
|
+
<RichTextEditor
|
|
24
|
+
advancedEditor={editor}
|
|
25
|
+
label="Label"
|
|
26
|
+
requiredIndicator
|
|
27
|
+
{...props}
|
|
28
|
+
>
|
|
29
|
+
<EditorContent editor={editor}/>
|
|
30
|
+
</RichTextEditor>
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default RichTextEditorAdvancedRequiredIndicator
|
data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_required_indicator.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
The `requiredIndicator`/`required_indicator` prop displays a red asterisk (*) next to the label, visually indicating that the field is required. This is purely visual and does not enforce validation.
|
|
2
|
+
|
|
3
|
+
You can use `requiredIndicator`/`required_indicator` with any validation approach: HTML5 validation via the `required` prop, client-side validation, or backend validation. For this reason, it works independently and doesn't need to be paired with the `required` prop.
|
data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.html.erb
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<%= pb_rails("rich_text_editor", props: {
|
|
2
|
+
id: "required-indicator",
|
|
3
|
+
input_options: {
|
|
4
|
+
id: 'hidden_input_id',
|
|
5
|
+
name: "hidden_input_name"
|
|
6
|
+
},
|
|
7
|
+
label: "Label",
|
|
8
|
+
required_indicator: true,
|
|
9
|
+
value: "Add your text here. You can format your text, add links, quotes, and bullets."
|
|
10
|
+
}) %>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import RichTextEditor from '../../pb_rich_text_editor/_rich_text_editor'
|
|
3
|
+
|
|
4
|
+
const RichTextEditorRequiredIndicator = (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
|
+
label="Label"
|
|
12
|
+
onChange={handleOnChange}
|
|
13
|
+
requiredIndicator
|
|
14
|
+
value={value}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
</div>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default RichTextEditorRequiredIndicator
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
The `requiredIndicator`/`required_indicator` prop displays a red asterisk (*) next to the label, visually indicating that the field is required. This is purely visual and does not enforce validation.
|
|
2
|
+
|
|
3
|
+
You can use `requiredIndicator`/`required_indicator` with any validation approach: HTML5 validation via the `required` prop, client-side validation, or backend validation. For this reason, it works independently and doesn't need to be paired with the `required` prop.
|
|
@@ -9,6 +9,7 @@ examples:
|
|
|
9
9
|
- rich_text_editor_templates: Templates
|
|
10
10
|
# - rich_text_editor_toolbar_bottom: Toolbar Bottom
|
|
11
11
|
- rich_text_editor_inline: Inline
|
|
12
|
+
- rich_text_editor_required_indicator: Required Indicator
|
|
12
13
|
- rich_text_editor_preview: Preview
|
|
13
14
|
|
|
14
15
|
react:
|
|
@@ -31,5 +32,7 @@ examples:
|
|
|
31
32
|
- rich_text_editor_advanced_inline: Advanced (Inline)
|
|
32
33
|
- rich_text_editor_advanced_height: Advanced Height
|
|
33
34
|
- rich_text_editor_advanced_min_height: Advanced Min Height
|
|
35
|
+
- rich_text_editor_required_indicator: Required Indicator
|
|
36
|
+
- rich_text_editor_advanced_required_indicator: Advanced Required Indicator
|
|
34
37
|
- rich_text_editor_preview: Preview
|
|
35
38
|
- rich_text_editor_advanced_preview: Advanced Preview
|
|
@@ -19,3 +19,5 @@ export { default as RichTextEditorAdvancedSticky } from './_rich_text_editor_adv
|
|
|
19
19
|
export { default as RichTextEditorAdvancedInline } from './_rich_text_editor_advanced_inline.jsx'
|
|
20
20
|
export { default as RichTextEditorAdvancedHeight } from './_rich_text_editor_advanced_height.jsx'
|
|
21
21
|
export { default as RichTextEditorAdvancedMinHeight } from './_rich_text_editor_advanced_min_height.jsx'
|
|
22
|
+
export { default as RichTextEditorRequiredIndicator } from './_rich_text_editor_required_indicator.jsx'
|
|
23
|
+
export { default as RichTextEditorAdvancedRequiredIndicator } from './_rich_text_editor_advanced_required_indicator.jsx'
|
|
@@ -21,6 +21,9 @@ module Playbook
|
|
|
21
21
|
prop :template
|
|
22
22
|
prop :placeholder
|
|
23
23
|
prop :input_options
|
|
24
|
+
prop :label
|
|
25
|
+
prop :required_indicator, type: Playbook::Props::Boolean,
|
|
26
|
+
default: false
|
|
24
27
|
|
|
25
28
|
def classname
|
|
26
29
|
generate_classname("pb_rich_text_editor_kit", simple_class, focus_class, sticky_class, separator: " ")
|
|
@@ -51,6 +54,8 @@ module Playbook
|
|
|
51
54
|
template: template,
|
|
52
55
|
placeholder: placeholder,
|
|
53
56
|
inputOptions: input_options,
|
|
57
|
+
label: label,
|
|
58
|
+
requiredIndicator: required_indicator,
|
|
54
59
|
}
|
|
55
60
|
end
|
|
56
61
|
end
|