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.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -6
  3. data/app/pb_kits/playbook/_playbook.scss +1 -0
  4. data/app/pb_kits/playbook/data/menu.yml +1 -1
  5. data/app/pb_kits/playbook/index.js +3 -0
  6. data/app/pb_kits/playbook/packs/examples.js +6 -0
  7. data/app/pb_kits/playbook/packs/site_styles/docs/_kit_doc.scss +22 -6
  8. data/app/pb_kits/playbook/pb_avatar/_avatar.jsx +5 -1
  9. data/app/pb_kits/playbook/pb_background/_background.html.erb +14 -0
  10. data/app/pb_kits/playbook/pb_background/_background.jsx +64 -0
  11. data/app/pb_kits/playbook/pb_background/_background.scss +15 -0
  12. data/app/pb_kits/playbook/pb_background/background.rb +36 -0
  13. data/app/pb_kits/playbook/pb_background/docs/_background_default.html.erb +41 -0
  14. data/app/pb_kits/playbook/pb_background/docs/_background_default.jsx +75 -0
  15. data/app/pb_kits/playbook/pb_background/docs/example.yml +8 -0
  16. data/app/pb_kits/playbook/pb_background/docs/index.js +1 -0
  17. data/app/pb_kits/playbook/pb_badge/_badge.jsx +4 -2
  18. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +1 -1
  19. data/app/pb_kits/playbook/pb_button/_button.jsx +5 -1
  20. data/app/pb_kits/playbook/pb_button_toolbar/_button_toolbar.jsx +5 -1
  21. data/app/pb_kits/playbook/pb_caption/_caption.jsx +2 -2
  22. data/app/pb_kits/playbook/pb_checkbox/_checkbox.jsx +5 -2
  23. data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +3 -1
  24. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_options.html.erb +10 -0
  25. data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +1 -0
  26. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.html.erb +1 -1
  27. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +130 -0
  28. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.scss +1 -1
  29. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_block.jsx +39 -0
  30. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_colors.jsx +29 -0
  31. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_default.jsx +28 -0
  32. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_inner_sizes.jsx +117 -0
  33. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_live_data.jsx +53 -0
  34. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_rounded.jsx +30 -0
  35. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_labels.jsx +45 -0
  36. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_legend_kit.jsx +30 -0
  37. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_with_title.jsx +45 -0
  38. data/app/pb_kits/playbook/pb_circle_chart/docs/example.yml +11 -0
  39. data/app/pb_kits/playbook/pb_circle_chart/docs/index.js +9 -0
  40. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.jsx +5 -1
  41. data/app/pb_kits/playbook/pb_contact/_contact.jsx +5 -1
  42. data/app/pb_kits/playbook/pb_currency/_currency.jsx +5 -1
  43. data/app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx +5 -1
  44. data/app/pb_kits/playbook/pb_date/date.rb +2 -1
  45. data/app/pb_kits/playbook/pb_date/docs/_date_default.html.erb +8 -1
  46. data/app/pb_kits/playbook/pb_date/docs/_date_timezone.html.erb +51 -0
  47. data/app/pb_kits/playbook/pb_date/docs/_date_timezone.md +6 -0
  48. data/app/pb_kits/playbook/pb_date/docs/_description.md +2 -0
  49. data/app/pb_kits/playbook/pb_date/docs/example.yml +1 -0
  50. data/app/pb_kits/playbook/pb_date_picker/_date_picker.jsx +7 -4
  51. data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +0 -4
  52. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +3 -3
  53. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.js +8 -10
  54. data/app/pb_kits/playbook/pb_date_picker/docs/{_date_picker_read_only.html.erb → _date_picker_allow_input.html.erb} +1 -1
  55. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_allow_input.jsx +13 -0
  56. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_allow_input.md +1 -0
  57. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx +34 -0
  58. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.md +3 -0
  59. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +3 -2
  60. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +2 -1
  61. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_calendar_input_icon.scss +1 -0
  62. data/app/pb_kits/playbook/pb_date_range_stacked/_date_range_stacked.jsx +5 -1
  63. data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.jsx +2 -2
  64. data/app/pb_kits/playbook/pb_date_year_stacked/_date_year_stacked.jsx +5 -1
  65. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx +2 -2
  66. data/app/pb_kits/playbook/pb_flex/_flex.jsx +2 -2
  67. data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +1 -1
  68. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +6 -1
  69. data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +3 -2
  70. data/app/pb_kits/playbook/pb_gauge/_gauge.jsx +1 -1
  71. data/app/pb_kits/playbook/pb_highlight/_highlight.jsx +1 -1
  72. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.jsx +2 -2
  73. data/app/pb_kits/playbook/pb_icon/_icon.jsx +2 -2
  74. data/app/pb_kits/playbook/pb_icon_value/_icon_value.jsx +5 -1
  75. data/app/pb_kits/playbook/pb_image/_image.jsx +5 -1
  76. data/app/pb_kits/playbook/pb_label_pill/_label_pill.jsx +5 -1
  77. data/app/pb_kits/playbook/pb_layout/_layout.jsx +4 -4
  78. data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +1 -1
  79. data/app/pb_kits/playbook/pb_list/_list.jsx +3 -2
  80. data/app/pb_kits/playbook/pb_list/_list_item.jsx +3 -2
  81. data/app/pb_kits/playbook/pb_logistic/_logistic.jsx +5 -1
  82. data/app/pb_kits/playbook/pb_message/_message.jsx +5 -1
  83. data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx +5 -2
  84. data/app/pb_kits/playbook/pb_nav/_nav.jsx +2 -2
  85. data/app/pb_kits/playbook/pb_person/_person.jsx +5 -1
  86. data/app/pb_kits/playbook/pb_person_contact/_person_contact.jsx +5 -1
  87. data/app/pb_kits/playbook/pb_popover/_popover.jsx +5 -1
  88. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.jsx +4 -4
  89. data/app/pb_kits/playbook/pb_progress_step/_progress_step.jsx +1 -1
  90. data/app/pb_kits/playbook/pb_radio/_radio.html.erb +1 -1
  91. data/app/pb_kits/playbook/pb_radio/docs/_radio_options.html.erb +9 -0
  92. data/app/pb_kits/playbook/pb_radio/docs/example.yml +1 -0
  93. data/app/pb_kits/playbook/pb_radio/radio.rb +2 -4
  94. data/app/pb_kits/playbook/pb_section_separator/_section_separator.jsx +1 -1
  95. data/app/pb_kits/playbook/pb_select/_select.scss +1 -1
  96. data/app/pb_kits/playbook/pb_stat_change/_stat_change.jsx +2 -2
  97. data/app/pb_kits/playbook/pb_stat_value/_stat_value.jsx +3 -3
  98. data/app/pb_kits/playbook/pb_stat_value/docs/_stat_value_default.jsx +6 -1
  99. data/app/pb_kits/playbook/pb_table/_table.jsx +2 -2
  100. data/app/pb_kits/playbook/pb_text_input/_text_input.jsx +1 -1
  101. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +17 -8
  102. data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +1 -1
  103. data/app/pb_kits/playbook/pb_time/_time.html.erb +23 -17
  104. data/app/pb_kits/playbook/pb_time/_time.jsx +22 -13
  105. data/app/pb_kits/playbook/pb_time/_time.scss +16 -8
  106. data/app/pb_kits/playbook/pb_time/docs/_time_align.html.erb +18 -0
  107. data/app/pb_kits/playbook/pb_time/docs/_time_align.jsx +3 -3
  108. data/app/pb_kits/playbook/pb_time/docs/_time_default.html.erb +47 -3
  109. data/app/pb_kits/playbook/pb_time/docs/_time_default.jsx +33 -4
  110. data/app/pb_kits/playbook/pb_time/docs/_time_sizes.html.erb +11 -0
  111. data/app/pb_kits/playbook/pb_time/docs/_time_sizes.jsx +19 -0
  112. data/app/pb_kits/playbook/pb_time/docs/_time_timestamp.html.erb +3 -1
  113. data/app/pb_kits/playbook/pb_time/docs/_time_timestamp.jsx +0 -7
  114. data/app/pb_kits/playbook/pb_time/docs/_time_timezone.html.erb +38 -0
  115. data/app/pb_kits/playbook/pb_time/docs/_time_timezone.jsx +12 -14
  116. data/app/pb_kits/playbook/pb_time/docs/example.yml +6 -2
  117. data/app/pb_kits/playbook/pb_time/docs/index.js +1 -0
  118. data/app/pb_kits/playbook/pb_time/time.rb +14 -2
  119. data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.jsx +1 -1
  120. data/app/pb_kits/playbook/pb_time_stacked/_time_stacked.jsx +3 -3
  121. data/app/pb_kits/playbook/pb_timestamp/_timestamp.jsx +1 -1
  122. data/app/pb_kits/playbook/pb_title/_title.jsx +5 -1
  123. data/app/pb_kits/playbook/pb_title_count/_title_count.jsx +5 -1
  124. data/app/pb_kits/playbook/pb_title_detail/_title_detail.jsx +1 -1
  125. data/app/pb_kits/playbook/pb_toggle/_toggle.jsx +3 -3
  126. data/app/pb_kits/playbook/pb_toggle/_toggle.scss +41 -43
  127. data/app/pb_kits/playbook/pb_toggle/docs/example.yml +0 -2
  128. data/app/pb_kits/playbook/pb_toggle/docs/index.js +0 -1
  129. data/app/pb_kits/playbook/pb_toggle/toggle.rb +2 -2
  130. data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +60 -0
  131. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +20 -3
  132. data/app/pb_kits/playbook/pb_typeahead/components/Control.jsx +30 -0
  133. data/app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.jsx +13 -0
  134. data/app/pb_kits/playbook/pb_typeahead/components/MenuList.jsx +12 -0
  135. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.jsx +51 -0
  136. data/app/pb_kits/playbook/pb_typeahead/components/Option.jsx +34 -0
  137. data/app/pb_kits/playbook/pb_typeahead/components/Placeholder.jsx +13 -0
  138. data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.jsx +13 -0
  139. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default.jsx +22 -0
  140. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills.jsx +29 -0
  141. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx +84 -0
  142. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_summary.jsx +45 -0
  143. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_users.jsx +101 -0
  144. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_summary.jsx +27 -0
  145. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +8 -2
  146. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +4 -0
  147. data/app/pb_kits/playbook/pb_user_badge/_user_badge.jsx +5 -2
  148. data/app/pb_kits/playbook/plugins/pb_chart.js +1 -1
  149. data/app/pb_kits/playbook/tokens/_typography.scss +3 -3
  150. data/lib/generators/kit/templates/kit_jsx.erb.tt +1 -1
  151. data/lib/playbook/version.rb +1 -1
  152. metadata +50 -8
  153. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_read_only.jsx +0 -13
  154. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_read_only.md +0 -1
  155. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_size.html.erb +0 -11
  156. 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: Sizes
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: Sizes
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[lg sm xs],
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
- generate_classname("pb_time_kit", size)
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, className, globalProps(props))}
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: 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))
@@ -24,7 +24,7 @@ const Timestamp = (props: TimestampProps) => {
24
24
  return (
25
25
  <div
26
26
  {...dataProps}
27
- className={classnames(className, pbCss, globalProps(props))}
27
+ className={classnames(pbCss, globalProps(props), className)}
28
28
  id={id}
29
29
  >
30
30
  <Caption
@@ -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(buildCss('pb_title_kit', size, variant), className, globalProps(props))
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(buildCss('pb_title_count_kit', align, size), className, globalProps(props))
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
 
@@ -25,7 +25,7 @@ const TitleDetail = (props: TitleDetailProps) => {
25
25
  return (
26
26
  <div
27
27
  {...dataProps}
28
- className={classnames(className, pbCss, globalProps(props))}
28
+ className={classnames(pbCss, globalProps(props), className)}
29
29
  id={id}
30
30
  >
31
31
  <Title
@@ -34,7 +34,7 @@ const Toggle = ({
34
34
  id,
35
35
  name,
36
36
  onChange = () => {},
37
- size = 'md',
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
- ), className)
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 cubic-bezier(0.95, 0.05, 0.795, 0.035);
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
- $width: $size;
18
- $height: $width/2;
19
-
20
- .pb_toggle_wrapper {
21
- .pb_toggle_control {
22
- cursor: pointer;
23
- transition: $transition;
24
- width: $width;
25
- height: $height;
26
- display: block;
27
- border-radius: $height;
28
- border: 3px solid $color_checkbox_default;
29
- background-color: $color_checkbox_default;
30
- position: relative;
31
- box-sizing: content-box;
32
- &:after {
33
- transition: $transition;
34
- content: "";
35
- width: $width/2;
36
- height: $height;
37
- display: block;
38
- background-color: $white;
39
- border-radius: 50%;
40
- position: absolute;
41
- top: 0;
42
- left: 0;
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
- input {
46
- display: none;
47
- &:checked + .pb_toggle_control {
48
- border-color: $color_checkbox_success;
49
- background-color: $color_checkbox_success;
50
- &:after{
51
- left: $width/2;
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'
@@ -16,7 +16,7 @@ module Playbook
16
16
  prop :name
17
17
  prop :size, type: Playbook::Props::Enum,
18
18
  values: %w[sm md],
19
- default: "md"
19
+ default: "sm"
20
20
  prop :value
21
21
 
22
22
  def classname
@@ -34,4 +34,4 @@ module Playbook
34
34
  end
35
35
  end
36
36
  end
37
- end
37
+ end
@@ -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 > input:first-child {
21
- padding-right: $space_xl;
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,12 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import { components } from 'react-select'
5
+
6
+ const MenuList = (props: any) => (
7
+ <components.MenuList {...props}>
8
+ {props.children}
9
+ </components.MenuList>
10
+ )
11
+
12
+ export default MenuList