playbook_ui 6.5.2 → 6.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -4
- data/app/pb_kits/playbook/index.js +1 -0
- data/app/pb_kits/playbook/packs/examples.js +2 -0
- data/app/pb_kits/playbook/packs/site_styles/docs/_kit_doc.scss +6 -0
- data/app/pb_kits/playbook/pb_date/date.rb +2 -1
- data/app/pb_kits/playbook/pb_date/docs/_date_default.html.erb +8 -1
- data/app/pb_kits/playbook/pb_date/docs/_date_timezone.html.erb +51 -0
- data/app/pb_kits/playbook/pb_date/docs/_date_timezone.md +6 -0
- data/app/pb_kits/playbook/pb_date/docs/_description.md +2 -0
- data/app/pb_kits/playbook/pb_date/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_text_input/_text_input.scss +17 -8
- data/app/pb_kits/playbook/pb_time/_time.html.erb +23 -17
- data/app/pb_kits/playbook/pb_time/_time.jsx +20 -11
- data/app/pb_kits/playbook/pb_time/_time.scss +16 -8
- data/app/pb_kits/playbook/pb_time/docs/_time_align.html.erb +18 -0
- data/app/pb_kits/playbook/pb_time/docs/_time_align.jsx +3 -3
- data/app/pb_kits/playbook/pb_time/docs/_time_dark.html.erb +70 -0
- data/app/pb_kits/playbook/pb_time/docs/_time_dark.jsx +1 -6
- data/app/pb_kits/playbook/pb_time/docs/_time_default.html.erb +47 -3
- data/app/pb_kits/playbook/pb_time/docs/_time_default.jsx +33 -4
- data/app/pb_kits/playbook/pb_time/docs/_time_sizes.html.erb +11 -0
- data/app/pb_kits/playbook/pb_time/docs/_time_sizes.jsx +19 -0
- data/app/pb_kits/playbook/pb_time/docs/_time_timestamp.html.erb +2 -1
- data/app/pb_kits/playbook/pb_time/docs/_time_timestamp.jsx +0 -7
- data/app/pb_kits/playbook/pb_time/docs/_time_timezone.html.erb +42 -0
- data/app/pb_kits/playbook/pb_time/docs/_time_timezone.jsx +12 -14
- data/app/pb_kits/playbook/pb_time/docs/example.yml +7 -2
- data/app/pb_kits/playbook/pb_time/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_time/time.rb +14 -2
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +60 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +20 -3
- data/app/pb_kits/playbook/pb_typeahead/components/Control.jsx +30 -0
- data/app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.jsx +13 -0
- data/app/pb_kits/playbook/pb_typeahead/components/MenuList.jsx +12 -0
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.jsx +51 -0
- data/app/pb_kits/playbook/pb_typeahead/components/Option.jsx +34 -0
- data/app/pb_kits/playbook/pb_typeahead/components/Placeholder.jsx +13 -0
- data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.jsx +13 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default.jsx +22 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills.jsx +29 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx +84 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_summary.jsx +45 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_users.jsx +101 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_summary.jsx +27 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +8 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +4 -0
- data/app/pb_kits/playbook/tokens/_typography.scss +3 -3
- data/lib/playbook/version.rb +1 -1
- metadata +24 -2
@@ -1,5 +1,7 @@
|
|
1
1
|
@import "../tokens/colors";
|
2
2
|
@import "../tokens/border_radius";
|
3
|
+
@import "../tokens/spacing";
|
4
|
+
@import "../tokens/shadows";
|
3
5
|
|
4
6
|
[class^=pb_typeahead_kit] {
|
5
7
|
.pb_typeahead_wrapper {
|
@@ -17,8 +19,10 @@
|
|
17
19
|
}
|
18
20
|
|
19
21
|
[class^=pb_text_input_kit] {
|
20
|
-
.text_input_wrapper
|
21
|
-
|
22
|
+
.text_input_wrapper {
|
23
|
+
& > input:first-child {
|
24
|
+
padding-right: $space_xl;
|
25
|
+
}
|
22
26
|
}
|
23
27
|
}
|
24
28
|
|
@@ -31,7 +35,7 @@
|
|
31
35
|
}
|
32
36
|
}
|
33
37
|
}
|
34
|
-
|
38
|
+
|
35
39
|
[class^=pb_list_kit] {
|
36
40
|
max-height: 18em;
|
37
41
|
overflow-y: auto;
|
@@ -86,4 +90,17 @@
|
|
86
90
|
color: $text_dk_light;
|
87
91
|
}
|
88
92
|
}
|
93
|
+
|
94
|
+
&.react-select {
|
95
|
+
.text_input {
|
96
|
+
display: inherit;
|
97
|
+
padding: 3px 4px;
|
98
|
+
&_indicators {
|
99
|
+
max-width: 70px;
|
100
|
+
}
|
101
|
+
&_value_container {
|
102
|
+
flex-grow: 1;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
89
106
|
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React from 'react'
|
4
|
+
import { components } from 'react-select'
|
5
|
+
|
6
|
+
import {
|
7
|
+
Flex,
|
8
|
+
TextInput,
|
9
|
+
} from '../..'
|
10
|
+
|
11
|
+
type Props = {
|
12
|
+
selectProps: any,
|
13
|
+
}
|
14
|
+
|
15
|
+
const TypeaheadControl = (props: Props) => (
|
16
|
+
<div className="pb_typeahead_wrapper">
|
17
|
+
<TextInput
|
18
|
+
label={props.selectProps.label}
|
19
|
+
>
|
20
|
+
<Flex>
|
21
|
+
<components.Control
|
22
|
+
className="text_input"
|
23
|
+
{...props}
|
24
|
+
/>
|
25
|
+
</Flex>
|
26
|
+
</TextInput>
|
27
|
+
</div>
|
28
|
+
)
|
29
|
+
|
30
|
+
export default TypeaheadControl
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React from 'react'
|
4
|
+
import { components } from 'react-select'
|
5
|
+
|
6
|
+
const IndicatorsContainer = (props: any) => (
|
7
|
+
<components.IndicatorsContainer
|
8
|
+
className="text_input_indicators"
|
9
|
+
{...props}
|
10
|
+
/>
|
11
|
+
)
|
12
|
+
|
13
|
+
export default IndicatorsContainer
|
@@ -0,0 +1,51 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React from 'react'
|
4
|
+
import { components } from 'react-select'
|
5
|
+
|
6
|
+
import { FormPill } from '../../'
|
7
|
+
|
8
|
+
type Props = {
|
9
|
+
data: object,
|
10
|
+
multiValueTemplate: any,
|
11
|
+
removeProps: any,
|
12
|
+
selectProps: any,
|
13
|
+
}
|
14
|
+
|
15
|
+
const MultiValue = (props: Props) => {
|
16
|
+
const {
|
17
|
+
data,
|
18
|
+
removeProps,
|
19
|
+
selectProps,
|
20
|
+
} = props
|
21
|
+
|
22
|
+
const handleOnClick = () => {
|
23
|
+
if (selectProps.onMultiValueClick) selectProps.onMultiValueClick(data)
|
24
|
+
removeProps.onClick()
|
25
|
+
}
|
26
|
+
const { imageUrl, label } = data
|
27
|
+
|
28
|
+
return (
|
29
|
+
<components.MultiValueContainer
|
30
|
+
className="text_input_multivalue_container"
|
31
|
+
{...props}
|
32
|
+
>
|
33
|
+
<If condition={imageUrl}>
|
34
|
+
<FormPill
|
35
|
+
avatarUrl={imageUrl}
|
36
|
+
marginRight="xs"
|
37
|
+
name={label}
|
38
|
+
onClick={handleOnClick}
|
39
|
+
/>
|
40
|
+
<Else />
|
41
|
+
<FormPill
|
42
|
+
marginRight="xs"
|
43
|
+
onClick={handleOnClick}
|
44
|
+
text={label}
|
45
|
+
/>
|
46
|
+
</If>
|
47
|
+
</components.MultiValueContainer>
|
48
|
+
)
|
49
|
+
}
|
50
|
+
|
51
|
+
export default MultiValue
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React from 'react'
|
4
|
+
import { components } from 'react-select'
|
5
|
+
|
6
|
+
import {
|
7
|
+
User,
|
8
|
+
} from '../../'
|
9
|
+
|
10
|
+
const Option = (props: any) => {
|
11
|
+
const {
|
12
|
+
imageUrl,
|
13
|
+
label,
|
14
|
+
} = props.data
|
15
|
+
return (
|
16
|
+
<components.Option {...props}>
|
17
|
+
<Choose>
|
18
|
+
<When condition={imageUrl}>
|
19
|
+
<User
|
20
|
+
align="left"
|
21
|
+
avatarUrl={imageUrl}
|
22
|
+
name={label}
|
23
|
+
orientation="horizontal"
|
24
|
+
/>
|
25
|
+
</When>
|
26
|
+
<When condition={!imageUrl}>
|
27
|
+
{label}
|
28
|
+
</When>
|
29
|
+
</Choose>
|
30
|
+
</components.Option>
|
31
|
+
)
|
32
|
+
}
|
33
|
+
|
34
|
+
export default Option
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React from 'react'
|
4
|
+
import { components } from 'react-select'
|
5
|
+
|
6
|
+
const ValueContainer = (props: Props) => (
|
7
|
+
<components.ValueContainer
|
8
|
+
className="text_input_value_container"
|
9
|
+
{...props}
|
10
|
+
/>
|
11
|
+
)
|
12
|
+
|
13
|
+
export default ValueContainer
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// @flow
|
2
|
+
|
3
|
+
import React from 'react'
|
4
|
+
import { Typeahead } from '../../'
|
5
|
+
|
6
|
+
const options = [
|
7
|
+
{ label: 'Orange', value: '#FFA500' },
|
8
|
+
{ label: 'Red', value: '#FF0000' },
|
9
|
+
{ label: 'Green', value: '#00FF00' },
|
10
|
+
{ label: 'Blue', value: '#0000FF' },
|
11
|
+
]
|
12
|
+
|
13
|
+
const TypeaheadDefault = () => {
|
14
|
+
return (
|
15
|
+
<Typeahead
|
16
|
+
label="Colors"
|
17
|
+
options={options}
|
18
|
+
/>
|
19
|
+
)
|
20
|
+
}
|
21
|
+
|
22
|
+
export default TypeaheadDefault
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React from 'react'
|
4
|
+
import { Typeahead } from '../..'
|
5
|
+
|
6
|
+
const options = [
|
7
|
+
{ label: 'Windows', value: '#FFA500' },
|
8
|
+
{ label: 'Siding', value: '#FF0000' },
|
9
|
+
{ label: 'Doors', value: '#00FF00' },
|
10
|
+
{ label: 'Roofs', value: '#0000FF' },
|
11
|
+
]
|
12
|
+
|
13
|
+
import TypeaheadWithPillsSummary from './_typeahead_with_pills_summary'
|
14
|
+
|
15
|
+
const TypeaheadWithPills = () => {
|
16
|
+
return (
|
17
|
+
<>
|
18
|
+
<TypeaheadWithPillsSummary />
|
19
|
+
<Typeahead
|
20
|
+
isMulti
|
21
|
+
label="Colors"
|
22
|
+
options={options}
|
23
|
+
placeholder=""
|
24
|
+
/>
|
25
|
+
</>
|
26
|
+
)
|
27
|
+
}
|
28
|
+
|
29
|
+
export default TypeaheadWithPills
|
@@ -0,0 +1,84 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React, { useState } from 'react'
|
4
|
+
|
5
|
+
import {
|
6
|
+
Caption,
|
7
|
+
Typeahead,
|
8
|
+
User,
|
9
|
+
} from '../..'
|
10
|
+
|
11
|
+
/**
|
12
|
+
*
|
13
|
+
* @const filterResults
|
14
|
+
* @ignore
|
15
|
+
* @returns {[Object]} - a custom mapping of objects, minimally containing
|
16
|
+
* `value` and `label` among other possible fields
|
17
|
+
* @summary - for doc example purposes only
|
18
|
+
*/
|
19
|
+
|
20
|
+
const filterResults = (results) =>
|
21
|
+
results.items.map((result) => {
|
22
|
+
return {
|
23
|
+
label: result.login,
|
24
|
+
value: result.id,
|
25
|
+
}
|
26
|
+
})
|
27
|
+
|
28
|
+
/**
|
29
|
+
*
|
30
|
+
* @const promiseOptions
|
31
|
+
* @ignore
|
32
|
+
* @returns {Promise} - fetch API data results from Typeahead input text
|
33
|
+
* @see - https://react-select.com/home#async
|
34
|
+
* @summary - for doc example purposes only
|
35
|
+
*/
|
36
|
+
|
37
|
+
const promiseOptions = (inputValue) =>
|
38
|
+
new Promise((resolve) => {
|
39
|
+
if (inputValue) {
|
40
|
+
fetch(`https://api.github.com/search/users?q=${inputValue}`)
|
41
|
+
.then((response) => response.json())
|
42
|
+
.then((results) => resolve(filterResults(results)))
|
43
|
+
} else {
|
44
|
+
resolve([])
|
45
|
+
}
|
46
|
+
})
|
47
|
+
|
48
|
+
const TypeaheadWithPillsAsync = () => {
|
49
|
+
const [users, setUsers] = useState([])
|
50
|
+
const handleOnChange = (value) => setUsers(value)
|
51
|
+
|
52
|
+
return (
|
53
|
+
<>
|
54
|
+
<If condition={users && users.length > 0}>
|
55
|
+
<Caption
|
56
|
+
marginBottom="xs"
|
57
|
+
text="State (Users)"
|
58
|
+
/>
|
59
|
+
<For
|
60
|
+
each="user"
|
61
|
+
of={users}
|
62
|
+
>
|
63
|
+
<User
|
64
|
+
align="left"
|
65
|
+
key={user.value}
|
66
|
+
marginBottom="md"
|
67
|
+
name={user.label}
|
68
|
+
orientation="horizontal"
|
69
|
+
/>
|
70
|
+
</For>
|
71
|
+
</If>
|
72
|
+
<Typeahead
|
73
|
+
async
|
74
|
+
isMulti
|
75
|
+
label="Github Users"
|
76
|
+
loadOptions={promiseOptions}
|
77
|
+
onChange={handleOnChange}
|
78
|
+
placeholder="type the name of a Github user"
|
79
|
+
/>
|
80
|
+
</>
|
81
|
+
)
|
82
|
+
}
|
83
|
+
|
84
|
+
export default TypeaheadWithPillsAsync
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React from 'react'
|
4
|
+
import { Body, Flex, FlexItem, Icon } from '../..'
|
5
|
+
|
6
|
+
const TypeaheadWithPillsAsyncSummary = () => {
|
7
|
+
return (
|
8
|
+
<>
|
9
|
+
<Flex
|
10
|
+
marginBottom="lg"
|
11
|
+
vertical="center"
|
12
|
+
>
|
13
|
+
<FlexItem>
|
14
|
+
<Body
|
15
|
+
color="light"
|
16
|
+
>
|
17
|
+
<Icon
|
18
|
+
icon="info-circle"
|
19
|
+
marginRight="xs"
|
20
|
+
/>
|
21
|
+
</Body>
|
22
|
+
</FlexItem>
|
23
|
+
<FlexItem>
|
24
|
+
<Body
|
25
|
+
color="light"
|
26
|
+
>
|
27
|
+
{'If the data field '}
|
28
|
+
<code>{'imageUrl'}</code>
|
29
|
+
{' is present, '}
|
30
|
+
<code>{'FormPill'}</code>
|
31
|
+
{' will receive that field as a prop and display the image. '}
|
32
|
+
<br />
|
33
|
+
{'Additionally, you can also leverage the callback prop: '}
|
34
|
+
<code>{'onMultiValueClick'}</code>
|
35
|
+
{' to perform custom work when a '}
|
36
|
+
<code>{'MultiValue'}</code>
|
37
|
+
{' item is clicked.'}
|
38
|
+
</Body>
|
39
|
+
</FlexItem>
|
40
|
+
</Flex>
|
41
|
+
</>
|
42
|
+
)
|
43
|
+
}
|
44
|
+
|
45
|
+
export default TypeaheadWithPillsAsyncSummary
|
@@ -0,0 +1,101 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React, { useState } from 'react'
|
4
|
+
|
5
|
+
import {
|
6
|
+
Caption,
|
7
|
+
Typeahead,
|
8
|
+
User,
|
9
|
+
} from '../..'
|
10
|
+
|
11
|
+
import TypeaheadWithPillsAsyncSummary from './_typeahead_with_pills_async_summary'
|
12
|
+
|
13
|
+
/**
|
14
|
+
*
|
15
|
+
* @const filterResults
|
16
|
+
* @ignore
|
17
|
+
* @returns {[Object]} - a custom mapping of objects, minimally containing
|
18
|
+
* `value` and `label` among other possible fields
|
19
|
+
* @summary - for doc example purposes only
|
20
|
+
*/
|
21
|
+
|
22
|
+
const filterResults = (results) =>
|
23
|
+
results.items.map((result) => {
|
24
|
+
return {
|
25
|
+
imageUrl: result.avatar_url, //add the custom field
|
26
|
+
label: result.login,
|
27
|
+
value: result.id,
|
28
|
+
}
|
29
|
+
})
|
30
|
+
|
31
|
+
/**
|
32
|
+
*
|
33
|
+
* @const promiseOptions
|
34
|
+
* @ignore
|
35
|
+
* @returns {Promise} - fetch API data results from Typeahead input text
|
36
|
+
* @see - https://react-select.com/home#async
|
37
|
+
* @summary - for doc example purposes only
|
38
|
+
*/
|
39
|
+
|
40
|
+
const promiseOptions = (inputValue) =>
|
41
|
+
new Promise((resolve) => {
|
42
|
+
if (inputValue) {
|
43
|
+
fetch(`https://api.github.com/search/users?q=${inputValue}`)
|
44
|
+
.then((response) => response.json())
|
45
|
+
.then((results) => resolve(filterResults(results)))
|
46
|
+
} else {
|
47
|
+
resolve([])
|
48
|
+
}
|
49
|
+
})
|
50
|
+
|
51
|
+
const TypeaheadWithPillsAsyncUsers = () => {
|
52
|
+
const [users, setUsers] = useState([])
|
53
|
+
const handleOnChange = (value) => setUsers(value)
|
54
|
+
|
55
|
+
/**
|
56
|
+
*
|
57
|
+
* @const handleOnMultiValueClick {function} - a custom callback for the MultiValue click
|
58
|
+
* @ignore
|
59
|
+
* @returns {null}
|
60
|
+
* @summary - for doc example purposes only
|
61
|
+
*/
|
62
|
+
const handleOnMultiValueClick = (value) => {
|
63
|
+
alert(`You removed the user: "${value.label}"`)
|
64
|
+
}
|
65
|
+
|
66
|
+
return (
|
67
|
+
<>
|
68
|
+
<TypeaheadWithPillsAsyncSummary />
|
69
|
+
<If condition={users && users.length > 0}>
|
70
|
+
<Caption
|
71
|
+
marginBottom="xs"
|
72
|
+
text="State (Users)"
|
73
|
+
/>
|
74
|
+
<For
|
75
|
+
each="user"
|
76
|
+
of={users}
|
77
|
+
>
|
78
|
+
<User
|
79
|
+
align="left"
|
80
|
+
avatarUrl={user.imageUrl}
|
81
|
+
key={user.value}
|
82
|
+
marginBottom="md"
|
83
|
+
name={user.label}
|
84
|
+
orientation="horizontal"
|
85
|
+
/>
|
86
|
+
</For>
|
87
|
+
</If>
|
88
|
+
<Typeahead
|
89
|
+
async
|
90
|
+
isMulti
|
91
|
+
label="Github Users"
|
92
|
+
loadOptions={promiseOptions}
|
93
|
+
onChange={handleOnChange}
|
94
|
+
onMultiValueClick={handleOnMultiValueClick}
|
95
|
+
placeholder="type the name of a Github user"
|
96
|
+
/>
|
97
|
+
</>
|
98
|
+
)
|
99
|
+
}
|
100
|
+
|
101
|
+
export default TypeaheadWithPillsAsyncUsers
|