playbook_ui 15.5.0.pre.alpha.play2663multiuserkitaddtooltipsupport12718 → 15.5.0.pre.alpha.play250212696
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_multiple_users/_multiple_users.scss +0 -10
- data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.tsx +15 -66
- data/app/pb_kits/playbook/pb_multiple_users/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_multiple_users/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_multiple_users/multiple_users.test.js +0 -25
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +15 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -0
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +6 -1
- data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +34 -7
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_input_display.html.erb +30 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_input_display.jsx +37 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_input_display.md +3 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +6 -1
- data/dist/chunks/{_typeahead-CkkCTRLh.js → _typeahead-978gNTWh.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/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +6 -5
- data/app/pb_kits/playbook/pb_multiple_users/docs/_multiple_users_with_tooltip.jsx +0 -42
- data/app/pb_kits/playbook/pb_multiple_users/docs/_multiple_users_with_tooltip.md +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f25d8e230fb6f3cf92eac4b1e458b83579eba7a8f201a70f84c54fb97698b6b
|
|
4
|
+
data.tar.gz: f63d76ad13dada00d5d24667c202d4b8de8b29559fe5b6c0fbcf28eb8e3205f8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3f81a0dbf26bbbe3705c641959e175d4d4807690c16c672200e0a75a9fda6929eefe20ed29305f863c2229c6b5427a61327372364c4adb4f043ede86ac58cfb0
|
|
7
|
+
data.tar.gz: 9e0869caebd6545288ebe34e1df3d8c3f51faf21c915237aae222029abe6274c934ba2453b46c59f476ea3b38f58e0be319817b5f3d017fef7b915232a5fc5aa
|
|
@@ -36,16 +36,6 @@ $pb_multiple_users_size_xxs: map-get($avatar-sizes, "xxs");
|
|
|
36
36
|
height: $pb_multiple_users_size_xxs;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
.user_tooltip {
|
|
41
|
-
margin-left: $pb_multiple_users_overlap !important;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.user_count_tooltip {
|
|
45
|
-
margin-left: $pb_multiple_users_overlap !important;
|
|
46
|
-
position: relative;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
39
|
.pb_multiple_users_item {
|
|
50
40
|
margin-left: $pb_multiple_users_overlap;
|
|
51
41
|
margin-right: 0;
|
|
@@ -5,19 +5,17 @@ import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../uti
|
|
|
5
5
|
import { globalProps } from '../utilities/globalProps'
|
|
6
6
|
|
|
7
7
|
import Avatar from '../pb_avatar/_avatar'
|
|
8
|
-
import Tooltip from '../pb_tooltip/_tooltip'
|
|
9
8
|
|
|
10
9
|
type MultipleUsersProps = {
|
|
11
10
|
aria?: { [key: string]: string },
|
|
12
11
|
className?: string,
|
|
13
12
|
dark?: boolean,
|
|
14
13
|
data?: { [key: string]: string },
|
|
15
|
-
htmlOptions?: {
|
|
14
|
+
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
|
16
15
|
id?: string,
|
|
17
16
|
maxDisplayedUsers?: number,
|
|
18
17
|
reverse?: boolean,
|
|
19
18
|
size?: "md" | "lg" | "sm" | "xl" | "xs" | "xxs",
|
|
20
|
-
withTooltip?: boolean,
|
|
21
19
|
users: Array<{ [key: string]: string }>,
|
|
22
20
|
}
|
|
23
21
|
|
|
@@ -32,7 +30,6 @@ const MultipleUsers = (props: MultipleUsersProps): React.ReactElement => {
|
|
|
32
30
|
maxDisplayedUsers = 4,
|
|
33
31
|
reverse = false,
|
|
34
32
|
size = 'xs',
|
|
35
|
-
withTooltip = false,
|
|
36
33
|
users,
|
|
37
34
|
} = props
|
|
38
35
|
|
|
@@ -65,70 +62,22 @@ const MultipleUsers = (props: MultipleUsersProps): React.ReactElement => {
|
|
|
65
62
|
className={classes}
|
|
66
63
|
id={id}
|
|
67
64
|
>
|
|
68
|
-
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{...avatarData}
|
|
79
|
-
className={"pb_multiple_users_item" + (withTooltip ? " user_tooltip" : "")}
|
|
80
|
-
dark={dark}
|
|
81
|
-
imageAlt={avatarData.name}
|
|
82
|
-
key={index}
|
|
83
|
-
size={size}
|
|
84
|
-
/>
|
|
85
|
-
</Tooltip>
|
|
86
|
-
))}
|
|
65
|
+
{usersToDisplay.map((avatarData, index) => (
|
|
66
|
+
<Avatar
|
|
67
|
+
{...avatarData}
|
|
68
|
+
className="pb_multiple_users_item"
|
|
69
|
+
dark={dark}
|
|
70
|
+
imageAlt={avatarData.name}
|
|
71
|
+
key={index}
|
|
72
|
+
size={size}
|
|
73
|
+
/>
|
|
74
|
+
))}
|
|
87
75
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
<div>
|
|
93
|
-
{
|
|
94
|
-
usersToDisplay.length < users.length ?
|
|
95
|
-
users.slice(displayCount).map((u, i) => (
|
|
96
|
-
<div key={i}>{u.tooltip}</div>
|
|
97
|
-
))
|
|
98
|
-
:
|
|
99
|
-
''
|
|
100
|
-
}
|
|
101
|
-
</div>
|
|
102
|
-
}
|
|
103
|
-
zIndex={10}
|
|
104
|
-
>
|
|
105
|
-
<div className={itemClasses + (withTooltip ? " user_count_tooltip" : "")}>
|
|
106
|
-
{`+${users.length - displayCount}`}
|
|
107
|
-
</div>
|
|
108
|
-
</Tooltip>
|
|
109
|
-
}
|
|
110
|
-
</>
|
|
111
|
-
:
|
|
112
|
-
<>
|
|
113
|
-
{usersToDisplay.map((avatarData, index) => (
|
|
114
|
-
<Avatar
|
|
115
|
-
{...avatarData}
|
|
116
|
-
className="pb_multiple_users_item"
|
|
117
|
-
dark={dark}
|
|
118
|
-
imageAlt={avatarData.name}
|
|
119
|
-
key={index}
|
|
120
|
-
size={size}
|
|
121
|
-
/>
|
|
122
|
-
))}
|
|
123
|
-
|
|
124
|
-
{users.length > maxDisplayedUsers &&
|
|
125
|
-
<div className={itemClasses}>
|
|
126
|
-
{`+${users.length - 3}`}
|
|
127
|
-
</div>
|
|
128
|
-
}
|
|
129
|
-
</>
|
|
76
|
+
{ users.length > maxDisplayedUsers &&
|
|
77
|
+
<div className={itemClasses}>
|
|
78
|
+
{`+${users.length - 3}`}
|
|
79
|
+
</div>
|
|
130
80
|
}
|
|
131
|
-
|
|
132
81
|
</div>
|
|
133
82
|
)
|
|
134
83
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { default as MultipleUsersDefault } from './_multiple_users_default.jsx'
|
|
2
2
|
export { default as MultipleUsersReverse } from './_multiple_users_reverse.jsx'
|
|
3
3
|
export { default as MultipleUsersSize } from './_multiple_users_size.jsx'
|
|
4
|
-
export { default as MultipleUsersWithTooltip } from './_multiple_users_with_tooltip.jsx'
|
|
@@ -49,29 +49,4 @@ test('should render aria-label', () => {
|
|
|
49
49
|
|
|
50
50
|
const kit = screen.getByTestId(testId)
|
|
51
51
|
expect(kit).toHaveAttribute('aria-label', testId)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
test('should render withTooltip prop', () => {
|
|
55
|
-
render(
|
|
56
|
-
<MultipleUsers
|
|
57
|
-
data={{ testid: testId }}
|
|
58
|
-
users={[
|
|
59
|
-
{
|
|
60
|
-
name: 'Patrick Welch',
|
|
61
|
-
imageUrl: 'https://randomuser.me/api/portraits/men/9.jpg',
|
|
62
|
-
tooltip: "Patrick Welch - Online"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: 'Lucille Sanchez',
|
|
66
|
-
imageUrl: 'https://randomuser.me/api/portraits/women/6.jpg',
|
|
67
|
-
tooltip: "Lucille Sanchez - Offline"
|
|
68
|
-
},
|
|
69
|
-
]}
|
|
70
|
-
withTooltip
|
|
71
|
-
/>
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
const kit = screen.getByTestId(testId)
|
|
75
|
-
const childWithTooltip = kit.querySelector('.pb_tooltip_kit')
|
|
76
|
-
expect(childWithTooltip).not.toBeNull()
|
|
77
52
|
})
|
|
@@ -276,3 +276,18 @@ test('multi-value badges have tabIndex and focus class when focused', () => {
|
|
|
276
276
|
})
|
|
277
277
|
})
|
|
278
278
|
|
|
279
|
+
test('input display none shows number of selected items', () => {
|
|
280
|
+
render(
|
|
281
|
+
<Typeahead
|
|
282
|
+
data={{ testid: 'input-display-none-test' }}
|
|
283
|
+
defaultValue={[options[0], options[1]]}
|
|
284
|
+
inputDisplay="none"
|
|
285
|
+
isMulti
|
|
286
|
+
options={options}
|
|
287
|
+
/>
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
const kit = screen.getByTestId('input-display-none-test')
|
|
291
|
+
const inputDisplayDiv = kit.querySelector(".pb_typeahead_selection_count")
|
|
292
|
+
expect(inputDisplayDiv).toHaveTextContent("2 items selected")
|
|
293
|
+
})
|
|
@@ -43,6 +43,7 @@ type TypeaheadProps = {
|
|
|
43
43
|
error?: string,
|
|
44
44
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
|
45
45
|
id?: string,
|
|
46
|
+
inputDisplay?: "pills" | "none",
|
|
46
47
|
label?: string,
|
|
47
48
|
loadOptions?: string | Noop,
|
|
48
49
|
getOptionLabel?: string | (() => string),
|
|
@@ -89,6 +90,7 @@ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
|
|
|
89
90
|
getOptionValue,
|
|
90
91
|
htmlOptions = {},
|
|
91
92
|
id,
|
|
93
|
+
inputDisplay = "pills",
|
|
92
94
|
name,
|
|
93
95
|
loadOptions = noop,
|
|
94
96
|
marginBottom = "sm",
|
|
@@ -238,6 +240,7 @@ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
|
|
|
238
240
|
getOptionValue: isString(getOptionValue) ? get(window, getOptionValue) : getOptionValue,
|
|
239
241
|
defaultOptions: true,
|
|
240
242
|
id: id || uniqueId(),
|
|
243
|
+
inputDisplay: inputDisplay,
|
|
241
244
|
inline: false,
|
|
242
245
|
isClearable: true,
|
|
243
246
|
isSearchable: true,
|
|
@@ -19,7 +19,12 @@ type Props = {
|
|
|
19
19
|
const MultiValue = (props: Props) => {
|
|
20
20
|
const { removeProps, isFocused } = props
|
|
21
21
|
const { imageUrl, label } = props.data
|
|
22
|
-
const { dark, multiKit, pillColor, truncate, wrapped } = props.selectProps
|
|
22
|
+
const { dark, multiKit, pillColor, truncate, wrapped, inputDisplay } = props.selectProps
|
|
23
|
+
|
|
24
|
+
// If inputDisplay is "none", don't render the pill/badge, just return null (the count handled in ValueContainer file)
|
|
25
|
+
if (inputDisplay === 'none') {
|
|
26
|
+
return null
|
|
27
|
+
}
|
|
23
28
|
|
|
24
29
|
const formPillProps = {
|
|
25
30
|
marginRight: 'xs',
|
|
@@ -1,15 +1,42 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { components } from 'react-select'
|
|
3
|
+
import Body from '../../pb_body/_body'
|
|
3
4
|
|
|
4
5
|
type ValueContainerProps = {
|
|
5
|
-
children: React.ReactNode,
|
|
6
|
+
children: React.ReactNode | React.ReactNode[],
|
|
7
|
+
selectProps?: Record<string, unknown>,
|
|
8
|
+
hasValue?: boolean,
|
|
6
9
|
}
|
|
7
10
|
|
|
8
|
-
const ValueContainer = (props: ValueContainerProps): React.ReactElement =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
)
|
|
11
|
+
const ValueContainer = (props: ValueContainerProps | any): React.ReactElement => {
|
|
12
|
+
const { children, selectProps, hasValue } = props
|
|
13
|
+
const inputDisplay = (selectProps as any)?.inputDisplay
|
|
14
|
+
const value = (selectProps as any)?.value
|
|
15
|
+
|
|
16
|
+
// When inputDisplay is "none" and there are selected values, show count text (this is for multi-select only)
|
|
17
|
+
if (inputDisplay === 'none' && hasValue && value) {
|
|
18
|
+
const selectedCount = Array.isArray(value) ? value.length : 0
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<components.ValueContainer
|
|
22
|
+
className="text_input_value_container"
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
25
|
+
<Body
|
|
26
|
+
className="pb_typeahead_selection_count"
|
|
27
|
+
text={`${selectedCount} item${selectedCount !== 1 ? 's' : ''} selected`}
|
|
28
|
+
/>
|
|
29
|
+
{children}
|
|
30
|
+
</components.ValueContainer>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<components.ValueContainer
|
|
36
|
+
className="text_input_value_container"
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
14
41
|
|
|
15
42
|
export default ValueContainer
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<%
|
|
2
|
+
options = [
|
|
3
|
+
{ label: 'Orange', value: '#FFA500' },
|
|
4
|
+
{ label: 'Red', value: '#FF0000' },
|
|
5
|
+
{ label: 'Green', value: '#00FF00' },
|
|
6
|
+
{ label: 'Blue', value: '#0000FF' },
|
|
7
|
+
{ label: 'Yellow', value: '#FFFF00' },
|
|
8
|
+
{ label: 'Purple', value: '#800080' },
|
|
9
|
+
{ label: 'Cyan', value: '#00FFFF' },
|
|
10
|
+
{ label: 'Magenta', value: '#FF00FF' }
|
|
11
|
+
]
|
|
12
|
+
%>
|
|
13
|
+
|
|
14
|
+
<%= pb_rails("typeahead", props: {
|
|
15
|
+
id: "typeahead-input-display-none",
|
|
16
|
+
label: "With Input Display None",
|
|
17
|
+
options: options,
|
|
18
|
+
name: :foo,
|
|
19
|
+
input_display: "none",
|
|
20
|
+
})
|
|
21
|
+
%>
|
|
22
|
+
<br/>
|
|
23
|
+
<%= pb_rails("typeahead", props: {
|
|
24
|
+
id: "typeahead-input-display-pills",
|
|
25
|
+
label: "With Input Display Pills (Default)",
|
|
26
|
+
options: options,
|
|
27
|
+
name: :foo,
|
|
28
|
+
pills: true,
|
|
29
|
+
})
|
|
30
|
+
%>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import Typeahead from '../_typeahead'
|
|
4
|
+
|
|
5
|
+
const options = [
|
|
6
|
+
{ label: 'Orange', value: '#FFA500' },
|
|
7
|
+
{ label: 'Red', value: '#FF0000' },
|
|
8
|
+
{ label: 'Green', value: '#00FF00' },
|
|
9
|
+
{ label: 'Blue', value: '#0000FF' },
|
|
10
|
+
{ label: 'Yellow', value: '#FFFF00' },
|
|
11
|
+
{ label: 'Purple', value: '#800080' },
|
|
12
|
+
{ label: 'Cyan', value: '#00FFFF' },
|
|
13
|
+
{ label: 'Magenta', value: '#FF00FF' }
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
const TypeaheadInputDisplay = (props) => {
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
<Typeahead
|
|
20
|
+
inputDisplay="none"
|
|
21
|
+
isMulti
|
|
22
|
+
label="With Input Display None"
|
|
23
|
+
options={options}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
<br/>
|
|
27
|
+
<Typeahead
|
|
28
|
+
isMulti
|
|
29
|
+
label="With Input Display Pills (Default)"
|
|
30
|
+
options={options}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
</>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default TypeaheadInputDisplay
|
|
@@ -5,6 +5,7 @@ examples:
|
|
|
5
5
|
- typeahead_default_options: With Default Options
|
|
6
6
|
- typeahead_with_context: With Context
|
|
7
7
|
- typeahead_with_pills: With Pills
|
|
8
|
+
- typeahead_input_display: Input Display
|
|
8
9
|
- typeahead_without_pills: Without Pills (Single Select)
|
|
9
10
|
- typeahead_with_pills_async: With Pills (Async Data)
|
|
10
11
|
- typeahead_with_pills_async_users: With Pills (Async Data w/ Users)
|
|
@@ -26,6 +27,7 @@ examples:
|
|
|
26
27
|
- typeahead_react_hook: React Hook
|
|
27
28
|
- typeahead_with_highlight: With Highlight
|
|
28
29
|
- typeahead_with_pills: With Pills
|
|
30
|
+
- typeahead_input_display: Input Display
|
|
29
31
|
- typeahead_with_pills_async: With Pills (Async Data)
|
|
30
32
|
- typeahead_with_pills_async_users: With Pills (Async Data w/ Users)
|
|
31
33
|
- typeahead_with_pills_async_custom_options: With Pills (Async Data w/ Custom Options)
|
|
@@ -17,4 +17,5 @@ export { default as TypeaheadReactHook } from './_typeahead_react_hook.jsx'
|
|
|
17
17
|
export { default as TypeaheadDisabled } from './_typeahead_disabled.jsx'
|
|
18
18
|
export { default as TypeaheadPreserveInput } from './_typeahead_preserve_input.jsx'
|
|
19
19
|
export { default as TypeaheadDefaultValue } from './_typeahead_default_value.jsx'
|
|
20
|
-
export { default as TypeaheadCustomOptions } from './_typeahead_custom_options.jsx'
|
|
20
|
+
export { default as TypeaheadCustomOptions } from './_typeahead_custom_options.jsx'
|
|
21
|
+
export { default as TypeaheadInputDisplay } from './_typeahead_input_display.jsx'
|
|
@@ -25,6 +25,10 @@ module Playbook
|
|
|
25
25
|
prop :is_multi, type: Playbook::Props::Boolean,
|
|
26
26
|
default: true
|
|
27
27
|
|
|
28
|
+
prop :input_display, type: Playbook::Props::Enum,
|
|
29
|
+
values: %w[none pills],
|
|
30
|
+
default: "pills"
|
|
31
|
+
|
|
28
32
|
prop :pills, type: Playbook::Props::Boolean,
|
|
29
33
|
default: false
|
|
30
34
|
|
|
@@ -78,7 +82,7 @@ module Playbook
|
|
|
78
82
|
end
|
|
79
83
|
|
|
80
84
|
def is_react?
|
|
81
|
-
pills || !is_multi || wrapped
|
|
85
|
+
pills || !is_multi || wrapped || input_display == "none"
|
|
82
86
|
end
|
|
83
87
|
|
|
84
88
|
def typeahead_react_options
|
|
@@ -91,6 +95,7 @@ module Playbook
|
|
|
91
95
|
id: id,
|
|
92
96
|
inline: inline,
|
|
93
97
|
isMulti: is_multi,
|
|
98
|
+
inputDisplay: input_display,
|
|
94
99
|
label: label,
|
|
95
100
|
marginBottom: margin_bottom,
|
|
96
101
|
multiKit: multi_kit,
|