playbook_ui 14.15.0.pre.alpha.PBNTR902multilevelselecthiddeninputbug6580 → 14.15.0.pre.alpha.PLAY1756pbcontenttagpt76661

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +7 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.jsx +102 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.md +4 -0
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -1
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
  7. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -1
  8. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
  9. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +20 -5
  10. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.jsx +91 -0
  11. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.md +1 -0
  12. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -0
  13. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -0
  14. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +6 -0
  15. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_default.html.erb +1 -1
  16. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_hidden_inputs.html.erb +5 -0
  17. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_hidden_inputs.md +1 -0
  18. data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -1
  19. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +3 -0
  20. data/app/pb_kits/playbook/pb_popover/_popover.tsx +1 -1
  21. data/app/pb_kits/playbook/pb_popover/popover.test.js +1 -1
  22. data/app/pb_kits/playbook/pb_selectable_list/selectable_list.html.erb +1 -6
  23. data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +1 -5
  24. data/app/pb_kits/playbook/pb_table/table.html.erb +2 -12
  25. data/app/pb_kits/playbook/pb_text_input/inputMask.ts +2 -3
  26. data/app/pb_kits/playbook/pb_text_input/text_input.html.erb +1 -5
  27. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon_rails.html.erb +22 -0
  28. data/app/pb_kits/playbook/pb_tooltip/docs/example.yml +1 -0
  29. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +16 -4
  30. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.jsx +66 -0
  31. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_react_hook.md +1 -0
  32. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx +1 -1
  33. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_users.jsx +1 -1
  34. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +1 -0
  35. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
  36. data/dist/chunks/_typeahead-B8f4HM8I.js +36 -0
  37. data/dist/chunks/{_weekday_stacked-C7auj4WH.js → _weekday_stacked-1q2eI-As.js} +1 -1
  38. data/dist/chunks/vendor.js +1 -1
  39. data/dist/playbook-doc.js +1 -1
  40. data/dist/playbook-rails-react-bindings.js +1 -1
  41. data/dist/playbook-rails.js +1 -1
  42. data/dist/playbook.css +1 -1
  43. data/lib/playbook/version.rb +1 -1
  44. metadata +13 -5
  45. data/app/pb_kits/playbook/pb_tooltip/docs/_tooltip_icon.erb +0 -10
  46. data/dist/chunks/_typeahead-CaXmU2Fm.js +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a00831a74f0cc915ba685be7843a1f75e06e3e07d9b8a040de46d64fee8ee61
4
- data.tar.gz: c72c150c0375716b34e2345b4e2795f23bf31de4a2cd4be89bf2c512707193f2
3
+ metadata.gz: 04c84f6d639e8469a19d870f731de39c61229fd36b69eb9f610758e6ab534f40
4
+ data.tar.gz: 9ea88292e7adc0dd619da8d094ed218ce5b1221cba40a91b08f23489215b9920
5
5
  SHA512:
6
- metadata.gz: 93c741d7b069ba3993f69c2a6ec8ad74d226b0914788ad20d849907fc5698003ea68eaaf0b4e5b4232d3a1a4b6abfcd1cf3ee95546a83d0ad91112f56b840e3f
7
- data.tar.gz: 9463bcb48229ea23e51a054f3d4ba539233c668fd4ad893f7a8846b30bbb4ef86372b25cfcb4f8fe97609d4edb22e0f4b62567ec0e4f041df21cc62653474e1f
6
+ metadata.gz: 34abcbde117037d1970f6c16fcb9eb4e86547bb4c2b85d40924dccf17f59c92819fd520ea815b957b0d8e41d49a36d2ca0e769273d896e8b9658b09ff24dc031
7
+ data.tar.gz: 89945bd7afd9dc670b386411a2e62e01e27aaa58ef4a2bbaeec57f05a08950481a780cebbbf78dc14b5917af8b422467b6b22deb8996249c0d869a760cde76ba
@@ -161,6 +161,13 @@
161
161
  }
162
162
  }
163
163
  }
164
+ td {
165
+ [class^=pb_text_input_kit] .text_input_wrapper input {
166
+ padding: 0 $space_xxs;
167
+ font-size: 14px;
168
+ text-align: right;
169
+ }
170
+ }
164
171
  }
165
172
 
166
173
  .table-header-cells-active:first-child {
@@ -0,0 +1,102 @@
1
+ import React, { useState } from "react";
2
+ import { AdvancedTable, TextInput, Body } from "playbook-ui";
3
+ import MOCK_DATA from "./advanced_table_mock_data.json";
4
+
5
+ const AdvancedTableInlineEditing = (props) => {
6
+ const [editedValues, setEditedValues] = useState({});
7
+
8
+ const EditableCell = ({ rowId, originalValue, onSave }) => {
9
+ const [localValue, setLocalValue] = useState(originalValue);
10
+
11
+ const handleChange = (e) => setLocalValue(e.target.value);
12
+
13
+ const handleBlur = () => {
14
+ originalValue !== localValue && onSave(rowId, localValue);
15
+ };
16
+
17
+ return (
18
+ <TextInput inline
19
+ marginBottom="none"
20
+ {...props}
21
+ >
22
+ <input
23
+ onBlur={handleBlur}
24
+ onChange={handleChange}
25
+ onKeyDown={(e) => e.key === 'Enter' && handleBlur()}
26
+ value={localValue}
27
+ />
28
+ </TextInput>
29
+ );
30
+ };
31
+
32
+ const columnDefinitions = [
33
+ {
34
+ accessor: "year",
35
+ label: "Year",
36
+ cellAccessors: ["quarter", "month", "day"],
37
+ },
38
+ {
39
+ accessor: "newEnrollments",
40
+ label: "New Enrollments",
41
+ },
42
+ {
43
+ accessor: "scheduledMeetings",
44
+ label: "Scheduled Meetings",
45
+ editable: true,
46
+ customRenderer: (row) => {
47
+ return (
48
+ <EditableCell
49
+ onSave={(id, val) => {
50
+ setEditedValues((prev) => ({ ...prev, [id]: val }));
51
+ }}
52
+ originalValue={
53
+ editedValues[row.id] ?? row.original.scheduledMeetings
54
+ }
55
+ rowId={row.id}
56
+ />
57
+ );
58
+ },
59
+ },
60
+ {
61
+ accessor: "attendanceRate",
62
+ label: "Attendance Rate",
63
+ },
64
+ {
65
+ accessor: "completedClasses",
66
+ label: "Completed Classes",
67
+ },
68
+ {
69
+ accessor: "classCompletionRate",
70
+ label: "Class Completion Rate",
71
+ },
72
+ {
73
+ accessor: "graduatedStudents",
74
+ label: "Graduated Students",
75
+ },
76
+ ];
77
+
78
+ return (
79
+ <div className="App">
80
+ <AdvancedTable
81
+ columnDefinitions={columnDefinitions}
82
+ tableData={MOCK_DATA}
83
+ {...props}
84
+ />
85
+ {
86
+ editedValues && Object.keys(editedValues).length > 0 && (
87
+ <>
88
+ <Body
89
+ marginTop="md"
90
+ {...props}
91
+ >
92
+ Edited Values by Row Id:
93
+ </Body>
94
+ <pre style={{color: 'white'}}>{JSON.stringify(editedValues, null, 2)}</pre>
95
+ </>
96
+ )
97
+ }
98
+ </div>
99
+ );
100
+ };
101
+
102
+ export default AdvancedTableInlineEditing;
@@ -0,0 +1,4 @@
1
+ Inline Cell Editing can be achieved with a combination of our `TextInput` kit and the `customRenderer` method available through columnDefinitions.
2
+
3
+ Hover over any cell within the 'Scheduled Meetings' column to see the TextInput and type in to change values. Values can be saved by clicking away from the TextInput or by hitting 'Enter'.
4
+ See the code snippet below to see how this was achieved. Devs must manage state themselves as shown.
@@ -36,4 +36,5 @@ examples:
36
36
  - advanced_table_selectable_rows: Selectable Rows
37
37
  - advanced_table_selectable_rows_no_subrows: Selectable Rows (No Subrows)
38
38
  - advanced_table_selectable_rows_actions: Selectable Rows (With Actions)
39
- - advanced_table_selectable_rows_header: Selectable Rows (No Actions Bar)
39
+ - advanced_table_selectable_rows_header: Selectable Rows (No Actions Bar)
40
+ - advanced_table_inline_editing: Inline Cell Editing
@@ -20,4 +20,5 @@ export { default as AdvancedTableNoSubrows } from './_advanced_table_no_subrows.
20
20
  export { default as AdvancedTableSelectableRowsHeader } from './_advanced_table_selectable_rows_header.jsx'
21
21
  export { default as AdvancedTableSelectableRowsActions } from './_advanced_table_selectable_rows_actions.jsx'
22
22
  export { default as AdvancedTableTablePropsStickyHeader } from './_advanced_table_table_props_sticky_header.jsx'
23
- export { default as AdvancedTableColumnHeadersCustomCell } from './_advanced_table_column_headers_custom_cell.jsx'
23
+ export { default as AdvancedTableColumnHeadersCustomCell } from './_advanced_table_column_headers_custom_cell.jsx'
24
+ export { default as AdvancedTableInlineEditing } from './_advanced_table_inline_editing.jsx'
@@ -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)." } } %>
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect, useRef } from "react";
1
+ import React, { useState, useEffect, useRef, forwardRef } from "react";
2
2
  import classnames from "classnames";
3
3
  import { globalProps, GlobalProps } from "../utilities/globalProps";
4
4
  import {
@@ -23,6 +23,13 @@ import {
23
23
  getExpandedItems,
24
24
  } from "./_helper_functions";
25
25
 
26
+ interface MultiLevelSelectComponent
27
+ extends React.ForwardRefExoticComponent<
28
+ MultiLevelSelectProps & React.RefAttributes<HTMLInputElement>
29
+ > {
30
+ Options: typeof MultiLevelSelectOptions;
31
+ }
32
+
26
33
  type MultiLevelSelectProps = {
27
34
  aria?: { [key: string]: string }
28
35
  className?: string
@@ -35,6 +42,7 @@ type MultiLevelSelectProps = {
35
42
  name?: string
36
43
  returnAllSelected?: boolean
37
44
  treeData?: { [key: string]: string; }[] | any
45
+ onChange?: (event: { target: { name?: string; value: any } }) => void
38
46
  onSelect?: (prop: { [key: string]: any }) => void
39
47
  selectedIds?: string[] | any
40
48
  variant?: "multi" | "single"
@@ -42,7 +50,7 @@ type MultiLevelSelectProps = {
42
50
  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",
43
51
  } & GlobalProps
44
52
 
45
- const MultiLevelSelect = (props: MultiLevelSelectProps) => {
53
+ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((props) => {
46
54
  const {
47
55
  aria = {},
48
56
  className,
@@ -55,6 +63,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
55
63
  name,
56
64
  returnAllSelected = false,
57
65
  treeData,
66
+ onChange = () => null,
58
67
  onSelect = () => null,
59
68
  selectedIds,
60
69
  variant = "multi",
@@ -287,8 +296,10 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
287
296
  // Logic for removing items from returnArray or defaultReturn when pills clicked
288
297
  if (returnAllSelected) {
289
298
  onSelect(getCheckedItems(updatedTree));
299
+ onChange({ target: { name, value: getCheckedItems(updatedTree) } });
290
300
  } else {
291
301
  onSelect(getDefaultCheckedItems(updatedTree));
302
+ onChange({ target: { name, value: getDefaultCheckedItems(updatedTree) } });
292
303
  }
293
304
  };
294
305
 
@@ -314,8 +325,10 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
314
325
  const updatedTree = changeItem(filtered[0], check);
315
326
  if (returnAllSelected) {
316
327
  onSelect(getCheckedItems(updatedTree));
328
+ onChange({ target: { name, value: getCheckedItems(updatedTree) } });
317
329
  } else {
318
330
  onSelect(getDefaultCheckedItems(updatedTree));
331
+ onChange({ target: { name, value: getDefaultCheckedItems(updatedTree) } });
319
332
  }
320
333
  };
321
334
 
@@ -348,6 +361,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
348
361
  setIsDropdownClosed(true);
349
362
 
350
363
  onSelect(selectedItem);
364
+ onChange({ target: { name, value: selectedItem } });
351
365
  };
352
366
 
353
367
  // Single select: reset the tree state upon typing
@@ -389,12 +403,12 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
389
403
  // Rendering formattedData to UI based on typeahead
390
404
  const renderNestedOptions = (items: { [key: string]: string; }[] | any ) => {
391
405
  const hasOptionsChild = React.Children.toArray(props.children).some(
392
- (child: any) => child.type === MultiLevelSelect.Options
406
+ (child) => React.isValidElement(child) && child.type === MultiLevelSelect.Options
393
407
  );
394
408
 
395
409
  if (hasOptionsChild) {
396
410
  return React.Children.map(props.children, (child) => {
397
- if (child.type === MultiLevelSelect.Options) {
411
+ if (React.isValidElement(child) && child.type === MultiLevelSelect.Options) {
398
412
  return React.cloneElement(child, { items });
399
413
  }
400
414
  return null;
@@ -559,8 +573,9 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
559
573
  </MultiLevelSelectContext.Provider>
560
574
  </div>
561
575
  );
562
- };
576
+ }) as MultiLevelSelectComponent;
563
577
 
578
+ MultiLevelSelect.displayName = "MultiLevelSelect";
564
579
  MultiLevelSelect.Options = MultiLevelSelectOptions;
565
580
 
566
581
  export default MultiLevelSelect;
@@ -0,0 +1,91 @@
1
+ import React from "react"
2
+ import MultiLevelSelect from "../_multi_level_select"
3
+ import { useForm } from "react-hook-form"
4
+
5
+ const treeData = [
6
+ {
7
+ label: "Power Home Remodeling",
8
+ value: "Power Home Remodeling",
9
+ id: "powerhome1",
10
+ expanded: true,
11
+ children: [
12
+ {
13
+ label: "People",
14
+ value: "People",
15
+ id: "people1",
16
+ expanded: true,
17
+ children: [
18
+ {
19
+ label: "Talent Acquisition",
20
+ value: "Talent Acquisition",
21
+ id: "talent1",
22
+ },
23
+ {
24
+ label: "Business Affairs",
25
+ value: "Business Affairs",
26
+ id: "business1",
27
+ children: [
28
+ {
29
+ label: "Initiatives",
30
+ value: "Initiatives",
31
+ id: "initiative1",
32
+ },
33
+ {
34
+ label: "Learning & Development",
35
+ value: "Learning & Development",
36
+ id: "development1",
37
+ },
38
+ ],
39
+ },
40
+ {
41
+ label: "People Experience",
42
+ value: "People Experience",
43
+ id: "experience1",
44
+ },
45
+ ],
46
+ },
47
+ {
48
+ label: "Contact Center",
49
+ value: "Contact Center",
50
+ id: "contact1",
51
+ children: [
52
+ {
53
+ label: "Appointment Management",
54
+ value: "Appointment Management",
55
+ id: "appointment1",
56
+ },
57
+ {
58
+ label: "Customer Service",
59
+ value: "Customer Service",
60
+ id: "customer1",
61
+ },
62
+ {
63
+ label: "Energy",
64
+ value: "Energy",
65
+ id: "energy1",
66
+ },
67
+ ],
68
+ },
69
+ ],
70
+ },
71
+ ]
72
+
73
+ const MultiLevelSelectReactHook = (props) => {
74
+ const { register, watch } = useForm()
75
+ const selectedItems = watch("departments")
76
+ selectedItems && console.log("Selected Items", selectedItems)
77
+
78
+ return (
79
+ <div>
80
+ <MultiLevelSelect
81
+ id="multiselect-default"
82
+ marginBottom="md"
83
+ treeData={treeData}
84
+ {...register("departments")}
85
+ {...props}
86
+ />
87
+ </div>
88
+ )
89
+ }
90
+
91
+ export default MultiLevelSelectReactHook
@@ -0,0 +1 @@
1
+ You can pass `react-hook-form` props to the MultiLevelSelect kit. Check your console to see the full data selected from this example.
@@ -12,6 +12,7 @@ examples:
12
12
 
13
13
  react:
14
14
  - multi_level_select_default: Default
15
+ - multi_level_select_react_hook: React Hook
15
16
  - multi_level_select_single: Single Select
16
17
  - multi_level_select_single_children_only: Single Select w/ Hidden Radios
17
18
  - multi_level_select_return_all_selected: Return All Selected
@@ -7,3 +7,4 @@ export { default as MultiLevelSelectColor } from './_multi_level_select_color.js
7
7
  export { default as MultiLevelSelectWithChildren } from './_multi_level_select_with_children.jsx'
8
8
  export { default as MultiLevelSelectWithChildrenWithRadios } from './_multi_level_select_with_children_with_radios.jsx'
9
9
  export { default as MultiLevelSelectDisabled } from './_multi_level_select_disabled.jsx'
10
+ export { default as MultiLevelSelectReactHook } from './_multi_level_select_react_hook.jsx'
@@ -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 () => {
@@ -1,9 +1,4 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- id: object.id,
6
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
7
2
  <% if enable_drag %>
8
3
  <%= pb_rails("draggable", props: {initial_items: object.items}) do %>
9
4
  <%= pb_rails("draggable/draggable_container") do %>
@@ -1,8 +1,4 @@
1
- <%= content_tag(:div,
2
- id: object.id,
3
- data: object.data,
4
- class: object.classname,
5
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
6
2
  <% if layout_option == "number" %>
7
3
  <% case object.size %>
8
4
  <% when "xs", "sm" %>
@@ -6,21 +6,11 @@
6
6
 
7
7
  <%= content_tag(:div, class: responsive_class, 'data-pb-table-wrapper' => true) do %>
8
8
  <% if object.tag == "table" %>
9
- <%= content_tag(:table,
10
- aria: object.aria,
11
- class: object.classname,
12
- data: object.data,
13
- id: object.id,
14
- **combined_html_options) do %>
9
+ <%= pb_content_tag(:table) do %>
15
10
  <%= content.presence %>
16
11
  <% end %>
17
12
  <% else %>
18
- <%= content_tag(:div,
19
- aria: object.aria,
20
- class: object.classname,
21
- data: object.data,
22
- id: object.id,
23
- **combined_html_options) do %>
13
+ <%= pb_content_tag do %>
24
14
  <%= content.presence %>
25
15
  <% end %>
26
16
  <% end %>
@@ -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',
@@ -1,8 +1,4 @@
1
- <%= content_tag(:div,
2
- aria: object.aria,
3
- class: object.classname,
4
- data: object.data,
5
- **combined_html_options) do %>
1
+ <%= pb_content_tag do %>
6
2
  <% if object.label.present? %>
7
3
  <%= pb_rails("caption", props: { text: object.label, dark: object.dark, classname: "pb_text_input_kit_label" }) %>
8
4
  <% end %>
@@ -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