playbook_ui 14.3.2 → 14.4.0.pre.alpha.PBNTR550typeaheadformpilltruncate3895

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/SortIconButton.tsx +23 -4
  3. data/app/pb_kits/playbook/pb_contact/_contact.tsx +17 -5
  4. data/app/pb_kits/playbook/pb_contact/contact.html.erb +14 -6
  5. data/app/pb_kits/playbook/pb_contact/contact.rb +4 -0
  6. data/app/pb_kits/playbook/pb_contact/contact.test.js +1 -1
  7. data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +4 -3
  8. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +1 -1
  9. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +4 -0
  10. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +6 -3
  11. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_inline.html.erb +1 -1
  12. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_flatpickr_styles.scss +2 -3
  13. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_header_styles.scss +6 -2
  14. data/app/pb_kits/playbook/pb_dialog/_dialog.scss +2 -0
  15. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +1 -1
  16. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +245 -23
  17. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +10 -2
  18. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_colors.html.erb +117 -0
  19. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_colors.jsx +227 -0
  20. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_colors.md +1 -0
  21. data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +2 -0
  22. data/app/pb_kits/playbook/pb_form_pill/docs/index.js +1 -0
  23. data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +1 -1
  24. data/app/pb_kits/playbook/pb_icon/icon.rb +1 -1
  25. data/app/pb_kits/playbook/pb_map/_map_controls.tsx +7 -1
  26. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +20 -5
  27. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color.html.erb +72 -0
  28. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color.jsx +91 -0
  29. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color_rails.md +1 -0
  30. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_color_react.md +1 -0
  31. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +2 -0
  32. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -0
  33. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +4 -0
  34. data/app/pb_kits/playbook/pb_multiple_users_stacked/_multiple_users_stacked.scss +97 -21
  35. data/app/pb_kits/playbook/pb_multiple_users_stacked/_multiple_users_stacked.test.js +166 -0
  36. data/app/pb_kits/playbook/pb_multiple_users_stacked/_multiple_users_stacked.tsx +45 -6
  37. data/app/pb_kits/playbook/pb_multiple_users_stacked/docs/_multiple_users_stacked_bubble.html.erb +73 -0
  38. data/app/pb_kits/playbook/pb_multiple_users_stacked/docs/_multiple_users_stacked_bubble.jsx +86 -0
  39. data/app/pb_kits/playbook/pb_multiple_users_stacked/docs/example.yml +2 -0
  40. data/app/pb_kits/playbook/pb_multiple_users_stacked/docs/index.js +1 -0
  41. data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.html.erb +6 -2
  42. data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.rb +21 -1
  43. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change.jsx +12 -1
  44. data/app/pb_kits/playbook/pb_pagination/docs/_pagination_page_change_react.md +3 -1
  45. data/app/pb_kits/playbook/pb_passphrase/_passphrase.tsx +10 -2
  46. data/app/pb_kits/playbook/pb_radio/_radio.tsx +92 -33
  47. data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.html.erb +48 -0
  48. data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.jsx +59 -0
  49. data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.md +1 -0
  50. data/app/pb_kits/playbook/pb_radio/docs/example.yml +2 -0
  51. data/app/pb_kits/playbook/pb_radio/docs/index.js +1 -0
  52. data/app/pb_kits/playbook/pb_radio/index.js +17 -0
  53. data/app/pb_kits/playbook/pb_radio/radio.html.erb +35 -13
  54. data/app/pb_kits/playbook/pb_radio/radio.rb +3 -1
  55. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +12 -5
  56. data/app/pb_kits/playbook/pb_select/_select.tsx +5 -2
  57. data/app/pb_kits/playbook/pb_select/select.html.erb +1 -1
  58. data/app/pb_kits/playbook/pb_select/select.rb +4 -0
  59. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +0 -1
  60. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +0 -1
  61. data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +30 -0
  62. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +11 -1
  63. data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +6 -5
  64. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +28 -18
  65. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_margin_bottom.html.erb +88 -0
  66. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_margin_bottom.jsx +60 -0
  67. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_color.html.erb +31 -0
  68. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_color.jsx +26 -0
  69. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_color_rails.md +1 -0
  70. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_color_react.md +1 -0
  71. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +4 -0
  72. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +2 -0
  73. data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +2 -1
  74. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +10 -1
  75. data/app/pb_kits/playbook/tokens/_colors.scss +2 -0
  76. data/app/pb_kits/playbook/utilities/icons/allicons.tsx +123 -0
  77. data/app/pb_kits/playbook/utilities/icons/angle-down.svg +3 -0
  78. data/app/pb_kits/playbook/utilities/icons/envelope.svg +3 -0
  79. data/dist/chunks/_typeahead-Ctc4yCCN.js +22 -0
  80. data/dist/chunks/_weekday_stacked-B4Xs5p_U.js +45 -0
  81. data/dist/chunks/lib-CEpcaI8y.js +29 -0
  82. data/dist/chunks/{pb_form_validation-u2wnZ3oe.js → pb_form_validation-D9zkwt2b.js} +1 -1
  83. data/dist/chunks/vendor.js +1 -1
  84. data/dist/playbook-doc.js +1 -1
  85. data/dist/playbook-rails-react-bindings.js +1 -1
  86. data/dist/playbook-rails.js +1 -1
  87. data/dist/playbook.css +1 -1
  88. data/lib/playbook/version.rb +2 -2
  89. metadata +30 -9
  90. data/dist/chunks/_typeahead-DbAz2Okr.js +0 -22
  91. data/dist/chunks/_weekday_stacked-CZ5S17_d.js +0 -45
  92. data/dist/chunks/lib-D9uVVKnh.js +0 -16
@@ -1,5 +1,7 @@
1
1
  import React, { useState } from 'react'
2
2
 
3
+ import { getAllIcons } from "../../utilities/icons/allicons"
4
+
3
5
  import Flex from '../../pb_flex/_flex'
4
6
  import PbReactPopover from '../../pb_popover/_popover'
5
7
  import Button from '../../pb_button/_button'
@@ -65,6 +67,7 @@ const toolbarDropdownItems = [
65
67
  },
66
68
  ]
67
69
 
70
+ const angleDown = getAllIcons()["angleDown"].icon as unknown as { [key: string]: SVGElement }
68
71
 
69
72
  const handleTogglePopover = () => {
70
73
  setShowPopover(!showPopover)
@@ -92,8 +95,10 @@ for (const { text, isActive, icon } of toolbarDropdownItems) {
92
95
  <Flex className={showPopover ? "fa-flip-vertical" : ""}
93
96
  display="inline_flex"
94
97
  >
95
- <Icon fixedWidth
96
- icon="angle-down"
98
+ <Icon
99
+ className="svg-inline--fa"
100
+ customIcon={angleDown}
101
+ fixedWidth
97
102
  margin-left="xs"
98
103
  />
99
104
  </Flex>
@@ -125,8 +130,10 @@ const popoverReference = (
125
130
  <Flex className={showPopover ? "fa-flip-vertical" : ""}
126
131
  display="inline_flex"
127
132
  >
128
- <Icon fixedWidth
129
- icon="angle-down"
133
+ <Icon
134
+ className="svg-inline--fa"
135
+ customIcon={angleDown}
136
+ fixedWidth
130
137
  margin-left="xs"
131
138
  />
132
139
  </Flex>
@@ -169,4 +176,4 @@ const popoverReference = (
169
176
  )
170
177
  }
171
178
 
172
- export default ToolbarDropdown
179
+ export default ToolbarDropdown
@@ -4,6 +4,7 @@ import classnames from 'classnames'
4
4
  import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
5
5
  import { globalProps, GlobalProps, domSafeProps } from '../utilities/globalProps'
6
6
  import type { InputCallback } from '../types'
7
+ import { getAllIcons } from "../utilities/icons/allicons"
7
8
 
8
9
  import Body from '../pb_body/_body'
9
10
  import Caption from '../pb_caption/_caption'
@@ -90,6 +91,8 @@ const Select = ({
90
91
  compactClass
91
92
  );
92
93
 
94
+ const angleDown = getAllIcons()["angleDown"].icon as unknown as { [key: string]: SVGElement }
95
+
93
96
  const selectWrapperClass = classnames(buildCss('pb_select_kit_wrapper'), { error }, className)
94
97
  const selectBody =(() =>{
95
98
  if (children) return children
@@ -134,9 +137,9 @@ const Select = ({
134
137
  {selectBody}
135
138
  { multiple !== true ?
136
139
  <Icon
137
- className="pb_select_kit_caret"
140
+ className="pb_select_kit_caret svg-inline--fa"
141
+ customIcon={angleDown}
138
142
  fixedWidth
139
- icon="angle-down"
140
143
  />
141
144
  :
142
145
  null
@@ -26,7 +26,7 @@
26
26
  <%= pb_rails("body", props: { status: "negative", text: object.error }) %>
27
27
  <% end %>
28
28
  <% if object.multiple != true %>
29
- <%= pb_rails("icon", props: { icon: "angle-down", fixed_width: true, classname: "pb_select_kit_caret"}) %>
29
+ <%= pb_rails("icon", props: { custom_icon: Playbook::Engine::root.join(angle_down_path), fixed_width: true, classname: "pb_select_kit_caret"}) %>
30
30
  <% end %>
31
31
  </label>
32
32
  <% end %>
@@ -84,6 +84,10 @@ module Playbook
84
84
  end
85
85
  end
86
86
 
87
+ def angle_down_path
88
+ "app/pb_kits/playbook/utilities/icons/angle-down.svg"
89
+ end
90
+
87
91
  private
88
92
 
89
93
  def error_class
@@ -45,7 +45,6 @@
45
45
  }
46
46
  }
47
47
  .text_input_wrapper {
48
- margin-bottom: 1rem;
49
48
  input::placeholder,
50
49
  .text_input .placeholder {
51
50
  @include pb_body_light_dark;
@@ -68,7 +68,6 @@
68
68
  opacity: 0;
69
69
  }
70
70
  [class^=pb_list_kit] {
71
- margin-top: -$space-sm;
72
71
  li {
73
72
  transition: background-color .25s ease-in-out;
74
73
  }
@@ -107,4 +107,34 @@ test('should pass className prop', () => {
107
107
 
108
108
  const kit = screen.getByTestId('typeahead-test')
109
109
  expect(kit).toHaveClass(className)
110
+ })
111
+
112
+ test('typeahead textinput has mb_sm class by default', () => {
113
+ render(
114
+ <Typeahead
115
+ data={{ testid: 'default-mb-test' }}
116
+ options={options}
117
+ />
118
+ )
119
+
120
+ const kit = screen.getByTestId('default-mb-test')
121
+ expect(kit).toHaveClass("pb_typeahead_kit mb_sm")
122
+ const textInput = kit.querySelector(".pb_text_input_kit")
123
+ expect(textInput).toHaveClass("mb_none")
124
+ })
125
+
126
+ test('typeahead with colored pills', () => {
127
+ render(
128
+ <Typeahead
129
+ data={{ testid: 'pills-color-test' }}
130
+ defaultValue={[options[0]]}
131
+ isMulti
132
+ options={options}
133
+ pillColor="neutral"
134
+ />
135
+ )
136
+
137
+ const kit = screen.getByTestId('pills-color-test')
138
+ const pill = kit.querySelector(".pb_form_pill_kit_neutral")
139
+ expect(pill).toBeInTheDocument()
110
140
  })
@@ -45,12 +45,15 @@ type TypeaheadProps = {
45
45
  getOptionLabel?: string | (() => any),
46
46
  getOptionValue?: string | (() => any),
47
47
  name?: string,
48
+ marginBottom?: "none" | "xxs" | "xs" | "sm" | "md" | "lg" | "xl",
49
+ 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",
48
50
  } & GlobalProps
49
51
 
50
52
  export type SelectValueType = {
51
53
  label: string,
52
54
  value: string,
53
55
  imageUrl?: string,
56
+ pillColor?: string,
54
57
  }
55
58
 
56
59
  type TagOnChangeValues = {
@@ -76,6 +79,8 @@ const Typeahead = ({
76
79
  htmlOptions = {},
77
80
  id,
78
81
  loadOptions = noop,
82
+ marginBottom = "sm",
83
+ pillColor,
79
84
  ...props
80
85
  }: TypeaheadProps) => {
81
86
  const selectProps = {
@@ -105,6 +110,7 @@ const Typeahead = ({
105
110
  onCreateOption: null as null,
106
111
  plusIcon: false,
107
112
  onMultiValueClick: (_option: SelectValueType): any => undefined,
113
+ pillColor: pillColor,
108
114
  ...props,
109
115
  }
110
116
 
@@ -130,11 +136,15 @@ const Typeahead = ({
130
136
  }
131
137
  }
132
138
 
139
+ const filteredProps: TypeaheadProps = {...props}
140
+ delete filteredProps.truncate
141
+
133
142
  const dataProps = buildDataProps(data)
134
143
  const htmlProps = buildHtmlProps(htmlOptions)
135
144
  const classes = classnames(
136
145
  'pb_typeahead_kit react-select',
137
- globalProps(props),
146
+ `mb_${marginBottom}`,
147
+ globalProps(filteredProps),
138
148
  className
139
149
  )
140
150
 
@@ -11,14 +11,15 @@ type Props = {
11
11
  const TypeaheadControl = (props: Props) => (
12
12
  <div className="pb_typeahead_wrapper">
13
13
  <TextInput
14
- dark={props.selectProps.dark}
15
- error={props.selectProps.error}
16
- label={props.selectProps.label}
14
+ dark={props.selectProps.dark}
15
+ error={props.selectProps.error}
16
+ label={props.selectProps.label}
17
+ marginBottom="none"
17
18
  >
18
19
  <Flex>
19
20
  <components.Control
20
- className="text_input"
21
- {...props}
21
+ className="text_input"
22
+ {...props}
22
23
  />
23
24
  </Flex>
24
25
  </TextInput>
@@ -8,6 +8,7 @@ import { SelectValueType } from '../_typeahead'
8
8
  type Props = {
9
9
  data: SelectValueType,
10
10
  multiValueTemplate: any,
11
+ 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",
11
12
  removeProps: any,
12
13
  selectProps: any,
13
14
  }
@@ -15,48 +16,57 @@ type Props = {
15
16
  const MultiValue = (props: Props) => {
16
17
  const { removeProps } = props
17
18
  const { imageUrl, label } = props.data
18
- const { multiKit } = props.selectProps
19
+ const { dark, multiKit, pillColor, truncate } = props.selectProps
19
20
 
20
21
  const formPillProps = {
21
22
  marginRight: 'xs',
22
23
  name: label,
23
24
  avatarUrl: '',
25
+ dark,
24
26
  }
25
27
 
26
28
  if (typeof imageUrl === 'string') formPillProps.avatarUrl = imageUrl
27
29
 
28
30
  return (
29
31
  <components.MultiValueContainer
30
- className="text_input_multivalue_container"
31
- {...props}
32
+ className="text_input_multivalue_container"
33
+ {...props}
32
34
  >
33
35
  {multiKit === 'badge' &&
34
36
  <Badge
35
- closeProps={removeProps}
36
- removeIcon
37
- text={label}
38
- variant="primary"
37
+ closeProps={removeProps}
38
+ removeIcon
39
+ text={label}
40
+ variant="primary"
39
41
  />
40
42
  }
41
43
 
42
44
  {multiKit !== 'badge' && imageUrl &&
43
45
  <FormPill
44
- avatarUrl={imageUrl}
45
- closeProps={removeProps}
46
- marginRight="xs"
47
- name={label}
48
- size={multiKit === 'smallPill' ? 'small' : ''}
49
- text=''
46
+ avatarUrl={imageUrl}
47
+ closeProps={removeProps}
48
+ color={pillColor}
49
+ dark={dark}
50
+ marginRight="xs"
51
+ name={label}
52
+ size={multiKit === 'smallPill' ? 'small' : ''}
53
+ text=''
54
+ truncate={truncate}
55
+ {...props}
50
56
  />
51
57
  }
52
58
 
53
59
  {multiKit !== 'badge' && !imageUrl &&
54
60
  <FormPill
55
- closeProps={removeProps}
56
- marginRight="xs"
57
- name=''
58
- size={multiKit === 'smallPill' ? 'small' : ''}
59
- text={label}
61
+ closeProps={removeProps}
62
+ color={pillColor}
63
+ dark={dark}
64
+ marginRight="xs"
65
+ name=''
66
+ size={multiKit === 'smallPill' ? 'small' : ''}
67
+ text={label}
68
+ truncate={truncate}
69
+ {...props}
60
70
  />
61
71
  }
62
72
  </components.MultiValueContainer>
@@ -0,0 +1,88 @@
1
+ <%
2
+ options = [
3
+ { label: 'Orange', value: '#FFA500' },
4
+ { label: 'Red', value: '#FF0000' },
5
+ { label: 'Green', value: '#00FF00' },
6
+ { label: 'Blue', value: '#0000FF' },
7
+ ]
8
+ %>
9
+
10
+ <%= pb_rails("typeahead", props: {
11
+ id: "typeahead-default",
12
+ placeholder: "All Colors",
13
+ options: options,
14
+ label: "None",
15
+ name: :foo,
16
+ is_multi: false,
17
+ margin_bottom: "none",
18
+ })
19
+ %>
20
+ <%= pb_rails("typeahead", props: {
21
+ id: "typeahead-default",
22
+ placeholder: "All Colors",
23
+ options: options,
24
+ label: "XXS",
25
+ name: :foo,
26
+ is_multi: false,
27
+ margin_bottom: "xxs",
28
+ })
29
+ %>
30
+ <%= pb_rails("typeahead", props: {
31
+ id: "typeahead-default",
32
+ placeholder: "All Colors",
33
+ options: options,
34
+ label: "XS",
35
+ name: :foo,
36
+ is_multi: false,
37
+ margin_bottom: "xs",
38
+ })
39
+ %>
40
+ <%= pb_rails("typeahead", props: {
41
+ id: "typeahead-default",
42
+ placeholder: "All Colors",
43
+ options: options,
44
+ label: "Default - SM",
45
+ name: :foo,
46
+ is_multi: false,
47
+ })
48
+ %>
49
+ <%= pb_rails("typeahead", props: {
50
+ id: "typeahead-default",
51
+ placeholder: "All Colors",
52
+ options: options,
53
+ label: "MD",
54
+ name: :foo,
55
+ is_multi: false,
56
+ margin_bottom: "md",
57
+ })
58
+ %>
59
+ <%= pb_rails("typeahead", props: {
60
+ id: "typeahead-default",
61
+ placeholder: "All Colors",
62
+ options: options,
63
+ label: "LG",
64
+ name: :foo,
65
+ is_multi: false,
66
+ margin_bottom: "lg",
67
+ })
68
+ %>
69
+ <%= pb_rails("typeahead", props: {
70
+ id: "typeahead-default",
71
+ placeholder: "All Colors",
72
+ options: options,
73
+ label: "XL",
74
+ name: :foo,
75
+ is_multi: false,
76
+ margin_bottom: "xl",
77
+ })
78
+ %>
79
+
80
+ <%= javascript_tag defer: "defer" do %>
81
+ document.addEventListener("pb-typeahead-kit-typeahead-default-result-option-select", function(event) {
82
+ console.log('Single Option selected')
83
+ console.dir(event.detail)
84
+ })
85
+ document.addEventListener("pb-typeahead-kit-typeahead-default-result-clear", function() {
86
+ console.log('All options cleared')
87
+ })
88
+ <% end %>
@@ -0,0 +1,60 @@
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
+ ]
11
+
12
+ const TypeaheadMarginBottom = (props) => {
13
+ return (
14
+ <>
15
+ <Typeahead
16
+ label="None"
17
+ marginBottom="none"
18
+ options={options}
19
+ {...props}
20
+ />
21
+ <Typeahead
22
+ label="XXS"
23
+ marginBottom="xxs"
24
+ options={options}
25
+ {...props}
26
+ />
27
+ <Typeahead
28
+ label="XS"
29
+ marginBottom="xs"
30
+ options={options}
31
+ {...props}
32
+ />
33
+ <Typeahead
34
+ label="Default - SM"
35
+ options={options}
36
+ {...props}
37
+ />
38
+ <Typeahead
39
+ label="MD"
40
+ marginBottom="md"
41
+ options={options}
42
+ {...props}
43
+ />
44
+ <Typeahead
45
+ label="LG"
46
+ marginBottom="lg"
47
+ options={options}
48
+ {...props}
49
+ />
50
+ <Typeahead
51
+ label="XL"
52
+ marginBottom="xl"
53
+ options={options}
54
+ {...props}
55
+ />
56
+ </>
57
+ )
58
+ }
59
+
60
+ export default TypeaheadMarginBottom
@@ -0,0 +1,31 @@
1
+ <%
2
+ options = [
3
+ { label: 'Windows', value: '#FFA500' },
4
+ { label: 'Siding', value: '#FF0000' },
5
+ { label: 'Doors', value: '#00FF00' },
6
+ { label: 'Roofs', value: '#0000FF' },
7
+ ]
8
+ %>
9
+
10
+ <%= pb_rails("typeahead", props: { id: "typeahead-pills-example1", pill_color: "neutral", default_options: [options.first], options: options, label: "Colors", name: :foo, pills: true }) %>
11
+
12
+ <%= pb_rails("button", props: {id: "clear-pills", text: "Clear All Options", variant: "secondary"}) %>
13
+
14
+ <!-- This section is an example of the available JavaScript event hooks -->
15
+ <%= javascript_tag defer: "defer" do %>
16
+ document.addEventListener("pb-typeahead-kit-typeahead-pills-example1-result-option-select", function(event) {
17
+ console.log('Option selected')
18
+ console.dir(event.detail)
19
+ })
20
+ document.addEventListener("pb-typeahead-kit-typeahead-pills-example1-result-option-remove", function(event) {
21
+ console.log('Option removed')
22
+ console.dir(event.detail)
23
+ })
24
+ document.addEventListener("pb-typeahead-kit-typeahead-pills-example1-result-clear", function() {
25
+ console.log('All options cleared')
26
+ })
27
+
28
+ document.querySelector('#clear-pills').addEventListener('click', function() {
29
+ document.dispatchEvent(new CustomEvent('pb-typeahead-kit-typeahead-pills-example1:clear'))
30
+ })
31
+ <% end %>
@@ -0,0 +1,26 @@
1
+ import React from 'react'
2
+ import { Typeahead } from 'playbook-ui'
3
+
4
+ const options = [
5
+ { label: 'Windows', value: '#FFA500' },
6
+ { label: 'Siding', value: '#FF0000' },
7
+ { label: 'Doors', value: '#00FF00' },
8
+ { label: 'Roofs', value: '#0000FF' },
9
+ ]
10
+
11
+ const TypeaheadWithPills = (props) => {
12
+ return (
13
+ <>
14
+ <Typeahead
15
+ isMulti
16
+ label="Colors"
17
+ options={options}
18
+ pillColor="neutral"
19
+ placeholder=""
20
+ {...props}
21
+ />
22
+ </>
23
+ )
24
+ }
25
+
26
+ export default TypeaheadWithPills
@@ -0,0 +1 @@
1
+ Change the form pill color by passing the optional `pill_color` prop. Product, Data, and Status colors are available options. Check them out <a href="https://playbook.powerapp.cloud/kits/form_pill#form-pill-colors" target="_blank">here</a> in the Form Pill colors example.
@@ -0,0 +1 @@
1
+ Change the form pill color by passing the optional `pillColor` prop. Product, Data, and Status colors are available options. Check them out <a href="https://playbook.powerapp.cloud/kits/form_pill/react#form-pill-colors" target="_blank">here</a> in the Form Pill colors example.
@@ -9,6 +9,8 @@ examples:
9
9
  - typeahead_inline: Inline
10
10
  - typeahead_multi_kit: Multi Kit Options
11
11
  - typeahead_error_state: Error State
12
+ - typeahead_margin_bottom: Margin Bottom
13
+ - typeahead_with_pills_color: With Pills (Custom Color)
12
14
 
13
15
  react:
14
16
  - typeahead_default: Default
@@ -23,3 +25,5 @@ examples:
23
25
  - typeahead_async_createable: Createable (+ Async Data)
24
26
  - typeahead_error_state: Error State
25
27
  - typeahead_custom_menu_list: Custom MenuList
28
+ - typeahead_margin_bottom: Margin Bottom
29
+ - typeahead_with_pills_color: With Pills (Custom Color)
@@ -10,3 +10,5 @@ export { default as TypeaheadCreateable } from './_typeahead_createable.jsx'
10
10
  export { default as TypeaheadAsyncCreateable } from './_typeahead_async_createable.jsx'
11
11
  export { default as TypeaheadErrorState } from './_typeahead_error_state.jsx'
12
12
  export { default as TypeaheadCustomMenuList } from './_typeahead_custom_menu_list.jsx'
13
+ export { default as TypeaheadMarginBottom } from './_typeahead_margin_bottom.jsx'
14
+ export { default as TypeaheadWithPillsColor } from './_typeahead_with_pills_color.jsx'
@@ -20,7 +20,8 @@
20
20
  label: object.label,
21
21
  name: object.name,
22
22
  value: object.value,
23
- placeholder: object.placeholder
23
+ placeholder: object.placeholder,
24
+ margin_bottom: "none",
24
25
  }) %>
25
26
  <%= pb_rails("list", props: { ordered: false, borderless: false, xpadding: true, role: "status", aria: { live: "polite" }, data: { pb_typeahead_kit_results: true } }) do %>
26
27
  <% end %>
@@ -34,9 +34,16 @@ module Playbook
34
34
  prop :search_term_minimum_length, default: 3
35
35
  prop :search_debounce_timeout, default: 250
36
36
  prop :value
37
+ prop :margin_bottom, type: Playbook::Props::Enum,
38
+ values: %w[none xxs xs sm md lg xl],
39
+ default: "sm"
40
+ prop :pill_color, type: Playbook::Props::Enum,
41
+ values: %w[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],
42
+ default: "primary"
37
43
 
38
44
  def classname
39
- generate_classname("pb_typeahead_kit")
45
+ default_margin_bottom = margin_bottom.present? ? "" : " mb_sm"
46
+ generate_classname("pb_typeahead_kit") + default_margin_bottom
40
47
  end
41
48
 
42
49
  def inline_class
@@ -58,6 +65,7 @@ module Playbook
58
65
  def typeahead_react_options
59
66
  base_options = {
60
67
  className: classname,
68
+ pillColor: pill_color,
61
69
  dark: dark,
62
70
  defaultValue: default_options,
63
71
  error: error,
@@ -65,6 +73,7 @@ module Playbook
65
73
  inline: inline,
66
74
  isMulti: is_multi,
67
75
  label: label,
76
+ marginBottom: margin_bottom,
68
77
  multiKit: multi_kit,
69
78
  name: name,
70
79
  options: options,
@@ -259,6 +259,7 @@ $solar: $product_4_background !default; // deprecated
259
259
  $roofing: $product_5_background !default; // deprecated
260
260
  $gutters: $product_6_background !default; // deprecated
261
261
  $insulation: $product_7_background !default; // deprecated
262
+ $accessories: $product_8_background !default; // added specifically for form_pill product map
262
263
  $product_colors: (
263
264
  windows: $windows,
264
265
  siding: $siding,
@@ -267,6 +268,7 @@ $product_colors: (
267
268
  roofing: $roofing,
268
269
  gutters: $gutters,
269
270
  insulation: $insulation,
271
+ accessories: $accessories,
270
272
  product_1_background: $product_1_background,
271
273
  product_1_highlight: $product_1_highlight,
272
274
  product_2_background: $product_2_background,