playbook_ui 14.15.0.pre.alpha.play1854reacthookmultilvlselect6572 → 14.15.0.pre.alpha.play1910emptystatekitreactbeta6685

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +4 -2
  3. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +7 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.jsx +102 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.md +4 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -1
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
  8. data/app/pb_kits/playbook/pb_empty_state/_empty_state.scss +38 -0
  9. data/app/pb_kits/playbook/pb_empty_state/_empty_state.tsx +213 -0
  10. data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_alignment.jsx +38 -0
  11. data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_orientation.jsx +19 -0
  12. data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_size.jsx +35 -0
  13. data/app/pb_kits/playbook/pb_empty_state/docs/default_image/computer_fly_no_branding.svg +21 -0
  14. data/app/pb_kits/playbook/pb_empty_state/docs/default_image/utils.tsx +122 -0
  15. data/app/pb_kits/playbook/pb_empty_state/docs/example.yml +7 -0
  16. data/app/pb_kits/playbook/pb_empty_state/docs/index.js +3 -0
  17. data/app/pb_kits/playbook/pb_empty_state/empty_state.test.jsx +17 -0
  18. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -1
  19. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
  20. data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +1 -1
  21. data/app/pb_kits/playbook/pb_icon_button/icon_button.html.erb +1 -1
  22. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +12 -0
  23. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.md +1 -1
  24. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +1 -1
  25. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +6 -0
  26. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_default.html.erb +1 -1
  27. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_hidden_inputs.html.erb +5 -0
  28. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_hidden_inputs.md +1 -0
  29. data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -1
  30. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +3 -0
  31. data/app/pb_kits/playbook/pb_popover/_popover.tsx +1 -1
  32. data/app/pb_kits/playbook/pb_popover/popover.test.js +1 -1
  33. data/app/pb_kits/playbook/pb_text_input/inputMask.ts +2 -3
  34. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon_rails.html.erb +22 -0
  35. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -0
  36. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +16 -4
  37. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.jsx +66 -0
  38. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.md +1 -0
  39. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx +1 -1
  40. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_users.jsx +1 -1
  41. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +1 -0
  42. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
  43. data/dist/chunks/_typeahead-Z1NtlQ7Y.js +36 -0
  44. data/dist/chunks/_weekday_stacked-Bh2hQ0JB.js +45 -0
  45. data/dist/chunks/vendor.js +1 -1
  46. data/dist/menu.yml +9 -1
  47. data/dist/playbook-doc.js +1 -1
  48. data/dist/playbook-rails-react-bindings.js +1 -1
  49. data/dist/playbook-rails.js +1 -1
  50. data/dist/playbook.css +1 -1
  51. data/lib/playbook/version.rb +1 -1
  52. metadata +21 -5
  53. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon.erb +0 -10
  54. data/dist/chunks/_typeahead-DKSD8vAY.js +0 -36
  55. data/dist/chunks/_weekday_stacked-C-GXG8yh.js +0 -45
@@ -0,0 +1,122 @@
1
+ import React from "react";
2
+
3
+ const computer = (
4
+ <svg
5
+ fill="none"
6
+ height={251}
7
+ width={341}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ >
10
+ <path
11
+ d="M13.131 233.77c8.809-2.023 18.518-1.86 26.426-6.068 17.42-9.269 21.361-45.131 10.744-58.369-15.926-19.858-33.825-2.383-25.724 10.342 2.817 4.425 9.208 7.26 14.112 8.505 40.222 10.212 62.266-21.411 91.212-43.379 8.325-6.318 16.972-12.289 25.976-17.712 7.597-4.575 15.571-8.608 23.725-12.22 8.436-3.738 16.866-7.895 25.954-9.791 19.121-3.989 30.617-6.438 50.156-7.193 6.868-.265 21.421 2.154 27.93 4.179a73.8 73.8 0 0 1 13.162 5.561c4.289 2.319 8.378 5.018 12.09 8.093 3.993 3.307 7.64 7.011 10.912 10.96 2.894 3.491 5.521 7.237 7.503 11.258 2.173 4.41 3.901 9.072 4.873 13.855.896 4.408-.929 18.105-2.018 22.49-2.446 9.854-26.142 9.975-33.36 5.394-17.25-10.948 2.072-41.177 8.585-49.299 15.495-19.328 29.66-28.821 24.775-54.869-.21-1.121-5.837-23.386-11.566-27.894-5.729-4.509-16.046-17.098-28.713-17.486"
12
+ stroke="#DFE3E8"
13
+ strokeDasharray="5 9"
14
+ strokeLinecap="round"
15
+ strokeLinejoin="round"
16
+ strokeWidth={3}
17
+ />
18
+ <path d="M12.034 231.969h240.667v16.979H12.034z"
19
+ fill="#fff"
20
+ />
21
+ <path
22
+ clipRule="evenodd"
23
+ d="M24.04 232c1.59 9.986 50.66 18 110.96 18s109.37-8.014 110.96-18H24.04Z"
24
+ fill="#EFEFEF"
25
+ fillRule="evenodd"
26
+ opacity={0.398}
27
+ />
28
+ <path d="M12.028 233.803h240.726v-3.26H12.028v3.26Z"
29
+ fill="#DFE3E8"
30
+ />
31
+ <path
32
+ clipRule="evenodd"
33
+ d="M111.452 145.308h124.137c3 0 5.432 2.432 5.432 5.433v83.244a5.432 5.432 0 0 1-5.432 5.433H111.452c-3 0-5.432-2.432-5.432-5.433v-83.244a5.432 5.432 0 0 1 5.432-5.433Z"
34
+ fill="#E6EBEF"
35
+ fillRule="evenodd"
36
+ />
37
+ <mask
38
+ height={95}
39
+ id="a"
40
+ maskUnits="userSpaceOnUse"
41
+ style={{
42
+ maskType: "luminance",
43
+ }}
44
+ width={136}
45
+ x={106}
46
+ y={145}
47
+ >
48
+ <path
49
+ clipRule="evenodd"
50
+ d="M111.452 145.308h124.137c3 0 5.432 2.432 5.432 5.433v83.244a5.432 5.432 0 0 1-5.432 5.433H111.452c-3 0-5.432-2.432-5.432-5.433v-83.244a5.432 5.432 0 0 1 5.432-5.433Z"
51
+ fill="#fff"
52
+ fillRule="evenodd"
53
+ />
54
+ </mask>
55
+ <g mask="url(#a)">
56
+ <path
57
+ clipRule="evenodd"
58
+ d="m233.81 130.202-98.487 126.253H90.747l-9.791-155.738 152.854 29.485Z"
59
+ fill="#EFF3F6"
60
+ fillRule="evenodd"
61
+ />
62
+ </g>
63
+ <path
64
+ clipRule="evenodd"
65
+ d="m190.054 195.575-15.874 11.326v4.703a.423.423 0 0 1-.669.348l-15.206-10.848-.018-.013a.596.596 0 0 1-.249-.486v-11.039c0-.193.093-.375.25-.486l.017-.013 15.875-11.326v-4.703c0-.347.387-.549.668-.348l15.206 10.848.018.013c.157.111.25.293.25.485V195.076a.596.596 0 0 1-.251.486l-.017.013Z"
66
+ fill="#F9F9F9"
67
+ fillRule="evenodd"
68
+ />
69
+ <path
70
+ d="m174.18 206.901-.872-1.222a1.503 1.503 0 0 0-.628 1.222h1.5Zm15.874-11.326.871 1.221.02-.014-.891-1.207Zm-16.543 16.377.872-1.22-.001-.001-.871 1.221Zm-15.206-10.848-.88 1.215.009.006.871-1.221Zm-.018-.013.88-1.215-.008-.006-.872 1.221Zm.001-12.011.87 1.222.021-.016-.891-1.206Zm.017-.013-.871-1.221-.02.014.891 1.207Zm15.875-11.326.871 1.221a1.5 1.5 0 0 0 .629-1.221h-1.5Zm.668-5.051-.872 1.22.001.001.871-1.221Zm15.206 10.848.88-1.215-.009-.006-.871 1.221Zm.018.013-.88 1.215.011.008.869-1.223Zm-.001 12.011-.87-1.222-.02.015.89 1.207Zm-15.02 12.56 15.874-11.326-1.742-2.442-15.875 11.325 1.743 2.443Zm.629 3.482v-4.703h-3v4.703h3Zm-3.041 1.569c1.29.921 3.041-.023 3.041-1.569h-3c0-.853.974-1.393 1.703-.872l-1.744 2.441Zm-15.205-10.848 15.206 10.848 1.742-2.442-15.206-10.848-1.742 2.442Zm-.027-.02.018.014 1.76-2.43-.018-.013-1.76 2.429Zm-.869-1.7c0 .676.325 1.312.877 1.707l1.744-2.442a.905.905 0 0 1 .379.735h-3Zm0-.005v.005h3v-.005h-3Zm0-11.03v11.03h3v-11.03h-3Zm0-.004v.004h3v-.004h-3Zm.88-1.709a2.098 2.098 0 0 0-.88 1.709h3c0 .29-.14.565-.38.736l-1.74-2.445Zm-.004.003-.017.013 1.782 2.413.017-.012-1.782-2.414Zm15.894-11.34-15.874 11.326 1.742 2.442 15.875-11.326-1.743-2.442Zm-.628-3.482v4.703h3v-4.703h-3Zm3.04-1.569c-1.29-.921-3.04.023-3.04 1.569h3c0 .853-.975 1.393-1.704.872l1.744-2.441Zm15.205 10.848-15.206-10.848-1.742 2.442 15.206 10.848 1.742-2.442Zm.028.02-.019-.014-1.76 2.43.018.013 1.761-2.429Zm.869 1.699c0-.673-.324-1.312-.881-1.708l-1.738 2.446a.906.906 0 0 1-.381-.738h3Zm0 .006v-.006h-3v.006h3Zm0 11.029v-11.029h-3v11.029h3Zm0 .005v-.005h-3v.005h3Zm-.881 1.709a2.1 2.1 0 0 0 .881-1.709h-3c0-.29.139-.565.379-.736l1.74 2.445Zm.004-.003.017-.013-1.781-2.414-.017.013 1.781 2.414Z"
71
+ fill="#DFE3E8"
72
+ />
73
+ <path
74
+ clipRule="evenodd"
75
+ d="M236.947 145.308H111.452c-3 0-5.432 2.432-5.432 5.433v83.244a5.432 5.432 0 0 0 5.432 5.433h125.495c3 0 5.433-2.432 5.433-5.433v-83.244a5.433 5.433 0 0 0-5.433-5.433Zm-127.668 5.433c0-1.2.973-2.173 2.173-2.173h125.495c1.2 0 2.173.973 2.173 2.173v83.244c0 1.2-.973 2.173-2.173 2.173H111.452c-1.2 0-2.173-.973-2.173-2.173v-83.244Z"
76
+ fill="#DFE3E8"
77
+ fillRule="evenodd"
78
+ />
79
+ <circle
80
+ cx={272.814}
81
+ cy={31.086}
82
+ r={6.5}
83
+ stroke="#DFE3E8"
84
+ strokeWidth={3}
85
+ transform="rotate(-58 272.814 31.086)"
86
+ />
87
+ <path
88
+ d="m269.32 17.808 1.156-1.85c.435-.697 1.284-.86 1.869-.494l15.564 9.725c.584.366.811 1.2.376 1.897l-1.156 1.85c-.435.696-1.285.859-1.87.494l-15.564-9.726c-.584-.365-.81-1.2-.375-1.896Z"
89
+ stroke="#DFE3E8"
90
+ strokeWidth={3}
91
+ />
92
+ <path
93
+ d="m271.277 14.944-.852-6.723"
94
+ stroke="#DFE3E8"
95
+ strokeLinecap="round"
96
+ strokeLinejoin="round"
97
+ strokeWidth={4}
98
+ />
99
+ <path
100
+ clipRule="evenodd"
101
+ d="m268.414 18.314-6.042 2.12 6.042-2.12Z"
102
+ stroke="#DFE3E8"
103
+ strokeLinecap="round"
104
+ strokeLinejoin="round"
105
+ strokeWidth={4}
106
+ />
107
+ <circle
108
+ cx={283.883}
109
+ cy={13.973}
110
+ r={6.5}
111
+ stroke="#DFE3E8"
112
+ strokeWidth={3}
113
+ transform="rotate(-58 283.883 13.973)"
114
+ />
115
+ </svg>
116
+ )
117
+
118
+ export const getDefaultImage = () => {
119
+ return {
120
+ computer,
121
+ }
122
+ }
@@ -0,0 +1,7 @@
1
+ examples:
2
+
3
+
4
+ react:
5
+ - empty_state_size: Size
6
+ - empty_state_orientation: Orientation
7
+ - empty_state_alignment: Alignment
@@ -0,0 +1,3 @@
1
+ export { default as EmptyStateOrientation } from './_empty_state_orientation.jsx'
2
+ export { default as EmptyStateSize } from './_empty_state_size.jsx'
3
+ export { default as EmptyStateAlignment } from './_empty_state_alignment.jsx'
@@ -0,0 +1,17 @@
1
+ import React from 'react'
2
+ import { render, screen } from '../utilities/test-utils'
3
+
4
+ import { EmptyState } from 'playbook-ui'
5
+
6
+
7
+ test('returns namespaced class name', () => {
8
+ render(
9
+ <EmptyState
10
+ data={{ testid: 'primary-test' }}
11
+ text="some text"
12
+ />
13
+ )
14
+
15
+ const kit = screen.getByTestId('primary-test')
16
+ expect(kit).toHaveClass('pb_empty_state_kit')
17
+ })
@@ -25,7 +25,7 @@
25
25
  <%= pb_form_with(scope: :example, url: "", method: :get) do |form| %>
26
26
  <%= form.typeahead :example_typeahead, props: { data: { typeahead_example1: true, user: {} }, label: true, placeholder: "Search for a user" } %>
27
27
  <%= form.text_field :example_text_field, props: { label: true } %>
28
- <%= form.phone_number_field :example_phone_number_field, props: { label: "Example phone field" } %>
28
+ <%= form.phone_number_field :example_phone_number_field, props: { label: "Example phone field", hidden_inputs: true } %>
29
29
  <%= form.email_field :example_email_field, props: { label: true } %>
30
30
  <%= form.number_field :example_number_field, props: { label: true } %>
31
31
  <%= form.search_field :example_search_field, props: { label: true } %>
@@ -24,7 +24,7 @@
24
24
  <%= pb_form_with(scope: :example, method: :get, url: "", validate: true) do |form| %>
25
25
  <%= form.typeahead :example_typeahead_validation, props: { data: { typeahead_example2: true, user: {} }, label: true, placeholder: "Search for a user", required: true, validation: { message: "Please select a user." } } %>
26
26
  <%= form.text_field :example_text_field_validation, props: { label: true, required: true } %>
27
- <%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field" } %>
27
+ <%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field", hidden_inputs: true } %>
28
28
  <%= form.email_field :example_email_field_validation, props: { label: true, required: true } %>
29
29
  <%= form.number_field :example_number_field_validation, props: { label: true, required: true } %>
30
30
  <%= form.search_field :example_project_number_validation, props: { label: true, required: true, validation: { pattern: "[0-9]{2}-[0-9]{5}", message: "Please enter a valid project number (example: 33-12345)." } } %>
@@ -49,7 +49,7 @@ const IconButton = (props: IconButtonProps) => {
49
49
  id={id}
50
50
  >
51
51
  <Button
52
- borderRadius="lg"
52
+ borderRadius="xs"
53
53
  htmlType={htmlType}
54
54
  link={link}
55
55
  newWindow={newWindow}
@@ -4,7 +4,7 @@
4
4
  new_window:object.new_window,
5
5
  target: object.target,
6
6
  dark: object.dark,
7
- border_radius: "lg" }) do %>
7
+ border_radius: "xs" }) do %>
8
8
  <%= pb_rails("icon", props: { icon: object.icon,
9
9
  fixed_width: true,
10
10
  dark: object.dark,
@@ -473,6 +473,18 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
473
473
  ))
474
474
  : null}
475
475
 
476
+ {!returnAllSelected
477
+ ? defaultReturn.map((item) => (
478
+ <input
479
+ disabled={disabled}
480
+ key={item.id}
481
+ name={`${name}[]`}
482
+ type="hidden"
483
+ value={item.id}
484
+ />
485
+ ))
486
+ : null}
487
+
476
488
  {returnAllSelected &&
477
489
  returnedArray.length !== 0 &&
478
490
  inputDisplay === "pills"
@@ -1 +1 @@
1
- You can pass `react-hook-form` props to the Typeahead kit. Check your console to see the full data selected from this example.
1
+ You can pass `react-hook-form` props to the MultiLevelSelect kit. Check your console to see the full data selected from this example.
@@ -40,7 +40,7 @@ module Playbook
40
40
  treeData: tree_data,
41
41
  returnAllSelected: return_all_selected,
42
42
  selectedIds: selected_ids,
43
- input_name: input_name,
43
+ inputName: input_name,
44
44
  variant: variant,
45
45
  pillColor: pill_color,
46
46
  wrapped: wrapped,
@@ -23,6 +23,7 @@ type PhoneNumberInputProps = {
23
23
  data?: { [key: string]: string },
24
24
  disabled?: boolean,
25
25
  error?: string,
26
+ hiddenInputs?: boolean,
26
27
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
27
28
  id?: string,
28
29
  initialCountry?: string,
@@ -72,6 +73,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
72
73
  dark = false,
73
74
  data = {},
74
75
  disabled = false,
76
+ hiddenInputs = false,
75
77
  htmlOptions = {},
76
78
  id = "",
77
79
  initialCountry = "",
@@ -243,6 +245,10 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
243
245
  countrySearch: false,
244
246
  fixDropdownWidth: false,
245
247
  formatAsYouType: formatAsYouType,
248
+ hiddenInput: hiddenInputs ? () => ({
249
+ phone: `${name}_full`,
250
+ country: `${name}_country_code`,
251
+ }) : null,
246
252
  })
247
253
 
248
254
  itiRef.current = telInputInit;
@@ -1,3 +1,3 @@
1
1
  <%= pb_rails("phone_number_input", props: {
2
- id: "hello"
2
+ id: "hello",
3
3
  }) %>
@@ -0,0 +1,5 @@
1
+ <%= pb_rails("phone_number_input", props: {
2
+ hidden_inputs: true,
3
+ id: "hidden_inputs",
4
+ name: "hidden_inputs",
5
+ }) %>
@@ -0,0 +1 @@
1
+ The `hidden_inputs` boolean prop generates two hidden input fields, {field_name}_full and {field_name}_country_code. The value passed when the form is submitted contains the full phone number including the country code. Because it requires the submission of a form to function, only use this prop on Rails phone number elements within html form tags `<form>/<form>` or [pb_forms](https://playbook.powerapp.cloud/kits/form). Read the [intl-tel-input](https://intl-tel-input.com/examples/hidden-input.html) docs for more information.
@@ -16,4 +16,6 @@ examples:
16
16
  - phone_number_input_initial_country: Initial Country
17
17
  - phone_number_input_only_countries: Limited Countries
18
18
  - phone_number_input_validation: Form Validation
19
- - phone_number_input_format: Format as You Type
19
+ - phone_number_input_format: Format as You Type
20
+ - phone_number_input_hidden_inputs: Hidden Inputs
21
+
@@ -23,6 +23,8 @@ module Playbook
23
23
  default: ""
24
24
  prop :format_as_you_type, type: Playbook::Props::Boolean,
25
25
  default: false
26
+ prop :hidden_inputs, type: Playbook::Props::Boolean,
27
+ default: false
26
28
 
27
29
  def classname
28
30
  generate_classname("pb_phone_number_input")
@@ -35,6 +37,7 @@ module Playbook
35
37
  disabled: disabled,
36
38
  error: error,
37
39
  formatAsYouType: format_as_you_type,
40
+ hiddenInputs: hidden_inputs,
38
41
  initialCountry: initial_country,
39
42
  label: label,
40
43
  name: name,
@@ -84,7 +84,7 @@ const Popover = (props: PbPopoverProps) => {
84
84
  } = props;
85
85
 
86
86
  const items = globalProps(props).split(' ')
87
- const filteredItems = items.filter(item => !item.includes('min_width'))
87
+ const filteredItems = items.filter(item => !item.includes('min-width') && !item.includes('width'))
88
88
  const filteredGlobalProps = filteredItems.join(' ')
89
89
  const popoverSpacing =
90
90
  filteredGlobalProps.includes("dark") || !filteredGlobalProps
@@ -181,7 +181,7 @@ const PopoverTestClicktoClose3 = () => {
181
181
  const btn = screen.getByText(/click me/i)
182
182
  fireEvent.click(btn);
183
183
  const kit = screen.getByText("Click Anywhere");
184
- expect(kit).toHaveClass("pb_popover_body max_width_240px overflow_handling");
184
+ expect(kit).toHaveClass("pb_popover_body p_sm overflow_handling");
185
185
  });
186
186
 
187
187
  test("closes Popover on click anywhere", async () => {
@@ -17,7 +17,7 @@ const formatCurrencyDefaultValue = (value: string): string => {
17
17
 
18
18
  // Parse the numeric value as a float to handle decimals
19
19
  const dollars = parseFloat(numericValue)
20
- if (isNaN(dollars) || dollars === 0) return ''
20
+ if (isNaN(dollars)) return ''
21
21
 
22
22
  // Format as currency
23
23
  return new Intl.NumberFormat('en-US', {
@@ -30,10 +30,9 @@ const formatCurrencyDefaultValue = (value: string): string => {
30
30
  const formatCurrency = (value: string): string => {
31
31
  const numericValue = value.replace(/[^0-9]/g, '').slice(0, 15)
32
32
 
33
- if (!numericValue) return ''
33
+ if (!numericValue || numericValue === "00") return ''
34
34
 
35
35
  const dollars = parseFloat((parseInt(numericValue) / 100).toFixed(2))
36
- if (dollars === 0) return ''
37
36
 
38
37
  return new Intl.NumberFormat('en-US', {
39
38
  style: 'currency',
@@ -0,0 +1,22 @@
1
+ <%= pb_rails "flex", props: { flex_direction: "row", gap: "md", wrap: true } do %>
2
+ <%= pb_rails "button", props: { id: "tool-tip-with-icon-1", text: "Tooltip With Icon" } %>
3
+ <%= pb_rails "tooltip", props: { trigger_element_selector: "#tool-tip-with-icon-1", tooltip_id: "tool-tip-with-icon-1", position: "top" } do %>
4
+ <%= pb_rails("icon", props: { icon: "paper-plane", fixed_width: true, color: "white", size: "1x", padding_right: "xxs" }) %>
5
+ Send Email
6
+ <% end %>
7
+ <%= pb_rails "button", props: { id: "tool-tip-with-icon-2", text: "Tooltip With Icon" } %>
8
+ <%= pb_rails "tooltip", props: { trigger_element_selector: "#tool-tip-with-icon-2", tooltip_id: "tool-tip-with-icon-2", position: "bottom" } do %>
9
+ <%= pb_rails("icon", props: { icon: "paper-plane", fixed_width: true, color: "white", size: "1x", padding_right: "xxs" }) %>
10
+ Send Email
11
+ <% end %>
12
+ <%= pb_rails "button", props: { id: "tool-tip-with-icon-3", text: "Tooltip With Icon" } %>
13
+ <%= pb_rails "tooltip", props: { trigger_element_selector: "#tool-tip-with-icon-3", tooltip_id: "tool-tip-with-icon-3", position: "left" } do %>
14
+ <%= pb_rails("icon", props: { icon: "paper-plane", fixed_width: true, color: "white", size: "1x", padding_right: "xxs" }) %>
15
+ Send Email
16
+ <% end %>
17
+ <%= pb_rails "button", props: { id: "tool-tip-with-icon-4", text: "Tooltip With Icon" } %>
18
+ <%= pb_rails "tooltip", props: { trigger_element_selector: "#tool-tip-with-icon-4", tooltip_id: "tool-tip-with-icon-4", position: "right" } do %>
19
+ <%= pb_rails("icon", props: { icon: "paper-plane", fixed_width: true, color: "white", size: "1x", padding_right: "xxs" }) %>
20
+ Send Email
21
+ <% end %>
22
+ <% end %>
@@ -4,6 +4,7 @@ examples:
4
4
  - tooltip_default: Default
5
5
  - tooltip_interaction: Content Interaction
6
6
  - tooltip_selectors: Using Common Selectors
7
+ - tooltip_icon_rails: Tooltip with Icon
7
8
  - tooltip_with_icon_circle: Icon Circle Tooltip
8
9
  - tooltip_delay_rails: Delay
9
10
  - tooltip_show_tooltip: Show Tooltip
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect} from 'react'
1
+ import React, { useState, useEffect, forwardRef} from 'react'
2
2
  import Select from 'react-select'
3
3
  import AsyncSelect from 'react-select/async'
4
4
  import CreateableSelect from 'react-select/creatable'
@@ -49,6 +49,7 @@ type TypeaheadProps = {
49
49
  options?: Array<{ label: string; value?: string }>,
50
50
  marginBottom?: "none" | "xxs" | "xs" | "sm" | "md" | "lg" | "xl",
51
51
  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",
52
+ onChange?: any,
52
53
  optionsByContext?: Record<string, Array<{ label: string; value?: string }>>
53
54
  searchContextSelector?: string,
54
55
  clearOnContextChange?: boolean,
@@ -71,8 +72,7 @@ type TagOnChangeValues = {
71
72
  * @constant {React.ReactComponent} Typeahead
72
73
  * @param {TypeaheadProps} props - props as described at https://react-select.com/props
73
74
  */
74
-
75
- const Typeahead = ({
75
+ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
76
76
  async,
77
77
  className,
78
78
  components = {},
@@ -83,9 +83,11 @@ const Typeahead = ({
83
83
  getOptionValue,
84
84
  htmlOptions = {},
85
85
  id,
86
+ name,
86
87
  loadOptions = noop,
87
88
  marginBottom = "sm",
88
89
  pillColor,
90
+ onChange,
89
91
  optionsByContext = {},
90
92
  searchContextSelector,
91
93
  clearOnContextChange = false,
@@ -156,6 +158,15 @@ const Typeahead = ({
156
158
  )
157
159
 
158
160
  const handleOnChange = (_data: SelectValueType, { action, option, removedValue }: TagOnChangeValues) => {
161
+ if (onChange) {
162
+ const isReactHookForm = onChange.toString().includes("target")
163
+ if (isReactHookForm) {
164
+ onChange({ target: { name, value: _data } })
165
+ } else {
166
+ onChange(_data)
167
+ }
168
+ }
169
+
159
170
  if (action === 'select-option') {
160
171
  if (selectProps.onMultiValueClick) selectProps.onMultiValueClick(option)
161
172
  const multiValueClearEvent = new CustomEvent(`pb-typeahead-kit-${selectProps.id}-result-option-select`, { detail: option ? option : _data })
@@ -199,10 +210,11 @@ const Typeahead = ({
199
210
  />
200
211
  </div>
201
212
  )
202
- }
213
+ })
203
214
 
204
215
  Object.keys(kitComponents).forEach((k) => {
205
216
  (Typeahead as GenericObject)[k] = (kitComponents as {[key: string]: unknown})[k]
206
217
  })
207
218
 
219
+ Typeahead.displayName = 'Typeahead'
208
220
  export default Typeahead
@@ -0,0 +1,66 @@
1
+ import React from 'react'
2
+
3
+ import { Typeahead, Title } from 'playbook-ui'
4
+ import { useForm } from 'react-hook-form'
5
+
6
+ const languages = [
7
+ { label: 'JavaScript', value: '1995', category: 'Web Development' },
8
+ { label: 'Python', value: '1991', category: 'General Purpose' },
9
+ { label: 'Java', value: '1995', category: 'Enterprise' },
10
+ { label: 'C++', value: '1985', category: 'Systems Programming' },
11
+ { label: 'Go', value: '2009', category: 'Systems Programming' },
12
+ { label: 'Rust', value: '2010', category: 'Systems Programming' },
13
+ { label: 'Swift', value: '2014', category: 'Mobile Development' },
14
+ { label: 'Kotlin', value: '2011', category: 'Mobile Development' },
15
+ { label: 'Ruby', value: '1995', category: 'General Purpose' },
16
+ { label: 'PHP', value: '1995', category: 'Web Development' },
17
+ ]
18
+
19
+ const colors = [
20
+ { label: 'Orange', value: '#FFA500' },
21
+ { label: 'Red', value: '#FF0000' },
22
+ { label: 'Green', value: '#00FF00' },
23
+ { label: 'Blue', value: '#0000FF' },
24
+ ]
25
+
26
+ const TypeaheadReactHook = (props) => {
27
+ const { register, watch } = useForm()
28
+
29
+ const selectedLanguages = watch('languages')
30
+ const selectedColor = watch('color')
31
+
32
+ return (
33
+ <>
34
+ <Typeahead
35
+ isMulti
36
+ label="Multi Select Languages"
37
+ multiKit="language"
38
+ options={languages}
39
+ {...props}
40
+ {...register('languages')}
41
+ />
42
+ <Title
43
+ size={4}
44
+ text='Selected Languages'
45
+ />
46
+ {selectedLanguages && selectedLanguages.map(language => (
47
+ <p key={language.label}>{`${language.label} - ${language.value} - ${language.category}`}</p>
48
+ ))}
49
+
50
+ <Typeahead
51
+ label="Colors"
52
+ marginTop="lg"
53
+ options={colors}
54
+ {...props}
55
+ {...register('color')}
56
+ />
57
+ <Title
58
+ size={4}
59
+ text='Selected Color'
60
+ />
61
+ <p>{ selectedColor && `${selectedColor.label} - ${selectedColor.value}`}</p>
62
+ </>
63
+ )
64
+ }
65
+
66
+ export default TypeaheadReactHook
@@ -0,0 +1 @@
1
+ You can pass `react-hook-form` props to the Typeahead kit.
@@ -49,7 +49,7 @@ const TypeaheadWithPillsAsyncCustomOptions = (props) => {
49
49
  * @summary - for doc example purposes only
50
50
  */
51
51
  const handleOnMultiValueClick = (value) => {
52
- alert(`You removed the user: "${value.label}"`)
52
+ alert(`You added the user: "${value.label}"`)
53
53
  }
54
54
 
55
55
  return (
@@ -56,7 +56,7 @@ const TypeaheadWithPillsAsyncUsers = (props) => {
56
56
  * @summary - for doc example purposes only
57
57
  */
58
58
  const handleOnMultiValueClick = (value) => {
59
- alert(`You removed the user: "${value.label}"`)
59
+ alert(`You added the user: "${value.label}"`)
60
60
  }
61
61
 
62
62
  return (
@@ -17,6 +17,7 @@ examples:
17
17
 
18
18
  react:
19
19
  - typeahead_default: Default
20
+ - typeahead_react_hook: React Hook
20
21
  - typeahead_with_highlight: With Highlight
21
22
  - typeahead_with_pills: With Pills
22
23
  - typeahead_with_pills_async: With Pills (Async Data)
@@ -13,3 +13,4 @@ export { default as TypeaheadCustomMenuList } from './_typeahead_custom_menu_lis
13
13
  export { default as TypeaheadMarginBottom } from './_typeahead_margin_bottom.jsx'
14
14
  export { default as TypeaheadWithPillsColor } from './_typeahead_with_pills_color.jsx'
15
15
  export { default as TypeaheadTruncatedText } from './_typeahead_truncated_text.jsx'
16
+ export { default as TypeaheadReactHook } from './_typeahead_react_hook.jsx'