playbook_ui 13.32.0.pre.alpha.play1416movealiaslogic3266 → 13.33.0.pre.alpha.PLAY1454formpillicons3309

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom.md +4 -0
  3. data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +1 -1
  4. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +12 -7
  5. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection.html.erb +10 -0
  6. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection.jsx +31 -0
  7. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_value.html.erb +10 -0
  8. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_value.jsx +31 -0
  9. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +4 -0
  10. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +3 -1
  11. data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +4 -4
  12. data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +11 -0
  13. data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +1 -1
  14. data/app/pb_kits/playbook/pb_dropdown/index.js +54 -3
  15. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +112 -5
  16. data/app/pb_kits/playbook/pb_form_pill/_form_pill.test.jsx +64 -0
  17. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +62 -18
  18. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_example.html.erb +5 -1
  19. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_example.jsx +1 -0
  20. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_icon.html.erb +5 -0
  21. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_icon.jsx +19 -0
  22. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_size.html.erb +2 -0
  23. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_size.jsx +2 -0
  24. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_tag.html.erb +4 -1
  25. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_tag.jsx +3 -2
  26. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.html.erb +2 -0
  27. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.jsx +2 -0
  28. data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +2 -1
  29. data/app/pb_kits/playbook/pb_form_pill/docs/index.js +1 -1
  30. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +17 -10
  31. data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +10 -1
  32. data/app/pb_kits/playbook/pb_icon/_icon.scss +210 -1
  33. data/app/pb_kits/playbook/pb_icon/_icon.tsx +97 -7
  34. data/app/pb_kits/playbook/pb_icon/icon.rb +22 -16
  35. data/app/pb_kits/playbook/pb_nav/_nav_item.test.js +2 -2
  36. data/app/pb_kits/playbook/pb_nav/docs/_tab_nav.html.erb +48 -0
  37. data/app/pb_kits/playbook/pb_nav/docs/_tab_nav.md +3 -0
  38. data/app/pb_kits/playbook/pb_nav/docs/example.yml +1 -0
  39. data/app/pb_kits/playbook/pb_nav/index.js +43 -0
  40. data/app/pb_kits/playbook/pb_nav/nav.rb +9 -0
  41. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/MoreExtensionsDropdown.tsx +1 -1
  42. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +1 -1
  43. data/app/pb_kits/playbook/pb_star_rating/_star_rating.scss +11 -2
  44. data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_interactive.html.erb +1 -0
  45. data/app/pb_kits/playbook/pb_star_rating/docs/example.yml +1 -1
  46. data/app/pb_kits/playbook/pb_star_rating/index.js +50 -0
  47. data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +25 -5
  48. data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +6 -0
  49. data/app/pb_kits/playbook/pb_table/_table.tsx +1 -1
  50. data/app/pb_kits/playbook/pb_table/index.ts +4 -4
  51. data/app/pb_kits/playbook/pb_table/subcomponents/_table_body.tsx +1 -1
  52. data/app/pb_kits/playbook/pb_table/subcomponents/_table_cell.tsx +1 -1
  53. data/app/pb_kits/playbook/pb_table/subcomponents/_table_head.tsx +1 -1
  54. data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +1 -1
  55. data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +1 -1
  56. data/app/pb_kits/playbook/pb_table/table.test.js +2 -0
  57. data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +1 -1
  58. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_default.jsx +1 -1
  59. data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +45 -27
  60. data/app/pb_kits/playbook/pb_textarea/index.tsx +3 -3
  61. data/app/pb_kits/playbook/pb_time/_time.tsx +3 -3
  62. data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.tsx +1 -1
  63. data/app/pb_kits/playbook/pb_timeline/_item.tsx +1 -1
  64. data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +1 -1
  65. data/app/pb_kits/playbook/pb_title_detail/_title_detail.tsx +10 -10
  66. data/app/pb_kits/playbook/pb_toggle/_toggle.tsx +1 -1
  67. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +2 -2
  68. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +1 -2
  69. data/app/pb_kits/playbook/pb_treemap_chart/treemapChart.test.js +2 -0
  70. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -3
  71. data/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx +4 -4
  72. data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +11 -7
  73. data/app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.tsx +8 -3
  74. data/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx +6 -1
  75. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +18 -19
  76. data/app/pb_kits/playbook/pb_typeahead/components/Option.tsx +6 -6
  77. data/app/pb_kits/playbook/pb_typeahead/components/Placeholder.tsx +6 -6
  78. data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +3 -3
  79. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx +2 -0
  80. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default.html.erb +22 -57
  81. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx +2 -2
  82. data/app/pb_kits/playbook/pb_typeahead/index.ts +31 -31
  83. data/app/pb_kits/playbook/pb_user/_user.tsx +1 -1
  84. data/app/pb_kits/playbook/pb_user_badge/_user_badge.tsx +6 -6
  85. data/app/pb_kits/playbook/pb_user_badge/badges/million-dollar.tsx +236 -235
  86. data/app/pb_kits/playbook/pb_user_badge/badges/veteran.tsx +1 -1
  87. data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.tsx +68 -63
  88. data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +2 -2
  89. data/app/pb_kits/playbook/playbook-rails.js +6 -0
  90. data/dist/playbook-rails.js +5 -5
  91. data/lib/playbook/forms/builder/star_rating_field.rb +14 -0
  92. data/lib/playbook/forms/builder.rb +1 -0
  93. data/lib/playbook/version.rb +2 -2
  94. metadata +15 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d1aed3316880a926a79a26bfcd3d52de79643bf5d3eae32fb83361cc7100910
4
- data.tar.gz: b4a9a1ac34bb88bcd0832459ceaf0cb9b6e69b977b77b692dd6e8a10fd87a909
3
+ metadata.gz: e3efbce8e6bf0e2038cb58c547e077b7b44abba6abf56c59a4fc907fbfce2c5e
4
+ data.tar.gz: 7880d9315a8eaa5c0e9a3a265511ec50560452fe801cdbc4c0ccacd8dc788d83
5
5
  SHA512:
6
- metadata.gz: 963631c67377d7a3e384fd000cc6d70cf31f614a9d7899b36d897b0bb1556ad96462ccb2a0d1545292fc79701ab98f245f9626d954c0a7564a0775637448c632
7
- data.tar.gz: 25f0696a7caae4ad9e1cc22103b976b9c1498badb5b065ffc71c9f32cd0bd177c22679fbbb398a405ee776bcdb64c4ebcb014b0dc0e3d506981fa90d4b9175f0
6
+ metadata.gz: 0dbccb4ffc9f8ddf6aa98023dcfe77065eb705d3d2212ab6dff3d0c15e6797708f20789530ea9fcde6a1f2d687f4c6d2ff57e106f983171ed6d326b7f62ff99c
7
+ data.tar.gz: 8d4dc0b7828a8d9add30dd1c23416fbc4181a2ecb319e38792a80a717aef3b37e75a99790ef42d703be18dcd09c474faaaa5c4b6e6b612097bfb1044167128ed
@@ -1,2 +1,6 @@
1
1
  The `customOptions` prop provides comprehensive access to additional [Highcharts options](https://api.highcharts.com/highcharts/) that are not explicitly defined as props.
2
2
  It's important to note that certain options may require specific script imports to function properly.
3
+
4
+ Note: If you are having trouble getting any Highcharts options to work, please match the formatting of our [staticOptions](https://github.com/powerhome/playbook/blob/master/playbook/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx#L85-L141). For example, `yAxis` will need to be wrapped with square brackets.
5
+
6
+ You may also need to override any of the [defaults](https://github.com/powerhome/playbook/blob/master/playbook/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx#L45-L73) in order to get that options to work.
@@ -28,7 +28,7 @@ exports[`html structure is correct 1`] = `
28
28
  style="vertical-align: middle; color: rgb(193, 205, 214);"
29
29
  >
30
30
  <i
31
- class="pb_icon_kit far fa-fw fa-lg fa-chevron-down"
31
+ class="pb_icon_kit far fa-lg fa-fw fa-lg fa-chevron-down"
32
32
  />
33
33
  <span
34
34
  aria-label="chevron-down icon"
@@ -22,10 +22,12 @@ import {
22
22
  type DropdownProps = {
23
23
  aria?: { [key: string]: string };
24
24
  autocomplete?: boolean;
25
+ blankSelection?: string;
25
26
  children?: React.ReactChild[] | React.ReactChild | React.ReactElement[];
26
27
  className?: string;
27
28
  dark?: boolean;
28
29
  data?: { [key: string]: string };
30
+ defaultValue?: GenericObject;
29
31
  error?: string;
30
32
  htmlOptions?: { [key: string]: string | number | boolean | (() => void) },
31
33
  id?: string;
@@ -40,10 +42,12 @@ const Dropdown = (props: DropdownProps) => {
40
42
  const {
41
43
  aria = {},
42
44
  autocomplete = false,
45
+ blankSelection = '',
43
46
  children,
44
47
  className,
45
48
  dark = false,
46
49
  data = {},
50
+ defaultValue = {},
47
51
  error,
48
52
  htmlOptions = {},
49
53
  id,
@@ -66,7 +70,7 @@ const Dropdown = (props: DropdownProps) => {
66
70
  const [isDropDownClosed, setIsDropDownClosed, toggleDropdown] = useDropdown(isClosed);
67
71
 
68
72
  const [filterItem, setFilterItem] = useState("");
69
- const [selected, setSelected] = useState<GenericObject>({});
73
+ const [selected, setSelected] = useState<GenericObject>(defaultValue);
70
74
  const [isInputFocused, setIsInputFocused] = useState(false);
71
75
  const [hasTriggerSubcomponent, setHasTriggerSubcomponent] = useState(true);
72
76
  const [hasContainerSubcomponent, setHasContainerSubcomponent] =
@@ -116,11 +120,12 @@ const Dropdown = (props: DropdownProps) => {
116
120
  setIsDropDownClosed(isClosed)
117
121
  }, [isClosed])
118
122
 
119
- const filteredOptions = options?.filter((option: GenericObject) => {
123
+ const blankSelectionOption: GenericObject = blankSelection ? [{ label: blankSelection, value: "" }] : [];
124
+ const optionsWithBlankSelection = blankSelectionOption.concat(options);
125
+ const filteredOptions = optionsWithBlankSelection?.filter((option: GenericObject) => {
120
126
  const label = typeof option.label === 'string' ? option.label.toLowerCase() : option.label;
121
127
  return String(label).toLowerCase().includes(filterItem.toLowerCase());
122
- }
123
- );
128
+ });
124
129
 
125
130
  // For keyboard accessibility: Set focus within dropdown to selected item if it exists
126
131
  useEffect(() => {
@@ -194,7 +199,7 @@ const Dropdown = (props: DropdownProps) => {
194
199
  inputWrapperRef,
195
200
  isDropDownClosed,
196
201
  isInputFocused,
197
- options,
202
+ optionsWithBlankSelection,
198
203
  selected,
199
204
  setFocusedOptionIndex,
200
205
  setIsDropDownClosed,
@@ -233,8 +238,8 @@ const Dropdown = (props: DropdownProps) => {
233
238
  <>
234
239
  <DropdownTrigger />
235
240
  <DropdownContainer>
236
- {options &&
237
- options?.map((option: GenericObject) => (
241
+ {optionsWithBlankSelection &&
242
+ optionsWithBlankSelection?.map((option: GenericObject) => (
238
243
  <Dropdown.Option key={option.id}
239
244
  option={option}
240
245
  />
@@ -0,0 +1,10 @@
1
+ <%
2
+ options = [
3
+ { label: 'United States', value: 'United States', id: 'us' },
4
+ { label: 'Canada', value: 'Canada', id: 'ca' },
5
+ { label: 'Pakistan', value: 'Pakistan', id: 'pk' },
6
+ ]
7
+
8
+ %>
9
+
10
+ <%= pb_rails("dropdown", props: { blank_selection: "Select One...", options: options }) %>
@@ -0,0 +1,31 @@
1
+ import React from 'react'
2
+ import { Dropdown } from '../../'
3
+
4
+ const DropdownBlankSelection = (props) => {
5
+ const options = [
6
+ {
7
+ label: "United States",
8
+ value: "United States",
9
+ },
10
+ {
11
+ label: "Canada",
12
+ value: "Canada",
13
+ },
14
+ {
15
+ label: "Pakistan",
16
+ value: "Pakistan",
17
+ }
18
+ ];
19
+
20
+ return (
21
+ <>
22
+ <Dropdown
23
+ blankSelection="Select one..."
24
+ options={options}
25
+ {...props}
26
+ />
27
+ </>
28
+ )
29
+ }
30
+
31
+ export default DropdownBlankSelection
@@ -0,0 +1,10 @@
1
+ <%
2
+ options = [
3
+ { label: 'United States', value: 'United States', id: 'us' },
4
+ { label: 'Canada', value: 'Canada', id: 'ca' },
5
+ { label: 'Pakistan', value: 'Pakistan', id: 'pk' },
6
+ ]
7
+
8
+ %>
9
+
10
+ <%= pb_rails("dropdown", props: {options: options, default_value: options.last}) %>
@@ -0,0 +1,31 @@
1
+ import React from 'react'
2
+ import { Dropdown } from '../../'
3
+
4
+ const DropdownDefaultValue = (props) => {
5
+ const options = [
6
+ {
7
+ label: "United States",
8
+ value: "United States",
9
+ },
10
+ {
11
+ label: "Canada",
12
+ value: "Canada",
13
+ },
14
+ {
15
+ label: "Pakistan",
16
+ value: "Pakistan",
17
+ }
18
+ ];
19
+
20
+ return (
21
+ <>
22
+ <Dropdown
23
+ defaultValue={options[2]}
24
+ options={options}
25
+ {...props}
26
+ />
27
+ </>
28
+ )
29
+ }
30
+
31
+ export default DropdownDefaultValue
@@ -8,6 +8,8 @@ examples:
8
8
  - dropdown_with_custom_trigger_rails: Custom Trigger
9
9
  - dropdown_with_custom_padding: Custom Option Padding
10
10
  - dropdown_error: Dropdown with Error
11
+ - dropdown_default_value: Default Value
12
+ - dropdown_blank_selection: Blank Selection
11
13
 
12
14
  react:
13
15
  - dropdown_default: Default
@@ -18,6 +20,8 @@ examples:
18
20
  - dropdown_with_custom_trigger: Custom Trigger
19
21
  - dropdown_with_custom_padding: Custom Option Padding
20
22
  - dropdown_error: Dropdown with Error
23
+ - dropdown_default_value: Default Value
24
+ - dropdown_blank_selection: Blank Selection
21
25
  # - dropdown_with_autocomplete: Autocomplete
22
26
  # - dropdown_with_autocomplete_and_custom_display: Autocomplete with Custom Display
23
27
  # - dropdown_with_external_control: useDropdown Hook
@@ -9,4 +9,6 @@ export { default as DropdownWithLabel } from './_dropdown_with_label.jsx'
9
9
  export { default as DropdownWithExternalControl } from './_dropdown_with_external_control.jsx'
10
10
  export { default as DropdownWithHook } from './_dropdown_with_hook.jsx'
11
11
  export { default as DropdownSubcomponentStructure } from './_dropdown_subcomponent_structure.jsx'
12
- export { default as DropdownError } from './_dropdown_error.jsx'
12
+ export { default as DropdownError } from './_dropdown_error.jsx'
13
+ export { default as DropdownDefaultValue } from './_dropdown_default_value.jsx'
14
+ export { default as DropdownBlankSelection } from './_dropdown_blank_selection.jsx'
@@ -8,8 +8,8 @@
8
8
  <%= pb_rails("caption", props: {text: object.label, margin_bottom:"xs"}) %>
9
9
  <% end %>
10
10
  <div class="dropdown_wrapper<%= error_class %>" style="position: relative">
11
- <input type="hidden" name="<%= object.name %>" id="dropdown-selected-option" value="" />
12
- <input id="dropdown-form-validation" name="<%= object.name %>_form_validation" value="" style="display: none" <%= object.required ? "required" : ""%> />
11
+ <input type="hidden" name="<%= object.name %>" id="dropdown-selected-option" value="<%= input_default_value %>" />
12
+ <input id="dropdown-form-validation" name="<%= object.name %>_form_validation" value="<%= input_default_value %>" style="display: none" <%= object.required ? "required" : ""%> />
13
13
 
14
14
  <% if content.present? %>
15
15
  <%= content.presence %>
@@ -17,8 +17,8 @@
17
17
  <% else %>
18
18
  <%= pb_rails("dropdown/dropdown_trigger") %>
19
19
  <%= pb_rails("dropdown/dropdown_container") do %>
20
- <% if object.options.present? %>
21
- <% object.options.each do |option| %>
20
+ <% if options_with_blank.present? %>
21
+ <% options_with_blank.each do |option| %>
22
22
  <%= pb_rails("dropdown/dropdown_option", props: {option: option}) %>
23
23
  <% end %>
24
24
  <% end %>
@@ -10,6 +10,9 @@ module Playbook
10
10
  prop :error, type: Playbook::Props::String
11
11
  prop :required, type: Playbook::Props::Boolean,
12
12
  default: false
13
+ prop :default_value
14
+ prop :blank_selection, type: Playbook::Props::String,
15
+ default: ""
13
16
 
14
17
  def data
15
18
  Hash(prop(:data)).merge(pb_dropdown: true)
@@ -24,6 +27,14 @@ module Playbook
24
27
  def error_class
25
28
  error.present? ? " error" : ""
26
29
  end
30
+
31
+ def input_default_value
32
+ default_value.present? ? default_value.transform_keys(&:to_s) : ""
33
+ end
34
+
35
+ def options_with_blank
36
+ blank_selection.present? ? [{ id: "", value: "", label: blank_selection }] + options : options
37
+ end
27
38
  end
28
39
  end
29
40
  end
@@ -11,7 +11,7 @@ module Playbook
11
11
  prop :custom_display
12
12
 
13
13
  def data
14
- Hash(prop(:data)).merge(dropdown_trigger: true)
14
+ Hash(prop(:data)).merge(dropdown_trigger: true, dropdown_placeholder: default_display_placeholder)
15
15
  end
16
16
 
17
17
  def classname
@@ -9,6 +9,8 @@ const UP_ARROW_SELECTOR = "#dropdown_close_icon";
9
9
  const OPTION_SELECTOR = "[data-dropdown-option-label]";
10
10
  const CUSTOM_DISPLAY_SELECTOR = "[data-dropdown-custom-trigger]";
11
11
  const INPUT_FORM_VALIDATION = "#dropdown-form-validation";
12
+ const DROPDOWN_TRIGGER_DISPLAY = "#dropdown_trigger_display";
13
+ const DROPDOWN_PLACEHOLDER = "[data-dropdown-placeholder]";
12
14
 
13
15
  export default class PbDropdown extends PbEnhancedElement {
14
16
  static get selector() {
@@ -21,9 +23,11 @@ export default class PbDropdown extends PbEnhancedElement {
21
23
 
22
24
  connect() {
23
25
  this.keyboardHandler = new PbDropdownKeyboard(this);
26
+ this.setDefaultValue();
24
27
  this.bindEventListeners();
25
28
  this.updateArrowDisplay(false);
26
29
  this.handleFormValidation();
30
+ this.handleFormReset();
27
31
  }
28
32
 
29
33
  bindEventListeners() {
@@ -83,9 +87,7 @@ export default class PbDropdown extends PbEnhancedElement {
83
87
  }
84
88
 
85
89
  onOptionSelected(value, selectedOption) {
86
- const triggerElement = this.element.querySelector(
87
- "#dropdown_trigger_display"
88
- );
90
+ const triggerElement = this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);
89
91
  const customDisplayElement = this.element.querySelector(
90
92
  "#dropdown_trigger_custom_display"
91
93
  );
@@ -179,4 +181,53 @@ export default class PbDropdown extends PbEnhancedElement {
179
181
  }
180
182
  }
181
183
  }
184
+
185
+ setDefaultValue() {
186
+ const hiddenInput = this.element.querySelector("#dropdown-selected-option");
187
+
188
+ if (hiddenInput.value) {
189
+ const inputFormValidation = this.element.querySelector(INPUT_FORM_VALIDATION);
190
+ const defaultValue = JSON.parse(hiddenInput.value.replaceAll("=>", ":"));
191
+ const options = this.element.querySelectorAll(OPTION_SELECTOR);
192
+
193
+ options.forEach((option) => {
194
+ if (defaultValue.id === JSON.parse(option.dataset.dropdownOptionLabel).id) {
195
+ option.classList.add("pb_dropdown_option_selected");
196
+ }
197
+ });
198
+
199
+ this.setTriggerElementText(defaultValue.label);
200
+
201
+ hiddenInput.value = defaultValue.id;
202
+ inputFormValidation.value = defaultValue.id;
203
+ }
204
+ }
205
+
206
+ handleFormReset() {
207
+ const form = this.element.closest("form");
208
+
209
+ if (form) {
210
+ form.addEventListener("reset", () => {
211
+ this.resetDropdownValue();
212
+ });
213
+ }
214
+ }
215
+
216
+ resetDropdownValue() {
217
+ const hiddenInput = this.element.querySelector("#dropdown-selected-option");
218
+ const inputFormValidation = this.element.querySelector(INPUT_FORM_VALIDATION);
219
+
220
+ hiddenInput.value = "";
221
+ inputFormValidation.value = "";
222
+
223
+ const defaultPlaceholder = this.element.querySelector(DROPDOWN_PLACEHOLDER);
224
+ this.setTriggerElementText(defaultPlaceholder.dataset.dropdownPlaceholder);
225
+ }
226
+
227
+ setTriggerElementText(text) {
228
+ const triggerElement = this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);
229
+ if (triggerElement) {
230
+ triggerElement.textContent = text;
231
+ }
232
+ }
182
233
  }
@@ -8,6 +8,7 @@ $selector: ".pb_form_pill";
8
8
  $pb_form_pill_height: 37px;
9
9
  $form_pill_colors: (
10
10
  primary: map-get($status_color_text, "primary"),
11
+ neutral: map-get($status_color_text, "neutral"),
11
12
  );
12
13
 
13
14
 
@@ -23,34 +24,75 @@ $form_pill_colors: (
23
24
  cursor: pointer;
24
25
  @each $color_name, $color_value in $form_pill_colors {
25
26
  &[class*=_#{$color_name}] {
26
- background-color: rgba($color_value, $opacity-1);
27
+ background-color: mix($color_value, $card_light, 10%);
28
+ @if ($color_name == "neutral") {
29
+ background-color: $white;
30
+ border: 1px solid $border_light;
31
+ }
27
32
  transition: background-color 0.2s ease;
28
33
  box-shadow: none;
29
34
  @media (hover:hover) {
30
35
  &:hover {
31
- background-color: rgba($color_value, $opacity-2);
36
+ background-color: mix($color_value, $card_light, 20%);
37
+ @if ($color_name == "neutral") {
38
+ background-color: mix($neutral, $card_light, 20%);
39
+ border: 1px solid $border_light;
40
+ }
41
+ }
42
+ &:active {
43
+ background-color: mix($color_value, $card_light, 30%);
44
+ @if ($color_name == "neutral") {
45
+ background-color: mix($neutral, $card_light, 30%);
46
+ }
32
47
  }
33
48
  }
34
49
  #{$selector}_text {
35
50
  color: $color_value;
51
+ @if ($color_name == "neutral") {
52
+ color: $text_lt_default;
53
+ }
36
54
  padding-left: $space-sm;
37
- padding-right: $space-sm/4;
55
+ padding-right: $space-sm/2;
38
56
  }
39
57
  #{$selector}_close {
40
58
  color: $color_value;
41
- padding-left: $space-sm/2;
59
+ padding-left: $space-sm/4;
42
60
  padding-right: $space-sm/4;
43
61
  display: flex;
44
62
  align-items: center;
45
- height: 100%;
63
+ // I had to temporarily change height to 27px so new hover state darker background forms a circle not an oval
64
+ // before size change (ticket 2 of 4) - change back to 100% when $pb_form_pill_height changed to 27px from 37px
65
+ height: 27px;
66
+ border-radius: 70px;
46
67
  cursor: pointer;
68
+ &:hover {
69
+ background-color: mix($color_value, $card_light, 40%);
70
+ @if ($color_name == "neutral") {
71
+ background-color: mix($neutral, $card_light, 60%);
72
+ }
73
+ }
47
74
  }
48
75
  #{$selector}_tag {
49
76
  color: $color_value;
50
77
  padding-left: $space-sm;
78
+ @if ($color_name == "neutral") {
79
+ color: $text_lt_default;
80
+ }
51
81
  }
52
82
  }
53
83
  }
84
+ &:focus {
85
+ outline: $primary solid 2px;
86
+ outline-offset: -1px;
87
+ }
88
+ &:focus-visible {
89
+ outline: $primary solid 2px;
90
+ outline-offset: -1px;
91
+ }
92
+ .pb_form_pill_icon {
93
+ height: 12px !important;
94
+ width: 12px !important;
95
+ }
54
96
  &.small {
55
97
  height: fit-content;
56
98
  height: -moz-fit-content;
@@ -70,6 +112,71 @@ $form_pill_colors: (
70
112
  &::before { line-height: 21px; }
71
113
  }
72
114
  }
115
+ &.dark {
116
+ @each $color_name, $color_value in $form_pill_colors {
117
+ // In dark mode, the base patterns below are needed for the next tickets for success, warning, error, info.
118
+ // Primary and Neutral are exceptions to the general rule in the handoff
119
+ &[class*=_#{$color_name}] {
120
+ // background-color: mix($color_value, $card_dark, 10%);
121
+ // .pb_form_pill_tag {
122
+ // color: $color_name;
123
+ // }
124
+ // .pb_form_pill_close {
125
+ // color: $color_name;
126
+ // &:hover {
127
+ // background-color: mix($color_value, $card_dark, 40%);
128
+ // }
129
+ // }
130
+ // &:hover {
131
+ // background-color: mix($color_value, $card_dark, 20%);
132
+ // }
133
+ // &:active {
134
+ // background-color: mix($color_value, $card_dark, 30%);
135
+ // }
136
+ @if ($color_name == "neutral") {
137
+ background-color: transparent;
138
+ border: 1px solid $border_dark;
139
+ .pb_form_pill_text, .pb_form_pill_tag {
140
+ color: $text_dk_default;
141
+ }
142
+ .pb_form_pill_close {
143
+ color: $text_dk_default;
144
+ &:hover {
145
+ background-color: mix($neutral, $card_dark, 40%);
146
+ }
147
+ }
148
+ &:hover {
149
+ background-color: mix($white, $card_dark, 10%);
150
+ }
151
+ &:active {
152
+ background-color: mix($white, $card_dark, 20%);
153
+ }
154
+ &:focus {
155
+ border: 1px solid $primary;
156
+ }
157
+ }
158
+ @if ($color_name == "primary") {
159
+ background-color: mix($active_dark, $card_dark, 10%);
160
+ .pb_form_pill_text, .pb_form_pill_tag {
161
+ color: $active_dark;
162
+ }
163
+ .pb_form_pill_close {
164
+ color: $active_dark;
165
+ &:hover {
166
+ background-color: mix($active_dark, $card_dark, 40%);
167
+ }
168
+ }
169
+ &:hover {
170
+ background-color: mix($active_dark, $card_dark, 20px);
171
+ }
172
+ &:active {
173
+ background-color: mix($active_dark, $card_dark, 30%);
174
+ }
175
+ }
176
+ }
177
+ }
178
+ }
179
+
73
180
  &[class*=lowercase] {
74
181
  text-transform: lowercase;
75
182
  }
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { render, screen } from '../utilities/test-utils';
3
+ import FormPill from './_form_pill';
4
+
5
+ const testId = 'formpill';
6
+
7
+ test('should render classname', () => {
8
+ render(
9
+ <FormPill
10
+ data={{ testid: testId }}
11
+ text="test"
12
+ />
13
+ )
14
+
15
+ const kit = screen.getByTestId(testId)
16
+ expect(kit).toHaveClass('pb_form_pill_kit_primary none')
17
+ });
18
+
19
+ test('displays text content', () => {
20
+ render(
21
+ <FormPill
22
+ data={{ testid: testId }}
23
+ text="test"
24
+ />
25
+ )
26
+
27
+ const text = screen.getByText("test")
28
+ expect(text).toBeInTheDocument()
29
+ });
30
+
31
+ test('displays color variant', () => {
32
+ render(
33
+ <FormPill
34
+ color={"neutral"}
35
+ data={{ testid: testId }}
36
+ text={"test"}
37
+ />
38
+ )
39
+ const kit = screen.getByTestId(testId)
40
+ expect(kit).toHaveClass(`pb_form_pill_kit_neutral none`)
41
+ });
42
+
43
+ test('displays size variant', () => {
44
+ render(
45
+ <FormPill
46
+ data={{ testid: testId }}
47
+ size={"small"}
48
+ text={"test"}
49
+ />
50
+ )
51
+ const kit = screen.getByTestId('formpill')
52
+ expect(kit).toHaveClass(`pb_form_pill_kit_primary small none`)
53
+ });
54
+
55
+ test('displays icon', () => {
56
+ render(
57
+ <FormPill
58
+ data={{ testid: testId }}
59
+ icon={"test"}
60
+ />
61
+ )
62
+ const kit = screen.getByTestId('formpill')
63
+ expect(kit).toHaveClass(`pb_form_pill_kit_primary_icon none`)
64
+ });