playbook_ui 14.16.0.pre.rc.0 → 14.16.0.pre.rc.1
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_popover/_popover.tsx +1 -1
- data/app/pb_kits/playbook/pb_popover/popover.test.js +1 -1
- data/app/pb_kits/playbook/pb_text_input/inputMask.ts +2 -3
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon_rails.html.erb +22 -0
- data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +16 -4
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.jsx +66 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.md +1 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_users.jsx +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- data/dist/chunks/_typeahead-XZ7pSWeu.js +36 -0
- data/dist/chunks/{_weekday_stacked-RWsNWtMH.js → _weekday_stacked-DkgblYXe.js} +1 -1
- data/dist/chunks/lazysizes-DHz07jlL.js +1 -0
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +8 -6
- data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon.erb +0 -10
- data/dist/chunks/_typeahead-RfKdit7E.js +0 -36
- data/dist/chunks/lazysizes-B7xYodB-.js +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 408cff49bb1a860fa5e13e4f3b2cbbb1fade96335721b0da125445509e65985f
|
4
|
+
data.tar.gz: 3fa1f1bd792a316d5754ebbf30dd68093cb9620155a5c0c95a56d79449e9ef09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5ef34e782ea21f845646ce545e0a5b724de93037c86c1150eafb4e27e09f9a2d35d1f738128dd865b47c62d8d32422c29f1973ded6fa0afd553a46bebe4a2d6
|
7
|
+
data.tar.gz: 7061aea824206762a1515325f50d488fa72415d2b29cccd32366cc24b01b9f09187169c73a59391c9c29fe440d7171d3bf9eadf635f1268c20bb2de66cc15dc4
|
@@ -84,7 +84,7 @@ const Popover = (props: PbPopoverProps) => {
|
|
84
84
|
} = props;
|
85
85
|
|
86
86
|
const items = globalProps(props).split(' ')
|
87
|
-
const filteredItems = items.filter(item => !item.includes('
|
87
|
+
const filteredItems = items.filter(item => !item.includes('min-width') && !item.includes('width'))
|
88
88
|
const filteredGlobalProps = filteredItems.join(' ')
|
89
89
|
const popoverSpacing =
|
90
90
|
filteredGlobalProps.includes("dark") || !filteredGlobalProps
|
@@ -181,7 +181,7 @@ const PopoverTestClicktoClose3 = () => {
|
|
181
181
|
const btn = screen.getByText(/click me/i)
|
182
182
|
fireEvent.click(btn);
|
183
183
|
const kit = screen.getByText("Click Anywhere");
|
184
|
-
expect(kit).toHaveClass("pb_popover_body
|
184
|
+
expect(kit).toHaveClass("pb_popover_body p_sm overflow_handling");
|
185
185
|
});
|
186
186
|
|
187
187
|
test("closes Popover on click anywhere", async () => {
|
@@ -17,7 +17,7 @@ const formatCurrencyDefaultValue = (value: string): string => {
|
|
17
17
|
|
18
18
|
// Parse the numeric value as a float to handle decimals
|
19
19
|
const dollars = parseFloat(numericValue)
|
20
|
-
if (isNaN(dollars)
|
20
|
+
if (isNaN(dollars)) return ''
|
21
21
|
|
22
22
|
// Format as currency
|
23
23
|
return new Intl.NumberFormat('en-US', {
|
@@ -30,10 +30,9 @@ const formatCurrencyDefaultValue = (value: string): string => {
|
|
30
30
|
const formatCurrency = (value: string): string => {
|
31
31
|
const numericValue = value.replace(/[^0-9]/g, '').slice(0, 15)
|
32
32
|
|
33
|
-
if (!numericValue) return ''
|
33
|
+
if (!numericValue || numericValue === "00") return ''
|
34
34
|
|
35
35
|
const dollars = parseFloat((parseInt(numericValue) / 100).toFixed(2))
|
36
|
-
if (dollars === 0) return ''
|
37
36
|
|
38
37
|
return new Intl.NumberFormat('en-US', {
|
39
38
|
style: 'currency',
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%= pb_rails "flex", props: { flex_direction: "row", gap: "md", wrap: true } do %>
|
2
|
+
<%= pb_rails "button", props: { id: "tool-tip-with-icon-1", text: "Tooltip With Icon" } %>
|
3
|
+
<%= pb_rails "tooltip", props: { trigger_element_selector: "#tool-tip-with-icon-1", tooltip_id: "tool-tip-with-icon-1", position: "top" } do %>
|
4
|
+
<%= pb_rails("icon", props: { icon: "paper-plane", fixed_width: true, color: "white", size: "1x", padding_right: "xxs" }) %>
|
5
|
+
Send Email
|
6
|
+
<% end %>
|
7
|
+
<%= pb_rails "button", props: { id: "tool-tip-with-icon-2", text: "Tooltip With Icon" } %>
|
8
|
+
<%= pb_rails "tooltip", props: { trigger_element_selector: "#tool-tip-with-icon-2", tooltip_id: "tool-tip-with-icon-2", position: "bottom" } do %>
|
9
|
+
<%= pb_rails("icon", props: { icon: "paper-plane", fixed_width: true, color: "white", size: "1x", padding_right: "xxs" }) %>
|
10
|
+
Send Email
|
11
|
+
<% end %>
|
12
|
+
<%= pb_rails "button", props: { id: "tool-tip-with-icon-3", text: "Tooltip With Icon" } %>
|
13
|
+
<%= pb_rails "tooltip", props: { trigger_element_selector: "#tool-tip-with-icon-3", tooltip_id: "tool-tip-with-icon-3", position: "left" } do %>
|
14
|
+
<%= pb_rails("icon", props: { icon: "paper-plane", fixed_width: true, color: "white", size: "1x", padding_right: "xxs" }) %>
|
15
|
+
Send Email
|
16
|
+
<% end %>
|
17
|
+
<%= pb_rails "button", props: { id: "tool-tip-with-icon-4", text: "Tooltip With Icon" } %>
|
18
|
+
<%= pb_rails "tooltip", props: { trigger_element_selector: "#tool-tip-with-icon-4", tooltip_id: "tool-tip-with-icon-4", position: "right" } do %>
|
19
|
+
<%= pb_rails("icon", props: { icon: "paper-plane", fixed_width: true, color: "white", size: "1x", padding_right: "xxs" }) %>
|
20
|
+
Send Email
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
@@ -4,6 +4,7 @@ examples:
|
|
4
4
|
- tooltip_default: Default
|
5
5
|
- tooltip_interaction: Content Interaction
|
6
6
|
- tooltip_selectors: Using Common Selectors
|
7
|
+
- tooltip_icon_rails: Tooltip with Icon
|
7
8
|
- tooltip_with_icon_circle: Icon Circle Tooltip
|
8
9
|
- tooltip_delay_rails: Delay
|
9
10
|
- tooltip_show_tooltip: Show Tooltip
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useState, useEffect} from 'react'
|
1
|
+
import React, { useState, useEffect, forwardRef} from 'react'
|
2
2
|
import Select from 'react-select'
|
3
3
|
import AsyncSelect from 'react-select/async'
|
4
4
|
import CreateableSelect from 'react-select/creatable'
|
@@ -49,6 +49,7 @@ type TypeaheadProps = {
|
|
49
49
|
options?: Array<{ label: string; value?: string }>,
|
50
50
|
marginBottom?: "none" | "xxs" | "xs" | "sm" | "md" | "lg" | "xl",
|
51
51
|
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",
|
52
|
+
onChange?: any,
|
52
53
|
optionsByContext?: Record<string, Array<{ label: string; value?: string }>>
|
53
54
|
searchContextSelector?: string,
|
54
55
|
clearOnContextChange?: boolean,
|
@@ -71,8 +72,7 @@ type TagOnChangeValues = {
|
|
71
72
|
* @constant {React.ReactComponent} Typeahead
|
72
73
|
* @param {TypeaheadProps} props - props as described at https://react-select.com/props
|
73
74
|
*/
|
74
|
-
|
75
|
-
const Typeahead = ({
|
75
|
+
const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
|
76
76
|
async,
|
77
77
|
className,
|
78
78
|
components = {},
|
@@ -83,9 +83,11 @@ const Typeahead = ({
|
|
83
83
|
getOptionValue,
|
84
84
|
htmlOptions = {},
|
85
85
|
id,
|
86
|
+
name,
|
86
87
|
loadOptions = noop,
|
87
88
|
marginBottom = "sm",
|
88
89
|
pillColor,
|
90
|
+
onChange,
|
89
91
|
optionsByContext = {},
|
90
92
|
searchContextSelector,
|
91
93
|
clearOnContextChange = false,
|
@@ -156,6 +158,15 @@ const Typeahead = ({
|
|
156
158
|
)
|
157
159
|
|
158
160
|
const handleOnChange = (_data: SelectValueType, { action, option, removedValue }: TagOnChangeValues) => {
|
161
|
+
if (onChange) {
|
162
|
+
const isReactHookForm = onChange.toString().includes("target")
|
163
|
+
if (isReactHookForm) {
|
164
|
+
onChange({ target: { name, value: _data } })
|
165
|
+
} else {
|
166
|
+
onChange(_data)
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
159
170
|
if (action === 'select-option') {
|
160
171
|
if (selectProps.onMultiValueClick) selectProps.onMultiValueClick(option)
|
161
172
|
const multiValueClearEvent = new CustomEvent(`pb-typeahead-kit-${selectProps.id}-result-option-select`, { detail: option ? option : _data })
|
@@ -199,10 +210,11 @@ const Typeahead = ({
|
|
199
210
|
/>
|
200
211
|
</div>
|
201
212
|
)
|
202
|
-
}
|
213
|
+
})
|
203
214
|
|
204
215
|
Object.keys(kitComponents).forEach((k) => {
|
205
216
|
(Typeahead as GenericObject)[k] = (kitComponents as {[key: string]: unknown})[k]
|
206
217
|
})
|
207
218
|
|
219
|
+
Typeahead.displayName = 'Typeahead'
|
208
220
|
export default Typeahead
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import { Typeahead, Title } from 'playbook-ui'
|
4
|
+
import { useForm } from 'react-hook-form'
|
5
|
+
|
6
|
+
const languages = [
|
7
|
+
{ label: 'JavaScript', value: '1995', category: 'Web Development' },
|
8
|
+
{ label: 'Python', value: '1991', category: 'General Purpose' },
|
9
|
+
{ label: 'Java', value: '1995', category: 'Enterprise' },
|
10
|
+
{ label: 'C++', value: '1985', category: 'Systems Programming' },
|
11
|
+
{ label: 'Go', value: '2009', category: 'Systems Programming' },
|
12
|
+
{ label: 'Rust', value: '2010', category: 'Systems Programming' },
|
13
|
+
{ label: 'Swift', value: '2014', category: 'Mobile Development' },
|
14
|
+
{ label: 'Kotlin', value: '2011', category: 'Mobile Development' },
|
15
|
+
{ label: 'Ruby', value: '1995', category: 'General Purpose' },
|
16
|
+
{ label: 'PHP', value: '1995', category: 'Web Development' },
|
17
|
+
]
|
18
|
+
|
19
|
+
const colors = [
|
20
|
+
{ label: 'Orange', value: '#FFA500' },
|
21
|
+
{ label: 'Red', value: '#FF0000' },
|
22
|
+
{ label: 'Green', value: '#00FF00' },
|
23
|
+
{ label: 'Blue', value: '#0000FF' },
|
24
|
+
]
|
25
|
+
|
26
|
+
const TypeaheadReactHook = (props) => {
|
27
|
+
const { register, watch } = useForm()
|
28
|
+
|
29
|
+
const selectedLanguages = watch('languages')
|
30
|
+
const selectedColor = watch('color')
|
31
|
+
|
32
|
+
return (
|
33
|
+
<>
|
34
|
+
<Typeahead
|
35
|
+
isMulti
|
36
|
+
label="Multi Select Languages"
|
37
|
+
multiKit="language"
|
38
|
+
options={languages}
|
39
|
+
{...props}
|
40
|
+
{...register('languages')}
|
41
|
+
/>
|
42
|
+
<Title
|
43
|
+
size={4}
|
44
|
+
text='Selected Languages'
|
45
|
+
/>
|
46
|
+
{selectedLanguages && selectedLanguages.map(language => (
|
47
|
+
<p key={language.label}>{`${language.label} - ${language.value} - ${language.category}`}</p>
|
48
|
+
))}
|
49
|
+
|
50
|
+
<Typeahead
|
51
|
+
label="Colors"
|
52
|
+
marginTop="lg"
|
53
|
+
options={colors}
|
54
|
+
{...props}
|
55
|
+
{...register('color')}
|
56
|
+
/>
|
57
|
+
<Title
|
58
|
+
size={4}
|
59
|
+
text='Selected Color'
|
60
|
+
/>
|
61
|
+
<p>{ selectedColor && `${selectedColor.label} - ${selectedColor.value}`}</p>
|
62
|
+
</>
|
63
|
+
)
|
64
|
+
}
|
65
|
+
|
66
|
+
export default TypeaheadReactHook
|
@@ -0,0 +1 @@
|
|
1
|
+
You can pass `react-hook-form` props to the Typeahead kit.
|
@@ -49,7 +49,7 @@ const TypeaheadWithPillsAsyncCustomOptions = (props) => {
|
|
49
49
|
* @summary - for doc example purposes only
|
50
50
|
*/
|
51
51
|
const handleOnMultiValueClick = (value) => {
|
52
|
-
alert(`You
|
52
|
+
alert(`You added the user: "${value.label}"`)
|
53
53
|
}
|
54
54
|
|
55
55
|
return (
|
@@ -56,7 +56,7 @@ const TypeaheadWithPillsAsyncUsers = (props) => {
|
|
56
56
|
* @summary - for doc example purposes only
|
57
57
|
*/
|
58
58
|
const handleOnMultiValueClick = (value) => {
|
59
|
-
alert(`You
|
59
|
+
alert(`You added the user: "${value.label}"`)
|
60
60
|
}
|
61
61
|
|
62
62
|
return (
|
@@ -13,3 +13,4 @@ export { default as TypeaheadCustomMenuList } from './_typeahead_custom_menu_lis
|
|
13
13
|
export { default as TypeaheadMarginBottom } from './_typeahead_margin_bottom.jsx'
|
14
14
|
export { default as TypeaheadWithPillsColor } from './_typeahead_with_pills_color.jsx'
|
15
15
|
export { default as TypeaheadTruncatedText } from './_typeahead_truncated_text.jsx'
|
16
|
+
export { default as TypeaheadReactHook } from './_typeahead_react_hook.jsx'
|