playbook_ui 14.15.0.pre.alpha.PBNTR900phonenumberinputhidden6593 → 14.15.0.pre.alpha.PBNTR900phonenumberinputhidden6620

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 (32) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -1
  3. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
  4. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +4 -2
  5. data/app/pb_kits/playbook/pb_phone_number_input/docs/{_phone_number_input_default_rails.html.erb → _phone_number_input_default.html.erb} +1 -1
  6. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_hidden_inputs.html.erb +5 -0
  7. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_hidden_inputs.md +1 -0
  8. data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +4 -2
  9. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +3 -0
  10. data/app/pb_kits/playbook/pb_popover/_popover.tsx +1 -1
  11. data/app/pb_kits/playbook/pb_popover/popover.test.js +1 -1
  12. data/app/pb_kits/playbook/pb_text_input/inputMask.ts +2 -3
  13. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon_rails.html.erb +22 -0
  14. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -0
  15. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +16 -4
  16. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.jsx +66 -0
  17. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.md +1 -0
  18. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx +1 -1
  19. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_users.jsx +1 -1
  20. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +1 -0
  21. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
  22. data/dist/chunks/_typeahead-ClZGb4WZ.js +36 -0
  23. data/dist/chunks/{_weekday_stacked-iCkVKLxW.js → _weekday_stacked-BAbPkPFp.js} +1 -1
  24. data/dist/chunks/vendor.js +1 -1
  25. data/dist/playbook-doc.js +1 -1
  26. data/dist/playbook-rails-react-bindings.js +1 -1
  27. data/dist/playbook-rails.js +1 -1
  28. data/lib/playbook/version.rb +1 -1
  29. metadata +10 -7
  30. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_default_rails.md +0 -2
  31. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon.erb +0 -10
  32. data/dist/chunks/_typeahead-Cu4WtFsC.js +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b49818abae486db8f2278f8a55d56ad134fe281991fed0df1f146e350c180f48
4
- data.tar.gz: '00328c8493c5262b03db8289724c3fd9526aed880cb51dde183e98ab8861f40d'
3
+ metadata.gz: af5f1da0aaf0cd40aafd6b96b9a779b53e4c14c4ce9c787b0340cafca230c9d1
4
+ data.tar.gz: c39d210a4ca1ae7188b4663835bece3f3aa9fa3ba95ab11b9d650937d16285a1
5
5
  SHA512:
6
- metadata.gz: 12405e9d91640cf2c7385513d16baea2318a576422c68d0f6cea79ee7e25c19e6ac062e62b20303156931cfe78bc19edf526d602f52536da7262a8c071dbb258
7
- data.tar.gz: ef9eb9aa455db56e0fdf58ceaefe8100b8ea3124617e5c86fee0871b11ebd6f659b5e8e6f35617593fbb962d0d6e141975ffa696e8b1b4be3fc8bbec543f8778
6
+ metadata.gz: 9b160464434afb7a464003a1161d572d9dd41711914a4ee149d486d9091ea4de027ae01b5c119174931f4ba563db9b79940c3a198bb73eea9f0e2034a896e8a1
7
+ data.tar.gz: 0da85724ed33fb7d80e560585831f94e743b7f3d8cf8d23e86b19bd5c269d2ce6769c4744f14c15805c9e62ae91b74dc1c7b6c761e22f4767cc3f3d1cf5b5e70
@@ -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)." } } %>
@@ -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,10 +245,10 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
243
245
  countrySearch: false,
244
246
  fixDropdownWidth: false,
245
247
  formatAsYouType: formatAsYouType,
246
- hiddenInput: () => ({
248
+ hiddenInput: hiddenInputs ? () => ({
247
249
  phone: `${name}_full`,
248
250
  country: `${name}_country_code`,
249
- }),
251
+ }) : null,
250
252
  })
251
253
 
252
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.
@@ -11,9 +11,11 @@ examples:
11
11
  - phone_number_input_format: Format as You Type
12
12
 
13
13
  rails:
14
- - phone_number_input_default_rails: Default
14
+ - phone_number_input_default: Default
15
15
  - phone_number_input_preferred_countries: Preferred Countries
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'