playbook_ui 13.25.0 → 13.26.0.pre.alpha.jasoncypretpatch12820

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