playbook_ui 15.1.0.pre.alpha.testingtiptap11043 → 15.1.0.pre.alpha.typeaheadscss11143
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_form/docs/_form_form_with_validate.html.erb +11 -0
- data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.tsx +2 -2
- data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.scss +15 -21
- data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.tsx +6 -5
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +2 -0
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.rb +11 -3
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.test.js +9 -8
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +1 -39
- data/app/pb_kits/playbook/pb_rich_text_editor/_previewer_mixin.scss +13 -3
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +10 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +10 -10
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +39 -1
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +2 -0
- data/dist/chunks/{_line_graph-Ck_xk6x5.js → _line_graph-B-1uF3pN.js} +1 -1
- data/dist/chunks/{_typeahead-xcdYzO-v.js → _typeahead-C8eN5nhR.js} +1 -1
- data/dist/chunks/{_weekday_stacked-CcaJugnT.js → _weekday_stacked-1o7KVL87.js} +2 -2
- data/dist/chunks/vendor.js +1 -1
- 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/version.rb +1 -1
- metadata +5 -6
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_simple.jsx +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 146b2b16a0667788778819436fdb56b04d5a5287d6f0495d3959a6462816432c
|
4
|
+
data.tar.gz: b8076a2e020e664f1e6765e9bc18ea8ebc7b4281046d57489952e0b040aff998
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2efcb9e518ee3d5f013522621873d38ad9a18522d59b9d2b7f6f547aed7cd88ad7694fa01d5acd9b83cd4973e6a60ecb7b291a0631a216ee4e7f8aeeb8d8983d
|
7
|
+
data.tar.gz: c63671f77d1ac529fa10ca7bc079e1d36ccdbb73d04b64b5b7744630edf6c8a67e53d65146044b3c4e491f8e62ad2e2a8335778583868cda38a3ddd800f0467e
|
@@ -21,6 +21,15 @@
|
|
21
21
|
]
|
22
22
|
%>
|
23
23
|
|
24
|
+
<%
|
25
|
+
example_typeahead_options = [
|
26
|
+
{ label: 'Orange', value: '#FFA500' },
|
27
|
+
{ label: 'Red', value: '#FF0000' },
|
28
|
+
{ label: 'Green', value: '#00FF00' },
|
29
|
+
{ label: 'Blue', value: '#0000FF' },
|
30
|
+
]
|
31
|
+
%>
|
32
|
+
|
24
33
|
<% treeData = [{
|
25
34
|
label: "Power Home Remodeling",
|
26
35
|
value: "Power Home Remodeling",
|
@@ -89,6 +98,8 @@
|
|
89
98
|
|
90
99
|
<%= pb_form_with(scope: :example, method: :get, url: "", validate: true) do |form| %>
|
91
100
|
<%= form.typeahead :example_typeahead_validation, props: { data: { typeahead_example2: true, user: {} }, label: true, placeholder: "Search for a user", required: true, validation: { message: "Please select a user." } } %>
|
101
|
+
<%= form.typeahead :example_typeahead_validation_react, props: { options: example_typeahead_options, pills: true, label: "Example Typeahead (React Rendered)", placeholder: "Search for a user", required: true, validation: { message: "Please select a color." } } %>
|
102
|
+
<%= form.typeahead :example_typeahead_validation_react_2, props: { options: example_typeahead_options, pills: true, label: "Example Typeahead 2 (React Rendered)", placeholder: "Search for a user", required: true } %>
|
92
103
|
<%= form.text_field :example_text_field_validation, props: { label: true, required: true } %>
|
93
104
|
<%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field", hidden_inputs: true } %>
|
94
105
|
<%= form.email_field :example_email_field_validation, props: { label: true, required: true } %>
|
@@ -3,7 +3,7 @@ import React from 'react'
|
|
3
3
|
import classnames from 'classnames'
|
4
4
|
|
5
5
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
6
|
-
import { globalProps } from '../utilities/globalProps'
|
6
|
+
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
7
7
|
|
8
8
|
import Icon from '../pb_icon/_icon'
|
9
9
|
|
@@ -26,7 +26,7 @@ type IconCircleProps = {
|
|
26
26
|
| "orange"
|
27
27
|
| "green"
|
28
28
|
| "lighter",
|
29
|
-
}
|
29
|
+
} & GlobalProps
|
30
30
|
|
31
31
|
const IconCircle = (props: IconCircleProps) => {
|
32
32
|
const {
|
@@ -3,51 +3,45 @@
|
|
3
3
|
@import "../tokens/spacing";
|
4
4
|
@import "../pb_icon_circle/icon_circle";
|
5
5
|
|
6
|
-
|
6
|
+
.pb_icon_stat_value_kit_horizontal,
|
7
|
+
.pb_icon_stat_value_kit_vertical
|
8
|
+
{
|
7
9
|
display: flex;
|
8
10
|
align-items: baseline;
|
9
11
|
|
10
|
-
|
12
|
+
&.pb_icon_stat_value_kit_vertical {
|
11
13
|
flex-direction: column;
|
12
14
|
|
13
|
-
|
15
|
+
&.text_align_center {
|
14
16
|
align-items: center;
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
.pb_title_kit,
|
19
|
+
.pb_body_kit,
|
20
|
+
.pb_caption_kit_md {
|
19
21
|
text-align: center;
|
20
22
|
}
|
21
23
|
}
|
22
24
|
|
23
|
-
|
25
|
+
&.text_align_right {
|
24
26
|
align-items: flex-end;
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
.pb_title_kit,
|
29
|
+
.pb_body_kit,
|
30
|
+
.pb_caption_kit_md {
|
29
31
|
text-align: right;
|
30
32
|
}
|
31
33
|
}
|
32
|
-
|
33
|
-
[class^=pb_icon_circle] {
|
34
|
-
margin-bottom: $space-xs;
|
35
|
-
}
|
36
34
|
}
|
37
35
|
|
38
|
-
|
36
|
+
&.pb_icon_stat_value_kit_horizontal {
|
39
37
|
align-items: center;
|
40
38
|
|
41
|
-
|
39
|
+
&.text_align_center {
|
42
40
|
justify-content: center;
|
43
41
|
}
|
44
42
|
|
45
|
-
|
43
|
+
&.text_align_right {
|
46
44
|
justify-content: flex-end;
|
47
45
|
}
|
48
|
-
|
49
|
-
[class^=pb_icon_circle] {
|
50
|
-
margin-right: $space-sm;
|
51
|
-
}
|
52
46
|
}
|
53
47
|
}
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
2
2
|
import classnames from 'classnames'
|
3
3
|
|
4
4
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
5
|
-
import { globalProps } from '../utilities/globalProps'
|
5
|
+
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
6
6
|
|
7
7
|
import Body from '../pb_body/_body'
|
8
8
|
import Caption from '../pb_caption/_caption'
|
@@ -33,8 +33,7 @@ type IconStatValueProps = {
|
|
33
33
|
| "yellow"
|
34
34
|
| "orange"
|
35
35
|
| "green"
|
36
|
-
|
37
|
-
}
|
36
|
+
} & GlobalProps
|
38
37
|
|
39
38
|
const IconStatValue = (props: IconStatValueProps): React.ReactElement => {
|
40
39
|
const {
|
@@ -50,13 +49,13 @@ const IconStatValue = (props: IconStatValueProps): React.ReactElement => {
|
|
50
49
|
text = '',
|
51
50
|
unit = '',
|
52
51
|
value = 0,
|
53
|
-
variant = '
|
52
|
+
variant = 'default',
|
54
53
|
} = props
|
55
54
|
const ariaProps = buildAriaProps(aria)
|
56
55
|
const dataProps = buildDataProps(data)
|
57
56
|
const htmlProps = buildHtmlProps(htmlOptions)
|
58
57
|
const classes = classnames(
|
59
|
-
buildCss('pb_icon_stat_value_kit', orientation
|
58
|
+
buildCss('pb_icon_stat_value_kit', orientation), globalProps(props),
|
60
59
|
className
|
61
60
|
)
|
62
61
|
const titleSize = function(size: "sm" | "md" | "lg") {
|
@@ -101,6 +100,8 @@ const IconStatValue = (props: IconStatValueProps): React.ReactElement => {
|
|
101
100
|
<IconCircle
|
102
101
|
dark={dark}
|
103
102
|
icon={icon}
|
103
|
+
marginBottom={orientation == 'vertical' ? 'xs' : undefined}
|
104
|
+
marginRight={orientation == 'horizontal' ? 'sm' : undefined}
|
104
105
|
size={size}
|
105
106
|
variant={variant}
|
106
107
|
/>
|
@@ -9,8 +9,8 @@ module Playbook
|
|
9
9
|
values: %w[sm md lg],
|
10
10
|
default: "sm"
|
11
11
|
prop :variant, type: Playbook::Props::Enum,
|
12
|
-
values: %w[default royal blue purple teal red yellow green orange
|
13
|
-
default: "
|
12
|
+
values: %w[default royal blue purple teal red yellow green orange],
|
13
|
+
default: "default"
|
14
14
|
|
15
15
|
prop :orientation, type: Playbook::Props::Enum,
|
16
16
|
values: %w[vertical horizontal],
|
@@ -25,7 +25,7 @@ module Playbook
|
|
25
25
|
prop :value
|
26
26
|
|
27
27
|
def classname
|
28
|
-
generate_classname("pb_icon_stat_value_kit", orientation
|
28
|
+
generate_classname("pb_icon_stat_value_kit", orientation)
|
29
29
|
end
|
30
30
|
|
31
31
|
def value_string
|
@@ -41,6 +41,14 @@ module Playbook
|
|
41
41
|
3
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
def icon_margin_right
|
46
|
+
orientation === "horizontal" && "sm"
|
47
|
+
end
|
48
|
+
|
49
|
+
def icon_margin_bottom
|
50
|
+
orientation === "vertical" && "xs"
|
51
|
+
end
|
44
52
|
end
|
45
53
|
end
|
46
54
|
end
|
@@ -18,7 +18,7 @@ describe("IconStatValue Kit", () => {
|
|
18
18
|
)
|
19
19
|
|
20
20
|
const kit = screen.getByTestId(testId)
|
21
|
-
expect(kit).toHaveClass("
|
21
|
+
expect(kit).toHaveClass("pb_icon_stat_value_kit_horizontal")
|
22
22
|
})
|
23
23
|
|
24
24
|
test("renders icon", () => {
|
@@ -99,9 +99,10 @@ describe("IconStatValue Kit", () => {
|
|
99
99
|
value={64.18}
|
100
100
|
/>
|
101
101
|
)
|
102
|
-
|
102
|
+
const size = sizeProp === "sm" ? "3" : sizeProp === "md" ? "2" : "1"
|
103
103
|
const kit = screen.getByTestId(testId)
|
104
|
-
|
104
|
+
const title = kit.querySelector(".pb_title_kit")
|
105
|
+
expect(title).toHaveClass(`pb_title_${size}`)
|
105
106
|
|
106
107
|
cleanup()
|
107
108
|
})
|
@@ -115,8 +116,7 @@ describe("IconStatValue Kit", () => {
|
|
115
116
|
"teal",
|
116
117
|
"red",
|
117
118
|
"yellow",
|
118
|
-
"green"
|
119
|
-
"lighter"].forEach(
|
119
|
+
"green"].forEach(
|
120
120
|
(colorProp) => {
|
121
121
|
render(
|
122
122
|
<IconStatValue
|
@@ -128,9 +128,10 @@ describe("IconStatValue Kit", () => {
|
|
128
128
|
variant={colorProp}
|
129
129
|
/>
|
130
130
|
)
|
131
|
-
|
131
|
+
|
132
132
|
const kit = screen.getByTestId(testId)
|
133
|
-
|
133
|
+
const iconCircle = kit.querySelector(`.pb_icon_circle_kit_size_sm_${colorProp}`)
|
134
|
+
expect(iconCircle).toBeInTheDocument()
|
134
135
|
|
135
136
|
cleanup()
|
136
137
|
})
|
@@ -149,7 +150,7 @@ describe("IconStatValue Kit", () => {
|
|
149
150
|
)
|
150
151
|
|
151
152
|
const kit = screen.getByTestId(testId)
|
152
|
-
expect(kit).toHaveClass("
|
153
|
+
expect(kit).toHaveClass("pb_icon_stat_value_kit_vertical")
|
153
154
|
})
|
154
155
|
|
155
156
|
})
|
@@ -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,21 +33,6 @@ const EditorToolbar = ({ editor, extensions, simple }: any): React.ReactElement
|
|
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
38
|
className="toolbar"
|
@@ -57,25 +42,6 @@ const EditorToolbar = ({ editor, extensions, simple }: any): React.ReactElement
|
|
57
42
|
paddingX="sm"
|
58
43
|
paddingY="xxs"
|
59
44
|
>
|
60
|
-
{
|
61
|
-
simple ? (
|
62
|
-
<>
|
63
|
-
<Flex className="toolbar_block">
|
64
|
-
{simpleToolbaritems && simpleToolbaritems.map(
|
65
|
-
({ icon, text, classname, onclick}: ToolbarTypes, index: number) => (
|
66
|
-
<EditorButton
|
67
|
-
classname={classname}
|
68
|
-
icon={icon}
|
69
|
-
key={index}
|
70
|
-
onclick={onclick}
|
71
|
-
text={text}
|
72
|
-
/>
|
73
|
-
)
|
74
|
-
)}
|
75
|
-
</Flex>
|
76
|
-
</>
|
77
|
-
) : (
|
78
|
-
<>
|
79
45
|
<FlexItem className="toolbar_block"
|
80
46
|
displayFlex
|
81
47
|
>
|
@@ -103,10 +69,6 @@ const EditorToolbar = ({ editor, extensions, simple }: any): React.ReactElement
|
|
103
69
|
}
|
104
70
|
</FlexItem>
|
105
71
|
<ToolbarHistoryItems editor={editor} />
|
106
|
-
</>
|
107
|
-
)
|
108
|
-
}
|
109
|
-
|
110
72
|
</Flex>
|
111
73
|
</Background>
|
112
74
|
);
|
@@ -12,6 +12,7 @@
|
|
12
12
|
}
|
13
13
|
|
14
14
|
@mixin preview_tiptap_p {
|
15
|
+
margin: 1rem 0 0 0;
|
15
16
|
min-height: 1rem;
|
16
17
|
}
|
17
18
|
|
@@ -55,9 +56,13 @@
|
|
55
56
|
}
|
56
57
|
|
57
58
|
@mixin preview_tiptap_blockquote {
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
font-size: $font_larger;
|
60
|
+
padding: $space_sm $space_md;
|
61
|
+
font-style: italic;
|
62
|
+
margin: 1rem 0 0 0;
|
63
|
+
p {
|
64
|
+
margin: 0;
|
65
|
+
}
|
61
66
|
}
|
62
67
|
|
63
68
|
@mixin preview_tiptap_h1 {
|
@@ -65,6 +70,7 @@
|
|
65
70
|
line-height: $text_larger;
|
66
71
|
font-weight: $bolder;
|
67
72
|
letter-spacing: $lspace_tight;
|
73
|
+
margin: 2.1rem 0 0 0;
|
68
74
|
}
|
69
75
|
|
70
76
|
@mixin preview_tiptap_h2 {
|
@@ -72,6 +78,7 @@
|
|
72
78
|
line-height: $text_larger;
|
73
79
|
font-weight: $bolder;
|
74
80
|
letter-spacing: $lspace_tight;
|
81
|
+
margin: 1.9rem 0 0 0;
|
75
82
|
}
|
76
83
|
|
77
84
|
@mixin preview_tiptap_h3 {
|
@@ -79,6 +86,7 @@
|
|
79
86
|
line-height: $text_large;
|
80
87
|
font-weight: $bolder;
|
81
88
|
letter-spacing: $lspace_tight;
|
89
|
+
margin: 1.7rem 0 0 0;
|
82
90
|
}
|
83
91
|
|
84
92
|
@mixin preview_tiptap_smaller_headings {
|
@@ -86,6 +94,7 @@
|
|
86
94
|
line-height: $text_base;
|
87
95
|
letter-spacing: $lspace_tight;
|
88
96
|
font-weight: $bolder;
|
97
|
+
margin: 1rem 0 0 0;
|
89
98
|
}
|
90
99
|
|
91
100
|
@mixin preview_tiptap_hr {
|
@@ -101,6 +110,7 @@
|
|
101
110
|
}
|
102
111
|
|
103
112
|
@mixin preview_tiptap_ol {
|
113
|
+
margin: 1rem 0 0 0;
|
104
114
|
padding-left: $space_md;
|
105
115
|
list-style: decimal;
|
106
116
|
li {
|
@@ -16,7 +16,6 @@ examples:
|
|
16
16
|
- rich_text_editor_advanced_default: Advanced Default
|
17
17
|
- rich_text_editor_more_extensions: Advanced (Extra Extensions)
|
18
18
|
- rich_text_editor_toolbar_disabled: Advanced (Toolbar disabled)
|
19
|
-
- rich_text_editor_advanced_simple: Advanced (Simple)
|
20
19
|
- rich_text_editor_simple: Simple
|
21
20
|
- rich_text_editor_attributes: Attributes
|
22
21
|
- rich_text_editor_focus: Focus
|
@@ -11,4 +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'
|
@@ -4,7 +4,7 @@
|
|
4
4
|
@import "../tokens/shadows";
|
5
5
|
@import "../tokens/positioning";
|
6
6
|
|
7
|
-
|
7
|
+
.pb_typeahead_kit {
|
8
8
|
.typeahead-kit-select__option {
|
9
9
|
cursor: pointer;
|
10
10
|
}
|
@@ -28,7 +28,7 @@
|
|
28
28
|
transition: opacity .15s ease-in-out;
|
29
29
|
}
|
30
30
|
}
|
31
|
-
|
31
|
+
.pb_text_input_kit {
|
32
32
|
.text_input_wrapper {
|
33
33
|
.text_input {
|
34
34
|
max-height: none;
|
@@ -47,7 +47,7 @@
|
|
47
47
|
}
|
48
48
|
}
|
49
49
|
}
|
50
|
-
|
50
|
+
.pb_list_kit_xpadding_borderless_ {
|
51
51
|
max-height: 18em;
|
52
52
|
overflow-y: auto;
|
53
53
|
overscroll-behavior: contain;
|
@@ -60,15 +60,15 @@
|
|
60
60
|
border-radius: $border_rad_heavier;
|
61
61
|
transition: opacity .25s ease-in-out;
|
62
62
|
}
|
63
|
-
&:focus-within
|
63
|
+
&:focus-within .pb_list_kit_xpadding_borderless_ {
|
64
64
|
display: block;
|
65
65
|
opacity: 1;
|
66
66
|
}
|
67
|
-
&:not(:focus-within)
|
67
|
+
&:not(:focus-within) .pb_list_kit_xpadding_borderless_ {
|
68
68
|
display: none;
|
69
69
|
opacity: 0;
|
70
70
|
}
|
71
|
-
|
71
|
+
.pb_list_kit_xpadding_borderless_ {
|
72
72
|
li {
|
73
73
|
transition: background-color .25s ease-in-out;
|
74
74
|
}
|
@@ -161,7 +161,7 @@
|
|
161
161
|
.typeahead-plus-icon {
|
162
162
|
color: $text_lt_lighter;
|
163
163
|
}
|
164
|
-
|
164
|
+
.pb_badge_kit_primary span {
|
165
165
|
line-height: 16.5px;
|
166
166
|
letter-spacing: normal;
|
167
167
|
}
|
@@ -176,14 +176,14 @@
|
|
176
176
|
}
|
177
177
|
}
|
178
178
|
|
179
|
-
|
179
|
+
&.dark {
|
180
180
|
.pb_typeahead_wrapper .pb_typeahead_loading_indicator {
|
181
181
|
color: $text_dk_light;
|
182
182
|
}
|
183
183
|
.pb_text_input_kit_label {
|
184
184
|
color: $text_dk_light;
|
185
185
|
}
|
186
|
-
|
186
|
+
.pb_text_input_kit.dark .text_input_wrapper .text_input {
|
187
187
|
display: inherit !important;
|
188
188
|
}
|
189
189
|
.typeahead-kit-select__menu {
|
@@ -227,7 +227,7 @@
|
|
227
227
|
.typeahead-kit-select__option--is-focused {
|
228
228
|
background-color: $active_dark;
|
229
229
|
}
|
230
|
-
|
230
|
+
.pb_list_kit_xpadding_borderless_ {
|
231
231
|
background-color: $bg_dark;
|
232
232
|
}
|
233
233
|
.pb_item_kit {
|
@@ -53,6 +53,8 @@ type TypeaheadProps = {
|
|
53
53
|
pillColor?: "primary" | "neutral" | "success" | "warning" | "error" | "info" | "data_1" | "data_2" | "data_3" | "data_4" | "data_5" | "data_6" | "data_7" | "data_8" | "windows" | "siding" | "roofing" | "doors" | "gutters" | "solar" | "insulation" | "accessories",
|
54
54
|
onChange?: any,
|
55
55
|
optionsByContext?: Record<string, Array<{ label: string; value?: string }>>
|
56
|
+
required?: boolean,
|
57
|
+
validation?: { message: string },
|
56
58
|
searchContextSelector?: string,
|
57
59
|
clearOnContextChange?: boolean,
|
58
60
|
preserveSearchInput?: boolean,
|
@@ -94,12 +96,16 @@ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
|
|
94
96
|
onChange,
|
95
97
|
optionsByContext = {},
|
96
98
|
searchContextSelector,
|
99
|
+
required = false,
|
100
|
+
validation,
|
97
101
|
clearOnContextChange = false,
|
98
102
|
preserveSearchInput = false, // Default to false to maintain backward compatibility
|
99
103
|
...props
|
100
104
|
}: TypeaheadProps) => {
|
101
105
|
// State to manage the input value when preserveSearchInput is true
|
102
106
|
const [inputValue, setInputValue] = useState("")
|
107
|
+
// State to track if form has been submitted to control validation display for react rendered rails kit
|
108
|
+
const [formSubmitted, setFormSubmitted] = useState(false)
|
103
109
|
|
104
110
|
// If preserveSearchInput is true, we need to control the input value
|
105
111
|
const handleInputChange = preserveSearchInput
|
@@ -135,6 +141,7 @@ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
|
|
135
141
|
|
136
142
|
const selectProps = {
|
137
143
|
cacheOptions: true,
|
144
|
+
required,
|
138
145
|
components: {
|
139
146
|
Control,
|
140
147
|
ClearIndicator,
|
@@ -170,6 +177,27 @@ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
|
|
170
177
|
|
171
178
|
const [contextValue, setContextValue] = useState("")
|
172
179
|
|
180
|
+
// Add listener for form validation to track when validation should be shown (needed for react rendered rails kit)
|
181
|
+
useEffect(() => {
|
182
|
+
const handleInvalid = (event: Event) => {
|
183
|
+
const target = event.target as HTMLInputElement
|
184
|
+
const typeaheadContainer = target.closest('[data-pb-react-component="Typeahead"]')
|
185
|
+
|
186
|
+
if (typeaheadContainer) {
|
187
|
+
// Check if this invalid event is specifically for our typeahead by comparing names so we do not have to require ids
|
188
|
+
const invalidInputName = target.name || target.getAttribute('name')
|
189
|
+
if (invalidInputName === name) {
|
190
|
+
setFormSubmitted(true)
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
document.addEventListener('invalid', handleInvalid, true)
|
195
|
+
|
196
|
+
return () => {
|
197
|
+
document.removeEventListener('invalid', handleInvalid, true)
|
198
|
+
}
|
199
|
+
}, [name])
|
200
|
+
|
173
201
|
// Add listener for clearing
|
174
202
|
useEffect(() => {
|
175
203
|
const handleClear = () => {
|
@@ -230,6 +258,11 @@ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
|
|
230
258
|
}
|
231
259
|
}
|
232
260
|
|
261
|
+
// Reset form submitted state when a selection is made (this is all for react rendered rails kit)
|
262
|
+
if (action === 'select-option') {
|
263
|
+
setFormSubmitted(false)
|
264
|
+
}
|
265
|
+
|
233
266
|
// If a value is selected and we're preserving input on blur, clear the input
|
234
267
|
if (action === 'select-option' && preserveSearchInput) {
|
235
268
|
setInputValue('')
|
@@ -268,6 +301,11 @@ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
|
|
268
301
|
|
269
302
|
const inlineClass = selectProps.inline ? 'inline' : null
|
270
303
|
|
304
|
+
const shouldShowValidationError = required &&
|
305
|
+
formSubmitted
|
306
|
+
|
307
|
+
const errorDisplay = error || (shouldShowValidationError ? validation?.message || "Please fill out this field." : "")
|
308
|
+
|
271
309
|
return (
|
272
310
|
<div
|
273
311
|
{...dataProps}
|
@@ -276,7 +314,7 @@ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
|
|
276
314
|
>
|
277
315
|
<Tag
|
278
316
|
classNamePrefix="typeahead-kit-select"
|
279
|
-
error={
|
317
|
+
error={errorDisplay}
|
280
318
|
isDisabled={disabled}
|
281
319
|
onChange={handleOnChange}
|
282
320
|
{...selectProps}
|
@@ -101,6 +101,8 @@ module Playbook
|
|
101
101
|
plusIcon: plus_icon,
|
102
102
|
truncate: truncate,
|
103
103
|
wrapped: wrapped,
|
104
|
+
required: required,
|
105
|
+
validation: validation,
|
104
106
|
searchContextSelector: search_context_selector,
|
105
107
|
optionsByContext: options_by_context,
|
106
108
|
clearOnContextChange: clear_on_context_change,
|