playbook_ui 7.0.1.pre.alpha12 → 7.0.1.pre.alpha14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -6
- data/app/pb_kits/playbook/_playbook.scss +1 -0
- data/app/pb_kits/playbook/data/menu.yml +1 -1
- data/app/pb_kits/playbook/index.js +3 -0
- data/app/pb_kits/playbook/packs/examples.js +6 -0
- data/app/pb_kits/playbook/packs/site_styles/docs/_kit_doc.scss +22 -6
- data/app/pb_kits/playbook/pb_avatar/_avatar.jsx +5 -1
- data/app/pb_kits/playbook/pb_background/_background.html.erb +14 -0
- data/app/pb_kits/playbook/pb_background/_background.jsx +64 -0
- data/app/pb_kits/playbook/pb_background/_background.scss +15 -0
- data/app/pb_kits/playbook/pb_background/background.rb +36 -0
- data/app/pb_kits/playbook/pb_background/docs/_background_default.html.erb +41 -0
- data/app/pb_kits/playbook/pb_background/docs/_background_default.jsx +75 -0
- data/app/pb_kits/playbook/pb_background/docs/example.yml +8 -0
- data/app/pb_kits/playbook/pb_background/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_badge/_badge.jsx +4 -2
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +1 -1
- data/app/pb_kits/playbook/pb_button/_button.jsx +5 -1
- data/app/pb_kits/playbook/pb_button_toolbar/_button_toolbar.jsx +5 -1
- data/app/pb_kits/playbook/pb_caption/_caption.jsx +2 -2
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.jsx +5 -2
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +3 -1
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_options.html.erb +10 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.html.erb +1 -1
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +130 -0
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.scss +1 -1
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_block.jsx +39 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_colors.jsx +29 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_default.jsx +28 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_inner_sizes.jsx +117 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_live_data.jsx +53 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_rounded.jsx +30 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_labels.jsx +45 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_legend_kit.jsx +30 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_title.jsx +45 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/example.yml +11 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/index.js +9 -0
- data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.jsx +5 -1
- data/app/pb_kits/playbook/pb_contact/_contact.jsx +5 -1
- data/app/pb_kits/playbook/pb_currency/_currency.jsx +5 -1
- data/app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx +5 -1
- 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_date_picker/_date_picker.jsx +7 -4
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +0 -4
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +3 -3
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.js +8 -10
- data/app/pb_kits/playbook/pb_date_picker/docs/{_date_picker_read_only.html.erb → _date_picker_allow_input.html.erb} +1 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_allow_input.jsx +13 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_allow_input.md +1 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx +34 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.md +3 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +3 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_calendar_input_icon.scss +1 -0
- data/app/pb_kits/playbook/pb_date_range_stacked/_date_range_stacked.jsx +5 -1
- data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx +2 -2
- data/app/pb_kits/playbook/pb_date_year_stacked/_date_year_stacked.jsx +5 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx +2 -2
- data/app/pb_kits/playbook/pb_flex/_flex.jsx +2 -2
- data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +1 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +6 -1
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +3 -2
- data/app/pb_kits/playbook/pb_gauge/_gauge.jsx +1 -1
- data/app/pb_kits/playbook/pb_highlight/_highlight.jsx +1 -1
- data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.jsx +2 -2
- data/app/pb_kits/playbook/pb_icon/_icon.jsx +2 -2
- data/app/pb_kits/playbook/pb_icon_value/_icon_value.jsx +5 -1
- data/app/pb_kits/playbook/pb_image/_image.jsx +5 -1
- data/app/pb_kits/playbook/pb_label_pill/_label_pill.jsx +5 -1
- data/app/pb_kits/playbook/pb_layout/_layout.jsx +4 -4
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +1 -1
- data/app/pb_kits/playbook/pb_list/_list.jsx +3 -2
- data/app/pb_kits/playbook/pb_list/_list_item.jsx +3 -2
- data/app/pb_kits/playbook/pb_logistic/_logistic.jsx +5 -1
- data/app/pb_kits/playbook/pb_message/_message.jsx +5 -1
- data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx +5 -2
- data/app/pb_kits/playbook/pb_nav/_nav.jsx +2 -2
- data/app/pb_kits/playbook/pb_person/_person.jsx +5 -1
- data/app/pb_kits/playbook/pb_person_contact/_person_contact.jsx +5 -1
- data/app/pb_kits/playbook/pb_popover/_popover.jsx +5 -1
- data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.jsx +4 -4
- data/app/pb_kits/playbook/pb_progress_step/_progress_step.jsx +1 -1
- data/app/pb_kits/playbook/pb_radio/_radio.html.erb +1 -1
- data/app/pb_kits/playbook/pb_radio/docs/_radio_options.html.erb +9 -0
- data/app/pb_kits/playbook/pb_radio/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_radio/radio.rb +2 -4
- data/app/pb_kits/playbook/pb_section_separator/_section_separator.jsx +1 -1
- data/app/pb_kits/playbook/pb_select/_select.scss +1 -1
- data/app/pb_kits/playbook/pb_stat_change/_stat_change.jsx +2 -2
- data/app/pb_kits/playbook/pb_stat_value/_stat_value.jsx +3 -3
- data/app/pb_kits/playbook/pb_stat_value/docs/_stat_value_default.jsx +6 -1
- data/app/pb_kits/playbook/pb_table/_table.jsx +2 -2
- data/app/pb_kits/playbook/pb_text_input/_text_input.jsx +1 -1
- data/app/pb_kits/playbook/pb_text_input/_text_input.scss +17 -8
- data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +1 -1
- data/app/pb_kits/playbook/pb_time/_time.html.erb +23 -17
- data/app/pb_kits/playbook/pb_time/_time.jsx +22 -13
- 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_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 +3 -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 +38 -0
- data/app/pb_kits/playbook/pb_time/docs/_time_timezone.jsx +12 -14
- data/app/pb_kits/playbook/pb_time/docs/example.yml +6 -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_time_range_inline/_time_range_inline.jsx +1 -1
- data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.jsx +3 -3
- data/app/pb_kits/playbook/pb_timestamp/_timestamp.jsx +1 -1
- data/app/pb_kits/playbook/pb_title/_title.jsx +5 -1
- data/app/pb_kits/playbook/pb_title_count/_title_count.jsx +5 -1
- data/app/pb_kits/playbook/pb_title_detail/_title_detail.jsx +1 -1
- data/app/pb_kits/playbook/pb_toggle/_toggle.jsx +3 -3
- data/app/pb_kits/playbook/pb_toggle/_toggle.scss +41 -43
- data/app/pb_kits/playbook/pb_toggle/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_toggle/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_toggle/toggle.rb +2 -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/pb_user_badge/_user_badge.jsx +5 -2
- data/app/pb_kits/playbook/plugins/pb_chart.js +1 -1
- data/app/pb_kits/playbook/tokens/_typography.scss +3 -3
- data/lib/generators/kit/templates/kit_jsx.erb.tt +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +50 -8
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_read_only.jsx +0 -13
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_read_only.md +0 -1
- data/app/pb_kits/playbook/pb_toggle/docs/_toggle_size.html.erb +0 -11
- data/app/pb_kits/playbook/pb_toggle/docs/_toggle_size.jsx +0 -44
@@ -1,11 +1,15 @@
|
|
1
1
|
examples:
|
2
2
|
|
3
3
|
rails:
|
4
|
-
- time_default:
|
4
|
+
- time_default: Default
|
5
|
+
- time_sizes: Sizes
|
5
6
|
- time_timestamp: Timestamp Values
|
7
|
+
- time_timezone: Handling Timezones
|
8
|
+
- time_align: Alignment
|
6
9
|
|
7
10
|
react:
|
8
|
-
- time_default:
|
11
|
+
- time_default: Default
|
12
|
+
- time_sizes: Sizes
|
9
13
|
- time_timestamp: Timestamp Values
|
10
14
|
- time_timezone: Handling Timezones
|
11
15
|
- time_align: Alignment
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export { default as TimeDefault } from './_time_default.jsx'
|
2
|
+
export { default as TimeSizes } from './_time_sizes.jsx'
|
2
3
|
export { default as TimeTimestamp } from './_time_timestamp.jsx'
|
3
4
|
export { default as TimeAlign } from './_time_align.jsx'
|
4
5
|
export { default as TimeTimezone } from './_time_timezone.jsx'
|
@@ -9,12 +9,24 @@ module Playbook
|
|
9
9
|
|
10
10
|
prop :time, required: true
|
11
11
|
prop :size, type: Playbook::Props::Enum,
|
12
|
-
values: %w[
|
12
|
+
values: %w[xs sm md lg],
|
13
13
|
default: "sm"
|
14
|
+
prop :align, type: Playbook::Props::Enum,
|
15
|
+
values: %w[left center right],
|
16
|
+
default: "left"
|
14
17
|
prop :timezone, default: "America/New_York"
|
18
|
+
prop :show_icon, type: Playbook::Props::Boolean,
|
19
|
+
default: false
|
20
|
+
prop :show_timezone, type: Playbook::Props::Boolean,
|
21
|
+
default: true
|
15
22
|
|
16
23
|
def classname
|
17
|
-
|
24
|
+
# convert deprecated prop values
|
25
|
+
mutated_size = size
|
26
|
+
mutated_size = "sm" if mutated_size == "xs"
|
27
|
+
mutated_size = "md" if mutated_size == "lg"
|
28
|
+
|
29
|
+
generate_classname("pb_time_kit", align, mutated_size)
|
18
30
|
end
|
19
31
|
|
20
32
|
def format_time_string
|
@@ -78,7 +78,7 @@ const TimeRangeInline = (props: TimeRangeInlineProps) => {
|
|
78
78
|
|
79
79
|
return (
|
80
80
|
<div
|
81
|
-
className={classnames('pb_time_range_inline_kit_' + alignment,
|
81
|
+
className={classnames('pb_time_range_inline_kit_' + alignment, globalProps(props), className)}
|
82
82
|
>
|
83
83
|
<div className="pb_time_range_inline_wrapper">
|
84
84
|
<If condition={size == 'xs'}>
|
@@ -26,11 +26,11 @@ type TimeStackedProps = {
|
|
26
26
|
const TimeStacked = (props: TimeStackedProps) => {
|
27
27
|
const { className, dark = false, date, tag = 'body' } = props
|
28
28
|
const classes = classnames(
|
29
|
-
className,
|
30
29
|
buildCss('pb_time_stacked_kit', {
|
31
|
-
dark
|
30
|
+
dark,
|
32
31
|
}),
|
33
|
-
globalProps(props)
|
32
|
+
globalProps(props),
|
33
|
+
className
|
34
34
|
)
|
35
35
|
|
36
36
|
const tagClasses = classnames(buildCss('pb_time_stacked_kit', tag))
|
@@ -32,7 +32,11 @@ const Title = (props: TitleProps) => {
|
|
32
32
|
|
33
33
|
const ariaProps = buildAriaProps(aria)
|
34
34
|
const dataProps = buildDataProps(data)
|
35
|
-
const classes = classnames(
|
35
|
+
const classes = classnames(
|
36
|
+
buildCss('pb_title_kit', size, variant),
|
37
|
+
globalProps(props),
|
38
|
+
className
|
39
|
+
)
|
36
40
|
const Tag = `${tag}`
|
37
41
|
|
38
42
|
return (
|
@@ -34,7 +34,11 @@ const TitleCount = (props: TitleCountProps) => {
|
|
34
34
|
const ariaProps = buildAriaProps(aria)
|
35
35
|
const dataProps = buildDataProps(data)
|
36
36
|
|
37
|
-
const css = classnames(
|
37
|
+
const css = classnames(
|
38
|
+
buildCss('pb_title_count_kit', align, size),
|
39
|
+
globalProps(props),
|
40
|
+
className
|
41
|
+
)
|
38
42
|
|
39
43
|
const formatCount = count.toLocaleString()
|
40
44
|
|
@@ -34,7 +34,7 @@ const Toggle = ({
|
|
34
34
|
id,
|
35
35
|
name,
|
36
36
|
onChange = () => {},
|
37
|
-
size = '
|
37
|
+
size = 'sm',
|
38
38
|
value,
|
39
39
|
...props
|
40
40
|
}: Props) => {
|
@@ -47,13 +47,13 @@ const Toggle = ({
|
|
47
47
|
on: checked,
|
48
48
|
off: !checked,
|
49
49
|
}
|
50
|
-
)
|
50
|
+
))
|
51
51
|
|
52
52
|
return (
|
53
53
|
<div
|
54
54
|
{...ariaProps}
|
55
55
|
{...dataProps}
|
56
|
-
className={classnames(css, globalProps(props))}
|
56
|
+
className={classnames(css, globalProps(props), className)}
|
57
57
|
id={id}
|
58
58
|
>
|
59
59
|
<label className="pb_toggle_wrapper">
|
@@ -2,55 +2,53 @@
|
|
2
2
|
|
3
3
|
$color_checkbox_success: $data_1;
|
4
4
|
$color_checkbox_default: $border_light;
|
5
|
-
$transition: .2s
|
6
|
-
$toggle_sizes: (
|
7
|
-
"sm": 50px,
|
8
|
-
"md": 60px,
|
9
|
-
);
|
5
|
+
$transition: .2s ease-in-out;
|
10
6
|
|
11
7
|
[class^=pb_toggle_kit] {
|
12
8
|
position: relative;
|
9
|
+
$width: 44px;
|
10
|
+
$height: $width/2;
|
11
|
+
$border_success: 3px solid $color_checkbox_success;
|
12
|
+
$border_default: 3px solid $color_checkbox_default;
|
13
13
|
|
14
|
-
@each $name, $size in $toggle_sizes {
|
15
|
-
&[class*=_#{$name}] {
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
}
|
15
|
+
.pb_toggle_wrapper {
|
16
|
+
.pb_toggle_control {
|
17
|
+
cursor: pointer;
|
18
|
+
transition: $transition;
|
19
|
+
width: $width;
|
20
|
+
height: $height;
|
21
|
+
display: block;
|
22
|
+
border-radius: $height;
|
23
|
+
border: $border_default;
|
24
|
+
position: relative;
|
25
|
+
box-sizing: content-box;
|
26
|
+
&:after {
|
27
|
+
transition: $transition;
|
28
|
+
content: "";
|
29
|
+
width: $width/2 - 4px;
|
30
|
+
height: $height - 4px;
|
31
|
+
background-color: $color_checkbox_default;
|
32
|
+
border-radius: 50%;
|
33
|
+
position: absolute;
|
34
|
+
top: 2px;
|
35
|
+
left: 2px;
|
36
|
+
}
|
37
|
+
&:hover {
|
38
|
+
border: $border_success;
|
39
|
+
&:after{
|
40
|
+
background-color: $color_checkbox_success;
|
44
41
|
}
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
42
|
+
}
|
43
|
+
}
|
44
|
+
input {
|
45
|
+
display: none;
|
46
|
+
&:checked + .pb_toggle_control {
|
47
|
+
border: $border_success;
|
48
|
+
background-color: $color_checkbox_success;
|
49
|
+
&:after{
|
50
|
+
left: $width/2 + 2px;
|
51
|
+
background-color: $white;
|
54
52
|
}
|
55
53
|
}
|
56
54
|
}
|
@@ -2,14 +2,12 @@ examples:
|
|
2
2
|
|
3
3
|
rails:
|
4
4
|
- toggle_default: Default State
|
5
|
-
- toggle_size: Sizes
|
6
5
|
- toggle_name: Name and Value
|
7
6
|
- toggle_custom: Custom checkbox input
|
8
7
|
- toggle_custom_radio: Custom radio inputs
|
9
8
|
|
10
9
|
react:
|
11
10
|
- toggle_default: Default State
|
12
|
-
- toggle_size: Sizes
|
13
11
|
- toggle_name: Name and Value
|
14
12
|
- toggle_custom: Custom checkbox input
|
15
13
|
- toggle_custom_radio: Custom radio inputs
|
@@ -1,5 +1,4 @@
|
|
1
1
|
export { default as ToggleDefault } from './_toggle_default'
|
2
|
-
export { default as ToggleSize } from './_toggle_size'
|
3
2
|
export { default as ToggleCustom } from './_toggle_custom'
|
4
3
|
export { default as ToggleName } from './_toggle_name'
|
5
4
|
export { default as ToggleCustomRadio } from './_toggle_custom_radio'
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React from 'react'
|
4
|
+
import Select from 'react-select'
|
5
|
+
import AsyncSelect from 'react-select/async'
|
6
|
+
|
7
|
+
import Control from './components/Control'
|
8
|
+
import IndicatorsContainer from './components/IndicatorsContainer'
|
9
|
+
import MenuList from './components/MenuList'
|
10
|
+
import MultiValue from './components/MultiValue'
|
11
|
+
import Option from './components/Option'
|
12
|
+
import Placeholder from './components/Placeholder'
|
13
|
+
import ValueContainer from './components/ValueContainer'
|
14
|
+
|
15
|
+
/**
|
16
|
+
* @typedef {object} Props
|
17
|
+
* @prop {boolean} async - whether Typeahead should fetch data from
|
18
|
+
* a remote location to populate the options
|
19
|
+
* @prop {string} label - the text for the optional typeahead input label
|
20
|
+
*/
|
21
|
+
|
22
|
+
type Props = {
|
23
|
+
async?: boolean,
|
24
|
+
label?: string,
|
25
|
+
}
|
26
|
+
|
27
|
+
/**
|
28
|
+
* @constant {React.ReactComponent} Typeahead
|
29
|
+
* @param {Props} props - props as described at https://react-select.com/props
|
30
|
+
*/
|
31
|
+
|
32
|
+
const Typeahead = (props: Props) => {
|
33
|
+
const selectProps = {
|
34
|
+
cacheOptions: true,
|
35
|
+
defaultOptions: true,
|
36
|
+
components: {
|
37
|
+
Control,
|
38
|
+
IndicatorsContainer,
|
39
|
+
IndicatorSeparator: null,
|
40
|
+
MenuList,
|
41
|
+
MultiValue,
|
42
|
+
Option,
|
43
|
+
Placeholder,
|
44
|
+
ValueContainer,
|
45
|
+
},
|
46
|
+
isClearable: true,
|
47
|
+
isSearchable: true,
|
48
|
+
...props,
|
49
|
+
}
|
50
|
+
|
51
|
+
const Tag = props.async ? AsyncSelect : Select
|
52
|
+
|
53
|
+
return (
|
54
|
+
<div className="pb_typeahead_kit react-select">
|
55
|
+
<Tag {...selectProps} />
|
56
|
+
</div>
|
57
|
+
)
|
58
|
+
}
|
59
|
+
|
60
|
+
export default Typeahead
|
@@ -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
|