playbook_ui 13.25.0.pre.alpha.barchartfix2766 → 13.26.0.pre.alpha.PBNTR291Dropdownrailsv22840

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/index.js +1 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +14 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +14 -10
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.html.erb +33 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.md +24 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.md +5 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -2
  9. data/app/pb_kits/playbook/pb_advanced_table/index.js +78 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +9 -5
  11. data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +4 -2
  12. data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +6 -2
  13. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +9 -4
  14. data/app/pb_kits/playbook/pb_avatar/Utilities/GetPlacementPropsHelper.tsx +44 -0
  15. data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +86 -21
  16. data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +26 -3
  17. data/app/pb_kits/playbook/pb_avatar/avatar.rb +41 -0
  18. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_badge_component_overlay.html.erb +71 -0
  19. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_badge_component_overlay.jsx +77 -0
  20. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_circle_icon_component_overlay.html.erb +71 -0
  21. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_circle_icon_component_overlay.jsx +77 -0
  22. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default.jsx +20 -0
  23. data/app/pb_kits/playbook/pb_avatar/docs/example.yml +4 -0
  24. data/app/pb_kits/playbook/pb_avatar/docs/index.js +2 -0
  25. data/app/pb_kits/playbook/pb_avatar_action_button/avatar_action_button.html.erb +6 -1
  26. data/app/pb_kits/playbook/pb_background/background.html.erb +11 -2
  27. data/app/pb_kits/playbook/pb_badge/badge.html.erb +6 -1
  28. data/app/pb_kits/playbook/pb_body/body.html.erb +6 -1
  29. data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumb_item.html.erb +6 -1
  30. data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumbs.html.erb +7 -2
  31. data/app/pb_kits/playbook/pb_button/button.html.erb +3 -2
  32. data/app/pb_kits/playbook/pb_button_toolbar/button_toolbar.html.erb +7 -2
  33. data/app/pb_kits/playbook/pb_caption/caption.html.erb +6 -1
  34. data/app/pb_kits/playbook/pb_card/card.html.erb +7 -1
  35. data/app/pb_kits/playbook/pb_card/card_body.html.erb +6 -1
  36. data/app/pb_kits/playbook/pb_card/card_header.html.erb +6 -1
  37. data/app/pb_kits/playbook/pb_checkbox/_checkbox.scss +49 -0
  38. data/app/pb_kits/playbook/pb_checkbox/_checkbox.tsx +3 -0
  39. data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +6 -1
  40. data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +2 -1
  41. data/app/pb_kits/playbook/pb_checkbox/checkbox.test.js +14 -0
  42. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_disabled.html.erb +23 -0
  43. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_disabled.jsx +29 -0
  44. data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +2 -0
  45. data/app/pb_kits/playbook/pb_checkbox/docs/index.js +1 -0
  46. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +6 -1
  47. data/app/pb_kits/playbook/pb_collapsible/collapsible.html.erb +6 -1
  48. data/app/pb_kits/playbook/pb_collapsible/collapsible_content.html.erb +6 -1
  49. data/app/pb_kits/playbook/pb_collapsible/collapsible_main.html.erb +7 -1
  50. data/app/pb_kits/playbook/pb_contact/contact.html.erb +6 -1
  51. data/app/pb_kits/playbook/pb_currency/currency.html.erb +6 -1
  52. data/app/pb_kits/playbook/pb_dashboard_value/dashboard_value.html.erb +6 -1
  53. data/app/pb_kits/playbook/pb_date/date.html.erb +6 -1
  54. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +6 -2
  55. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.md +3 -1
  56. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_close.md +3 -1
  57. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_range_limit.md +1 -1
  58. data/app/pb_kits/playbook/pb_date_range_inline/date_range_inline.html.erb +5 -1
  59. data/app/pb_kits/playbook/pb_date_range_stacked/date_range_stacked.html.erb +5 -1
  60. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +5 -1
  61. data/app/pb_kits/playbook/pb_date_time/date_time.html.erb +6 -1
  62. data/app/pb_kits/playbook/pb_date_time_stacked/date_time_stacked.html.erb +7 -1
  63. data/app/pb_kits/playbook/pb_date_year_stacked/date_year_stacked.html.erb +5 -1
  64. data/app/pb_kits/playbook/pb_detail/detail.html.erb +6 -1
  65. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +6 -1
  66. data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +7 -2
  67. data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +5 -1
  68. data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +6 -2
  69. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +94 -32
  70. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +64 -23
  71. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.html.erb +10 -0
  72. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.jsx +2 -20
  73. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default.md +1 -0
  74. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subcomponent_structure.html.erb +17 -0
  75. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subcomponent_structure.jsx +42 -0
  76. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subcomponent_structure.md +7 -0
  77. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete.jsx +2 -5
  78. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_autocomplete_and_custom_display.jsx +1 -2
  79. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.html.erb +60 -0
  80. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +2 -2
  81. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.md +3 -1
  82. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.html.erb +45 -0
  83. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.jsx +1 -4
  84. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_options.md +1 -1
  85. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.html.erb +17 -0
  86. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_padding.jsx +1 -4
  87. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_trigger.html.erb +47 -0
  88. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_external_control.jsx +59 -0
  89. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_hook.jsx +72 -0
  90. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.html.erb +10 -0
  91. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.jsx +39 -0
  92. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_label.md +1 -0
  93. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +15 -4
  94. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +5 -1
  95. data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +26 -0
  96. data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +20 -0
  97. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +200 -10
  98. data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +21 -0
  99. data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +19 -0
  100. data/app/pb_kits/playbook/pb_dropdown/dropdown_option.html.erb +27 -0
  101. data/app/pb_kits/playbook/pb_dropdown/dropdown_option.rb +22 -0
  102. data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +43 -0
  103. data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +30 -0
  104. data/app/pb_kits/playbook/pb_dropdown/hooks/useDropdown.tsx +2 -2
  105. data/app/pb_kits/playbook/pb_dropdown/hooks/useHandleOnKeydown.tsx +4 -4
  106. data/app/pb_kits/playbook/pb_dropdown/index.js +153 -0
  107. data/app/pb_kits/playbook/pb_dropdown/keyboard_accessibility.js +77 -0
  108. data/app/pb_kits/playbook/pb_dropdown/scss_partials/_dropdown_animation.scss +18 -0
  109. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +17 -8
  110. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownOption.tsx +29 -17
  111. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +96 -78
  112. data/app/pb_kits/playbook/pb_dropdown/utilities/clickOutsideHelper.tsx +41 -0
  113. data/app/pb_kits/playbook/pb_dropdown/utilities/index.ts +2 -0
  114. data/app/pb_kits/playbook/pb_dropdown/utilities/subComponentHelper.tsx +9 -7
  115. data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +6 -1
  116. data/app/pb_kits/playbook/pb_filter/filter.html.erb +5 -1
  117. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.html.erb +6 -1
  118. data/app/pb_kits/playbook/pb_flex/flex.html.erb +5 -1
  119. data/app/pb_kits/playbook/pb_flex/flex_item.html.erb +6 -2
  120. data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +6 -1
  121. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
  122. data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +6 -1
  123. data/app/pb_kits/playbook/pb_highlight/highlight.html.erb +5 -1
  124. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.html.erb +5 -1
  125. data/app/pb_kits/playbook/pb_icon_circle/icon_circle.html.erb +7 -2
  126. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +6 -1
  127. data/app/pb_kits/playbook/pb_icon_value/icon_value.html.erb +6 -1
  128. data/app/pb_kits/playbook/pb_label_pill/label_pill.html.erb +6 -1
  129. data/app/pb_kits/playbook/pb_label_value/label_value.html.erb +6 -1
  130. data/app/pb_kits/playbook/pb_layout/body.html.erb +5 -1
  131. data/app/pb_kits/playbook/pb_layout/footer.html.erb +5 -1
  132. data/app/pb_kits/playbook/pb_layout/header.html.erb +5 -1
  133. data/app/pb_kits/playbook/pb_layout/item.html.erb +5 -1
  134. data/app/pb_kits/playbook/pb_layout/layout.html.erb +5 -1
  135. data/app/pb_kits/playbook/pb_layout/sidebar.html.erb +5 -1
  136. data/app/pb_kits/playbook/pb_list/item.html.erb +8 -2
  137. data/app/pb_kits/playbook/pb_list/list.html.erb +8 -2
  138. data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.tsx +3 -1
  139. data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_custom.html.erb +13 -0
  140. data/app/pb_kits/playbook/pb_loading_inline/docs/_loading_inline_custom.jsx +26 -0
  141. data/app/pb_kits/playbook/pb_loading_inline/docs/{_loading_inline_light.html.erb → _loading_inline_default.html.erb} +2 -2
  142. data/app/pb_kits/playbook/pb_loading_inline/docs/{_loading_inline_light.jsx → _loading_inline_default.jsx} +2 -2
  143. data/app/pb_kits/playbook/pb_loading_inline/docs/example.yml +4 -2
  144. data/app/pb_kits/playbook/pb_loading_inline/docs/index.js +2 -1
  145. data/app/pb_kits/playbook/pb_loading_inline/loading_inline.html.erb +7 -2
  146. data/app/pb_kits/playbook/pb_loading_inline/loading_inline.rb +1 -0
  147. data/app/pb_kits/playbook/pb_loading_inline/loading_inline.test.js +14 -0
  148. data/app/pb_kits/playbook/pb_message/message.html.erb +6 -1
  149. data/app/pb_kits/playbook/pb_message/message_mention.html.erb +6 -1
  150. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb +6 -1
  151. data/app/pb_kits/playbook/pb_multiple_users/multiple_users.html.erb +6 -1
  152. data/app/pb_kits/playbook/pb_multiple_users_stacked/multiple_users_stacked.html.erb +6 -1
  153. data/app/pb_kits/playbook/pb_nav/item.html.erb +14 -3
  154. data/app/pb_kits/playbook/pb_nav/nav.html.erb +6 -1
  155. data/app/pb_kits/playbook/pb_online_status/online_status.html.erb +6 -2
  156. data/app/pb_kits/playbook/pb_pagination/pagination.html.erb +6 -1
  157. data/app/pb_kits/playbook/pb_passphrase/passphrase.html.erb +1 -1
  158. data/app/pb_kits/playbook/pb_person/person.html.erb +12 -7
  159. data/app/pb_kits/playbook/pb_person_contact/person_contact.html.erb +6 -1
  160. data/app/pb_kits/playbook/pb_pill/pill.html.erb +6 -1
  161. data/app/pb_kits/playbook/pb_popover/popover.html.erb +6 -1
  162. data/app/pb_kits/playbook/pb_progress_pills/progress_pills.html.erb +6 -2
  163. data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_flex.html.erb +3 -0
  164. data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_flex.jsx +16 -0
  165. data/app/pb_kits/playbook/pb_progress_simple/docs/_progress_simple_flex.md +1 -0
  166. data/app/pb_kits/playbook/pb_progress_simple/docs/example.yml +2 -0
  167. data/app/pb_kits/playbook/pb_progress_simple/docs/index.js +1 -0
  168. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +6 -3
  169. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.rb +1 -1
  170. data/app/pb_kits/playbook/pb_progress_step/progress_step.html.erb +5 -1
  171. data/app/pb_kits/playbook/pb_progress_step/progress_step_item.html.erb +5 -1
  172. data/app/pb_kits/playbook/pb_radio/_radio.scss +35 -0
  173. data/app/pb_kits/playbook/pb_radio/_radio.tsx +3 -0
  174. data/app/pb_kits/playbook/pb_radio/docs/_radio_alignment.jsx +4 -1
  175. data/app/pb_kits/playbook/pb_radio/docs/_radio_default.jsx +4 -1
  176. data/app/pb_kits/playbook/pb_radio/docs/_radio_disabled.html.erb +26 -0
  177. data/app/pb_kits/playbook/pb_radio/docs/_radio_disabled.jsx +31 -0
  178. data/app/pb_kits/playbook/pb_radio/docs/_radio_error.jsx +2 -1
  179. data/app/pb_kits/playbook/pb_radio/docs/example.yml +2 -0
  180. data/app/pb_kits/playbook/pb_radio/docs/index.js +1 -0
  181. data/app/pb_kits/playbook/pb_radio/radio.html.erb +8 -2
  182. data/app/pb_kits/playbook/pb_radio/radio.rb +5 -0
  183. data/app/pb_kits/playbook/pb_radio/radio.test.js +17 -0
  184. data/app/pb_kits/playbook/pb_section_separator/section_separator.html.erb +6 -1
  185. data/app/pb_kits/playbook/pb_select/select.html.erb +5 -1
  186. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +5 -1
  187. data/app/pb_kits/playbook/pb_selectable_card_icon/selectable_card_icon.html.erb +4 -1
  188. data/app/pb_kits/playbook/pb_selectable_icon/selectable_icon.html.erb +5 -1
  189. data/app/pb_kits/playbook/pb_selectable_list/selectable_list.html.erb +6 -1
  190. data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +6 -1
  191. data/app/pb_kits/playbook/pb_source/source.html.erb +5 -1
  192. data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +5 -1
  193. data/app/pb_kits/playbook/pb_stat_change/stat_change.html.erb +5 -1
  194. data/app/pb_kits/playbook/pb_stat_value/stat_value.html.erb +5 -1
  195. data/app/pb_kits/playbook/pb_table/table.html.erb +12 -2
  196. data/app/pb_kits/playbook/pb_table/table_body.html.erb +16 -6
  197. data/app/pb_kits/playbook/pb_table/table_cell.html.erb +16 -6
  198. data/app/pb_kits/playbook/pb_table/table_head.html.erb +16 -6
  199. data/app/pb_kits/playbook/pb_table/table_header.html.erb +13 -4
  200. data/app/pb_kits/playbook/pb_table/table_row.html.erb +16 -6
  201. data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +5 -1
  202. data/app/pb_kits/playbook/pb_time/time.html.erb +5 -1
  203. data/app/pb_kits/playbook/pb_time_range_inline/time_range_inline.html.erb +5 -1
  204. data/app/pb_kits/playbook/pb_time_stacked/time_stacked.html.erb +5 -1
  205. data/app/pb_kits/playbook/pb_timeline/item.html.erb +7 -3
  206. data/app/pb_kits/playbook/pb_timeline/timeline.html.erb +5 -1
  207. data/app/pb_kits/playbook/pb_timestamp/timestamp.html.erb +6 -1
  208. data/app/pb_kits/playbook/pb_title/title.html.erb +6 -1
  209. data/app/pb_kits/playbook/pb_title_count/title_count.html.erb +6 -1
  210. data/app/pb_kits/playbook/pb_title_detail/title_detail.html.erb +5 -1
  211. data/app/pb_kits/playbook/pb_toggle/toggle.html.erb +6 -1
  212. data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +1 -1
  213. data/app/pb_kits/playbook/pb_tooltip/tooltip.html.erb +5 -1
  214. data/app/pb_kits/playbook/pb_user/user.html.erb +6 -1
  215. data/app/pb_kits/playbook/pb_user_badge/user_badge.html.erb +6 -1
  216. data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.html.erb +6 -1
  217. data/app/pb_kits/playbook/playbook-rails.js +6 -0
  218. data/dist/menu.yml +1 -1
  219. data/dist/playbook-rails.js +6 -6
  220. data/lib/playbook/kit_base.rb +1 -1
  221. data/lib/playbook/version.rb +2 -2
  222. metadata +47 -5
  223. data/app/pb_kits/playbook/pb_advanced_table/docs/_description.md +0 -1
@@ -17,8 +17,9 @@ import Body from "../../pb_body/_body";
17
17
 
18
18
  type DropdownContainerProps = {
19
19
  aria?: { [key: string]: string };
20
- className?: string;
21
20
  children?: React.ReactChild[] | React.ReactChild;
21
+ className?: string;
22
+ dark?: boolean;
22
23
  data?: { [key: string]: string };
23
24
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
24
25
  id?: string;
@@ -28,8 +29,9 @@ type DropdownContainerProps = {
28
29
  const DropdownContainer = (props: DropdownContainerProps) => {
29
30
  const {
30
31
  aria = {},
31
- className,
32
32
  children,
33
+ className,
34
+ dark = false,
33
35
  data = {},
34
36
  htmlOptions = {},
35
37
  id,
@@ -37,12 +39,14 @@ const DropdownContainer = (props: DropdownContainerProps) => {
37
39
  } = props;
38
40
 
39
41
  const {
40
- isDropDownClosed,
41
- handleChange,
42
- filterItem,
42
+ dropdownContainerRef,
43
43
  filteredOptions,
44
+ filterItem,
45
+ handleChange,
44
46
  inputRef,
47
+ isDropDownClosed,
45
48
  setFocusedOptionIndex,
49
+ triggerRef
46
50
  } = useContext(DropdownContext);
47
51
 
48
52
  const ariaProps = buildAriaProps(aria);
@@ -62,9 +66,12 @@ const DropdownContainer = (props: DropdownContainerProps) => {
62
66
  className={classes}
63
67
  id={id}
64
68
  onMouseEnter={() => setFocusedOptionIndex(-1)}
69
+ ref={dropdownContainerRef}
70
+ style={triggerRef ? {} : { position: "absolute"}}
65
71
  >
66
72
  {searchbar && (
67
- <TextInput paddingTop="xs"
73
+ <TextInput dark={dark}
74
+ paddingTop="xs"
68
75
  paddingX="xs"
69
76
  >
70
77
  <input
@@ -75,9 +82,10 @@ const DropdownContainer = (props: DropdownContainerProps) => {
75
82
  />
76
83
  </TextInput>
77
84
  )}
78
- <List>{
85
+ <List dark={dark}>
86
+ {
79
87
  filteredOptions?.length === 0 ? (
80
- <ListItem
88
+ <ListItem dark={dark}
81
89
  display="flex"
82
90
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
83
91
  // @ts-ignore
@@ -85,6 +93,7 @@ const DropdownContainer = (props: DropdownContainerProps) => {
85
93
  padding="xs"
86
94
  >
87
95
  <Body color="light"
96
+ dark={dark}
88
97
  text="no option"
89
98
  />
90
99
  </ListItem>
@@ -17,39 +17,43 @@ import { GenericObject } from "../../types";
17
17
 
18
18
  type DropdownOptionProps = {
19
19
  aria?: { [key: string]: string };
20
- className?: string;
21
20
  children?: React.ReactChild[] | React.ReactChild;
21
+ className?: string;
22
+ dark?: boolean;
22
23
  data?: { [key: string]: string };
23
24
  htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
24
25
  id?: string;
25
- option?: GenericObject;
26
26
  key?: string;
27
+ option?: GenericObject;
27
28
  padding?: string;
28
29
  } & GlobalProps;
29
30
 
30
31
  const DropdownOption = (props: DropdownOptionProps) => {
31
32
  const {
32
33
  aria = {},
33
- className,
34
34
  children,
35
+ className,
36
+ dark = false,
35
37
  data = {},
36
38
  htmlOptions = {},
37
39
  id,
38
- option,
39
40
  key,
41
+ option,
40
42
  padding = "xs",
41
43
  } = props;
42
44
 
43
45
  const {
44
- handleOptionClick,
45
- selected,
46
- filterItem,
47
46
  filteredOptions,
47
+ filterItem,
48
48
  focusedOptionIndex,
49
+ handleOptionClick,
50
+ selected,
49
51
  } = useContext(DropdownContext);
50
52
 
51
- const isItemMatchingFilter = (option: GenericObject) =>
52
- option?.label.toLowerCase().includes(filterItem.toLowerCase());
53
+ const isItemMatchingFilter = (option: GenericObject) => {
54
+ const label = typeof option.label === 'string' ? option.label.toLowerCase() : option.label;
55
+ return String(label).toLowerCase().includes(filterItem.toLowerCase());
56
+ }
53
57
 
54
58
  if (!isItemMatchingFilter(option)) {
55
59
  return null;
@@ -57,20 +61,22 @@ const DropdownOption = (props: DropdownOptionProps) => {
57
61
  const isFocused =
58
62
  focusedOptionIndex >= 0 &&
59
63
  filteredOptions[focusedOptionIndex].label === option.label;
60
- const focusedClass = isFocused && "dropdown_option_focused";
64
+ const focusedClass = isFocused && "focused";
61
65
 
62
66
  const selectedClass = `${
63
67
  selected.label === option.label
64
- ? "dropdown_option_selected"
65
- : "dropdown_option_list"
68
+ ? "selected"
69
+ : "list"
66
70
  }`;
67
71
  const ariaProps = buildAriaProps(aria);
68
72
  const dataProps = buildDataProps(data);
69
73
  const htmlProps = buildHtmlProps(htmlOptions);
70
74
  const classes = classnames(
71
- buildCss("pb_dropdown_option"),
72
- selectedClass,
73
- focusedClass,
75
+ buildCss(
76
+ "pb_dropdown_option",
77
+ selectedClass,
78
+ focusedClass,
79
+ ),
74
80
  globalProps(props, {padding}),
75
81
  className
76
82
  );
@@ -87,18 +93,24 @@ const DropdownOption = (props: DropdownOptionProps) => {
87
93
  >
88
94
  <ListItem
89
95
  cursor="pointer"
96
+ dark={dark}
90
97
  data-name={option.value}
91
98
  key={option.label}
92
99
  padding="none"
93
100
  >
94
101
  <Flex
95
102
  align="center"
96
- className="dropdown_option"
103
+ className="dropdown_option_wrapper"
97
104
  justify="between"
98
105
  paddingX="sm"
99
106
  paddingY="xxs"
100
107
  >
101
- {children ? children : <Body text={option.label} />}
108
+ {children ?
109
+ children :
110
+ <Body dark={dark}
111
+ text={option.label}
112
+ />
113
+ }
102
114
  </Flex>
103
115
  </ListItem>
104
116
  </div>
@@ -21,6 +21,7 @@ type DropdownTriggerProps = {
21
21
  children?: React.ReactChild[] | React.ReactChild;
22
22
  className?: string;
23
23
  customDisplay?: React.ReactChild[] | React.ReactChild;
24
+ dark?: boolean;
24
25
  data?: { [key: string]: string };
25
26
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
26
27
  id?: string;
@@ -30,9 +31,10 @@ type DropdownTriggerProps = {
30
31
  const DropdownTrigger = (props: DropdownTriggerProps) => {
31
32
  const {
32
33
  aria = {},
33
- className,
34
34
  children,
35
+ className,
35
36
  customDisplay,
37
+ dark = false,
36
38
  data = {},
37
39
  htmlOptions = {},
38
40
  id,
@@ -41,15 +43,17 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
41
43
 
42
44
  const {
43
45
  autocomplete,
44
- handleWrapperClick,
45
- selected,
46
46
  filterItem,
47
47
  handleChange,
48
- toggleDropdown,
49
- isDropDownClosed,
48
+ handleWrapperClick,
50
49
  inputRef,
50
+ inputWrapperRef,
51
+ isDropDownClosed,
51
52
  isInputFocused,
53
+ selected,
52
54
  setIsInputFocused,
55
+ toggleDropdown,
56
+ triggerRef,
53
57
  } = useContext(DropdownContext);
54
58
 
55
59
  const handleKeyDown = useHandleOnKeyDown();
@@ -63,9 +67,11 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
63
67
  className
64
68
  );
65
69
 
66
- const triggerWrapperClasses = `dropdown_trigger_wrapper ${
67
- isInputFocused && "dropdown_trigger_wrapper_focus"
68
- } ${!autocomplete && "dropdown_trigger_wrapper_select_only"}`;
70
+ const triggerWrapperClasses = buildCss(
71
+ "dropdown_trigger_wrapper",
72
+ isInputFocused && "focus",
73
+ !autocomplete && "select_only"
74
+ );
69
75
 
70
76
  const customDisplayPlaceholder = selected.label ? (
71
77
  <b>{selected.label}</b>
@@ -92,79 +98,91 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
92
98
  className={classes}
93
99
  id={id}
94
100
  >
95
- {children ? (
96
- <div
97
- onClick={() => toggleDropdown()}
98
- onKeyDown= {handleKeyDown}
99
- style={{ display: "inline-block" }}
100
- tabIndex= {0}
101
- >
102
- {children}
103
- </div>
104
- ) : (
105
- <>
106
- <Flex
107
- align="center"
108
- borderRadius="lg"
109
- className={triggerWrapperClasses}
110
- cursor={`${autocomplete ? "text" : "pointer"}`}
111
- htmlOptions={{
112
- onClick: () => handleWrapperClick(),
113
- onKeyDown: handleKeyDown,
114
- tabIndex: "0",
115
- }}
116
- justify="between"
117
- paddingX="sm"
118
- paddingY="xs"
119
- >
120
- <FlexItem>
121
- <Flex align="center">
122
- {customDisplay ? (
123
- <Flex align="center">
124
- {customDisplay}
125
- <Body paddingLeft={`${selected.label ? "xs" : "none"}`}>
126
- {customDisplayPlaceholder}
127
- </Body>
128
- </Flex>
129
- ) : (
130
- <Body text={defaultDisplayPlaceholder} />
131
- )}
132
- {autocomplete && (
133
- <input
134
- className="dropdown_input"
135
- onChange={handleChange}
136
- onClick={() => toggleDropdown()}
137
- onFocus={() => setIsInputFocused(true)}
138
- onKeyDown={handleKeyDown}
139
- placeholder={
140
- selected.label
141
- ? ""
142
- : placeholder
143
- ? placeholder
144
- : "Select..."
145
- }
146
- ref={inputRef}
147
- value={filterItem}
148
- />
149
- )}
150
- </Flex>
151
- </FlexItem>
152
- <Body
153
- display="flex"
101
+ {
102
+ !triggerRef && (
103
+ children ? (
104
+ <div
105
+ onClick={() => toggleDropdown()}
106
+ onKeyDown= {handleKeyDown}
107
+ ref={inputWrapperRef}
108
+ style={{ display: "inline-block" }}
109
+ tabIndex= {0}
110
+ >
111
+ {children}
112
+ </div>
113
+ ) : (
114
+ <>
115
+ <Flex
116
+ align="center"
117
+ borderRadius="lg"
118
+ className={triggerWrapperClasses}
119
+ cursor={`${autocomplete ? "text" : "pointer"}`}
154
120
  htmlOptions={{
155
- onClick: (e: Event) => {e.stopPropagation();handleWrapperClick()}
121
+ onClick: () => handleWrapperClick(),
122
+ onKeyDown: handleKeyDown,
123
+ tabIndex: "0",
124
+ ref:inputWrapperRef
156
125
  }}
157
- key={`${isDropDownClosed ? "chevron-down" : "chevron-up"}`}
126
+ justify="between"
127
+ paddingX="sm"
128
+ paddingY="xs"
158
129
  >
159
- <Icon
160
- cursor="pointer"
161
- icon={`${isDropDownClosed ? "chevron-down" : "chevron-up"}`}
162
- size="sm"
163
- />
164
- </Body>
165
- </Flex>
166
- </>
167
- )}
130
+ <FlexItem>
131
+ <Flex align="center">
132
+ {customDisplay ? (
133
+ <Flex align="center">
134
+ {customDisplay}
135
+ <Body dark={dark}
136
+ paddingLeft={`${selected.label ? "xs" : "none"}`}
137
+ >
138
+ {customDisplayPlaceholder}
139
+ </Body>
140
+ </Flex>
141
+ ) : (
142
+ <Body dark={dark}
143
+ text={defaultDisplayPlaceholder}
144
+ />
145
+ )}
146
+ {autocomplete && (
147
+ <input
148
+ className="dropdown_input"
149
+ onChange={handleChange}
150
+ onClick={() => toggleDropdown()}
151
+ onFocus={() => setIsInputFocused(true)}
152
+ onKeyDown={handleKeyDown}
153
+ placeholder={
154
+ selected.label
155
+ ? ""
156
+ : placeholder
157
+ ? placeholder
158
+ : "Select..."
159
+ }
160
+ ref={inputRef}
161
+ value={filterItem}
162
+ />
163
+ )}
164
+ </Flex>
165
+ </FlexItem>
166
+ <Body
167
+ dark={dark}
168
+ display="flex"
169
+ htmlOptions={{
170
+ onClick: (e: Event) => {e.stopPropagation();handleWrapperClick()}
171
+ }}
172
+ key={`${isDropDownClosed ? "chevron-down" : "chevron-up"}`}
173
+ >
174
+ <Icon
175
+ cursor="pointer"
176
+ dark={dark}
177
+ icon={`${isDropDownClosed ? "chevron-down" : "chevron-up"}`}
178
+ size="sm"
179
+ />
180
+ </Body>
181
+ </Flex>
182
+ </>
183
+ )
184
+ )
185
+ }
168
186
  </div>
169
187
  );
170
188
  };
@@ -0,0 +1,41 @@
1
+ type HandleClickOutsideType = {
2
+ inputWrapperRef?: React.RefObject<HTMLDivElement>;
3
+ dropdownContainerRef?: React.RefObject<HTMLDivElement>;
4
+ setIsDropDownClosed?: (value: boolean) => void;
5
+ setFocusedOptionIndex?: (value: number) => void;
6
+ setIsInputFocused?: (value: boolean) => void;
7
+ };
8
+
9
+ export const handleClickOutside =
10
+ ({
11
+ inputWrapperRef,
12
+ dropdownContainerRef,
13
+ setIsDropDownClosed,
14
+ setFocusedOptionIndex,
15
+ setIsInputFocused,
16
+ }: HandleClickOutsideType) =>
17
+ (e: MouseEvent) => {
18
+ let targetElement = e.target as HTMLElement;
19
+ let shouldClose = true;
20
+
21
+ //Only needed for when useDropdown hook used with external trigger
22
+ while (targetElement && shouldClose) {
23
+ if (
24
+ targetElement.getAttribute("data-dropdown") === "pb-dropdown-trigger"
25
+ ) {
26
+ shouldClose = false;
27
+ }
28
+ targetElement = targetElement.parentElement as HTMLElement;
29
+ }
30
+ if (
31
+ inputWrapperRef.current &&
32
+ !inputWrapperRef.current.contains((e.target as HTMLElement)) &&
33
+ dropdownContainerRef.current &&
34
+ !dropdownContainerRef.current.contains((e.target as HTMLElement)) &&
35
+ shouldClose
36
+ ) {
37
+ setIsDropDownClosed(true);
38
+ setFocusedOptionIndex(-1);
39
+ setIsInputFocused(false);
40
+ }
41
+ };
@@ -0,0 +1,2 @@
1
+ export { separateChildComponents, prepareSubcomponents } from './subComponentHelper';
2
+ export { handleClickOutside } from './clickOutsideHelper';
@@ -4,11 +4,12 @@ import DropdownContainer from "../subcomponents/DropdownContainer";
4
4
 
5
5
  type PrepareComponentsProps = {
6
6
  children: React.ReactChild[] | React.ReactChild;
7
- hasTriggerSubcomponent: boolean;
8
- hasContainerSubcomponent: boolean;
9
- trigger: React.ReactChild;
10
7
  container: React.ReactChild;
8
+ dark?: boolean;
9
+ hasContainerSubcomponent: boolean;
10
+ hasTriggerSubcomponent: boolean;
11
11
  otherChildren: React.ReactChild[];
12
+ trigger: React.ReactChild;
12
13
  };
13
14
 
14
15
  export const separateChildComponents = (children: React.ReactChild[] | React.ReactChild | ReactElement[]) => {
@@ -36,19 +37,20 @@ export const prepareSubcomponents = ({
36
37
  trigger,
37
38
  container,
38
39
  otherChildren,
40
+ dark
39
41
  }: PrepareComponentsProps) => {
40
42
  const componentsToRender = [];
41
43
 
42
44
  if (!hasTriggerSubcomponent && !hasContainerSubcomponent) {
43
- componentsToRender.push(<DropdownTrigger />);
44
- componentsToRender.push(<DropdownContainer>{children}</DropdownContainer>);
45
+ componentsToRender.push(<DropdownTrigger dark={dark}/>);
46
+ componentsToRender.push(<DropdownContainer dark={dark}>{children}</DropdownContainer>);
45
47
  } else if (!hasTriggerSubcomponent && hasContainerSubcomponent) {
46
- componentsToRender.push(<DropdownTrigger />);
48
+ componentsToRender.push(<DropdownTrigger dark={dark}/>);
47
49
  componentsToRender.push(children);
48
50
  } else if (hasTriggerSubcomponent && !hasContainerSubcomponent) {
49
51
  componentsToRender.push(trigger);
50
52
  componentsToRender.push(
51
- <DropdownContainer>{otherChildren}</DropdownContainer>
53
+ <DropdownContainer dark={dark}>{otherChildren}</DropdownContainer>
52
54
  );
53
55
  } else {
54
56
  componentsToRender.push(trigger);
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag do %>
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 %>
2
7
  <%= pb_rails("form_group", props: {cursor: "pointer", full_width: object.full_width}) do %>
3
8
  <label for="upload-<%= object.id %>" class="pb_button_kit_secondary_inline_enabled"><%= "#{object.label}" %></label>
4
9
  <%= pb_rails("text_input", props: {
@@ -1,4 +1,8 @@
1
- <%= pb_content_tag do %>
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= object.wrapper do %>
3
7
  <%= pb_rails("flex", props: { orientation: "row", padding_right: "lg", vertical: "center" }) do %>
4
8
  <% if (object.template != "sort_only") %>
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag do %>
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ id: object.id,
4
+ data: object.data,
5
+ class: object.classname,
6
+ **combined_html_options) do %>
2
7
  <%= pb_rails("icon", props: { icon: object.icon_value, classname: "pb_icon", fixed_width: true }) %>
3
8
 
4
9
  <% if content %>
@@ -1,3 +1,7 @@
1
- <%= pb_content_tag do %>
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= content.presence %>
3
7
  <% end %>
@@ -1,4 +1,8 @@
1
- <%= pb_content_tag(:div,
2
- style: object.style_value) do %>
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ style: object.style_value,
6
+ **combined_html_options) do %>
3
7
  <%= content.presence %>
4
8
  <% end %>
@@ -1,3 +1,8 @@
1
- <%= pb_content_tag do %>
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 %>
2
7
  <%= content.presence %>
3
8
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= pb_content_tag(:div, class: object.classname + object.size_class) do %>
1
+ <%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, **combined_html_options) do %>
2
2
  <% if object.name.present? %>
3
3
  <%= pb_rails("avatar", props: { name: object.name, image_url: object.avatar_url, size: "xs" }) %>
4
4
  <%= pb_rails("title", props: { text: object.name, size: 4, classname: "pb_form_pill_text" }) %>
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag(:span) do %>
1
+ <%= content_tag(:span,
2
+ aria: object.aria,
3
+ class: object.classname,
4
+ data: object.data,
5
+ id: object.id,
6
+ **combined_html_options) do %>
2
7
  <%= link_to object.url, target: object.link_option do %>
3
8
  <%= pb_rails("badge", props: { dark: object.dark, variant: "primary", text: object.hashtag_text }) %>
4
9
  <% end %>
@@ -1,4 +1,8 @@
1
- <%= pb_content_tag(:span) do %>
1
+ <%= content_tag(:span,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <mark>
3
7
  <%= content.presence || object.text %>
4
8
  </mark>
@@ -1,4 +1,8 @@
1
- <%= pb_content_tag do %>
1
+ <%= content_tag(:div,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= pb_rails("home_address_street/#{emphasis}_emphasis", props: object.send("#{emphasis}_emphasis_props")) %>
3
7
  <% end %>
4
8
 
@@ -1,3 +1,8 @@
1
- <%= pb_content_tag do %>
2
- <%= pb_rails("icon", props: { dark: object.dark, icon: object.icon, fixed_width: true }) %>
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 %>
7
+ <%= pb_rails("icon", props: { dark: object.dark, icon: object.icon, fixed_width: true }) %>
3
8
  <% end %>
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag do %>
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ id: object.id,
4
+ data: object.data,
5
+ class: object.classname,
6
+ **combined_html_options) do %>
2
7
 
3
8
  <%= pb_rails("icon_circle", props: {
4
9
  dark: object.dark,
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag do %>
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 %>
2
7
  <%= pb_rails("body", props: { color: "light", dark: object.dark }) do %>
3
8
  <%= pb_rails("icon", props: { icon: object.icon, fixed_width: true }) %>
4
9
  <%= object.text %>
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag do %>
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ id: object.id,
4
+ data: object.data,
5
+ class: object.classname,
6
+ **combined_html_options) do %>
2
7
  <%= pb_rails("caption", props: { text: object.label, classname: "pb_label_pill_label"}) %>
3
8
  <%= pb_rails("pill", props: { text: object.pill_value, variant: object.variant, classname: "pb_label_pill_pill" }) %>
4
9
  <% end %>
@@ -1,4 +1,9 @@
1
- <%= pb_content_tag do %>
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ id: object.id,
4
+ data: object.data,
5
+ class: object.classname,
6
+ **combined_html_options) do %>
2
7
  <%= pb_rails("caption", props: { text: object.label, dark: object.dark }) %>
3
8
  <% if object.variant == "details" %>
4
9
  <%= pb_rails("flex", props: {inline: true, vertical: "center"}) do %>
@@ -1,3 +1,7 @@
1
- <%= pb_content_tag(object.tag) do %>
1
+ <%= content_tag(object.tag,
2
+ id: object.id,
3
+ data: object.data,
4
+ class: object.classname,
5
+ **combined_html_options) do %>
2
6
  <%= content.presence %>
3
7
  <% end %>